浏览代码

From now on, the default behaviour is to put performance models in
$HOME/.starpu/sampling rather than in the source dir.

Cédric Augonnet 15 年之前
父节点
当前提交
263464ee51

+ 14 - 5
configure.ac

@@ -417,18 +417,27 @@ if test x$enable_allocation_cache = xyes; then
 	AC_DEFINE(USE_ALLOCATION_CACHE, [1], [enable data allocation cache])
 fi
 
-# by default, we put the performance models in $PWD/.sampling/
-perf_model_dir=($PWD/.sampling/)
 AC_ARG_WITH(perf-model-dir, [AS_HELP_STRING([--with-perf-model-dir=<dir>], [specify where performance models shoulds be stored])],
 	[
-		if x$withval != x$no; then
-			perf_model_dir=$withval
+		if x$withval = xno; then
+			AC_MSG_ERROR(--without-perf-model-dir is not a valid option)
 		fi
+	
+		perf_model_dir=$withval
+		have_explicit_perf_model_dir=yes
+		AC_DEFINE_UNQUOTED(PERF_MODEL_DIR, ["$perf_model_dir"], [performance models location])
+	], [
+		# by default, we put the performance models in
+		# $HOME/.starpu/sampling/
+		have_explicit_perf_model_dir=no
+		perf_model_dir="\$HOME/.starpu/sampling/"
 	]
 	)
+AC_MSG_CHECKING(using explicit performance model location)
+AC_MSG_RESULT($have_explicit_perf_model_dir)
+
 AC_MSG_CHECKING(performance models location)
 AC_MSG_RESULT($perf_model_dir)
-AC_DEFINE_UNQUOTED(PERF_MODEL_DIR, "$perf_model_dir", [performance models location])
 
 # On many multicore CPUs, clock cycles are not synchronized
 AC_ARG_ENABLE(sync-clock, [AS_HELP_STRING([--enable-sync-clock], [Use monotonic clocks])],

+ 55 - 8
src/core/perfmodel/perfmodel.c

@@ -14,6 +14,7 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
+#include <common/utils.h>
 #include <unistd.h>
 #include <sys/stat.h>
 #include <core/perfmodel/perfmodel.h>
@@ -144,10 +145,43 @@ double data_expected_penalty(struct jobq_s *q, struct starpu_task *task)
 
 static int directory_existence_was_tested = 0;
 
+void _starpu_get_perf_model_dir(char *path, size_t maxlen)
+{
+#ifdef PERF_MODEL_DIR
+	/* use the directory specified at configure time */
+	snprintf(path, maxlen, "%s", PERF_MODEL_DIR);
+#else
+	/* by default, we use $HOME/.starpu/sampling */
+	const char *home_path = getenv("HOME");
+	snprintf(path, maxlen, "%s/.starpu/sampling/", home_path);
+#endif
+}
+
+void _starpu_get_perf_model_dir_codelets(char *path, size_t maxlen)
+{
+	_starpu_get_perf_model_dir(path, maxlen);
+	strncat(path, "codelets/", maxlen);
+}
+
+void _starpu_get_perf_model_dir_bus(char *path, size_t maxlen)
+{
+	_starpu_get_perf_model_dir(path, maxlen);
+	strncat(path, "bus/", maxlen);
+}
+
+void _starpu_get_perf_model_dir_debug(char *path, size_t maxlen)
+{
+	_starpu_get_perf_model_dir(path, maxlen);
+	strncat(path, "debug/", maxlen);
+}
+
 void create_sampling_directory_if_needed(void)
 {
 	if (!directory_existence_was_tested)
 	{
+		char perf_model_dir[256];
+		_starpu_get_perf_model_dir(perf_model_dir, 256);
+
 		/* The performance of the codelets are stored in
 		 * $PERF_MODEL_DIR/codelets/ while those of the bus are stored in
 		 * $PERF_MODEL_DIR/bus/ so that we don't have name collisions */
@@ -157,47 +191,60 @@ void create_sampling_directory_if_needed(void)
 		   changed in between. Instead, we create it and check if
 		   it already existed before */
 		int ret;
-		ret = mkdir(PERF_MODEL_DIR, S_IRWXU);
+		ret = starpu_mkpath(perf_model_dir, S_IRWXU);
+
 		if (ret == -1)
 		{
 			STARPU_ASSERT(errno == EEXIST);
 	
 			/* make sure that it is actually a directory */
 			struct stat sb;
-			stat(PERF_MODEL_DIR, &sb);
+			stat(perf_model_dir, &sb);
 			STARPU_ASSERT(S_ISDIR(sb.st_mode));
 		}
 	
-		ret = mkdir(PERF_MODEL_DIR_CODELETS, S_IRWXU);
+		/* Per-task performance models */
+		char perf_model_dir_codelets[256];
+		_starpu_get_perf_model_dir_codelets(perf_model_dir_codelets, 256);
+
+		ret = starpu_mkpath(perf_model_dir_codelets, S_IRWXU);
 		if (ret == -1)
 		{
 			STARPU_ASSERT(errno == EEXIST);
 	
 			/* make sure that it is actually a directory */
 			struct stat sb;
-			stat(PERF_MODEL_DIR, &sb);
+			stat(perf_model_dir_codelets, &sb);
 			STARPU_ASSERT(S_ISDIR(sb.st_mode));
 		}
 	
-		ret = mkdir(PERF_MODEL_DIR_BUS, S_IRWXU);
+		/* Performance of the memory subsystem */
+		char perf_model_dir_bus[256];
+		_starpu_get_perf_model_dir_bus(perf_model_dir_bus, 256);
+
+		ret = starpu_mkpath(perf_model_dir_bus, S_IRWXU);
 		if (ret == -1)
 		{
 			STARPU_ASSERT(errno == EEXIST);
 	
 			/* make sure that it is actually a directory */
 			struct stat sb;
-			stat(PERF_MODEL_DIR, &sb);
+			stat(perf_model_dir_bus, &sb);
 			STARPU_ASSERT(S_ISDIR(sb.st_mode));
 		}
 	
-		ret = mkdir(PERF_MODEL_DIR_DEBUG, S_IRWXU);
+		/* Performance debug measurements */
+		char perf_model_dir_debug[256];
+		_starpu_get_perf_model_dir_debug(perf_model_dir_debug, 256);
+
+		ret = starpu_mkpath(perf_model_dir_debug, S_IRWXU);
 		if (ret == -1)
 		{
 			STARPU_ASSERT(errno == EEXIST);
 	
 			/* make sure that it is actually a directory */
 			struct stat sb;
-			stat(PERF_MODEL_DIR, &sb);
+			stat(perf_model_dir_debug, &sb);
 			STARPU_ASSERT(S_ISDIR(sb.st_mode));
 		}
 	

+ 5 - 4
src/core/perfmodel/perfmodel.h

@@ -26,10 +26,6 @@
 #include <pthread.h>
 #include <stdio.h>
 
-#define PERF_MODEL_DIR_CODELETS	PERF_MODEL_DIR"/codelets/"
-#define PERF_MODEL_DIR_BUS	PERF_MODEL_DIR"/bus/"
-#define PERF_MODEL_DIR_DEBUG	PERF_MODEL_DIR"/debug/"
-
 struct starpu_buffer_descr_t;
 struct jobq_s;
 struct job_s;
@@ -85,6 +81,11 @@ struct starpu_model_list_t {
 //	struct starpu_history_entry_t entries[];
 //}
 
+void _starpu_get_perf_model_dir(char *path, size_t maxlen);
+void _starpu_get_perf_model_dir_codelets(char *path, size_t maxlen);
+void _starpu_get_perf_model_dir_bus(char *path, size_t maxlen);
+void _starpu_get_perf_model_dir_debug(char *path, size_t maxlen);
+
 double history_based_job_expected_length(struct starpu_perfmodel_t *model, enum starpu_perf_archtype arch, struct job_s *j);
 void register_model(struct starpu_perfmodel_t *model);
 void dump_registered_models(void);

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

@@ -234,7 +234,7 @@ static void benchmark_all_cuda_devices(void)
 
 static void get_bus_path(const char *type, char *path, size_t maxlen)
 {
-	strncpy(path, PERF_MODEL_DIR_BUS, maxlen);
+	_starpu_get_perf_model_dir_bus(path, maxlen);
 	strncat(path, type, maxlen);
 	
 	char hostname[32];

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

@@ -218,7 +218,7 @@ static void get_model_debug_path(struct starpu_perfmodel_t *model, const char *a
 {
 	STARPU_ASSERT(path);
 
-	strncpy(path, PERF_MODEL_DIR_DEBUG, maxlen);
+	_starpu_get_perf_model_dir_debug(path, maxlen);
 	strncat(path, model->symbol, maxlen);
 	
 	char hostname[32];
@@ -260,7 +260,7 @@ void register_model(struct starpu_perfmodel_t *model)
 
 static void get_model_path(struct starpu_perfmodel_t *model, char *path, size_t maxlen)
 {
-	strncpy(path, PERF_MODEL_DIR_CODELETS, maxlen);
+	_starpu_get_perf_model_dir_codelets(path, maxlen);
 	strncat(path, model->symbol, maxlen);
 	
 	char hostname[32];
@@ -412,12 +412,16 @@ static void load_history_based_model(struct starpu_perfmodel_t *model, unsigned
 
 /* This function is intended to be used by external tools that should read
  * the performance model files */
-int starpu_list_models() {
+int starpu_list_models(void)
+{
         char path[256];
         DIR *dp;
         struct dirent *ep;
 
-        strncpy(path, PERF_MODEL_DIR_CODELETS, 256);
+	char perf_model_dir_codelets[256];
+	_starpu_get_perf_model_dir_codelets(perf_model_dir_codelets, 256);
+
+        strncpy(path, perf_model_dir_codelets, 256);
         dp = opendir(path);
         if (dp != NULL) {
                 while ((ep = readdir(dp))) {