浏览代码

print bandwidths too in starpu_machine_display

Samuel Thibault 13 年之前
父节点
当前提交
47b21020da

+ 1 - 0
include/starpu_perfmodel.h

@@ -132,6 +132,7 @@ void starpu_perfmodel_get_arch_name(enum starpu_perf_archtype arch,
 int starpu_list_models(void);
 
 void starpu_force_bus_sampling(void);
+void starpu_print_bus_bandwidth(FILE *f);
 
 #ifdef __cplusplus
 }

+ 32 - 0
src/core/perfmodel/perfmodel_bus.c

@@ -921,6 +921,38 @@ static void write_bus_bandwidth_file_content(void)
 	fclose(f);
 }
 
+void starpu_print_bus_bandwidth(FILE *f)
+{
+	int src, dst, maxnode;
+
+        maxnode = ncuda;
+#ifdef STARPU_USE_OPENCL
+        maxnode += nopencl;
+#endif
+
+	fprintf(f, "from\t");
+	fprintf(f, "to RAM\t\t");
+	for (dst = 0; dst < ncuda; dst++)
+		fprintf(f, "to CUDA %d\t", dst);
+	for (dst = 0; dst < nopencl; dst++)
+		fprintf(f, "to OpenCL %d\t", dst);
+	fprintf(f, "\n");
+
+	for (src = 0; src <= maxnode; src++)
+	{
+		if (!src)
+			fprintf(f, "RAM\t");
+		else if (src <= ncuda)
+			fprintf(f, "CUDA %d\t", src-1);
+		else
+			fprintf(f, "OpenCL%d\t", src-ncuda-1);
+		for (dst = 0; dst <= maxnode; dst++)
+			fprintf(f, "%f\t", bandwidth_matrix[src][dst]);
+
+		fprintf(f, "\n");
+	}
+}
+
 static void generate_bus_bandwidth_file(void)
 {
 	if (!was_benchmarked)

+ 1 - 0
src/core/workers.h

@@ -77,6 +77,7 @@ struct starpu_worker_s {
 	unsigned worker_is_initialized;
 	starpu_worker_status status; /* what is the worker doing now ? (eg. CALLBACK) */
 	char name[48];
+	char short_name[10];
 
 #ifdef __GLIBC__
 	cpu_set_t initial_cpu_set;

+ 2 - 1
src/drivers/cpu/driver_cpu.c

@@ -95,7 +95,8 @@ void *_starpu_cpu_worker(void *arg)
 
 	_starpu_set_local_worker_key(cpu_arg);
 
-	snprintf(cpu_arg->name, 32, "CPU %d", devid);
+	snprintf(cpu_arg->name, sizeof(cpu_arg->name), "CPU %d", devid);
+	snprintf(cpu_arg->short_name, sizeof(cpu_arg->short_name), "CPU %d", devid);
 
 	cpu_arg->status = STATUS_UNKNOWN;
 

+ 3 - 2
src/drivers/cuda/driver_cuda.c

@@ -243,10 +243,11 @@ void *_starpu_cuda_worker(void *arg)
 	cudaGetDeviceProperties(&prop, devid);
 	strncpy(devname, prop.name, 128);
 #if CUDA_VERSION >= 3020
-	snprintf(args->name, 48, "CUDA %d (%s %02x:%02x.0)", args->devid, devname, prop.pciBusID, prop.pciDeviceID);
+	snprintf(args->name, sizeof(args->name), "CUDA %d (%s %02x:%02x.0)", args->devid, devname, prop.pciBusID, prop.pciDeviceID);
 #else
-	snprintf(args->name, 48, "CUDA %d (%s)", args->devid, devname);
+	snprintf(args->name, sizeof(args->name), "CUDA %d (%s)", args->devid, devname);
 #endif
+	snprintf(args->short_name, sizeof(args->short_name), "CUDA %d", args->devid);
 	_STARPU_DEBUG("cuda (%s) dev id %d thread is ready to run on CPU %d !\n", devname, devid, args->bindid);
 
 	STARPU_TRACE_WORKER_INIT_END

+ 2 - 1
src/drivers/gordon/driver_gordon.c

@@ -431,7 +431,8 @@ void *_starpu_gordon_worker(void *arg)
 	for (spu = 0; spu < gordon_set_arg->nworkers; spu++)
 	{
 		struct starpu_worker_s *worker = &gordon_set_arg->workers[spu];
-		snprintf(worker->name, 32, "SPU %d", worker->id);
+		snprintf(worker->name, sizeof(worker->name), "SPU %d", worker->id);
+		snprintf(worker->short_name, sizeof(worker->short_name), "SPU %d", worker->id);
 	}
 
 	/*

+ 2 - 1
src/drivers/opencl/driver_opencl.c

@@ -401,7 +401,8 @@ void *_starpu_opencl_worker(void *arg)
 	/* get the device's name */
 	char devname[128];
 	_starpu_opencl_get_device_name(devid, devname, 128);
-	snprintf(args->name, 32, "OpenCL %d (%s)", args->devid, devname);
+	snprintf(args->name, sizeof(args->name), "OpenCL %d (%s)", args->devid, devname);
+	snprintf(args->short_name, sizeof(args->short_name), "OpenCL %d", args->devid);
 
 	_STARPU_DEBUG("OpenCL (%s) dev id %d thread is ready to run on CPU %d !\n", devname, devid, args->bindid);
 

+ 2 - 0
tools/starpu_machine_display.c

@@ -91,6 +91,8 @@ int main(int argc, char **argv)
 
 	display_all_combined_workers();
 
+	starpu_print_bus_bandwidth(stdout);
+
 	starpu_shutdown();
 
 	return 0;