Przeglądaj źródła

Add STARPU_HOSTNAME to permit forcing using a given hostname for the machine (useful for clusters)

Samuel Thibault 14 lat temu
rodzic
commit
3fee4d2830

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

@@ -475,7 +475,11 @@ static void get_bus_path(const char *type, char *path, size_t maxlen)
 	strncat(path, type, maxlen);
 
 	char hostname[32];
-	gethostname(hostname, 32);
+	char *forced_hostname = getenv("STARPU_HOSTNAME");
+	if (forced_hostname && forced_hostname[0])
+		snprintf(hostname, sizeof(hostname), forced_hostname);
+	else
+		gethostname(hostname, sizeof(hostname));
 	strncat(path, ".", maxlen);
 	strncat(path, hostname, maxlen);
 }

+ 10 - 2
src/core/perfmodel/perfmodel_history.c

@@ -282,7 +282,11 @@ static void get_model_debug_path(struct starpu_perfmodel_t *model, const char *a
 	strncat(path, model->symbol, maxlen);
 	
 	char hostname[32];
-	gethostname(hostname, 32);
+	char *forced_hostname = getenv("STARPU_HOSTNAME");
+	if (forced_hostname && forced_hostname[0])
+		snprintf(hostname, sizeof(hostname), forced_hostname);
+	else
+		gethostname(hostname, sizeof(hostname));
 	strncat(path, ".", maxlen);
 	strncat(path, hostname, maxlen);
 	strncat(path, ".", maxlen);
@@ -326,7 +330,11 @@ static void get_model_path(struct starpu_perfmodel_t *model, char *path, size_t
 	strncat(path, model->symbol, maxlen);
 	
 	char hostname[32];
-	gethostname(hostname, 32);
+	char *forced_hostname = getenv("STARPU_HOSTNAME");
+	if (forced_hostname && forced_hostname[0])
+		snprintf(hostname, sizeof(hostname), forced_hostname);
+	else
+		gethostname(hostname, sizeof(hostname));
 	strncat(path, ".", maxlen);
 	strncat(path, hostname, maxlen);
 }