Browse Source

mic (perfmodel): Correction compilation error

Thibaud Lambert 11 years ago
parent
commit
099dd2cd32

+ 8 - 0
examples/cholesky/cholesky.h

@@ -138,9 +138,17 @@ void chol_cublas_codelet_update_u21(void *descr[], void *_args);
 void chol_cublas_codelet_update_u22(void *descr[], void *_args);
 #endif
 
+/*
 extern struct starpu_perfmodel chol_model_11;
 extern struct starpu_perfmodel chol_model_21;
 extern struct starpu_perfmodel chol_model_22;
+*/
+
+struct starpu_perfmodel chol_model_11;
+struct starpu_perfmodel chol_model_21;
+struct starpu_perfmodel chol_model_22;
+
+void initialize_chol_model(struct starpu_perfmodel* model, int i);
 
 static void STARPU_ATTRIBUTE_UNUSED parse_args(int argc, char **argv)
 {

+ 4 - 0
examples/cholesky/cholesky_grain_tag.c

@@ -292,6 +292,10 @@ static void initialize_system(float **A, unsigned dim, unsigned pinned)
 		exit(77);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
+	initialize_chol_model(&chol_model_11,11);
+	initialize_chol_model(&chol_model_21,21);
+	initialize_chol_model(&chol_model_22,22);
+
 	starpu_cublas_init();
 
 #ifndef STARPU_SIMGRID

+ 4 - 0
examples/cholesky/cholesky_implicit.c

@@ -346,6 +346,10 @@ int main(int argc, char **argv)
                 return 77;
         STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
+	initialize_chol_model(&chol_model_11,11);
+	initialize_chol_model(&chol_model_21,21);
+	initialize_chol_model(&chol_model_22,22);
+
 	starpu_cublas_init();
 
 	if(with_ctxs)

+ 28 - 3
examples/cholesky/cholesky_models.c

@@ -127,8 +127,33 @@ static double cuda_chol_task_22_cost(struct starpu_task *task, struct starpu_per
 }
 
 
-
-
+void initialize_chol_model(struct starpu_perfmodel* model, int i)
+{
+	intialize_model(model);
+	model.type = STARPU_HISTORY_BASED;
+	switch(i)
+	{
+		case(11):
+			model.per_arch[STARPU_CPU_WORKER][0][0][0] = { .cost_function = cpu_chol_task_11_cost };
+			model.per_arch[STARPU_CUDA_WORKER][0][0][0] = { .cost_function = cuda_chol_task_11_cost };
+			 model.symbol = "chol_model_11";
+			 break;
+		case(21):
+			 model.per_arch[STARPU_CPU_WORKER][0][0][0] = { .cost_function = cpu_chol_task_21_cost };
+			 model.per_arch[STARPU_CUDA_WORKER][0][0][0] = { .cost_function = cuda_chol_task_21_cost };
+			 model.symbol = "chol_model_21";
+			 break;
+		case(22):
+			 model.per_arch[STARPU_CPU_WORKER][0][0][0] = { .cost_function = cpu_chol_task_22_cost };
+			 model.per_arch[STARPU_CUDA_WORKER][0][0][0] = { .cost_function = cuda_chol_task_22_cost };
+			 model.symbol = "chol_model_22";
+			 break;
+		default:
+			 STARPU_ABORT();
+			 break;
+	}
+}
+/*
 struct starpu_perfmodel chol_model_11 =
 {
 	.per_arch =
@@ -160,4 +185,4 @@ struct starpu_perfmodel chol_model_22 =
 	},
 	.type = STARPU_HISTORY_BASED,
 	.symbol = "chol_model_22"
-};
+};*/

+ 4 - 0
examples/cholesky/cholesky_tag.c

@@ -258,6 +258,10 @@ static int initialize_system(float **A, unsigned dim, unsigned pinned)
 		return 77;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
+	initialize_chol_model(&chol_model_11,11);
+	initialize_chol_model(&chol_model_21,21);
+	initialize_chol_model(&chol_model_22,22);
+
 	starpu_cublas_init();
 
 #ifndef STARPU_SIMGRID

+ 4 - 0
examples/cholesky/cholesky_tile_tag.c

@@ -254,6 +254,10 @@ int main(int argc, char **argv)
 		return 77;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
+	initialize_chol_model(&chol_model_11,11);
+	initialize_chol_model(&chol_model_21,21);
+	initialize_chol_model(&chol_model_22,22);
+
 	/* Disable sequential consistency */
 	starpu_data_set_default_sequential_consistency_flag(0);
 

+ 49 - 61
examples/heat/lu_kernels_model.c

@@ -102,7 +102,7 @@ double task_22_cost(struct starpu_task *task, unsigned nimpl)
  */
 
 
-double task_11_cost_cuda(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
+double task_11_cost_cuda(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl)
 {
 	uint32_t n;
 
@@ -114,7 +114,7 @@ double task_11_cost_cuda(struct starpu_task *task, enum starpu_perfmodel_archtyp
 	return PERTURBATE(cost);
 }
 
-double task_12_cost_cuda(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
+double task_12_cost_cuda(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl)
 {
 	uint32_t n;
 
@@ -127,7 +127,7 @@ double task_12_cost_cuda(struct starpu_task *task, enum starpu_perfmodel_archtyp
 }
 
 
-double task_21_cost_cuda(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
+double task_21_cost_cuda(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl)
 {
 	uint32_t n;
 
@@ -141,7 +141,7 @@ double task_21_cost_cuda(struct starpu_task *task, enum starpu_perfmodel_archtyp
 
 
 
-double task_22_cost_cuda(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
+double task_22_cost_cuda(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl)
 {
 	uint32_t nx, ny, nz;
 
@@ -161,7 +161,7 @@ double task_22_cost_cuda(struct starpu_task *task, enum starpu_perfmodel_archtyp
  *
  */
 
-double task_11_cost_cpu(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
+double task_11_cost_cpu(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl)
 {
 	uint32_t n;
 
@@ -173,7 +173,7 @@ double task_11_cost_cpu(struct starpu_task *task, enum starpu_perfmodel_archtype
 	return PERTURBATE(cost);
 }
 
-double task_12_cost_cpu(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
+double task_12_cost_cpu(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl)
 {
 	uint32_t n;
 
@@ -186,7 +186,7 @@ double task_12_cost_cpu(struct starpu_task *task, enum starpu_perfmodel_archtype
 }
 
 
-double task_21_cost_cpu(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
+double task_21_cost_cpu(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl)
 {
 	uint32_t n;
 
@@ -200,7 +200,7 @@ double task_21_cost_cpu(struct starpu_task *task, enum starpu_perfmodel_archtype
 
 
 
-double task_22_cost_cpu(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
+double task_22_cost_cpu(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl)
 {
 	uint32_t nx, ny, nz;
 
@@ -214,74 +214,62 @@ double task_22_cost_cpu(struct starpu_task *task, enum starpu_perfmodel_archtype
 	return PERTURBATE(cost);
 }
 
-struct starpu_perfmodel model_11 =
+void initialize_chol_model(struct starpu_perfmodel* model, int i)
 {
-	.cost_function = task_11_cost,
-	.per_arch =
+	intialize_model(model);
+	model.type = STARPU_HISTORY_BASED;
+	switch(i)
 	{
-		[STARPU_CPU_DEFAULT][0] = { .cost_function = task_11_cost_cpu },
-		[STARPU_CUDA_DEFAULT][0] = { .cost_function = task_11_cost_cuda }
-	},
-	.type = STARPU_HISTORY_BASED,
+		case(11):
+			model.cost_function = task_11_cost;
+			model.per_arch[STARPU_CPU_WORKER][0][0][0].cost_function = task_11_cost_cpu;
+			model.per_arch[STARPU_CUDA_WORKER][0][0][0].cost_function = task_11_cost_cuda;
 #ifdef STARPU_ATLAS
-	.symbol = "lu_model_11_atlas"
+			model.symbol = "lu_model_11_atlas";
 #elif defined(STARPU_GOTO)
-	.symbol = "lu_model_11_goto"
+			model.symbol = "lu_model_11_goto";
 #else
-	.symbol = "lu_model_11"
+			model.symbol = "lu_model_11";
 #endif
-};
-
-struct starpu_perfmodel model_12 =
-{
-	.cost_function = task_12_cost,
-	.per_arch =
-	{
-		[STARPU_CPU_DEFAULT][0] = { .cost_function = task_12_cost_cpu },
-		[STARPU_CUDA_DEFAULT][0] = { .cost_function = task_12_cost_cuda }
-	},
-	.type = STARPU_HISTORY_BASED,
+			break;
+		case(12):
+			model.cost_function = task_12_cost;
+			model.per_arch[STARPU_CPU_WORKER][0][0][0].cost_function = task_12_cost_cpu;
+			model.per_arch[STARPU_CUDA_WORKER][0][0][0].cost_function = task_12_cost_cuda;
 #ifdef STARPU_ATLAS
-	.symbol = "lu_model_12_atlas"
+			model.symbol = "lu_model_12_atlas";
 #elif defined(STARPU_GOTO)
-	.symbol = "lu_model_12_goto"
+			model.symbol = "lu_model_12_goto";
 #else
-	.symbol = "lu_model_12"
+			model.symbol = "lu_model_12";
 #endif
-};
-
-struct starpu_perfmodel model_21 =
-{
-	.cost_function = task_21_cost,
-	.per_arch =
-	{
-		[STARPU_CPU_DEFAULT][0] = { .cost_function = task_21_cost_cpu },
-		[STARPU_CUDA_DEFAULT][0] = { .cost_function = task_21_cost_cuda }
-	},
-	.type = STARPU_HISTORY_BASED,
+			break;
+			case(21):
+			model.cost_function = task_21_cost;
+			model.per_arch[STARPU_CPU_WORKER][0][0][0].cost_function = task_21_cost_cpu;
+			model.per_arch[STARPU_CUDA_WORKER][0][0][0].cost_function = task_21_cost_cuda;
 #ifdef STARPU_ATLAS
-	.symbol = "lu_model_21_atlas"
+			model.symbol = "lu_model_21_atlas";
 #elif defined(STARPU_GOTO)
-	.symbol = "lu_model_21_goto"
+			model.symbol = "lu_model_21_goto";
 #else
-	.symbol = "lu_model_21"
+			model.symbol = "lu_model_21";
 #endif
-};
-
-struct starpu_perfmodel model_22 =
-{
-	.cost_function = task_22_cost,
-	.per_arch =
-	{
-		[STARPU_CPU_DEFAULT][0] = { .cost_function = task_22_cost_cpu },
-		[STARPU_CUDA_DEFAULT][0] = { .cost_function = task_22_cost_cuda }
-	},
-	.type = STARPU_HISTORY_BASED,
+			break;
+			case(22):
+			model.cost_function = task_22_cost;
+			model.per_arch[STARPU_CPU_WORKER][0][0][0].cost_function = task_22_cost_cpu;
+			model.per_arch[STARPU_CUDA_WORKER][0][0][0].cost_function = task_22_cost_cuda;
 #ifdef STARPU_ATLAS
-	.symbol = "lu_model_22_atlas"
+			model.symbol = "lu_model_22_atlas";
 #elif defined(STARPU_GOTO)
-	.symbol = "lu_model_22_goto"
+			model.symbol = "lu_model_22_goto";
 #else
-	.symbol = "lu_model_22"
+			model.symbol = "lu_model_22";
 #endif
-};
+			break;
+		default:
+			 STARPU_ABORT();
+			 break;
+	}
+}

+ 0 - 20
include/starpu_perfmodel.h

@@ -34,7 +34,6 @@ struct starpu_task;
 struct starpu_data_descr;
 
 #define STARPU_NARCH STARPU_ANY_WORKER
-//char archtype_name[STARPU_NARCH] = {"cpu","cuda","opencl","mic","scc"};
 
 struct starpu_perfmodel_arch
 {
@@ -43,25 +42,6 @@ struct starpu_perfmodel_arch
 	int ncore;
 };
 
-#ifdef __STDC_VERSION__
-#  if __STDC_VERSION__ > 199901L || STARPU_GNUC_PREREQ(4, 6)
-
-/* Make sure the following assertions hold, since StarPU relies on it.  */
-
-_Static_assert(STARPU_CPU_DEFAULT == 0,
-	       "invalid STARPU_CPU_DEFAULT value");
-_Static_assert(STARPU_CPU_DEFAULT < STARPU_CUDA_DEFAULT,
-	       "invalid STARPU_{CPU,CUDA}_DEFAULT values");
-_Static_assert(STARPU_CUDA_DEFAULT < STARPU_OPENCL_DEFAULT,
-	       "invalid STARPU_{CUDA,OPENCL}_DEFAULT values");
-_Static_assert(STARPU_OPENCL_DEFAULT < STARPU_MIC_DEFAULT,
-	       "invalid STARPU_{OPENCL,MIC}_DEFAULT values");
-_Static_assert(STARPU_MIC_DEFAULT < STARPU_SCC_DEFAULT,
-	       "invalid STARPU_{MIC,SCC}_DEFAULT values");
-
-#  endif
-#endif
-
 struct starpu_perfmodel_history_entry
 {
 	double mean;

+ 8 - 0
sc_hypervisor/examples/cholesky/cholesky.h

@@ -79,9 +79,17 @@ void chol_cublas_codelet_update_u21(void *descr[], void *_args);
 void chol_cublas_codelet_update_u22(void *descr[], void *_args);
 #endif
 
+/*
 extern struct starpu_perfmodel chol_model_11;
 extern struct starpu_perfmodel chol_model_21;
 extern struct starpu_perfmodel chol_model_22;
+*/
+
+struct starpu_perfmodel chol_model_11;
+struct starpu_perfmodel chol_model_21;
+struct starpu_perfmodel chol_model_22;
+
+void initialize_chol_model(struct starpu_perfmodel* model, int i);
 
 static void STARPU_ATTRIBUTE_UNUSED parse_args(int argc, char **argv)
 {

+ 4 - 0
sc_hypervisor/examples/cholesky/cholesky_grain_tag.c

@@ -276,6 +276,10 @@ static void initialize_system(float **A, unsigned dim, unsigned pinned)
 		exit(77);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
+	initialize_chol_model(&chol_model_11,11);
+	initialize_chol_model(&chol_model_21,21);
+	initialize_chol_model(&chol_model_22,22);
+
 	starpu_cublas_init();
 
 	if (pinned)

+ 4 - 0
sc_hypervisor/examples/cholesky/cholesky_implicit.c

@@ -342,6 +342,10 @@ int main(int argc, char **argv)
 
 	starpu_init(NULL);
 
+	initialize_chol_model(&chol_model_11,11);
+	initialize_chol_model(&chol_model_21,21);
+	initialize_chol_model(&chol_model_22,22);
+
 	starpu_cublas_init();
 
 	if(with_ctxs)

+ 25 - 30
sc_hypervisor/examples/cholesky/cholesky_models.c

@@ -126,35 +126,30 @@ static double cuda_chol_task_22_cost(struct starpu_task *task, enum starpu_perfm
 	return PERTURBATE(cost);
 }
 
-struct starpu_perfmodel chol_model_11 =
+void initialize_chol_model(struct starpu_perfmodel* model, int i)
 {
-	.per_arch =
+	intialize_model(model);
+	model.type = STARPU_HISTORY_BASED;
+	switch(i)
 	{
-		[STARPU_CPU_DEFAULT][0] = { .cost_function = cpu_chol_task_11_cost },
-		[STARPU_CUDA_DEFAULT][0] = { .cost_function = cuda_chol_task_11_cost }
-	},
-	.type = STARPU_HISTORY_BASED,
-	.symbol = "chol_model_11"
-};
-
-struct starpu_perfmodel chol_model_21 =
-{
-	.per_arch =
-	{
-		[STARPU_CPU_DEFAULT][0] = { .cost_function = cpu_chol_task_21_cost },
-		[STARPU_CUDA_DEFAULT][0] = { .cost_function = cuda_chol_task_21_cost }
-	},
-	.type = STARPU_HISTORY_BASED,
-	.symbol = "chol_model_21"
-};
-
-struct starpu_perfmodel chol_model_22 =
-{
-	.per_arch =
-	{
-		[STARPU_CPU_DEFAULT][0] = { .cost_function = cpu_chol_task_22_cost },
-		[STARPU_CUDA_DEFAULT][0] = { .cost_function = cuda_chol_task_22_cost }
-	},
-	.type = STARPU_HISTORY_BASED,
-	.symbol = "chol_model_22"
-};
+		case(11):
+			model.per_arch[STARPU_CPU_WORKER][0][0][0] = { .cost_function = cpu_chol_task_11_cost };
+			model.per_arch[STARPU_CUDA_WORKER][0][0][0] = { .cost_function = cuda_chol_task_11_cost };
+			 model.symbol = "chol_model_11";
+			 break;
+		case(21):
+			 model.per_arch[STARPU_CPU_WORKER][0][0][0] = { .cost_function = cpu_chol_task_21_cost };
+			 model.per_arch[STARPU_CUDA_WORKER][0][0][0] = { .cost_function = cuda_chol_task_21_cost };
+			 model.symbol = "chol_model_21";
+			 break;
+		case(22):
+			 model.per_arch[STARPU_CPU_WORKER][0][0][0] = { .cost_function = cpu_chol_task_22_cost };
+			 model.per_arch[STARPU_CUDA_WORKER][0][0][0] = { .cost_function = cuda_chol_task_22_cost };
+			 model.symbol = "chol_model_22";
+			 break;
+		default:
+			 STARPU_ABORT();
+			 break;
+	}
+}
+

+ 4 - 0
sc_hypervisor/examples/cholesky/cholesky_tag.c

@@ -249,6 +249,10 @@ static int initialize_system(float **A, unsigned dim, unsigned pinned)
 		return 77;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
+	initialize_chol_model(&chol_model_11,11);
+	initialize_chol_model(&chol_model_21,21);
+	initialize_chol_model(&chol_model_22,22);
+
 	starpu_cublas_init();
 
 	if (pinned)

+ 4 - 0
sc_hypervisor/examples/cholesky/cholesky_tile_tag.c

@@ -239,6 +239,10 @@ int main(int argc, char **argv)
 		return 77;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
+	initialize_chol_model(&chol_model_11,11);
+	initialize_chol_model(&chol_model_21,21);
+	initialize_chol_model(&chol_model_22,22);
+
 	/* Disable sequential consistency */
 	starpu_data_set_default_sequential_consistency_flag(0);
 

+ 40 - 5
tools/starpu_perfmodel_plot.c

@@ -194,10 +194,10 @@ static void display_perf_model(FILE *gnuplot_file, struct starpu_perfmodel *mode
 		fprintf(stderr,"Arch: %s\n", arch_name);
 
 #ifdef STARPU_USE_FXT
-	if (!gflops && !no_fxt_file && archtype_is_found[arch] && nimpl == 0)
+	if (!gflops && !no_fxt_file && archtype_is_found[arch->type][arch->devid][arch->ncore] && nimpl == 0)
 	{
 		print_comma(gnuplot_file, first);
-		fprintf(gnuplot_file, "\"< grep -w \\^%d %s\" using 2:3 title \"Profiling %s\"", arch, data_file_name, arch_name);
+		fprintf(gnuplot_file, "\"< grep -w \\^%d_%d_%d %s\" using 2:3 title \"Profiling %s\"", arch->type, arch->devid, arch->ncore, data_file_name, arch_name);
 	}
 #endif
 
@@ -420,6 +420,41 @@ static void display_all_perf_models(FILE *gnuplot_file, struct starpu_perfmodel
 }
 
 #ifdef STARPU_USE_FXT
+static int ** init_archtype_is_found_per_arch(int maxdevid, unsigned* maxncore_table)
+{
+	int devid, ncore;
+	int ** archtype_is_found_per_arch = malloc(sizeof(*archtype_is_found_per_arch)*(maxdevid+1));
+	archtype_is_found_per_arch[maxdevid] = NULL;
+	for(devid=0; devid<maxdevid; devid++)
+	{
+		int maxncore;
+		if(maxncore_table != NULL)
+			maxncore = maxncore_table[devid];
+		else
+			maxncore = 1;
+		
+		archtype_is_found_per_arch[devid] = malloc(sizeof(*archtype_is_found_per_arch[devid])*(maxncore+1));
+		archtype_is_found_per_arch[devid][maxncore] = NULL;
+		for(ncore=0; ncore<maxncore; ncore++)
+			archtype_is_found_per_arch[devid][ncore] = 0;
+	}
+	return archtype_is_found_per_arch;
+
+}
+
+
+static void init_achrtype_is_found()
+{
+	struct _starpu_machine_config *conf = _starpu_get_machine_config();
+
+	archtype_is_found[STARPU_CPU_WORKER] = init_archtype_is_found_per_arch(1,&conf->topology.ncpus);
+	archtype_is_found[STARPU_CUDA_WORKER] = init_archtype_is_found_per_arch(conf->topology.ncudagpus,NULL); 
+	archtype_is_found[STARPU_OPENCL_WORKER] = init_archtype_is_found_per_arch(conf->topology.nopenclgpus,NULL); 
+	archtype_is_found[STARPU_MIC_WORKER] = init_archtype_is_found_per_arch(conf->topology.nmicdevices,conf->topology.nmiccores); 
+	archtype_is_found[STARPU_SCC_WORKER] = init_archtype_is_found_per_arch(conf->topology.nsccdevices,NULL); 
+}
+
+
 static void dump_data_file(FILE *data_file)
 {
 	memset(archtype_is_found, 0, STARPU_NARCH_VARIATIONS*sizeof(int));
@@ -430,13 +465,13 @@ static void dump_data_file(FILE *data_file)
 		/* Dump only if the symbol matches user's request */
 		if (strncmp(dumped_codelets[i].symbol, symbol, (FXT_MAX_PARAMS - 4)*sizeof(unsigned long)-1) == 0)
 		{
-			enum starpu_perfmodel_archtype archtype = dumped_codelets[i].archtype;
-			archtype_is_found[archtype] = 1;
+			struct starpu_perfmodel_arch* arch = dumped_codelets[i].arch;
+			archtype_is_found[arch->type][arch->devid][arch->ncore] = 1;
 
 			size_t size = dumped_codelets[i].size;
 			float time = dumped_codelets[i].time;
 
-			fprintf(data_file, "%d	%f	%f\n", archtype, (float)size, time);
+			fprintf(data_file, "%d_%d_%d	%f	%f\n", arch->type, arch->devid, arch->ncore, (float)size, time);
 		}
 	}
 }