Explorar el Código

tests/main/{subgraph_repeat_tag.c,subgraph_repeat_regenerate_tag.c}: stop regenerating tasks when all loops are done, this permits to call starpu_data_unregister(), otherwise it would wait for the tasks

Nathalie Furmento hace 10 años
padre
commit
6d015be440
Se han modificado 2 ficheros con 69 adiciones y 0 borrados
  1. 41 0
      tests/main/subgraph_repeat_regenerate_tag.c
  2. 28 0
      tests/main/subgraph_repeat_tag.c

+ 41 - 0
tests/main/subgraph_repeat_regenerate_tag.c

@@ -51,6 +51,9 @@ static unsigned niter = 16384;
 static struct starpu_task taskA, taskB, taskC, taskD;
 
 static unsigned loop_cnt = 0;
+static unsigned loop_cnt_A = 0;
+static unsigned loop_cnt_B = 0;
+static unsigned loop_cnt_C = 0;
 static unsigned *check_cnt;
 static starpu_pthread_cond_t cond = STARPU_PTHREAD_COND_INITIALIZER;
 static starpu_pthread_mutex_t mutex = STARPU_PTHREAD_MUTEX_INITIALIZER;
@@ -78,6 +81,39 @@ static struct starpu_codelet dummy_codelet =
 	.nbuffers = 1
 };
 
+static void callback_task_A(void *arg STARPU_ATTRIBUTE_UNUSED)
+{
+	loop_cnt_A++;
+
+	if (loop_cnt_A == niter)
+	{
+		/* We are done */
+		taskA.regenerate = 0;
+	}
+}
+
+static void callback_task_B(void *arg STARPU_ATTRIBUTE_UNUSED)
+{
+	loop_cnt_B++;
+
+	if (loop_cnt_B == niter)
+	{
+		/* We are done */
+		taskB.regenerate = 0;
+	}
+}
+
+static void callback_task_C(void *arg STARPU_ATTRIBUTE_UNUSED)
+{
+	loop_cnt_C++;
+
+	if (loop_cnt_C == niter)
+	{
+		/* We are done */
+		taskC.regenerate = 0;
+	}
+}
+
 static void callback_task_D(void *arg STARPU_ATTRIBUTE_UNUSED)
 {
 	STARPU_PTHREAD_MUTEX_LOCK(&mutex);
@@ -127,6 +163,7 @@ int main(int argc, char **argv)
 	taskA.regenerate = 1; /* this task will be explicitely resubmitted if needed */
 	taskA.use_tag = 1;
 	taskA.tag_id = TAG_A;
+	taskA.callback_func = callback_task_A;
 	taskA.handles[0] = check_data;
 
 	starpu_task_init(&taskB);
@@ -136,6 +173,7 @@ int main(int argc, char **argv)
 	taskB.regenerate = 1;
 	taskB.use_tag = 1;
 	taskB.tag_id = TAG_B;
+	taskB.callback_func = callback_task_B;
 	taskB.handles[0] = check_data;
 
 	starpu_task_init(&taskC);
@@ -145,6 +183,7 @@ int main(int argc, char **argv)
 	taskC.regenerate = 1;
 	taskC.use_tag = 1;
 	taskC.tag_id = TAG_C;
+	taskC.callback_func = callback_task_C;
 	taskC.handles[0] = check_data;
 
 	starpu_task_init(&taskD);
@@ -184,6 +223,8 @@ int main(int argc, char **argv)
 
 	starpu_free(check_cnt);
 
+	starpu_data_unregister(check_data);
+
 	starpu_shutdown();
 
 	/* Cleanup the statically allocated tasks after shutdown, as StarPU is still working on it after the callback */

+ 28 - 0
tests/main/subgraph_repeat_tag.c

@@ -44,6 +44,8 @@ static unsigned niter = 16384;
 static struct starpu_task taskA, taskB, taskC, taskD;
 
 static unsigned loop_cnt = 0;
+static unsigned loop_cnt_B = 0;
+static unsigned loop_cnt_C = 0;
 static unsigned *check_cnt;
 static starpu_pthread_cond_t cond = STARPU_PTHREAD_COND_INITIALIZER;
 static starpu_pthread_mutex_t mutex = STARPU_PTHREAD_MUTEX_INITIALIZER;
@@ -71,6 +73,28 @@ static struct starpu_codelet dummy_codelet =
 	.nbuffers = 1
 };
 
+static void callback_task_B(void *arg STARPU_ATTRIBUTE_UNUSED)
+{
+	loop_cnt_B++;
+
+	if (loop_cnt_B == niter)
+	{
+		/* We are done */
+		taskB.regenerate = 0;
+	}
+}
+
+static void callback_task_C(void *arg STARPU_ATTRIBUTE_UNUSED)
+{
+	loop_cnt_C++;
+
+	if (loop_cnt_C == niter)
+	{
+		/* We are done */
+		taskC.regenerate = 0;
+	}
+}
+
 static void callback_task_D(void *arg STARPU_ATTRIBUTE_UNUSED)
 {
 	STARPU_PTHREAD_MUTEX_LOCK(&mutex);
@@ -126,6 +150,7 @@ int main(int argc, char **argv)
 	taskB.cl_arg = &taskB;
 	taskB.cl_arg_size = sizeof(&taskB);
 	taskB.regenerate = 1;
+	taskB.callback_func = callback_task_B;
 	taskB.handles[0] = check_data;
 
 	starpu_task_init(&taskC);
@@ -133,6 +158,7 @@ int main(int argc, char **argv)
 	taskC.cl_arg = &taskC;
 	taskC.cl_arg_size = sizeof(&taskC);
 	taskC.regenerate = 1;
+	taskC.callback_func = callback_task_C;
 	taskC.handles[0] = check_data;
 
 	starpu_task_init(&taskD);
@@ -168,6 +194,8 @@ int main(int argc, char **argv)
 
 	starpu_free(check_cnt);
 
+	starpu_data_unregister(check_data);
+
 	starpu_shutdown();
 
 	/* Cleanup the statically allocated tasks after shutdown, as StarPU is still working on it after the callback */