Samuel Thibault лет назад: 15
Родитель
Сommit
cbc4bd0ff8

+ 3 - 0
include/starpu-util.h

@@ -232,6 +232,9 @@ void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t
 cudaStream_t *starpu_get_local_cuda_stream(void);
 #endif
 
+/* If FILE is currently on a comment line, eat it.  */
+void starpu_drop_comments(FILE *f);
+
 #ifdef __cplusplus
 }
 #endif

+ 2 - 1
src/Makefile.am

@@ -133,7 +133,8 @@ libstarpu_la_SOURCES = 						\
 	util/malloc.c						\
 	util/execute_on_all.c					\
 	util/starpu_create_sync_task.c				\
-	util/starpu_cublas.c
+	util/starpu_cublas.c					\
+	util/file.c
 	
 if USE_CPU
 libstarpu_la_SOURCES += drivers/core/driver_core.c

+ 22 - 4
src/core/perfmodel/perfmodel_bus.c

@@ -276,6 +276,7 @@ static void load_bus_affinity_file_content(void)
 
 		int dummy;
 
+		starpu_drop_comments(f);
 		ret = fscanf(f, "%d\t", &dummy);
 		STARPU_ASSERT(ret == 1);
 
@@ -316,6 +317,11 @@ static void write_bus_affinity_file_content(void)
 	struct machine_config_s *config = _starpu_get_machine_config();
 	unsigned ncores = _starpu_topology_get_nhwcore(config);
 
+	fprintf(f, "# GPU\t");
+	for (core = 0; core < ncores; core++)
+		fprintf(f, "CPU%d\t", core);
+	fprintf(f, "\n");
+
 	int gpu;
 	for (gpu = 0; gpu < ncuda; gpu++)
 	{
@@ -387,11 +393,12 @@ static void load_bus_latency_file_content(void)
 
 	for (src = 0; src < STARPU_MAXNODES; src++)
 	{
+		starpu_drop_comments(f);
 		for (dst = 0; dst < STARPU_MAXNODES; dst++)
 		{
 			double latency;
 
-			n = fscanf(f, "%lf ", &latency);
+			n = fscanf(f, "%lf\t", &latency);
 			STARPU_ASSERT(n == 1);
 
 			latency_matrix[src][dst] = latency;
@@ -421,6 +428,11 @@ static void write_bus_latency_file_content(void)
 		STARPU_ABORT();
 	}
 
+	fprintf(f, "# ");
+	for (dst = 0; dst < STARPU_MAXNODES; dst++)
+		fprintf(f, "to %d\t", dst);
+	fprintf(f, "\n");
+
 	for (src = 0; src < STARPU_MAXNODES; src++)
 	{
 		for (dst = 0; dst < STARPU_MAXNODES; dst++)
@@ -440,7 +452,7 @@ static void write_bus_latency_file_content(void)
                                 latency = ((src && dst)?2000.0:500.0);
 			}
 
-			fprintf(f, "%lf ", latency);
+			fprintf(f, "%lf\t", latency);
 		}
 
 		fprintf(f, "\n");
@@ -501,11 +513,12 @@ static void load_bus_bandwith_file_content(void)
 
 	for (src = 0; src < STARPU_MAXNODES; src++)
 	{
+		starpu_drop_comments(f);
 		for (dst = 0; dst < STARPU_MAXNODES; dst++)
 		{
 			double bandwith;
 
-			n = fscanf(f, "%lf ", &bandwith);
+			n = fscanf(f, "%lf\t", &bandwith);
 			STARPU_ASSERT(n == 1);
 
 			bandwith_matrix[src][dst] = bandwith;
@@ -531,6 +544,11 @@ static void write_bus_bandwith_file_content(void)
 	f = fopen(path, "w+");
 	STARPU_ASSERT(f);
 
+	fprintf(f, "# ");
+	for (dst = 0; dst < STARPU_MAXNODES; dst++)
+		fprintf(f, "to %d\t", dst);
+	fprintf(f, "\n");
+
 	for (src = 0; src < STARPU_MAXNODES; src++)
 	{
 		for (dst = 0; dst < STARPU_MAXNODES; dst++)
@@ -558,7 +576,7 @@ static void write_bus_bandwith_file_content(void)
 			        bandwith = 0.0;
 			}
 			
-			fprintf(f, "%lf ", bandwith);
+			fprintf(f, "%lf\t", bandwith);
 		}
 
 		fprintf(f, "\n");

+ 4 - 26
src/core/perfmodel/perfmodel_history.c

@@ -48,28 +48,6 @@ static void insert_history_entry(struct starpu_history_entry_t *entry, struct st
 }
 
 
-static void drop_comments(FILE *f)
-{
-	while(1) {
-		int c = getc(f);
-
-		switch (c) {
-			case '#':
-			{
-				char s[128];
-				do {
-					fgets(s, sizeof(s), f);
-				} while (!strchr(s, '\n'));
-			}
-			case '\n':
-				continue;
-			default:
-				ungetc(c, f);
-				return;
-		}
-	}
-}
-
 static void dump_reg_model(FILE *f, struct starpu_regression_model_t *reg_model)
 {
 	fprintf(f, "# sumlnx\tsumlnx2\t\tsumlny\t\tsumlnxlny\talpha\t\tbeta\t\tn\n");
@@ -80,7 +58,7 @@ static void scan_reg_model(FILE *f, struct starpu_regression_model_t *reg_model)
 {
 	int res;
 
-	drop_comments(f);
+	starpu_drop_comments(f);
 
 	res = fscanf(f, "%le\t%le\t%le\t%le\t%le\t%le\t%u\n", &reg_model->sumlnx, &reg_model->sumlnx2, &reg_model->sumlny, &reg_model->sumlnxlny, &reg_model->alpha, &reg_model->beta, &reg_model->nsample);
 	STARPU_ASSERT(res == 7);
@@ -96,7 +74,7 @@ static void scan_history_entry(FILE *f, struct starpu_history_entry_t *entry)
 {
 	int res;
 
-	drop_comments(f);
+	starpu_drop_comments(f);
 
 	res = fscanf(f, "%x\t%zu\t%le\t%le\t%le\t%le\t%u\n", &entry->footprint, &entry->size, &entry->mean, &entry->deviation, &entry->sum, &entry->sum2, &entry->nsample);
 	STARPU_ASSERT(res == 7);
@@ -106,14 +84,14 @@ static void parse_per_arch_model_file(FILE *f, struct starpu_per_arch_perfmodel_
 {
 	unsigned nentries;
 
-	drop_comments(f);
+	starpu_drop_comments(f);
 
 	int res = fscanf(f, "%u\n", &nentries);
 	STARPU_ASSERT(res == 1);
 
 	scan_reg_model(f, &per_arch_model->regression);
 
-	drop_comments(f);
+	starpu_drop_comments(f);
 
 	res = fscanf(f, "%le\t%le\t%le\n", 
 		&per_arch_model->regression.a,