Bladeren bron

Add a way to choose the colors of tasks

Samuel Thibault 7 jaren geleden
bovenliggende
commit
4f42d4295c

+ 1 - 0
ChangeLog

@@ -100,6 +100,7 @@ Small features:
    starpu_task_insert_data_process_mode_array_arg
    * Do not show internal tasks in fxt dag by default. Allow to hide
    acquisitions too.
+   * Add a way to choose the dag.dot colors.
 
 StarPU 1.2.3 (svn revision 22444)
 ==============================================

+ 7 - 0
doc/doxygen/chapters/api/codelet_and_tasks.doxy

@@ -415,6 +415,10 @@ compiler implicitly do it in e.g. static storage case.
     Optional name of the codelet. This can be useful for debugging
     purposes.
 
+\var const char *starpu_codelet::color
+    Optional color of the codelet. This can be useful for debugging
+    purposes.
+
 \var const char *starpu_codelet::flags
     Various flags for the codelet.
 
@@ -759,6 +763,9 @@ the configuration of a task allocated with starpu_task_create().
     synchronization task (STARPU_TASK_TYPE_DATA_ACQUIRE), or a normal task
     (::STARPU_TASK_TYPE_NORMAL)
 
+\var int starpu_task::color
+    This field allows to specify the color of the task to be used in dag.dot.
+
 \var unsigned starpu_task::sched_ctx
     Scheduling context.
 

+ 7 - 4
examples/cholesky/cholesky_kernels.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2008-2015,2017                           Université de Bordeaux
+ * Copyright (C) 2008-2015,2017-2018                           Université de Bordeaux
  * Copyright (C) 2010-2012,2015,2017                      CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -312,7 +312,8 @@ struct starpu_codelet cl11 =
 #endif
 	.nbuffers = 1,
 	.modes = { STARPU_RW },
-	.model = &chol_model_11
+	.model = &chol_model_11,
+	.color = 0xffff00,
 };
 
 struct starpu_codelet cl21 =
@@ -328,7 +329,8 @@ struct starpu_codelet cl21 =
 	.cuda_flags = {STARPU_CUDA_ASYNC},
 	.nbuffers = 2,
 	.modes = { STARPU_R, STARPU_RW },
-	.model = &chol_model_21
+	.model = &chol_model_21,
+	.color = 0x8080ff,
 };
 
 struct starpu_codelet cl22 =
@@ -345,5 +347,6 @@ struct starpu_codelet cl22 =
 	.cuda_flags = {STARPU_CUDA_ASYNC},
 	.nbuffers = 3,
 	.modes = { STARPU_R, STARPU_R, STARPU_RW },
-	.model = &chol_model_22
+	.model = &chol_model_22,
+	.color = 0x00ff00,
 };

+ 5 - 1
examples/lu/xlu.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2011,2014-2015,2017                 Université de Bordeaux
+ * Copyright (C) 2009-2011,2014-2015,2017-2018                 Université de Bordeaux
  * Copyright (C) 2010                                     Mehdi Juhoor
  * Copyright (C) 2010-2013,2015,2017,2018                 CNRS
  * Copyright (C) 2013                                     Inria
@@ -43,6 +43,7 @@ static struct starpu_task *create_task_11(starpu_data_handle_t dataA, unsigned k
 	struct starpu_task *task = create_task(TAG11(k));
 
 	task->cl = &cl11;
+	task->color = 0xffff00;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = starpu_data_get_sub_data(dataA, 2, k, k);
@@ -69,6 +70,7 @@ static int create_task_12(starpu_data_handle_t dataA, unsigned k, unsigned j, un
 	struct starpu_task *task = create_task(TAG12(k, j));
 
 	task->cl = &cl12;
+	task->color = 0x8080ff;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = starpu_data_get_sub_data(dataA, 2, k, k);
@@ -100,6 +102,7 @@ static int create_task_21(starpu_data_handle_t dataA, unsigned k, unsigned i, un
 	struct starpu_task *task = create_task(TAG21(k, i));
 
 	task->cl = &cl21;
+	task->color = 0x8080c0;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = starpu_data_get_sub_data(dataA, 2, k, k);
@@ -134,6 +137,7 @@ static int create_task_22(starpu_data_handle_t dataA, unsigned k, unsigned i, un
 	struct starpu_task *task = create_task(TAG22(k, i, j));
 
 	task->cl = &cl22;
+	task->color = 0x00ff00;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = starpu_data_get_sub_data(dataA, 2, k, i); /* produced by TAG21(k, i) */

+ 5 - 1
examples/lu/xlu_implicit.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2011,2014-2015,2017                 Université de Bordeaux
+ * Copyright (C) 2010-2011,2014-2015,2017-2018            Université de Bordeaux
  * Copyright (C) 2010                                     Mehdi Juhoor
  * Copyright (C) 2010-2013,2015-2018                      CNRS
  * Copyright (C) 2013                                     Inria
@@ -32,6 +32,7 @@ static int create_task_11(starpu_data_handle_t dataA, unsigned k, unsigned no_pr
 	task->handles[0] = starpu_data_get_sub_data(dataA, 2, k, k);
 
 	task->tag_id = TAG11(k);
+	task->color = 0xffff00;
 
 	/* this is an important task */
 	if (!no_prio)
@@ -53,6 +54,7 @@ static int create_task_12(starpu_data_handle_t dataA, unsigned k, unsigned j, un
 	task->handles[1] = starpu_data_get_sub_data(dataA, 2, j, k);
 
 	task->tag_id = TAG12(k,j);
+	task->color = 0x8080ff;
 
 	if (!no_prio && (j == k+1))
 		task->priority = STARPU_MAX_PRIO;
@@ -74,6 +76,7 @@ static int create_task_21(starpu_data_handle_t dataA, unsigned k, unsigned i, un
 	task->handles[1] = starpu_data_get_sub_data(dataA, 2, k, i);
 
 	task->tag_id = TAG21(k,i);
+	task->color = 0x8080c0;
 
 	if (!no_prio && (i == k+1))
 		task->priority = STARPU_MAX_PRIO;
@@ -89,6 +92,7 @@ static int create_task_22(starpu_data_handle_t dataA, unsigned k, unsigned i, un
 	struct starpu_task *task = starpu_task_create();
 
 	task->cl = &cl22;
+	task->color = 0x00ff00;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = starpu_data_get_sub_data(dataA, 2, k, i);

+ 6 - 1
examples/lu/xlu_implicit_pivot.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2015,2017                           Université de Bordeaux
+ * Copyright (C) 2010-2015,2017-2018                           Université de Bordeaux
  * Copyright (C) 2010                                     Mehdi Juhoor
  * Copyright (C) 2010-2013,2015-2018                      CNRS
  * Copyright (C) 2013                                     Inria
@@ -37,6 +37,7 @@ static int create_task_pivot(starpu_data_handle_t *dataAp, unsigned nblocks,
 	struct starpu_task *task = starpu_task_create();
 
 	task->cl = &cl_pivot;
+	task->color = 0xc0c000;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = get_block(dataAp, nblocks, k, i);
@@ -63,6 +64,7 @@ static int create_task_11_pivot(starpu_data_handle_t *dataAp, unsigned nblocks,
 	struct starpu_task *task = starpu_task_create();
 
 	task->cl = &cl11_pivot;
+	task->color = 0xffff00;
 
 	task->cl_arg = &piv_description[k];
 
@@ -87,6 +89,7 @@ static int create_task_12(starpu_data_handle_t *dataAp, unsigned nblocks, unsign
 	struct starpu_task *task = starpu_task_create();
 
 	task->cl = &cl12;
+	task->color = 0x8080ff;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = get_block(dataAp, nblocks, k, k);
@@ -109,6 +112,7 @@ static int create_task_21(starpu_data_handle_t *dataAp, unsigned nblocks, unsign
 	struct starpu_task *task = starpu_task_create();
 
 	task->cl = &cl21;
+	task->color = 0x8080c0;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = get_block(dataAp, nblocks, k, k);
@@ -131,6 +135,7 @@ static int create_task_22(starpu_data_handle_t *dataAp, unsigned nblocks, unsign
 	struct starpu_task *task = starpu_task_create();
 
 	task->cl = &cl22;
+	task->color = 0x00ff00;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = get_block(dataAp, nblocks, k, i);

+ 6 - 1
examples/lu/xlu_pivot.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2015,2017                           Université de Bordeaux
+ * Copyright (C) 2009-2015,2017-2018                           Université de Bordeaux
  * Copyright (C) 2010-2013,2015,2017,2018                 CNRS
  * Copyright (C) 2011,2013                                Inria
  *
@@ -46,6 +46,7 @@ static int create_task_pivot(starpu_data_handle_t *dataAp, unsigned nblocks,
 	struct starpu_task *task = create_task(PIVOT(k, i));
 
 	task->cl = &cl_pivot;
+	task->color = 0xc0c000;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = get_block(dataAp, nblocks, k, i);
@@ -96,6 +97,7 @@ static struct starpu_task *create_task_11_pivot(starpu_data_handle_t *dataAp, un
 	struct starpu_task *task = create_task(TAG11(k));
 
 	task->cl = &cl11_pivot;
+	task->color = 0xffff00;
 
 	task->cl_arg = &piv_description[k];
 
@@ -125,6 +127,7 @@ static int create_task_12(starpu_data_handle_t *dataAp, unsigned nblocks, unsign
 	struct starpu_task *task = create_task(TAG12(k, j));
 
 	task->cl = &cl12;
+	task->color = 0x8080ff;
 
 	task->cl_arg = (void *)(task->tag_id);
 
@@ -163,6 +166,7 @@ static int create_task_21(starpu_data_handle_t *dataAp, unsigned nblocks, unsign
 	struct starpu_task *task = create_task(TAG21(k, i));
 
 	task->cl = &cl21;
+	task->color = 0x8080c0;
 
 	/* which sub-data is manipulated ? */
 	task->handles[0] = get_block(dataAp, nblocks, k, k);
@@ -193,6 +197,7 @@ static int create_task_22(starpu_data_handle_t *dataAp, unsigned nblocks, unsign
 	struct starpu_task *task = create_task(TAG22(k, i, j));
 
 	task->cl = &cl22;
+	task->color = 0x00ff00;
 
 	task->cl_arg = (void *)(task->tag_id);
 

+ 1 - 1
include/starpu_perfmodel.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011-2013,2016                           Inria
- * Copyright (C) 2009-2017                                Université de Bordeaux
+ * Copyright (C) 2009-2018                                Université de Bordeaux
  * Copyright (C) 2010-2017                                CNRS
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2011                                     Télécom-SudParis

+ 3 - 0
include/starpu_task.h

@@ -128,6 +128,7 @@ struct starpu_codelet
 	unsigned long per_worker_stats[STARPU_NMAXWORKERS];
 
 	const char *name;
+	unsigned color;
 
 	int flags;
 };
@@ -201,6 +202,7 @@ struct starpu_task
 
 	int magic;
 	unsigned type;
+	unsigned color;
 
 	unsigned sched_ctx;
 	int hypervisor_tag;
@@ -257,6 +259,7 @@ struct starpu_task
 	.starpu_private = NULL,				\
 	.magic = 42,                  			\
 	.type = 0,					\
+	.color = 0,					\
 	.sched_ctx = STARPU_NMAX_SCHED_CTXS,		\
 	.hypervisor_tag = 0,				\
 	.flops = 0.0,					\

+ 11 - 0
src/common/fxt.h

@@ -106,6 +106,8 @@
 
 #define _STARPU_FUT_DATA_WONT_USE	0x512c
 
+#define _STARPU_FUT_TASK_COLOR	0x512d
+
 #define	_STARPU_FUT_START_MEMRECLAIM	0x5131
 #define	_STARPU_FUT_END_MEMRECLAIM	0x5132
 
@@ -695,6 +697,14 @@ do {										\
 	}									\
 } while(0);
 
+#define _STARPU_TRACE_TASK_COLOR(job)						\
+do { \
+	if ((job)->task->color != 0) \
+		FUT_DO_PROBE3(_STARPU_FUT_TASK_COLOR, (job)->job_id, (job)->task->color, _starpu_gettid()); \
+	else if ((job)->task->cl && (job)->task->cl->color != 0) \
+		FUT_DO_PROBE3(_STARPU_FUT_TASK_COLOR, (job)->job_id, (job)->task->cl->color, _starpu_gettid()); \
+} while(0)
+
 #define _STARPU_TRACE_TASK_DONE(job)						\
 	FUT_DO_PROBE2(_STARPU_FUT_TASK_DONE, (job)->job_id, _starpu_gettid())
 
@@ -1129,6 +1139,7 @@ do {										\
 #define _STARPU_TRACE_TASK_DEPS(a, b)		do {(void)(a); (void)(b);} while(0)
 #define _STARPU_TRACE_GHOST_TASK_DEPS(a, b)	do {(void)(a); (void)(b);} while(0)
 #define _STARPU_TRACE_TASK_NAME(a)		do {(void)(a);} while(0)
+#define _STARPU_TRACE_TASK_COLOR(a)		do {(void)(a);} while(0)
 #define _STARPU_TRACE_TASK_DONE(a)		do {(void)(a);} while(0)
 #define _STARPU_TRACE_TAG_DONE(a)		do {(void)(a);} while(0)
 #define _STARPU_TRACE_DATA_NAME(a, b)		do {(void)(a); (void)(b);} while(0)

+ 33 - 8
src/debug/traces/starpu_fxt.c

@@ -103,6 +103,7 @@ struct task_info
 	unsigned long job_id;
 	unsigned long submit_order;
 	long priority;
+	int color;
 	uint64_t tag;
 	int workerid;
 	int node;
@@ -139,6 +140,7 @@ static struct task_info *get_task(unsigned long job_id, int mpi_rank)
 		task->job_id = job_id;
 		task->submit_order = 0;
 		task->priority = 0;
+		task->color = 0;
 		task->tag = 0;
 		task->workerid = -1;
 		task->node = -1;
@@ -1325,7 +1327,7 @@ static void create_paje_state_color(char *name, char *type, int ctx, float red,
 }
 #endif
 
-static void create_paje_state_if_not_found(char *name, struct starpu_fxt_options *options)
+static void create_paje_state_if_not_found(char *name, unsigned color, struct starpu_fxt_options *options)
 {
 	struct _starpu_symbol_name *itor;
 	for (itor = _starpu_symbol_name_list_begin(&symbol_list);
@@ -1354,7 +1356,13 @@ static void create_paje_state_if_not_found(char *name, struct starpu_fxt_options
 	uint32_t hash_sum = hash_symbol_red + hash_symbol_green + hash_symbol_blue;
 
 	float red, green, blue;
-	if (options->per_task_colour)
+	if (color != 0)
+	{
+		red = color / 0x100 / 0x100;
+		green = (color / 0x100) & 0xff;
+		blue = color & 0xff;
+	}
+	else if (options->per_task_colour)
 	{
 		red = (1.0f * hash_symbol_red) / hash_sum;
 		green = (1.0f * hash_symbol_green) / hash_sum;
@@ -1472,9 +1480,9 @@ static void handle_start_codelet_body(struct fxt_ev_64 *ev, struct starpu_fxt_op
 	double last_start_codelet_time = last_codelet_start[worker];
 	last_codelet_start[worker] = start_codelet_time;
 
-	create_paje_state_if_not_found(name, options);
-
 	struct task_info *task = get_task(ev->param[0], options->file_rank);
+	create_paje_state_if_not_found(name, task->color, options);
+
 	task->start_time = start_codelet_time;
 	task->workerid = worker;
 	task->name = strdup(name);
@@ -2619,12 +2627,21 @@ static void handle_task_submit(struct fxt_ev_64 *ev, struct starpu_fxt_options *
 	task->type = type;
 }
 
+static void handle_task_color(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
+{
+	unsigned long job_id = ev->param[0];
+	struct task_info *task = get_task(job_id, options->file_rank);
+	int color = (long) ev->param[1];
+
+	task->color = color;
+}
+
 static void handle_task_name(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
 {
 	char *prefix = options->file_prefix;
 
-	unsigned long job_id;
-	job_id = ev->param[0];
+	unsigned long job_id = ev->param[0];
+	struct task_info *task = get_task(job_id, options->file_rank);
 
 	unsigned long has_name = ev->param[3];
 	char *name = has_name?get_fxt_string(ev,4):"unknown";
@@ -2634,7 +2651,12 @@ static void handle_task_name(struct fxt_ev_64 *ev, struct starpu_fxt_options *op
 
 	const char *colour;
 	char buffer[32];
-	if (options->per_task_colour)
+	if (task->color != 0)
+	{
+		snprintf(buffer, sizeof(buffer), "#%06x", task->color);
+		colour = &buffer[0];
+	}
+	else if (options->per_task_colour)
 	{
 		snprintf(buffer, sizeof(buffer), "#%x%x%x",
 			 get_colour_symbol_red(name)/4,
@@ -2648,7 +2670,6 @@ static void handle_task_name(struct fxt_ev_64 *ev, struct starpu_fxt_options *op
 	}
 
 	unsigned exclude_from_dag = ev->param[2];
-	struct task_info *task = get_task(job_id, options->file_rank);
 	task->exclude_from_dag = exclude_from_dag;
 
 	if (!exclude_from_dag && show_task(task, options))
@@ -3405,6 +3426,10 @@ void _starpu_fxt_parse_new_file(char *filename_in, struct starpu_fxt_options *op
 				handle_task_name(&ev, options);
 				break;
 
+			case _STARPU_FUT_TASK_COLOR:
+				handle_task_color(&ev, options);
+				break;
+
 			case _STARPU_FUT_TASK_DONE:
 				handle_task_done(&ev, options);
 				break;

+ 5 - 1
src/drivers/driver_common/driver_common.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2011-2017                                Inria
- * Copyright (C) 2010-2017                                Université de Bordeaux
+ * Copyright (C) 2010-2018                                Université de Bordeaux
  * Copyright (C) 2010-2017                                CNRS
  * Copyright (C) 2013                                     Thibaut Lambert
  * Copyright (C) 2011                                     Télécom-SudParis
@@ -99,10 +99,14 @@ void _starpu_driver_start_job(struct _starpu_worker *worker, struct _starpu_job
 				}
 			}
 		}
+		_STARPU_TRACE_TASK_COLOR(j);
 		_STARPU_TRACE_START_CODELET_BODY(j, j->nimpl, &sched_ctx->perf_arch, workerid);
 	}
 	else
+	{
+		_STARPU_TRACE_TASK_COLOR(j);
 		_STARPU_TRACE_START_CODELET_BODY(j, j->nimpl, perf_arch, workerid);
+	}
 	_starpu_sched_ctx_unlock_read(sched_ctx->id);
 	_STARPU_TASK_BREAK_ON(task, exec);
 }