Bläddra i källkod

Dynamically initialize progression_hook_rwlock and tag_global_rwlock.

Using PTHREAD_RWLOCK_INITIALIZER seems to ead to weird failures on Darwin (see http://lists.gforge.inria.fr/pipermail/starpu-devel/2012-August/000629.html).
Cyril Roelandt 12 år sedan
förälder
incheckning
0c893dd530

+ 1 - 0
src/Makefile.am

@@ -60,6 +60,7 @@ noinst_HEADERS = 						\
 	core/dependencies/cg.h					\
 	core/dependencies/tags.h				\
 	core/dependencies/implicit_data_deps.h			\
+	core/progress_hook.h                                    \
 	core/sched_policy.h					\
 	core/perfmodel/perfmodel.h				\
 	core/perfmodel/regression.h				\

+ 10 - 1
src/core/dependencies/tags.c

@@ -36,7 +36,7 @@ struct _starpu_tag_table
 #define HASH_FIND_UINT64_T(head,find,out) HASH_FIND(hh,head,find,sizeof(uint64_t),out)
 
 static struct _starpu_tag_table *tag_htbl = NULL;
-static pthread_rwlock_t tag_global_rwlock = PTHREAD_RWLOCK_INITIALIZER;
+static pthread_rwlock_t tag_global_rwlock;
 
 static struct _starpu_cg *create_cg_apps(unsigned ntags)
 {
@@ -122,6 +122,15 @@ static void _starpu_tag_free(void *_tag)
 	}
 }
 
+/*
+ * Staticly initializing tag_global_rwlock seems to lead to weird errors
+ * on Darwin, so we do it dynamically.
+ */
+void _starpu_init_tags(void)
+{
+	_STARPU_PTHREAD_RWLOCK_INIT(&tag_global_rwlock, NULL);
+}
+
 void starpu_tag_remove(starpu_tag_t id)
 {
 	struct _starpu_tag_table *entry;

+ 2 - 0
src/core/dependencies/tags.h

@@ -61,6 +61,8 @@ struct _starpu_tag
 	unsigned is_submitted;
 };
 
+void _starpu_init_tags(void);
+
 void _starpu_notify_dependencies(struct _starpu_job *j);
 void _starpu_notify_tag_dependencies(struct _starpu_tag *tag);
 

+ 10 - 1
src/core/progress_hook.c

@@ -29,11 +29,20 @@ struct progression_hook
 };
 
 /* protect the hook table */
-static pthread_rwlock_t progression_hook_rwlock = PTHREAD_RWLOCK_INITIALIZER;
+static pthread_rwlock_t progression_hook_rwlock;
 
 static struct progression_hook hooks[NMAXHOOKS] = {{NULL, NULL, 0}};
 static int active_hook_cnt = 0;
 
+/*
+ * Staticly initializing progression_hook_rwlock seems to lead to weird errors
+ * on Darwin, so we do it dynamically.
+ */
+void _starpu_init_progression_hooks(void)
+{
+	_STARPU_PTHREAD_RWLOCK_INIT(&progression_hook_rwlock, NULL);
+}
+
 int starpu_progression_hook_register(unsigned (*func)(void *arg), void *arg)
 {
 	int hook;

+ 22 - 0
src/core/progress_hook.h

@@ -0,0 +1,22 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2012 inria
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#ifndef __PROGRESS_HOOK_H__
+#define __PROGRESS_HOOK_H__
+
+void _starpu_init_progression_hooks(void);
+
+#endif /* !__PROGRESS_HOOK_H__ */

+ 5 - 0
src/core/workers.c

@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <common/config.h>
 #include <common/utils.h>
+#include <core/progress_hook.h>
 #include <core/workers.h>
 #include <core/debug.h>
 #include <core/task.h>
@@ -660,6 +661,10 @@ int starpu_init(struct starpu_conf *user_conf)
 	/* Launch "basic" workers (ie. non-combined workers) */
 	_starpu_launch_drivers(&config);
 
+	_starpu_init_progression_hooks();
+
+	_starpu_init_tags();
+
 	_STARPU_PTHREAD_MUTEX_LOCK(&init_mutex);
 	initialized = INITIALIZED;
 	/* Tell everybody that we initialized */