Browse Source

Generate file sched_tasks.rec monitoring task push/pop of scheduler

Philippe SWARTVAGHER 5 years ago
parent
commit
15244a7ded
3 changed files with 52 additions and 6 deletions
  1. 1 0
      include/starpu_fxt.h
  2. 5 5
      src/core/sched_policy.c
  3. 46 1
      src/debug/traces/starpu_fxt.c

+ 1 - 0
include/starpu_fxt.h

@@ -62,6 +62,7 @@ struct starpu_fxt_options
 	char *out_paje_path;
 	char *distrib_time_path;
 	char *activity_path;
+	char *sched_tasks_path;
 	char *dag_path;
 	char *tasks_path;
 	char *data_path;

+ 5 - 5
src/core/sched_policy.c

@@ -405,7 +405,7 @@ static int _starpu_push_task_on_specific_worker(struct starpu_task *task, int wo
 			struct starpu_task *alias = starpu_task_dup(task);
 			alias->destroy = 1;
 
-			_STARPU_TRACE_JOB_PUSH(alias, alias->priority > 0);
+			_STARPU_TRACE_JOB_PUSH(alias, alias->priority);
 			worker = _starpu_get_worker_struct(combined_workerid[j]);
 			ret |= _starpu_push_local_task(worker, alias, 0);
 		}
@@ -537,7 +537,7 @@ int _starpu_push_task_to_workers(struct starpu_task *task)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(task->sched_ctx);
 
-	_STARPU_TRACE_JOB_PUSH(task, task->priority > 0);
+	_STARPU_TRACE_JOB_PUSH(task, task->priority);
 
 	/* if the contexts still does not have workers put the task back to its place in
 	   the empty ctx list */
@@ -626,7 +626,7 @@ int _starpu_push_task_to_workers(struct starpu_task *task)
 					if (job->task_size > 1)
 					{
 						alias = starpu_task_dup(task);
-						_STARPU_TRACE_JOB_PUSH(alias, alias->priority > 0);
+						_STARPU_TRACE_JOB_PUSH(alias, alias->priority);
 						alias->destroy = 1;
 					}
 					else
@@ -667,7 +667,7 @@ int _starpu_push_task_to_workers(struct starpu_task *task)
 		if(ret == -1)
 		{
 			_STARPU_MSG("repush task \n");
-			_STARPU_TRACE_JOB_POP(task, task->priority > 0);
+			_STARPU_TRACE_JOB_POP(task, task->priority);
 			ret = _starpu_push_task_to_workers(task);
 		}
 	}
@@ -694,7 +694,7 @@ int _starpu_pop_task_end(struct starpu_task *task)
 {
 	if (!task)
 		return 0;
-	_STARPU_TRACE_JOB_POP(task, task->priority > 0);
+	_STARPU_TRACE_JOB_POP(task, task->priority);
 	return 0;
 }
 

+ 46 - 1
src/debug/traces/starpu_fxt.c

@@ -88,6 +88,7 @@ static FILE *data_file;
 static FILE *papi_file;
 static FILE *trace_file;
 static FILE *comms_file;
+static FILE *sched_tasks_file;
 
 struct data_parameter_info
 {
@@ -2608,6 +2609,7 @@ static void handle_job_push(struct fxt_ev_64 *ev, struct starpu_fxt_options *opt
 	double current_timestamp = get_event_time_stamp(ev, options);
 
 	unsigned task = ev->param[0];
+	int priority = ev->param[1];
 
 	curq_size++;
 
@@ -2633,6 +2635,18 @@ static void handle_job_push(struct fxt_ev_64 *ev, struct starpu_fxt_options *opt
 
 	if (activity_file)
 		fprintf(activity_file, "cnt_ready\t%.9f\t%d\n", current_timestamp, curq_size);
+
+	if (sched_tasks_file)
+	{
+		fprintf(sched_tasks_file, "Type: push\n");
+		fprintf(sched_tasks_file, "Time: %.9f\n", current_timestamp);
+		fprintf(sched_tasks_file, "Priority: %d\n", priority);
+		if (options->file_rank < 0)
+			fprintf(sched_tasks_file, "JobId: %d\n", task);
+		else
+			fprintf(sched_tasks_file, "JobId: %d_%d\n", options->file_rank, task);
+		fprintf(sched_tasks_file, "\n");
+	}
 }
 
 
@@ -2640,6 +2654,7 @@ static void handle_job_pop(struct fxt_ev_64 *ev, struct starpu_fxt_options *opti
 {
 	double current_timestamp = get_event_time_stamp(ev, options);
 	unsigned task = ev->param[0];
+	int priority = ev->param[1];
 
 	curq_size--;
 	nsubmitted--;
@@ -2670,6 +2685,17 @@ static void handle_job_pop(struct fxt_ev_64 *ev, struct starpu_fxt_options *opti
 		fprintf(activity_file, "cnt_submitted\t%.9f\t%d\n", current_timestamp, nsubmitted);
 	}
 
+	if (sched_tasks_file)
+	{
+		fprintf(sched_tasks_file, "Type: pop\n");
+		fprintf(sched_tasks_file, "Time: %.9f\n", current_timestamp);
+		fprintf(sched_tasks_file, "Priority: %d\n", priority);
+		if (options->file_rank < 0)
+			fprintf(sched_tasks_file, "JobId: %d\n", task);
+		else
+			fprintf(sched_tasks_file, "JobId: %d_%d\n", options->file_rank, task);
+		fprintf(sched_tasks_file, "\n");
+	}
 }
 
 static void handle_component_new(struct fxt_ev_64 *ev, struct starpu_fxt_options *options STARPU_ATTRIBUTE_UNUSED)
@@ -3514,7 +3540,7 @@ void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *op
 				handle_update_task_cnt(&ev, options);
 				break;
 
-			/* monitor stack size */
+			/* monitor stack size and generate sched_tasks.rec */
 			case _STARPU_FUT_JOB_PUSH:
 				handle_job_push(&ev, options);
 				break;
@@ -4182,6 +4208,7 @@ void starpu_fxt_options_init(struct starpu_fxt_options *options)
 	options->distrib_time_path = "distrib.data";
 	options->dumped_codelets = NULL;
 	options->activity_path = "activity.data";
+	options->sched_tasks_path = "sched_tasks.rec";
 }
 
 static
@@ -4223,6 +4250,15 @@ void _starpu_fxt_activity_file_init(struct starpu_fxt_options *options)
 }
 
 static
+void _starpu_fxt_sched_tasks_file_init(struct starpu_fxt_options *options)
+{
+	if (options->sched_tasks_path)
+		sched_tasks_file = fopen(options->sched_tasks_path, "w+");
+	else
+		sched_tasks_file = NULL;
+}
+
+static
 void _starpu_fxt_anim_file_init(struct starpu_fxt_options *options)
 {
 	if (options->anim_path)
@@ -4306,6 +4342,13 @@ void _starpu_fxt_activity_file_close(void)
 }
 
 static
+void _starpu_fxt_sched_tasks_file_close(void)
+{
+	if (sched_tasks_file)
+		fclose(sched_tasks_file);
+}
+
+static
 void _starpu_fxt_anim_file_close(void)
 {
 	//_starpu_fxt_component_dump(stderr);
@@ -4444,6 +4487,7 @@ void starpu_fxt_generate_trace(struct starpu_fxt_options *options)
 	_starpu_fxt_dag_init(options->dag_path);
 	_starpu_fxt_distrib_file_init(options);
 	_starpu_fxt_activity_file_init(options);
+	_starpu_fxt_sched_tasks_file_init(options);
 	_starpu_fxt_anim_file_init(options);
 	_starpu_fxt_tasks_file_init(options);
 	_starpu_fxt_data_file_init(options);
@@ -4575,6 +4619,7 @@ void starpu_fxt_generate_trace(struct starpu_fxt_options *options)
 	/* close the different files */
 	_starpu_fxt_paje_file_close();
 	_starpu_fxt_activity_file_close();
+	_starpu_fxt_sched_tasks_file_close();
 	_starpu_fxt_distrib_file_close(options);
 	_starpu_fxt_anim_file_close();
 	_starpu_fxt_tasks_file_close();