Browse Source

starpu_fxt_tool manages 2 ctxs

Andra Hugo 13 years ago
parent
commit
439a8dcf5b

+ 17 - 14
sched_ctx_hypervisor/examples/cholesky/cholesky_implicit.c

@@ -192,21 +192,9 @@ static void cholesky(float *matA, unsigned size, unsigned ld, unsigned nblocks)
 	_cholesky(dataA, nblocks);
 }
 
-static void execute_cholesky(unsigned size, unsigned nblocks)
+static void execute_cholesky(float *mat, unsigned size, unsigned nblocks)
 {
-	float *mat;
-	starpu_malloc((void **)&mat, (size_t)size*size*sizeof(float));
-
 	unsigned i,j;
-	for (i = 0; i < size; i++)
-	{
-		for (j = 0; j < size; j++)
-		{
-			mat[j +i*size] = (1.0f/(1.0f+i+j)) + ((i == j)?1.0f*size:0.0f);
-			/* mat[j +i*size] = ((i == j)?1.0f*size:0.0f); */
-		}
-	}
-
 /* #define PRINT_OUTPUT */
 #ifdef PRINT_OUTPUT
 	FPRINTF(stdout, "Input :\n");
@@ -326,7 +314,22 @@ int main(int argc, char **argv)
 	else if(chole2)
 		start_2ndbench(execute_cholesky);
 	else
-		execute_cholesky(size, nblocks);
+	{
+		float *mat;
+		starpu_malloc((void **)&mat, (size_t)size*size*sizeof(float));
+		
+		unsigned i,j;
+		for (i = 0; i < size; i++)
+		{
+			for (j = 0; j < size; j++)
+			{
+				mat[j +i*size] = (1.0f/(1.0f+i+j)) + ((i == j)?1.0f*size:0.0f);
+				/* mat[j +i*size] = ((i == j)?1.0f*size:0.0f); */
+			}
+		}
+
+		execute_cholesky(mat, size, nblocks);
+	}
 
 	starpu_helper_cublas_shutdown();
 	starpu_shutdown();

+ 49 - 14
sched_ctx_hypervisor/examples/sched_ctx_utils/sched_ctx_utils.c

@@ -1,6 +1,7 @@
 #include "sched_ctx_utils.h"
 #include <starpu.h>
 #include "sched_ctx_hypervisor.h"
+#define NSAMPLES 3
 
 unsigned size1;
 unsigned size2;
@@ -18,9 +19,10 @@ typedef struct {
 	int the_other_ctx;
 	int *procs;
 	int nprocs;
-	void (*bench)(unsigned, unsigned);
+	void (*bench)(float*, unsigned, unsigned);
 	unsigned size;
 	unsigned nblocks;
+	float *mat[NSAMPLES];
 } params;
 
 typedef struct {
@@ -28,7 +30,6 @@ typedef struct {
 	double avg_timing;
 } retvals;
 
-#define NSAMPLES 3
 int first = 1;
 pthread_mutex_t mut;
 retvals rv[2];
@@ -81,7 +82,7 @@ void* start_bench(void *val){
 		starpu_set_sched_ctx(&p->ctx);
 
 	for(i = 0; i < NSAMPLES; i++)
-		p->bench(p->size, p->nblocks);
+		p->bench(p->mat[i], p->size, p->nblocks);
 
 	if(p->ctx != 0)
 	{
@@ -100,7 +101,23 @@ void* start_bench(void *val){
 	
 }
 
-void start_2benchs(void (*bench)(unsigned, unsigned))
+float* construct_matrix(unsigned size)
+{
+	float *mat;
+	starpu_malloc((void **)&mat, (size_t)size*size*sizeof(float));
+
+	unsigned i,j;
+	for (i = 0; i < size; i++)
+	{
+		for (j = 0; j < size; j++)
+		{
+			mat[j +i*size] = (1.0f/(1.0f+i+j)) + ((i == j)?1.0f*size:0.0f);
+			/* mat[j +i*size] = ((i == j)?1.0f*size:0.0f); */
+		}
+	}
+	return mat;
+}
+void start_2benchs(void (*bench)(float*, unsigned, unsigned))
 {
 	p1.bench = bench;
 	p1.size = size1;
@@ -109,7 +126,14 @@ void start_2benchs(void (*bench)(unsigned, unsigned))
 	p2.bench = bench;
 	p2.size = size2;
 	p2.nblocks = nblocks2;
-	
+
+	int i;
+	for(i = 0; i < NSAMPLES; i++)
+	{
+		p1.mat[i] = construct_matrix(p1.size);
+		p2.mat[i] = construct_matrix(p2.size);
+	}
+
 	pthread_t tid[2];
 	pthread_mutex_init(&mut, NULL);
 
@@ -136,12 +160,18 @@ void start_2benchs(void (*bench)(unsigned, unsigned))
 
 }
 
-void start_1stbench(void (*bench)(unsigned, unsigned))
+void start_1stbench(void (*bench)(float*, unsigned, unsigned))
 {
 	p1.bench = bench;
 	p1.size = size1;
 	p1.nblocks = nblocks1;
-	
+
+	int i;
+	for(i = 0; i < NSAMPLES; i++)
+	{
+		p1.mat[i] = construct_matrix(p1.size);
+	}
+
 	struct timeval start;
 	struct timeval end;
 
@@ -160,11 +190,16 @@ void start_1stbench(void (*bench)(unsigned, unsigned))
 	printf("%2.2f %2.2f\n", rv[0].avg_timing, timing);
 }
 
-void start_2ndbench(void (*bench)(unsigned, unsigned))
+void start_2ndbench(void (*bench)(float*, unsigned, unsigned))
 {
 	p2.bench = bench;
 	p2.size = size2;
 	p2.nblocks = nblocks2;
+	int i;
+	for(i = 0; i < NSAMPLES; i++)
+	{
+		p2.mat[i] = construct_matrix(p2.size);
+	}
 	
 	struct timeval start;
 	struct timeval end;
@@ -184,7 +219,7 @@ void start_2ndbench(void (*bench)(unsigned, unsigned))
 	printf("%2.2f %2.2f\n", rv[1].avg_timing, timing);
 }
 
-void construct_contexts(void (*bench)(unsigned, unsigned))
+void construct_contexts(void (*bench)(float*, unsigned, unsigned))
 {
 	struct starpu_sched_ctx_hypervisor_criteria *criteria = sched_ctx_hypervisor_init(SIMPLE_POLICY);
 	int nprocs1 = cpu1 + gpu + gpu1;
@@ -285,11 +320,11 @@ void set_hypervisor_conf(int event, int task_tag)
  		
 
 		sched_ctx_hypervisor_advise(p2.ctx, p2.procs, p2.nprocs, task_tag);
-		/* sched_ctx_hypervisor_ioctl(p2.ctx, */
-		/* 			   HYPERVISOR_MAX_IDLE, p2.procs, p2.nprocs, max_idle_time_small, */
-		/* 			   HYPERVISOR_TIME_TO_APPLY, task_tag, */
-		/* 			   HYPERVISOR_GRANULARITY, 1, */
-		/* 			   NULL); */
+		sched_ctx_hypervisor_ioctl(p2.ctx,
+					   HYPERVISOR_MAX_IDLE, p2.procs, p2.nprocs, max_idle_time_small,
+					   HYPERVISOR_TIME_TO_APPLY, task_tag,
+					   HYPERVISOR_GRANULARITY, 1,
+					   NULL);
 	}
 }
 

+ 4 - 4
sched_ctx_hypervisor/examples/sched_ctx_utils/sched_ctx_utils.h

@@ -9,8 +9,8 @@
 
 void parse_args_ctx(int argc, char **argv);
 void update_sched_ctx_timing_results(double gflops, double timing);
-void construct_contexts(void (*bench)(unsigned size, unsigned nblocks));
+void construct_contexts(void (*bench)(float *mat, unsigned size, unsigned nblocks));
 void end_contexts(void);
-void start_2benchs(void (*bench)(unsigned size, unsigned nblocks));
-void start_1stbench(void (*bench)(unsigned size, unsigned nblocks));
-void start_2ndbench(void (*bench)(unsigned size, unsigned nblocks));
+void start_2benchs(void (*bench)(float *mat, unsigned size, unsigned nblocks));
+void start_1stbench(void (*bench)(float *mat, unsigned size, unsigned nblocks));
+void start_2ndbench(void (*bench)(float *mat, unsigned size, unsigned nblocks));

+ 4 - 4
src/common/fxt.h

@@ -189,10 +189,10 @@ do {									\
 	if (model_name)                                                 \
 	{								\
 		/* we include the symbol name */			\
-		STARPU_FUT_DO_PROBE3STR(STARPU_FUT_START_CODELET_BODY, (job), syscall(SYS_gettid), 1, model_name); \
+		STARPU_FUT_DO_PROBE4STR(STARPU_FUT_START_CODELET_BODY, (job), ((job)->task)->sched_ctx, syscall(SYS_gettid), 1, model_name); \
 	}								\
 	else {                                                          \
-		FUT_DO_PROBE3(STARPU_FUT_START_CODELET_BODY, (job), syscall(SYS_gettid), 0); \
+		FUT_DO_PROBE4(STARPU_FUT_START_CODELET_BODY, (job), ((job)->task)->sched_ctx, syscall(SYS_gettid), 0); \
 	}								\
 } while(0);
 
@@ -248,10 +248,10 @@ do {										\
         const char *model_name = _starpu_get_model_name((job));                       \
 	if (model_name)					                        \
 	{									\
-		STARPU_FUT_DO_PROBE4STR(STARPU_FUT_TASK_DONE, (job)->job_id, syscall(SYS_gettid), (long unsigned)exclude_from_dag, 1, model_name);\
+		STARPU_FUT_DO_PROBE4STR(STARPU_FUT_TASK_DONE, (job)->job_id, syscall(SYS_gettid), (long unsigned)exclude_from_dag, 1, model_name); \
 	}									\
 	else {									\
-		FUT_DO_PROBE4(STARPU_FUT_TASK_DONE, (job)->job_id, syscall(SYS_gettid), (long unsigned)exclude_from_dag, 0);\
+		FUT_DO_PROBE4(STARPU_FUT_TASK_DONE, (job)->job_id, syscall(SYS_gettid), (long unsigned)exclude_from_dag, 0); \
 	}									\
 } while(0);
 

+ 3 - 3
src/core/workers.c

@@ -349,11 +349,11 @@ int starpu_init(struct starpu_conf *user_conf)
 #endif
 
 	srand(2008);
-	
+
 #ifdef STARPU_USE_FXT
-	_starpu_start_fxt_profiling();
+		_starpu_start_fxt_profiling();
 #endif
-	
+
 	_starpu_open_debug_logfile();
 
 	_starpu_data_interface_init();

+ 29 - 16
src/debug/traces/starpu_fxt.c

@@ -26,6 +26,7 @@ static char *cpus_worker_colors[STARPU_NMAXWORKERS] = {"/greens9/7", "/greens9/6
 static char *cuda_worker_colors[STARPU_NMAXWORKERS] = {"/ylorrd9/9", "/ylorrd9/6", "/ylorrd9/3", "/ylorrd9/1", "/ylorrd9/8", "/ylorrd9/7", "/ylorrd9/4", "/ylorrd9/2",  "/ylorrd9/1"};
 static char *opencl_worker_colors[STARPU_NMAXWORKERS] = {"/blues9/9", "/blues9/6", "/blues9/3", "/blues9/1", "/blues9/8", "/blues9/7", "/blues9/4", "/blues9/2",  "/blues9/1"};
 static char *other_worker_colors[STARPU_NMAXWORKERS] = {"/greys9/9", "/greys9/8", "/greys9/7", "/greys9/6"};
+
 static char *worker_colors[STARPU_NMAXWORKERS];
 
 static unsigned opencl_index = 0;
@@ -310,15 +311,15 @@ static void create_paje_state_if_not_found(char *name, struct starpu_fxt_options
 		strcpy(entry->name, name);
 
 	symbol_name_list_push_front(symbol_list, entry);
-	
+
+	float red, green, blue;
 	/* choose some colour ... that's disguting yes */
 	unsigned hash_symbol_red = get_colour_symbol_red(name);
 	unsigned hash_symbol_green = get_colour_symbol_green(name);
 	unsigned hash_symbol_blue = get_colour_symbol_blue(name);
-
+	
 	uint32_t hash_sum = hash_symbol_red + hash_symbol_green + hash_symbol_blue;
-
-	float red, green, blue;
+	
 	if (options->per_task_colour)
 	{
 		red = (1.0f * hash_symbol_red) / hash_sum;
@@ -331,24 +332,28 @@ static void create_paje_state_if_not_found(char *name, struct starpu_fxt_options
 		green = 0.6f;
 		blue = 0.4f;
 	}
-
 	/* create the Paje state */
 	if (out_paje_file)
-	fprintf(out_paje_file, "6       %s       S       %s \"%f %f %f\" \n", name, name, red, green, blue);
+	{
+		fprintf(out_paje_file, "6       %s       S       %s \"%f %f %f\" \n", name, name, red, green, blue);
+
+	}
+		
 }
 
 
 static void handle_start_codelet_body(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
 {
 	int worker;
-	worker = find_worker_id(ev->param[1]);
+	worker = find_worker_id(ev->param[2]);
 
+	unsigned sched_ctx = ev->param[1];
 	if (worker < 0) return;
 
 	char *prefix = options->file_prefix;
 
-	unsigned long has_name = ev->param[2];
-	char *name = has_name?(char *)&ev->param[3]:"unknown";
+	unsigned long has_name = ev->param[3];
+	char *name = has_name?(char *)&ev->param[4]:"unknown";
 
 	snprintf(last_codelet_symbol[worker], 128, "%s", name);
 
@@ -358,7 +363,14 @@ static void handle_start_codelet_body(struct fxt_ev_64 *ev, struct starpu_fxt_op
 	create_paje_state_if_not_found(name, options);
 
 	if (out_paje_file)
-	fprintf(out_paje_file, "10       %f	S      %s%"PRIu64"      %s\n", start_codelet_time, prefix, ev->param[1], name);
+	{
+		fprintf(out_paje_file, "10       %f	S      %s%"PRIu64"      %s\n", start_codelet_time, prefix, ev->param[2], name);
+		if(sched_ctx == 1)
+		fprintf(out_paje_file, "10       %f	S      %s%"PRIu64"      Ctx1\n", start_codelet_time, prefix, ev->param[2]);
+		else if(sched_ctx == 2)
+		fprintf(out_paje_file, "10       %f	S      %s%"PRIu64"      Ctx2\n", start_codelet_time, prefix, ev->param[2]);
+	}
+	
 }
 
 static long dumped_codelets_count;
@@ -455,7 +467,7 @@ static void handle_worker_status(struct fxt_ev_64 *ev, struct starpu_fxt_options
 
 	if (out_paje_file)
 	fprintf(out_paje_file, "10       %f	S      %s%"PRIu64"      %s\n",
-				get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], newstatus);
+		get_event_time_stamp(ev, options), options->file_prefix, ev->param[1], newstatus);
 }
 
 static double last_sleep_start[STARPU_NMAXWORKERS];
@@ -645,12 +657,13 @@ static void handle_task_done(struct fxt_ev_64 *ev, struct starpu_fxt_options *op
 {
 	unsigned long job_id;
 	job_id = ev->param[0];
+	unsigned sched_ctx = ev->param[1];
 
-	unsigned long has_name = ev->param[3];
-	char *name = has_name?(char *)&ev->param[4]:"unknown";
+	unsigned long has_name = ev->param[4];
+	char *name = has_name?(char *)&ev->param[5]:"unknown";
 
         int worker;
-        worker = find_worker_id(ev->param[1]);
+        worker = find_worker_id(ev->param[2]);
 
 	const char *colour;
 	char buffer[32];
@@ -662,10 +675,10 @@ static void handle_task_done(struct fxt_ev_64 *ev, struct starpu_fxt_options *op
 		colour = &buffer[0];
 	}
 	else {
-		colour= (worker < 0)?"#aaaaaa":get_worker_color(worker);
+		colour = (worker < 0)?"#aaaaaa":get_worker_color(worker);
 	}
 
-	unsigned exclude_from_dag = ev->param[2];
+	unsigned exclude_from_dag = ev->param[3];
 
 	if (!exclude_from_dag)
 		starpu_fxt_dag_set_task_done(job_id, name, colour);

+ 6 - 0
src/debug/traces/starpu_paje.c

@@ -124,6 +124,8 @@ void starpu_fxt_write_paje_header(FILE *file)
 	fprintf(file, "%%	Key	string\n");
 	fprintf(file, "%%EndEventDef\n");
 
+
+
 	fprintf(file, "                                        \n \
 	1       MPIP      0       \"MPI Program\"                      	\n \
 	1       P      MPIP       \"Program\"                      	\n \
@@ -148,6 +150,8 @@ void starpu_fxt_write_paje_header(FILE *file)
 	6       R       MS      Reclaiming         \".0 .1 .4\"		\n \
 	6       Co       MS     DriverCopy         \".3 .5 .1\"		\n \
 	6       No       MS     Nothing         \".0 .0 .0\"		\n \
+	6       Ctx1       S     InCtx1         \"255.0 255.0 .0\"		\n \
+	6       Ctx2       S     InCtx2         \".0 191.0 255.0\"		\n \
 	5       MPIL     MPIP	P	P      MPIL\n \
 	5       L       P	Mn	Mn      L\n");
 
@@ -155,3 +159,5 @@ void starpu_fxt_write_paje_header(FILE *file)
 }
 
 #endif
+
+