Explorar o código

thread: fix definitions of starpu_pthread_create and starpu_pthread_create_on

Nathalie Furmento %!s(int64=12) %!d(string=hai) anos
pai
achega
78570cad44
Modificáronse 3 ficheiros con 23 adicións e 13 borrados
  1. 3 1
      include/starpu_thread.h
  2. 3 3
      src/common/thread.c
  3. 17 9
      src/common/thread.h

+ 3 - 1
include/starpu_thread.h

@@ -39,6 +39,7 @@ extern "C"
 typedef int starpu_pthread_t;
 typedef int starpu_pthread_attr_t;
 
+int starpu_pthread_create_on(char *name, starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg, int where);
 int starpu_pthread_create(starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
 int starpu_pthread_join(starpu_pthread_t thread, void **retval);
 int starpu_pthread_attr_init(starpu_pthread_attr_t *attr);
@@ -50,7 +51,8 @@ int starpu_pthread_attr_setdetachstate(starpu_pthread_attr_t *attr, int detachst
 typedef pthread_t starpu_pthread_t;
 typedef pthread_attr_t starpu_pthread_attr_t;
 
-#define starpu_pthread_create pthread_create
+#define starpu_pthread_create(name, thread, attr, routine, arg) pthread_create(thread, attr, routine, arg)
+#define starpu_pthread_create_on(name, thread, attr, routine, arg, where) starpu_pthread_create(name, thread, attr, routine, arg)
 #define starpu_pthread_join pthread_join
 #define starpu_pthread_attr_init pthread_attr_init
 #define starpu_pthread_attr_destroy pthread_attr_destroy

+ 3 - 3
src/common/thread.c

@@ -27,7 +27,7 @@
 
 extern int _starpu_simgrid_thread_start(int argc, char *argv[]);
 
-int _starpu_pthread_create_on(char *name, starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg, int where)
+int starpu_pthread_create_on(char *name, starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg, int where)
 {
 	struct _starpu_pthread_args *_args = malloc(sizeof(*_args));
 	xbt_dynar_t _hosts;
@@ -40,9 +40,9 @@ int _starpu_pthread_create_on(char *name, starpu_pthread_t *thread, const starpu
 	return 0;
 }
 
-int starpu_pthread_create(starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg)
+int starpu_pthread_create(char *name, starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg)
 {
-	return _starpu_pthread_create_on("", thread, attr, start_routine, arg, 0);
+	return starpu_pthread_create_on(name, thread, attr, start_routine, arg, 0);
 }
 
 int starpu_pthread_join(starpu_pthread_t thread, void **retval)

+ 17 - 9
src/common/thread.h

@@ -24,17 +24,25 @@
  * Encapsulation of the starpu_pthread_create_* functions.
  */
 
-#define _STARPU_PTHREAD_CREATE_ON(name, thread, attr, routine, arg, where) do {		\
-	int p_ret =  starpu_pthread_create((thread), (attr), (routine), (arg));		\
-	if (STARPU_UNLIKELY(p_ret != 0)) {						\
-		fprintf(stderr,                         		                \
-			"%s:%d starpu_pthread_create: %s\n",                   		\
-			__FILE__, __LINE__, strerror(p_ret));                  		\
-	}                                                                      		\
+#define _STARPU_PTHREAD_CREATE_ON(name, thread, attr, routine, arg, where) do {		    		\
+	int p_ret =  starpu_pthread_create_on((name), (thread), (attr), (routine), (arg), (where)); 	\
+	if (STARPU_UNLIKELY(p_ret != 0)) {								\
+		fprintf(stderr,										\
+			"%s:%d starpu_pthread_create: %s\n",						\
+			__FILE__, __LINE__, strerror(p_ret));						\
+		STARPU_ABORT();										\
+	}												\
 } while (0)
 
-#define _STARPU_PTHREAD_CREATE(name, thread, attr, routine, arg)               		\
-	_STARPU_PTHREAD_CREATE_ON(name, thread, attr, routine, arg, 0)
+#define _STARPU_PTHREAD_CREATE(name, thread, attr, routine, arg) do {		    	\
+	int p_ret =  starpu_pthread_create((name), (thread), (attr), (routine), (arg)); \
+	if (STARPU_UNLIKELY(p_ret != 0)) {						\
+		fprintf(stderr,								\
+			"%s:%d starpu_pthread_create: %s\n",				\
+			__FILE__, __LINE__, strerror(p_ret));				\
+		STARPU_ABORT();								\
+	}										\
+} while (0)
 
 /*
  * Encapsulation of the starpu_pthread_mutex_* functions.