ソースを参照

bandwidth and latency seem to compute good values

Corentin Salingue 12 年 前
コミット
30ef63776b
共有3 個のファイルを変更した78 個の追加71 個の削除を含む
  1. 13 14
      src/core/disk.c
  2. 1 1
      src/core/perfmodel/perfmodel.h
  3. 64 56
      src/core/perfmodel/perfmodel_bus.c

+ 13 - 14
src/core/disk.c

@@ -33,7 +33,7 @@
 #include <common/uthash.h>
 
 #define SIZE	(1024*1024)
-#define NITER	128
+#define NITER	64
 
 
 struct disk_register {
@@ -64,8 +64,7 @@ starpu_disk_register(struct disk_ops * func, void *parameter)
 	/* remember it */
 	add_disk_in_list(memory_node,func,base);
 
-	//func->bandwidth(base,memory_node);
-	_starpu_save_bandwith_and_latency_disk(34,42,10,10, memory_node);
+	func->bandwidth(base,memory_node);
 	
 	return memory_node;
 }
@@ -311,7 +310,7 @@ get_stdio_bandwidth_between_disk_and_main_ram(void * base, unsigned node)
 {
 
 	unsigned iter;
-	double timing;
+	double timing_slowness, timing_latency;
 	struct timeval start;
 	struct timeval end;
 	
@@ -324,22 +323,21 @@ get_stdio_bandwidth_between_disk_and_main_ram(void * base, unsigned node)
 	void * mem = disk_register_list[pos]->functions->alloc(base, SIZE);
 	struct starpu_stdio_obj * tmp = (struct starpu_stdio_obj *) mem;
 
-	/* Measure upload bandwidth */
+	/* Measure upload slowness */
 	gettimeofday(&start, NULL);
 	for (iter = 0; iter < NITER; ++iter)
 	{
 		disk_register_list[pos]->functions->write(base, mem, buf, 0, SIZE);
 		/* clean cache memory */
 		int res = fflush (tmp->file);
-		STARPU_ASSERT_MSG(res == 0, "Bandwidth computation failed");
+		STARPU_ASSERT_MSG(res == 0, "Slowness computation failed");
 
 		res = fsync(tmp->descriptor);
-		STARPU_ASSERT_MSG(res == 0, "Bandwidth computation failed");
+		STARPU_ASSERT_MSG(res == 0, "Slowness computation failed");
 	}
 	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
+	timing_slowness = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 
-	printf("\n upload: %f ", timing/NITER/SIZE);
 
 	/* free memory */
 	disk_register_list[pos]->functions->free(base, mem, SIZE);
@@ -357,18 +355,19 @@ get_stdio_bandwidth_between_disk_and_main_ram(void * base, unsigned node)
 		disk_register_list[pos]->functions->write(base, mem, buf, rand() % ((2*SIZE)-1) +1 , 1);
 
 		int res = fflush (tmp->file);
-		STARPU_ASSERT_MSG(res == 0, "Bandwidth computation failed");
+		STARPU_ASSERT_MSG(res == 0, "Latency computation failed");
 
 		res = fsync(tmp->descriptor);
-		STARPU_ASSERT_MSG(res == 0, "Bandwidth computation failed");
+		STARPU_ASSERT_MSG(res == 0, "Latency computation failed");
 	}
 	gettimeofday(&end, NULL);
-	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
-
-	printf("\n latency: %f \n\n", timing/NITER);
+	timing_latency = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 
 	disk_register_list[pos]->functions->free(base, mem, SIZE);
 	free(buf);
+
+	_starpu_save_bandwidth_and_latency_disk((NITER/timing_slowness)*1000000, (NITER/timing_slowness)*1000000,
+					       timing_latency/NITER, timing_latency/NITER, node);
 }
 
 

+ 1 - 1
src/core/perfmodel/perfmodel.h

@@ -74,6 +74,6 @@ int *_starpu_get_opencl_affinity_vector(unsigned gpuid);
 #endif
 
 
-void _starpu_save_bandwith_and_latency_disk(double bandwidth_write, double bandwidth_read, 
+void _starpu_save_bandwidth_and_latency_disk(double bandwidth_write, double bandwidth_read, 
 					    double latency_write, double latency_read, unsigned node);
 #endif // __PERFMODEL_H__

+ 64 - 56
src/core/perfmodel/perfmodel_bus.c

@@ -1840,71 +1840,79 @@ double _starpu_predict_transfer_time(unsigned src_node, unsigned dst_node, size_
 
 
 /* calculate save bandwidth and latency */
-
-void _starpu_save_bandwith_and_latency_disk(double bandwidth_write, double bandwidth_read, double latency_write, double latency_read, unsigned node)
+/* bandwidth in MB/s - latency in µs */
+void _starpu_save_bandwidth_and_latency_disk(double bandwidth_write, double bandwidth_read, double latency_write, double latency_read, unsigned node)
 {
 	unsigned int i, j;
 	double slowness_disk_between_main_ram, slowness_main_ram_between_node;
 
-	/* for(i = 0; i < STARPU_MAXNODES; ++i) */
-	/* { */
-	/* 	for(j = 0; j < STARPU_MAXNODES; ++j) */
-	/* 	{ */
-	/* 		if (i == j && j == node) /\* source == destination *\/ */
-	/* 		{ */
-	/* 			bandwidth_matrix[i][j] = 0; */
-	/* 			printf("A"); */
-	/* 		}			 */
-	/* 		else if (i == node) /\* source == disk *\/ */
-	/* 		{ */
-	/* 			/\* convert in slowness *\/ */
-	/* 			if(bandwidth_read != 0) */
-	/* 				slowness_disk_between_main_ram = 1/bandwidth_read; */
-	/* 			else */
-	/* 				slowness_disk_between_main_ram = 0; */
-
-	/* 			if(bandwidth_matrix[STARPU_MAIN_RAM][j] != 0) */
-	/* 				slowness_main_ram_between_node = 1/bandwidth_matrix[STARPU_MAIN_RAM][j]; */
-	/* 			else */
-	/* 				slowness_main_ram_between_node = 0; */
+	/* save bandwith */
+	for(i = 0; i < STARPU_MAXNODES; ++i)
+	{
+		for(j = 0; j < STARPU_MAXNODES; ++j)
+		{
+			if (i == j && j == node) /* source == destination == node */
+			{
+				bandwidth_matrix[i][j] = 0;
+			}
+			else if (i == node) /* source == disk */
+			{
+				/* convert in slowness */
+				if(bandwidth_read != 0)
+					slowness_disk_between_main_ram = 1/bandwidth_read;
+				else
+					slowness_disk_between_main_ram = 0;
+
+				if(bandwidth_matrix[STARPU_MAIN_RAM][j] != 0)
+					slowness_main_ram_between_node = 1/bandwidth_matrix[STARPU_MAIN_RAM][j];
+				else
+					slowness_main_ram_between_node = 0;
 				
-	/* 			bandwidth_matrix[i][j] = 1/(slowness_disk_between_main_ram+slowness_main_ram_between_node); */
-	/* 			printf("B"); */
-	/* 		} */
-	/* 		else if (j == node) /\* destination == disk *\/ */
-	/* 		{ */
-	/* 			/\* convert in slowness *\/ */
-	/* 			if(bandwidth_write != 0) */
-	/* 				slowness_disk_between_main_ram = 1/bandwidth_write; */
-	/* 			else */
-	/* 				slowness_disk_between_main_ram = 0; */
-
-	/* 			if(bandwidth_matrix[i][STARPU_MAIN_RAM] != 0) */
-	/* 				slowness_main_ram_between_node = 1/bandwidth_matrix[i][STARPU_MAIN_RAM]; */
-	/* 			else */
-	/* 				slowness_main_ram_between_node = 0; */
-
-	/* 			bandwidth_matrix[i][j] = 1/(slowness_disk_between_main_ram+slowness_main_ram_between_node); */
-	/* 			printf("C"); */
-	/* 		} */
-	/* 		else if (j > node || i > node) */
-	/* 		{ */
-	/* 			bandwidth_matrix[i][j] = NAN; */
-	/* 			printf("D"); */
-	/* 		} */
-
-	/* 		printf("%f ", bandwidth_matrix[i][j]); */
-	/* 	} */
-	/* 	printf("\n"); */
-	/* } */
-	printf("\n\n");
+				bandwidth_matrix[i][j] = 1/(slowness_disk_between_main_ram+slowness_main_ram_between_node);
+			}
+			else if (j == node) /* destination == disk */
+			{
+				/* convert in slowness */
+				if(bandwidth_write != 0)
+					slowness_disk_between_main_ram = 1/bandwidth_write;
+				else
+					slowness_disk_between_main_ram = 0;
+
+				if(bandwidth_matrix[i][STARPU_MAIN_RAM] != 0)
+					slowness_main_ram_between_node = 1/bandwidth_matrix[i][STARPU_MAIN_RAM];
+				else
+					slowness_main_ram_between_node = 0;
+
+				bandwidth_matrix[i][j] = 1/(slowness_disk_between_main_ram+slowness_main_ram_between_node);
+			}
+			else if (j > node || i > node) /* not affected by the node */
+			{
+				bandwidth_matrix[i][j] = NAN;
+			}
+		}
+	}
+
+	/* save latency */
 	for(i = 0; i < STARPU_MAXNODES; ++i)
 	{
 		for(j = 0; j < STARPU_MAXNODES; ++j)
 		{
-			printf("%f ", bandwidth_matrix[i][j]);
+			if (i == j && j == node) /* source == destination == node */
+			{
+				latency_matrix[i][j] = 0;
+			}
+			else if (i == node) /* source == disk */
+			{			
+				latency_matrix[i][j] = (latency_write+latency_matrix[STARPU_MAIN_RAM][j]);
+			}
+			else if (j == node) /* destination == disk */
+			{
+				latency_matrix[i][j] = (latency_read+latency_matrix[i][STARPU_MAIN_RAM]);
+			}
+			else if (j > node || i > node) /* not affected by the node */
+			{
+				latency_matrix[i][j] = NAN;
+			}
 		}
-		printf("\n");
 	}
-	printf("\n\n");
 }