Sfoglia il codice sorgente

try to add bandwith values into matrix but not ready for the moment

Corentin Salingue 12 anni fa
parent
commit
8fcffa4265

+ 2 - 1
include/starpu_disk.h

@@ -1,3 +1,4 @@
+
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2013 Corentin Salingue
@@ -30,7 +31,7 @@ struct disk_ops {
 	/* readv, writev, read2d, write2d, etc. */
 	 void *  (*plug)   (void *parameter);
 	 void    (*unplug) (void *base);
-	void    (*bandwith) (void *base, unsigned node);
+	void    (*bandwidth) (void *base, unsigned node);
 };
 
 

+ 9 - 7
src/core/disk.c

@@ -24,6 +24,7 @@
 #include <common/config.h>
 #include <core/workers.h>
 #include <core/debug.h>
+#include <core/perfmodel/perfmodel.h>
 
 #include <core/topology.h>
 #include <drivers/cuda/driver_cuda.h>
@@ -63,7 +64,8 @@ starpu_disk_register(struct disk_ops * func, void *parameter)
 	/* remember it */
 	add_disk_in_list(memory_node,func,base);
 
-	func->bandwith(base,memory_node);
+	//func->bandwidth(base,memory_node);
+	_starpu_save_bandwith_and_latency_disk(34,42,10,10, memory_node);
 	
 	return memory_node;
 }
@@ -305,7 +307,7 @@ starpu_stdio_unplug (void *base)
 
 
 static void
-get_stdio_bandwith_between_disk_and_main_ram(void * base, unsigned node)
+get_stdio_bandwidth_between_disk_and_main_ram(void * base, unsigned node)
 {
 
 	unsigned iter;
@@ -329,10 +331,10 @@ get_stdio_bandwith_between_disk_and_main_ram(void * base, unsigned node)
 		disk_register_list[pos]->functions->write(base, mem, buf, 0, SIZE);
 		/* clean cache memory */
 		int res = fflush (tmp->file);
-		STARPU_ASSERT_MSG(res == 0, "Bandwith computation failed");
+		STARPU_ASSERT_MSG(res == 0, "Bandwidth computation failed");
 
 		res = fsync(tmp->descriptor);
-		STARPU_ASSERT_MSG(res == 0, "Bandwith computation failed");
+		STARPU_ASSERT_MSG(res == 0, "Bandwidth computation failed");
 	}
 	gettimeofday(&end, NULL);
 	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
@@ -355,10 +357,10 @@ get_stdio_bandwith_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, "Bandwith computation failed");
+		STARPU_ASSERT_MSG(res == 0, "Bandwidth computation failed");
 
 		res = fsync(tmp->descriptor);
-		STARPU_ASSERT_MSG(res == 0, "Bandwith computation failed");
+		STARPU_ASSERT_MSG(res == 0, "Bandwidth computation failed");
 	}
 	gettimeofday(&end, NULL);
 	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
@@ -380,5 +382,5 @@ struct disk_ops write_on_file = {
 	.write = starpu_stdio_write,
 	.plug = starpu_stdio_plug,
 	.unplug = starpu_stdio_unplug,
-	.bandwith = get_stdio_bandwith_between_disk_and_main_ram
+	.bandwidth = get_stdio_bandwidth_between_disk_and_main_ram
 };

+ 3 - 0
src/core/perfmodel/perfmodel.h

@@ -73,4 +73,7 @@ int *_starpu_get_cuda_affinity_vector(unsigned gpuid);
 int *_starpu_get_opencl_affinity_vector(unsigned gpuid);
 #endif
 
+
+void _starpu_save_bandwith_and_latency_disk(double bandwidth_write, double bandwidth_read, 
+					    double latency_write, double latency_read, unsigned node);
 #endif // __PERFMODEL_H__

+ 69 - 1
src/core/perfmodel/perfmodel_bus.c

@@ -1839,4 +1839,72 @@ double _starpu_predict_transfer_time(unsigned src_node, unsigned dst_node, size_
 }
 
 
-/* calculate bandwith and latency */
+/* 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)
+{
+	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; */
+				
+	/* 			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");
+	for(i = 0; i < STARPU_MAXNODES; ++i)
+	{
+		for(j = 0; j < STARPU_MAXNODES; ++j)
+		{
+			printf("%f ", bandwidth_matrix[i][j]);
+		}
+		printf("\n");
+	}
+	printf("\n\n");
+}