Sfoglia il codice sorgente

fix crash on macos: we need to initialize starpu_perfmodel's rwlock

Samuel Thibault 7 anni fa
parent
commit
ef3d46ef53

+ 4 - 0
doc/doxygen/chapters/api/performance_model.doxy

@@ -272,6 +272,10 @@ Return the architecture name for \p arch
 \ingroup API_Performance_Model
 Return the architecture type of the worker \p workerid.
 
+\fn void starpu_perfmodel_initialize(void)
+\ingroup API_Performance_Model
+If starpu_init is not used, starpu_perfmodel_initialize should be used before calling starpu_perfmodel_* functions.
+
 \fn int starpu_perfmodel_list(FILE *output)
 \ingroup API_Performance_Model
 Print a list of all performance models on \p output

+ 1 - 0
include/starpu_perfmodel.h

@@ -183,6 +183,7 @@ char* starpu_perfmodel_get_archtype_name(enum starpu_worker_archtype archtype);
 void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl);
 
 double starpu_perfmodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, uint32_t footprint);
+void starpu_perfmodel_initialize(void);
 int starpu_perfmodel_list(FILE *output);
 void starpu_perfmodel_print(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
 int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);

+ 7 - 1
src/core/perfmodel/perfmodel_history.c

@@ -1051,7 +1051,7 @@ static void _starpu_dump_registered_models(void)
 #endif
 }
 
-void _starpu_initialize_registered_performance_models(void)
+void starpu_perfmodel_initialize(void)
 {
 	/* make sure the performance model directory exists (or create it) */
 	_starpu_create_sampling_directory_if_needed();
@@ -1060,6 +1060,12 @@ void _starpu_initialize_registered_performance_models(void)
 
 	STARPU_PTHREAD_RWLOCK_INIT(&registered_models_rwlock, NULL);
 
+}
+
+void _starpu_initialize_registered_performance_models(void)
+{
+	starpu_perfmodel_initialize();
+
 	struct _starpu_machine_config *conf = _starpu_get_machine_config();
 	unsigned ncores = conf->topology.nhwcpus;
 	unsigned ncuda =  conf->topology.nhwcudagpus;

+ 1 - 0
tools/starpu_perfmodel_display.c

@@ -149,6 +149,7 @@ int main(int argc, char **argv)
 #endif
 
 	parse_args(argc, argv);
+	starpu_perfmodel_initialize();
 
         if (plist)
 	{

+ 1 - 0
tools/starpu_perfmodel_plot.c

@@ -464,6 +464,7 @@ int main(int argc, char **argv)
 #endif
 
 	parse_args(argc, argv, &options);
+	starpu_perfmodel_initialize();
 
 	if (options.directory)
 	{