Prechádzať zdrojové kódy

revert part of r15041 to always call the prologue_callback, but not for sched_ctx repushes. BTW, fix the prologue_callback_pop call for tasks with cl==NULL. BTW, fix the codelet_null_callback test

Samuel Thibault 10 rokov pred
rodič
commit
41c67bc4b8

+ 1 - 1
src/core/sched_ctx.c

@@ -1957,7 +1957,7 @@ void starpu_sched_ctx_move_task_to_ctx(struct starpu_task *task, unsigned sched_
 
 	_starpu_increment_nsubmitted_tasks_of_sched_ctx(j->task->sched_ctx);
 
-	_starpu_push_task(j);
+	_starpu_repush_task(j);
 
 	if(workerid != -1)
 		STARPU_PTHREAD_MUTEX_LOCK(&worker->sched_mutex);

+ 10 - 5
src/core/sched_policy.c

@@ -340,7 +340,14 @@ static int _starpu_push_task_on_specific_worker(struct starpu_task *task, int wo
 
 int _starpu_push_task(struct _starpu_job *j)
 {
+	if(j->task->prologue_callback_func)
+		j->task->prologue_callback_func(j->task->prologue_callback_arg);
 
+	_starpu_repush_task(j);
+}
+
+int _starpu_repush_task(struct _starpu_job *j)
+{
 	struct starpu_task *task = j->task;
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(task->sched_ctx);
 	unsigned nworkers = 0;
@@ -391,6 +398,9 @@ int _starpu_push_task(struct _starpu_job *j)
 	 * corresponding dependencies */
 	if (task->cl == NULL)
 	{
+		if(task->prologue_callback_pop_func)
+			task->prologue_callback_pop_func(task->prologue_callback_pop_arg);
+
 		_starpu_handle_job_termination(j);
 		_STARPU_LOG_OUT_TAG("handle_job_termination");
 		return 0;
@@ -472,12 +482,7 @@ int _starpu_push_task_to_workers(struct starpu_task *task)
 		if(!sched_ctx->sched_policy)
 		{
 			if(!sched_ctx->awake_workers)
-			{
-				if(task->prologue_callback_func)
-					task->prologue_callback_func(task->prologue_callback_arg);
-
 				ret = _starpu_push_task_on_specific_worker(task, sched_ctx->main_master);
-			}
 			else
 			{
 				struct starpu_worker_collection *workers = sched_ctx->workers;

+ 2 - 1
src/core/sched_policy.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2012-2013  Université de Bordeaux
+ * Copyright (C) 2010, 2012-2013, 2015  Université de Bordeaux
  * Copyright (C) 2011  INRIA
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -34,6 +34,7 @@ void _starpu_deinit_sched_policy(struct _starpu_sched_ctx *sched_ctx);
 struct starpu_sched_policy *_starpu_select_sched_policy(struct _starpu_machine_config *config, const char *required_policy);
 
 int _starpu_push_task(struct _starpu_job *task);
+int _starpu_repush_task(struct _starpu_job *task);
 
 /* actually pushes the tasks to the specific worker or to the scheduler */
 int _starpu_push_task_to_workers(struct starpu_task *task);

+ 32 - 23
tests/main/codelet_null_callback.c

@@ -18,33 +18,48 @@
 #include "../helper.h"
 
 static
-int expected_x=40;
-static
-int expected_y=12;
-
-static
 void callback(void *ptr)
 {
      int *x = (int *)ptr;
      FPRINTF(stderr, "x=%d\n", *x);
-     STARPU_ASSERT_MSG(*x == expected_x, "%d != %d\n", *x, expected_x);
+     STARPU_ASSERT_MSG(*x == 40, "%d != %d\n", *x, 40);
      (*x)++;
 }
 
 static
+void callback2(void *ptr)
+{
+     int *x2 = (int *)ptr;
+     FPRINTF(stderr, "x2=%d\n", *x2);
+     STARPU_ASSERT_MSG(*x2 == 41, "%d != %d\n", *x2, 41);
+     (*x2)++;
+}
+
+static
 void prologue_callback(void *ptr)
 {
      int *y = (int *)ptr;
      FPRINTF(stderr, "y=%d\n", *y);
-     STARPU_ASSERT_MSG(*y == expected_y, "%d != %d\n", *y, expected_y);
+     STARPU_ASSERT_MSG(*y == 12, "%d != %d\n", *y, 12);
      (*y)++;
 }
 
+static
+void prologue_callback_pop(void *ptr)
+{
+     int *z = (int *)ptr;
+     FPRINTF(stderr, "z=%d\n", *z);
+     STARPU_ASSERT_MSG(*z == 32, "%d != %d\n", *z, 32);
+     (*z)++;
+}
+
 int main(int argc, char **argv)
 {
 	int ret;
 	int x=40;
+	int x2=41;
 	int y=12;
+	int z=32;
 
 	ret = starpu_initialize(NULL, &argc, &argv);
 	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
@@ -55,36 +70,30 @@ int main(int argc, char **argv)
 				 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
 
-	expected_x ++;
 	ret = starpu_task_insert(NULL,
-				 STARPU_CALLBACK, callback,
-				 STARPU_CALLBACK_ARG, &x,
+				 STARPU_CALLBACK, callback2,
+				 STARPU_CALLBACK_ARG, &x2,
 				 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
 
-	expected_x ++;
-	STARPU_ASSERT_MSG(x == expected_x, "x should be equal to %d and not %d\n", expected_x, x);
-
 	ret = starpu_task_insert(NULL,
 				 STARPU_PROLOGUE_CALLBACK, prologue_callback,
 				 STARPU_PROLOGUE_CALLBACK_ARG, &y,
 				 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
 
-#ifdef STARPU_DEVEL
-#warning the following code should work
-#if 0
-	expected_y ++;
 	ret = starpu_task_insert(NULL,
-				 STARPU_PROLOGUE_CALLBACK_POP, prologue_callback,
-				 STARPU_PROLOGUE_CALLBACK_ARG, &y,
+				 STARPU_PROLOGUE_CALLBACK_POP, prologue_callback_pop,
+				 STARPU_PROLOGUE_CALLBACK_POP_ARG, &z,
 				 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
-#endif
-#endif
 
-	expected_y ++;
-	STARPU_ASSERT_MSG(y == expected_y, "y should be equal to %d and not %d\n", expected_y, y);
+	starpu_task_wait_for_all();
+
+	STARPU_ASSERT_MSG(x == 41, "x should be equal to %d and not %d\n", 41, x);
+	STARPU_ASSERT_MSG(x2 == 42, "x2 should be equal to %d and not %d\n", 42, x2);
+	STARPU_ASSERT_MSG(y == 13, "y should be equal to %d and not %d\n", 13, y);
+	STARPU_ASSERT_MSG(z == 33, "z should be equal to %d and not %d\n", 33, z);
 
 	starpu_shutdown();