Selaa lähdekoodia

Add yet more debugging about loading perfmodels. Fix gethostname issue with fqdn, and factorize it

Samuel Thibault 12 vuotta sitten
vanhempi
commit
9d798f070b

+ 17 - 1
src/common/utils.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2012  Université de Bordeaux 1
+ * Copyright (C) 2010, 2012-2013  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -132,3 +132,19 @@ char *_starpu_get_home_path(void)
 		_STARPU_ERROR("couldn't find a home place to put starpu data\n");
 	return path;
 }
+
+void _starpu_gethostname(char *hostname, size_t size)
+{
+	char *forced_hostname = getenv("STARPU_HOSTNAME");
+	if (forced_hostname && forced_hostname[0]) {
+		snprintf(hostname, size-1, "%s", forced_hostname);
+		hostname[size-1] = 0;
+	} else {
+		char *c;
+		gethostname(hostname, size-1);
+		hostname[size-1] = 0;
+		c = strchr(hostname, '.');
+		if (c)
+			*c = 0;
+	}
+}

+ 2 - 1
src/common/utils.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2012  Université de Bordeaux 1
+ * Copyright (C) 2010, 2012-2013  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -67,6 +67,7 @@ int _starpu_mkpath(const char *s, mode_t mode);
 void _starpu_mkpath_and_check(const char *s, mode_t mode);
 int _starpu_check_mutex_deadlock(_starpu_pthread_mutex_t *mutex);
 char *_starpu_get_home_path(void);
+void _starpu_gethostname(char *hostname, size_t size);
 
 /* If FILE is currently on a comment line, eat it.  */
 void _starpu_drop_comments(FILE *f);

+ 15 - 6
src/core/perfmodel/perfmodel_bus.c

@@ -32,6 +32,7 @@
 #include <common/config.h>
 #include <core/workers.h>
 #include <core/perfmodel/perfmodel.h>
+#include <common/utils.h>
 
 #ifdef STARPU_USE_OPENCL
 #include <starpu_opencl.h>
@@ -715,12 +716,8 @@ static void get_bus_path(const char *type, char *path, size_t maxlen)
 {
 	_starpu_get_perf_model_dir_bus(path, maxlen);
 
-	char hostname[32];
-	char *forced_hostname = getenv("STARPU_HOSTNAME");
-	if (forced_hostname && forced_hostname[0])
-		snprintf(hostname, sizeof(hostname), "%s", forced_hostname);
-	else
-		gethostname(hostname, sizeof(hostname));
+	char hostname[65];
+	_starpu_gethostname(hostname, sizeof(hostname));
 	strncat(path, hostname, maxlen);
 	strncat(path, ".", maxlen);
 	strncat(path, type, maxlen);
@@ -744,6 +741,8 @@ static void load_bus_affinity_file_content(void)
 	char path[256];
 	get_affinity_path(path, 256);
 
+	_STARPU_DEBUG("loading affinities from %s\n", path);
+
 	f = fopen(path, "r");
 	STARPU_ASSERT(f);
 
@@ -815,6 +814,9 @@ static void write_bus_affinity_file_content(void)
 	FILE *f;
 	char path[256];
 	get_affinity_path(path, 256);
+
+	_STARPU_DEBUG("writing affinities to %s\n", path);
+
 	f = fopen(path, "w+");
 	if (!f)
 	{
@@ -1006,6 +1008,8 @@ static void write_bus_latency_file_content(void)
 	char path[256];
 	get_latency_path(path, 256);
 
+	_STARPU_DEBUG("writing latencies to %s\n", path);
+
 	f = fopen(path, "w+");
 	if (!f)
 	{
@@ -1171,6 +1175,8 @@ static void write_bus_bandwidth_file_content(void)
 	char path[256];
 	get_bandwidth_path(path, 256);
 
+	_STARPU_DEBUG("writing bandwidth to %s\n", path);
+
 	f = fopen(path, "w+");
 	STARPU_ASSERT(f);
 
@@ -1434,6 +1440,9 @@ static void write_bus_config_file_content(void)
 
 	STARPU_ASSERT(was_benchmarked);
         get_config_path(path, 256);
+
+	_STARPU_DEBUG("writing config to %s\n", path);
+
         f = fopen(path, "w+");
 	STARPU_ASSERT(f);
 

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

@@ -591,12 +591,8 @@ static void get_model_debug_path(struct starpu_perfmodel *model, const char *arc
 	_starpu_get_perf_model_dir_debug(path, maxlen);
 	strncat(path, model->symbol, maxlen);
 
-	char hostname[32];
-	char *forced_hostname = getenv("STARPU_HOSTNAME");
-	if (forced_hostname && forced_hostname[0])
-		snprintf(hostname, sizeof(hostname), "%s", forced_hostname);
-	else
-		gethostname(hostname, sizeof(hostname));
+	char hostname[65];
+	_starpu_gethostname(hostname, sizeof(hostname));
 	strncat(path, ".", maxlen);
 	strncat(path, hostname, maxlen);
 	strncat(path, ".", maxlen);
@@ -661,12 +657,8 @@ static void get_model_path(struct starpu_perfmodel *model, char *path, size_t ma
 	_starpu_get_perf_model_dir_codelets(path, maxlen);
 	strncat(path, model->symbol, maxlen);
 
-	char hostname[32];
-	char *forced_hostname = getenv("STARPU_HOSTNAME");
-	if (forced_hostname && forced_hostname[0])
-		snprintf(hostname, sizeof(hostname), "%s", forced_hostname);
-	else
-		gethostname(hostname, sizeof(hostname));
+	char hostname[65];
+	_starpu_gethostname(hostname, sizeof(hostname));
 	strncat(path, ".", maxlen);
 	strncat(path, hostname, maxlen);
 }