Browse Source

Print task submission and execution progression too

Samuel Thibault 6 years ago
parent
commit
80bb958253
1 changed files with 34 additions and 10 deletions
  1. 34 10
      tools/starpu_replay.c

+ 34 - 10
tools/starpu_replay.c

@@ -50,7 +50,7 @@ static int static_workerid;
 
 /* TODO: move to core header while moving starpu_replay_sched to core */
 extern void schedRecInit(const char * filename);
-extern void applySchedRec(struct starpu_task * starpu_task, unsigned long submit_order);
+extern void applySchedRec(struct starpu_task * starpu_task, long submit_order);
 
 /* Enum for normal and "wontuse" tasks */
 enum task_type {NormalTask, WontUseTask};
@@ -102,7 +102,7 @@ static struct task
 	UT_hash_handle hh;
 	jobid_t jobid;
         int iteration;
-	unsigned long submit_order;
+	long submit_order;
 	jobid_t *deps;
 	size_t ndependson;
 	struct starpu_task task;
@@ -135,8 +135,8 @@ static struct starpu_rbtree tree = STARPU_RBTREE_INITIALIZER;
 /* the cmp_fn arg for rb_tree_insert() */
 unsigned int diff(struct starpu_rbtree_node * left_elm, struct starpu_rbtree_node * right_elm)
 {
-	int oleft = ((struct task *) left_elm)->submit_order;
-	int oright = ((struct task *) right_elm)->submit_order;
+	long oleft = ((struct task *) left_elm)->submit_order;
+	long oright = ((struct task *) right_elm)->submit_order;
 	if (oleft == -1 && oright == -1)
 	{
 		if (left_elm < right_elm)
@@ -163,6 +163,7 @@ double arch_cost_function(struct starpu_task *task, struct starpu_perfmodel_arch
 {
 	device = starpu_perfmodel_arch_comb_get(arch->ndevices, arch->devices);
 	STARPU_ASSERT(device != -1);
+	(void) nimpl;
 
 	/* Then, get the pointer to the value of the expected time */
 	double * val = (double *) ((struct task_arg *) (task->cl_arg))->perf+device;
@@ -177,13 +178,24 @@ double arch_cost_function(struct starpu_task *task, struct starpu_perfmodel_arch
 
 /* End of settings */
 
-void dumb_kernel(void) {}
+static unsigned long nexecuted_tasks;
+void dumb_kernel(void *buffers[], void *args) {
+	(void) buffers;
+	(void) args;
+	nexecuted_tasks++;
+	if (!(nexecuted_tasks % 1000))
+	{
+		printf("\rExecuting task %lu", nexecuted_tasks);
+		fflush(stdout);
+	}
+}
 
 /* [CODELET] Initialization of an unique codelet for all the tasks*/
 static int can_execute(unsigned worker_id, struct starpu_task *task, unsigned nimpl)
 {
 	struct starpu_perfmodel_arch * arch = starpu_worker_get_perf_archtype(worker_id, STARPU_NMAX_SCHED_CTXS);
 	double expected_time = ((struct task_arg *) (task->cl_arg))->perf[starpu_perfmodel_arch_comb_get(arch->ndevices, arch->devices)];
+	(void) nimpl;
 	if (!(expected_time == 0 || isnan(expected_time)))
 	{
 		return 1;
@@ -201,13 +213,14 @@ static struct starpu_perfmodel myperfmodel =
 
 static struct starpu_codelet cl =
 {
-	.cpu_funcs = { (void*) 1 },
+	.cpu_funcs = { dumb_kernel },
 	.cpu_funcs_name = { "dumb_kernel" },
-	.cuda_funcs = { (void*) 1 },
-	.opencl_funcs = { (void*) 1 },
+	.cuda_funcs = { dumb_kernel },
+	.opencl_funcs = { dumb_kernel },
 	.nbuffers = STARPU_VARIABLE_NBUFFERS,
 	.can_execute = can_execute,
 	.model = &myperfmodel,
+	.flags = STARPU_CODELET_SIMGRID_EXECUTE,
 };
 
 
@@ -343,7 +356,7 @@ int submit_tasks(void)
 
 	const struct starpu_rbtree * tmptree = &tree;
 	struct starpu_rbtree_node * currentNode = starpu_rbtree_first(tmptree);
-	unsigned long last_submitorder = 0;
+	long last_submitorder = 0;
 
 	while (currentNode != NULL)
 	{
@@ -408,7 +421,7 @@ int submit_tasks(void)
 			//printf("submitting task %s (%lu, %llu)\n", currentTask->task.name?currentTask->task.name:"anonymous", currentTask->jobid, (unsigned long long) currentTask->task.tag_id);
 			if (!(currentTask->submit_order % 1000))
 			{
-				printf("\rSubmitting task %lu", currentTask->submit_order);
+				printf("\rSubmitting task order %lu", currentTask->submit_order);
 				fflush(stdout);
 			}
 			if (currentTask->submit_order != -1)
@@ -456,6 +469,8 @@ int main(int argc, char **argv)
 	unsigned i;
 	size_t s_allocated = 128;
 
+	unsigned long nread_tasks = 0;
+
 	_STARPU_MALLOC(s, s_allocated);
 	dependson_size = REPLAY_NMAX_DEPENDENCIES; /* Change the value of REPLAY_NMAX_DEPENCIES to modify the number of dependencies */
 	_STARPU_MALLOC(dependson, dependson_size * sizeof (* dependson));
@@ -509,6 +524,7 @@ int main(int argc, char **argv)
 
 		if (!fgets(s, s_allocated, rec))
 		{
+			printf("\n");
 			int submitted = submit_tasks();
 
 			if (submitted == -1)
@@ -526,6 +542,7 @@ int main(int argc, char **argv)
 
 			if (!fgets(s + s_allocated-1, s_allocated+1, rec))
 			{
+				printf("\n");
 				int submitted = submit_tasks();
 
 				if (submitted == -1)
@@ -661,6 +678,13 @@ int main(int argc, char **argv)
 			/* Add this task to task hash */
 			HASH_ADD(hh, tasks, jobid, sizeof(jobid), task);
 
+			nread_tasks++;
+			if (!(nread_tasks % 1000))
+			{
+				printf("\rRead task %lu", nread_tasks);
+				fflush(stdout);
+			}
+
 			reset();
 		}