Преглед изворни кода

use starpu pthread functions

Nathalie Furmento пре 8 година
родитељ
комит
e20290a061

+ 11 - 11
examples/sched_ctx_utils/sched_ctx_utils.c

@@ -75,12 +75,12 @@ void init()
 
 	p1.id = 0;
 	p2.id = 1;
-	starpu_pthread_key_create(&key, NULL);
+	STARPU_PTHREAD_KEY_CREATE(&key, NULL);
 }
 
 void update_sched_ctx_timing_results(double flops, double avg_timing)
 {
-	unsigned *id = starpu_pthread_getspecific(key);
+	unsigned *id = STARPU_PTHREAD_GETSPECIFIC(key);
 	rv[*id].flops += flops;
 	rv[*id].avg_timing += avg_timing;
 }
@@ -90,7 +90,7 @@ void* start_bench(void *val)
 	struct params *p = (struct params*)val;
 	int i;
 
-	starpu_pthread_setspecific(key, &p->id);
+	STARPU_PTHREAD_SETSPECIFIC(key, &p->id);
 
 	if(p->ctx != 0)
 		starpu_sched_ctx_set_context(&p->ctx);
@@ -129,22 +129,22 @@ void start_2benchs(void (*bench)(unsigned, unsigned))
 	p2.nblocks = nblocks2;
 
 	starpu_pthread_t tid[2];
-	starpu_pthread_mutex_init(&mut, NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&mut, NULL);
 
 	double start;
 	double end;
 
 	start = starpu_timing_now();
 
-	starpu_pthread_create(&tid[0], NULL, (void*)start_bench, (void*)&p1);
-	starpu_pthread_create(&tid[1], NULL, (void*)start_bench, (void*)&p2);
+	STARPU_PTHREAD_CREATE(&tid[0], NULL, (void*)start_bench, (void*)&p1);
+	STARPU_PTHREAD_CREATE(&tid[1], NULL, (void*)start_bench, (void*)&p2);
 
-	starpu_pthread_join(tid[0], NULL);
-	starpu_pthread_join(tid[1], NULL);
+	STARPU_PTHREAD_JOIN(tid[0], NULL);
+	STARPU_PTHREAD_JOIN(tid[1], NULL);
 
 	end = starpu_timing_now();
 
-	starpu_pthread_mutex_destroy(&mut);
+	STARPU_PTHREAD_MUTEX_DESTROY(&mut);
 
 	double timing = end - start;
 	timing /= 1000000;
@@ -169,7 +169,7 @@ void start_1stbench(void (*bench)(unsigned, unsigned))
 
 	end = starpu_timing_now();
 
-	starpu_pthread_mutex_destroy(&mut);
+	STARPU_PTHREAD_MUTEX_DESTROY(&mut);
 
 	double timing = end - start;
 	timing /= 1000000;
@@ -193,7 +193,7 @@ void start_2ndbench(void (*bench)(unsigned, unsigned))
 
 	end = starpu_timing_now();
 
-	starpu_pthread_mutex_destroy(&mut);
+	STARPU_PTHREAD_MUTEX_DESTROY(&mut);
 
 	double timing = end - start;
 	timing /= 1000000;

+ 11 - 1
include/starpu_thread_util.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2012-2014, 2016-2017  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2017  CNRS
  *
  * 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
@@ -47,6 +47,16 @@
 	}									\
 } while (0)
 
+#define STARPU_PTHREAD_JOIN(thread, retval) do {		    	\
+	int p_ret =  starpu_pthread_join((thread), (retval)); \
+	if (STARPU_UNLIKELY(p_ret != 0)) {					\
+		fprintf(stderr,							\
+			"%s:%d starpu_pthread_join: %s\n",			\
+			__FILE__, __LINE__, strerror(p_ret));			\
+		STARPU_ABORT();							\
+	}									\
+} while (0)
+
 /*
  * Encapsulation of the starpu_pthread_mutex_* functions.
  */

+ 1 - 1
mpi/src/starpu_mpi.c

@@ -1691,7 +1691,7 @@ void _starpu_mpi_progress_shutdown(int *value)
 	(void) value;
 	MSG_process_sleep(1);
 #else
-	starpu_pthread_join(progress_thread, (void *)value);
+	STARPU_PTHREAD_JOIN(progress_thread, (void *)value);
 #endif
 
         /* free the request queues */

+ 9 - 9
sc_hypervisor/examples/app_driven_test/app_driven_test.c

@@ -30,7 +30,7 @@ struct params
 };
 
 unsigned val[2];
-pthread_mutex_t mut[2];
+starpu_pthread_mutex_t mut[2];
 
 /* Every implementation of a codelet must have this prototype, the first                                                                                                                                             * argument (buffers) describes the buffers/streams that are managed by the
  * DSM; the second arguments references read-only data that is passed as an
@@ -44,9 +44,9 @@ void cpu_func(__attribute__((unused))void *buffers[], void *cl_arg)
 	int i;
 	for(i = 0; i < NINCR; i++)
 	{
-		pthread_mutex_lock(&mut[params->sched_ctx - 1]);
+		STARPU_PTHREAD_MUTEX_LOCK(&mut[params->sched_ctx - 1]);
 		val[params->sched_ctx - 1]++;
-		pthread_mutex_unlock(&mut[params->sched_ctx - 1]);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&mut[params->sched_ctx - 1]);
 	}
 	if(params->task_tag != 0)
 		FPRINTF(stdout, "Task with tag %d executed in ctx = %u %u counter_tests\n", params->task_tag, params->sched_ctx, val[params->sched_ctx - 1]);
@@ -153,15 +153,15 @@ int main()
 
 	val[0] = 0;
 	val[1] = 0;
-	pthread_mutex_init(&mut[0], NULL);
-	pthread_mutex_init(&mut[1], NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&mut[0], NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&mut[1], NULL);
 
 	/* we create two threads to simulate simultaneous submission of tasks */
-	starpu_pthread_create(&tid[0], NULL, submit_tasks_thread, (void*)&sched_ctx1);
-	starpu_pthread_create(&tid[1], NULL, submit_tasks_thread, (void*)&sched_ctx2);
+	STARPU_PTHREAD_CREATE(&tid[0], NULL, submit_tasks_thread, (void*)&sched_ctx1);
+	STARPU_PTHREAD_CREATE(&tid[1], NULL, submit_tasks_thread, (void*)&sched_ctx2);
 
-	starpu_pthread_join(tid[0], NULL);
-	starpu_pthread_join(tid[1], NULL);
+	STARPU_PTHREAD_JOIN(tid[0], NULL);
+	STARPU_PTHREAD_JOIN(tid[1], NULL);
 
 	/* free starpu and hypervisor data */
 	starpu_shutdown();

+ 12 - 12
sc_hypervisor/examples/hierarchical_ctxs/resize_hierarchical_ctxs.c

@@ -25,7 +25,7 @@
 
 
 unsigned val[3];
-pthread_mutex_t mut[3];
+starpu_pthread_mutex_t mut[3];
 
 /* Every implementation of a codelet must have this prototype, the first                                                                                                                                             * argument (buffers) describes the buffers/streams that are managed by the
  * DSM; the second arguments references read-only data that is passed as an
@@ -39,9 +39,9 @@ void cpu_func(__attribute__((unused))void *buffers[], void *cl_arg)
 	int i;
 	for(i = 0; i < NINCR; i++)
 	{
-		pthread_mutex_lock(&mut[sched_ctx - 1]);
+		STARPU_PTHREAD_MUTEX_LOCK(&mut[sched_ctx - 1]);
 		val[sched_ctx - 1]++;
-		pthread_mutex_unlock(&mut[sched_ctx - 1]);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&mut[sched_ctx - 1]);
 	}
 }
 
@@ -139,18 +139,18 @@ int main()
 	val[0] = 0;
 	val[1] = 0;
 	val[2] = 0;
-	pthread_mutex_init(&mut[0], NULL);
-	pthread_mutex_init(&mut[1], NULL);
-	pthread_mutex_init(&mut[2], NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&mut[0], NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&mut[1], NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&mut[2], NULL);
 
 	/* we create two threads to simulate simultaneous submission of tasks */
-	starpu_pthread_create(&tid[0], NULL, submit_tasks_thread, (void*)&sched_ctx1);
-	starpu_pthread_create(&tid[1], NULL, submit_tasks_thread, (void*)&sched_ctx2);
-	starpu_pthread_create(&tid[2], NULL, submit_tasks_thread, (void*)&sched_ctx3);
+	STARPU_PTHREAD_CREATE(&tid[0], NULL, submit_tasks_thread, (void*)&sched_ctx1);
+	STARPU_PTHREAD_CREATE(&tid[1], NULL, submit_tasks_thread, (void*)&sched_ctx2);
+	STARPU_PTHREAD_CREATE(&tid[2], NULL, submit_tasks_thread, (void*)&sched_ctx3);
 
-	starpu_pthread_join(tid[0], NULL);
-	starpu_pthread_join(tid[1], NULL);
-	starpu_pthread_join(tid[2], NULL);
+	STARPU_PTHREAD_JOIN(tid[0], NULL);
+	STARPU_PTHREAD_JOIN(tid[1], NULL);
+	STARPU_PTHREAD_JOIN(tid[2], NULL);
 
 	/* free starpu and hypervisor data */
 	starpu_shutdown();

+ 9 - 9
sc_hypervisor/examples/lp_test/lp_resize_test.c

@@ -25,7 +25,7 @@
 
 
 unsigned val[2];
-pthread_mutex_t mut[2];
+starpu_pthread_mutex_t mut[2];
 
 /* Every implementation of a codelet must have this prototype, the first                                                                                                                                             * argument (buffers) describes the buffers/streams that are managed by the
  * DSM; the second arguments references read-only data that is passed as an
@@ -39,9 +39,9 @@ void cpu_func(__attribute__((unused))void *buffers[], void *cl_arg)
 	int i;
 	for(i = 0; i < NINCR; i++)
 	{
-		pthread_mutex_lock(&mut[sched_ctx - 1]);
+		STARPU_PTHREAD_MUTEX_LOCK(&mut[sched_ctx - 1]);
 		val[sched_ctx - 1]++;
-		pthread_mutex_unlock(&mut[sched_ctx - 1]);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&mut[sched_ctx - 1]);
 	}
 }
 
@@ -117,15 +117,15 @@ int main()
 
 	val[0] = 0;
 	val[1] = 0;
-	pthread_mutex_init(&mut[0], NULL);
-	pthread_mutex_init(&mut[1], NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&mut[0], NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&mut[1], NULL);
 
 	/* we create two threads to simulate simultaneous submission of tasks */
-	starpu_pthread_create(&tid[0], NULL, submit_tasks_thread, (void*)&sched_ctx1);
-	starpu_pthread_create(&tid[1], NULL, submit_tasks_thread, (void*)&sched_ctx2);
+	STARPU_PTHREAD_CREATE(&tid[0], NULL, submit_tasks_thread, (void*)&sched_ctx1);
+	STARPU_PTHREAD_CREATE(&tid[1], NULL, submit_tasks_thread, (void*)&sched_ctx2);
 
-	starpu_pthread_join(tid[0], NULL);
-	starpu_pthread_join(tid[1], NULL);
+	STARPU_PTHREAD_JOIN(tid[0], NULL);
+	STARPU_PTHREAD_JOIN(tid[1], NULL);
 
 	/* free starpu and hypervisor data */
 	starpu_shutdown();

+ 11 - 11
sc_hypervisor/examples/lp_test/lp_test.c

@@ -25,7 +25,7 @@
 
 
 unsigned val[2];
-pthread_mutex_t mut[2];
+starpu_pthread_mutex_t mut[2];
 
 /* Every implementation of a codelet must have this prototype, the first                                                                                                                                             * argument (buffers) describes the buffers/streams that are managed by the
  * DSM; the second arguments references read-only data that is passed as an
@@ -39,9 +39,9 @@ void cpu_func(__attribute__((unused))void *buffers[], void *cl_arg)
 	int i;
 	for(i = 0; i < NINCR; i++)
 	{
-		pthread_mutex_lock(&mut[sched_ctx - 1]);
+		STARPU_PTHREAD_MUTEX_LOCK(&mut[sched_ctx - 1]);
 		val[sched_ctx - 1]++;
-		pthread_mutex_unlock(&mut[sched_ctx - 1]);
+		STARPU_PTHREAD_MUTEX_UNLOCK(&mut[sched_ctx - 1]);
 	}
 }
 
@@ -91,12 +91,12 @@ int main()
 	struct sc_hypervisor_policy policy;
 	policy.custom = 0;
 	/* indicate which strategy to use
-	   in this particular case we use app_driven which allows the user to resize 
+	   in this particular case we use app_driven which allows the user to resize
 	   the ctxs dynamically at particular moments of the execution of the application */
 	policy.name = "feft_lp";
 	void *perf_counters = sc_hypervisor_init(&policy);
 
-	/* let starpu know which performance counters should use 
+	/* let starpu know which performance counters should use
 	   to inform the hypervisor how the application and the resources are executing */
 	starpu_sched_ctx_set_perf_counters(sched_ctx1, perf_counters);
 	starpu_sched_ctx_set_perf_counters(sched_ctx2, perf_counters);
@@ -116,15 +116,15 @@ int main()
 
 	val[0] = 0;
 	val[1] = 0;
-	pthread_mutex_init(&mut[0], NULL);
-	pthread_mutex_init(&mut[1], NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&mut[0], NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&mut[1], NULL);
 
 	/* we create two threads to simulate simultaneous submission of tasks */
-	starpu_pthread_create(&tid[0], NULL, submit_tasks_thread, (void*)&sched_ctx1);
-	starpu_pthread_create(&tid[1], NULL, submit_tasks_thread, (void*)&sched_ctx2);
+	STARPU_PTHREAD_CREATE(&tid[0], NULL, submit_tasks_thread, (void*)&sched_ctx1);
+	STARPU_PTHREAD_CREATE(&tid[1], NULL, submit_tasks_thread, (void*)&sched_ctx2);
 
-	starpu_pthread_join(tid[0], NULL);
-	starpu_pthread_join(tid[1], NULL);
+	STARPU_PTHREAD_JOIN(tid[0], NULL);
+	STARPU_PTHREAD_JOIN(tid[1], NULL);
 
 	/* free starpu and hypervisor data */
 	starpu_shutdown();

+ 14 - 14
sc_hypervisor/examples/sched_ctx_utils/sched_ctx_utils.c

@@ -79,12 +79,12 @@ void init()
 
 	p1.id = 0;
 	p2.id = 1;
-	starpu_pthread_key_create(&key, NULL);
+	STARPU_PTHREAD_KEY_CREATE(&key, NULL);
 }
 
 void update_sched_ctx_timing_results(double flops, double avg_timing)
 {
-	unsigned *id = starpu_pthread_getspecific(key);
+	unsigned *id = STARPU_PTHREAD_GETSPECIFIC(key);
 	rv[*id].flops += flops;
 	rv[*id].avg_timing += avg_timing;
 }
@@ -94,7 +94,7 @@ void* start_bench(void *val)
 	params *p = (params*)val;
 	int i;
 
-	starpu_pthread_setspecific(key, &p->id);
+	STARPU_PTHREAD_SETSPECIFIC(key, &p->id);
 
 	if(p->ctx != 0)
 		starpu_sched_ctx_set_context(&p->ctx);
@@ -104,14 +104,14 @@ void* start_bench(void *val)
 
 	/* if(p->ctx != 0) */
 	/* { */
-	/* 	starpu_pthread_mutex_lock(&mut); */
+	/* 	STARPU_PTHREAD_MUTEX_LOCK(&mut); */
 	/* 	if(first){ */
 	/* 		sc_hypervisor_unregiser_ctx(p->ctx); */
 	/* 		starpu_sched_ctx_delete(p->ctx, p->the_other_ctx); */
 	/* 	} */
 
 	/* 	first = 0; */
-	/* 	starpu_pthread_mutex_unlock(&mut); */
+	/* 	STARPU_PTHREAD_MUTEX_UNLOCK(&mut); */
 	/* } */
 	sc_hypervisor_stop_resize(p->the_other_ctx);
 	rv[p->id].flops /= NSAMPLES;
@@ -154,22 +154,22 @@ void start_2benchs(void (*bench)(float*, unsigned, unsigned))
 	}
 
 	starpu_pthread_t tid[2];
-	starpu_pthread_mutex_init(&mut, NULL);
+	STARPU_PTHREAD_MUTEX_INIT(&mut, NULL);
 
 	struct timeval start;
 	struct timeval end;
 
 	gettimeofday(&start, NULL);
 
-	starpu_pthread_create(&tid[0], NULL, (void*)start_bench, (void*)&p1);
-	starpu_pthread_create(&tid[1], NULL, (void*)start_bench, (void*)&p2);
+	STARPU_PTHREAD_CREATE(&tid[0], NULL, (void*)start_bench, (void*)&p1);
+	STARPU_PTHREAD_CREATE(&tid[1], NULL, (void*)start_bench, (void*)&p2);
 
-	starpu_pthread_join(tid[0], NULL);
-	starpu_pthread_join(tid[1], NULL);
+	STARPU_PTHREAD_JOIN(tid[0], NULL);
+	STARPU_PTHREAD_JOIN(tid[1], NULL);
 
 	gettimeofday(&end, NULL);
 
-	starpu_pthread_mutex_destroy(&mut);
+	STARPU_PTHREAD_MUTEX_DESTROY(&mut);
 
 	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 	timing /= 1000000;
@@ -200,7 +200,7 @@ void start_1stbench(void (*bench)(float*, unsigned, unsigned))
 
 	gettimeofday(&end, NULL);
 
-	starpu_pthread_mutex_destroy(&mut);
+	STARPU_PTHREAD_MUTEX_DESTROY(&mut);
 
 	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 	timing /= 1000000;
@@ -229,7 +229,7 @@ void start_2ndbench(void (*bench)(float*, unsigned, unsigned))
 
 	gettimeofday(&end, NULL);
 
-	starpu_pthread_mutex_destroy(&mut);
+	STARPU_PTHREAD_MUTEX_DESTROY(&mut);
 
 	double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));
 	timing /= 1000000;
@@ -332,7 +332,7 @@ void construct_contexts(void (*bench)(float*, unsigned, unsigned))
 
 void set_hypervisor_conf(int event, int task_tag)
 {
-/* 	unsigned *id = starpu_pthread_getspecific(key); */
+/* 	unsigned *id = STARPU_PTHREAD_GETSPECIFIC(key); */
 /* 	if(*id == 0) */
 /* 	{ */
 /* 		if(event == END_BENCH) */

+ 2 - 2
socl/src/cl_createcommandqueue.c

@@ -30,7 +30,7 @@ static void release_callback_command_queue(void * e) {
   gc_entity_unstore(&cq->context);
 
   /* Destruct object */
-  starpu_pthread_mutex_destroy(&cq->mutex);
+  STARPU_PTHREAD_MUTEX_DESTROY(&cq->mutex);
 }
 
 
@@ -73,7 +73,7 @@ soclCreateCommandQueue(cl_context                   context,
 
    cq->commands = NULL;
    cq->barrier = NULL;
-   starpu_pthread_mutex_init(&cq->mutex, NULL);
+   STARPU_PTHREAD_MUTEX_INIT(&cq->mutex, NULL);
 
    if (errcode_ret != NULL)
       *errcode_ret = CL_SUCCESS;

+ 1 - 1
socl/src/cl_createkernel.c

@@ -144,7 +144,7 @@ soclCreateKernel(cl_program    program,
    k->split_space = 0;
    k->split_data = NULL;
    k->split_perfs = NULL;
-   starpu_pthread_mutex_init(&k->split_lock, NULL);
+   STARPU_PTHREAD_MUTEX_INIT(&k->split_lock, NULL);
 
    #ifdef DEBUG
    static int id = 0;

+ 3 - 3
socl/src/gc.c

@@ -81,7 +81,7 @@ static void * gc_thread_routine(void *UNUSED(arg)) {
     }
 
     /* Otherwise we sleep */
-    starpu_pthread_cond_wait(&gc_cond, &gc_mutex);
+    STARPU_PTHREAD_COND_WAIT(&gc_cond, &gc_mutex);
 
   } while (1);
 
@@ -92,7 +92,7 @@ static starpu_pthread_t gc_thread;
 
 /* Start garbage collection */
 void gc_start(void) {
-  starpu_pthread_create(&gc_thread, NULL, gc_thread_routine, NULL);
+  STARPU_PTHREAD_CREATE(&gc_thread, NULL, gc_thread_routine, NULL);
 }
 
 /* Stop garbage collection */
@@ -103,7 +103,7 @@ void gc_stop(void) {
 
   GC_UNLOCK;
 
-  starpu_pthread_join(gc_thread, NULL);
+  STARPU_PTHREAD_JOIN(gc_thread, NULL);
 }
 
 int gc_entity_release_ex(entity e, const char * DEBUG_PARAM(caller)) {

+ 2 - 2
src/core/sched_ctx.c

@@ -1583,12 +1583,12 @@ int _starpu_wait_for_no_ready_of_sched_ctx(unsigned sched_ctx_id)
 
 void starpu_sched_ctx_set_context(unsigned *sched_ctx)
 {
-	starpu_pthread_setspecific(sched_ctx_key, (void*)sched_ctx);
+	STARPU_PTHREAD_SETSPECIFIC(sched_ctx_key, (void*)sched_ctx);
 }
 
 unsigned starpu_sched_ctx_get_context()
 {
-	unsigned *sched_ctx = (unsigned*)starpu_pthread_getspecific(sched_ctx_key);
+	unsigned *sched_ctx = (unsigned*)STARPU_PTHREAD_GETSPECIFIC(sched_ctx_key);
 	if(sched_ctx == NULL)
 		return STARPU_NMAX_SCHED_CTXS;
 	STARPU_ASSERT(*sched_ctx < STARPU_NMAX_SCHED_CTXS);

+ 2 - 2
src/core/simgrid.c

@@ -445,7 +445,7 @@ static int task_execute(int argc STARPU_ATTRIBUTE_UNUSED, char *argv[] STARPU_AT
 	/* FIXME: Ugly work-around for bug in simgrid: the MPI context is not properly set at MSG process startup */
 	MSG_process_sleep(0.000001);
 
-	unsigned workerid = (uintptr_t) starpu_pthread_getspecific(0);
+	unsigned workerid = (uintptr_t) STARPU_PTHREAD_GETSPECIFIC(0);
 	struct worker_runner *w = &worker_runner[workerid];
 
 	_STARPU_DEBUG("worker runner %u started\n", workerid);
@@ -687,7 +687,7 @@ static int transfer_execute(int argc STARPU_ATTRIBUTE_UNUSED, char *argv[] STARP
 	/* FIXME: Ugly work-around for bug in simgrid: the MPI context is not properly set at MSG process startup */
 	MSG_process_sleep(0.000001);
 
-	unsigned src_dst = (uintptr_t) starpu_pthread_getspecific(0);
+	unsigned src_dst = (uintptr_t) STARPU_PTHREAD_GETSPECIFIC(0);
 	unsigned src = src_dst >> 16;
 	unsigned dst = src_dst & 0xffff;
 	struct transfer_runner *t = &transfer_runner[src][dst];

+ 1 - 1
src/core/task.c

@@ -1312,5 +1312,5 @@ void _starpu_watchdog_shutdown(void)
 	if (!timeout_env)
 		return;
 
-	starpu_pthread_join(watchdog_thread, NULL);
+	STARPU_PTHREAD_JOIN(watchdog_thread, NULL);
 }

+ 2 - 3
src/drivers/mic/driver_mic_sink.c

@@ -112,8 +112,7 @@ void _starpu_mic_sink_launch_workers(struct _starpu_mp_node *node)
 		arg->coreid = i;
 		arg->node = node;
 
-		ret = starpu_pthread_create(&thread, &attr, _starpu_sink_thread, arg);
-		STARPU_ASSERT(ret == 0);
+		STARPU_PTHREAD_CREATE(&thread, &attr, _starpu_sink_thread, arg);
 		((starpu_pthread_t *)node->thread_table)[i] = thread;
 	}
 }
@@ -128,7 +127,7 @@ void _starpu_mic_sink_deinit(struct _starpu_mp_node *node)
 	for(i=0; i<node->nb_cores; i++)
 	{
 		sem_post(&node->sem_run_table[i]);
-		starpu_pthread_join(((starpu_pthread_t *)node->thread_table)[i],NULL);
+		STARPU_PTHREAD_JOIN(((starpu_pthread_t *)node->thread_table)[i],NULL);
 	}
 
 	free(node->thread_table);

+ 10 - 10
src/drivers/mp_common/sink_common.c

@@ -306,20 +306,20 @@ static void _starpu_sink_common_recv_workers(struct _starpu_mp_node * node, void
 	for(i=0; i<nworkers; i++)
 	{
 		workers[i].config = config;
-		starpu_pthread_mutex_init(&workers[i].mutex,NULL);
-		starpu_pthread_mutex_destroy(&workers[i].mutex);
+		STARPU_PTHREAD_MUTEX_INIT(&workers[i].mutex,NULL);
+		STARPU_PTHREAD_MUTEX_DESTROY(&workers[i].mutex);
 
-		starpu_pthread_cond_init(&workers[i].started_cond,NULL);
-		starpu_pthread_cond_destroy(&workers[i].started_cond);
+		STARPU_PTHREAD_COND_INIT(&workers[i].started_cond,NULL);
+		STARPU_PTHREAD_COND_DESTROY(&workers[i].started_cond);
 
-		starpu_pthread_cond_init(&workers[i].ready_cond,NULL);
-		starpu_pthread_cond_destroy(&workers[i].ready_cond);
+		STARPU_PTHREAD_COND_INIT(&workers[i].ready_cond,NULL);
+		STARPU_PTHREAD_COND_DESTROY(&workers[i].ready_cond);
 
-		starpu_pthread_mutex_init(&workers[i].sched_mutex,NULL);
-		starpu_pthread_mutex_destroy(&workers[i].sched_mutex);
+		STARPU_PTHREAD_MUTEX_INIT(&workers[i].sched_mutex,NULL);
+		STARPU_PTHREAD_MUTEX_DESTROY(&workers[i].sched_mutex);
 
-		starpu_pthread_cond_init(&workers[i].sched_cond,NULL);
-		starpu_pthread_cond_destroy(&workers[i].sched_cond);
+		STARPU_PTHREAD_COND_INIT(&workers[i].sched_cond,NULL);
+		STARPU_PTHREAD_COND_DESTROY(&workers[i].sched_cond);
 
 		workers[i].current_task = NULL;
 		workers[i].set = NULL;

+ 2 - 3
src/drivers/mpi/driver_mpi_sink.c

@@ -38,7 +38,7 @@ void _starpu_mpi_sink_deinit(struct _starpu_mp_node *node)
 	for(i=0; i<node->nb_cores; i++)
 	{
 		sem_post(&node->sem_run_table[i]);
-		starpu_pthread_join(((starpu_pthread_t *)node->thread_table)[i],NULL);
+		STARPU_PTHREAD_JOIN(((starpu_pthread_t *)node->thread_table)[i],NULL);
 	}
         free(node->thread_table);
 }
@@ -74,8 +74,7 @@ void _starpu_mpi_sink_launch_workers(struct _starpu_mp_node *node)
                 arg->coreid = i;
                 arg->node = node;
 
-                ret = starpu_pthread_create(&thread, &attr, _starpu_sink_thread, arg);
-                STARPU_ASSERT(ret == 0);
+                STARPU_PTHREAD_CREATE(&thread, &attr, _starpu_sink_thread, arg);
                 ((starpu_pthread_t *)node->thread_table)[i] = thread;
 
         }

+ 3 - 5
tests/datawizard/mpi_like.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2012, 2014, 2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2017  CNRS
  *
  * 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
@@ -203,15 +203,13 @@ int main(int argc, char **argv)
 
 	for (t = 0; t < NTHREADS; t++)
 	{
-		ret = starpu_pthread_create(&problem_data[t].thread, NULL, thread_func, &problem_data[t]);
-		STARPU_ASSERT(!ret);
+		STARPU_PTHREAD_CREATE(&problem_data[t].thread, NULL, thread_func, &problem_data[t]);
 	}
 
 	for (t = 0; t < NTHREADS; t++)
 	{
 		void *retval;
-		ret = starpu_pthread_join(problem_data[t].thread, &retval);
-		STARPU_ASSERT(!ret);
+		STARPU_PTHREAD_JOIN(problem_data[t].thread, &retval);
 		STARPU_ASSERT(retval == NULL);
 	}
 

+ 5 - 8
tests/datawizard/mpi_like_async.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2014, 2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016, 2017  CNRS
  *
  * 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
@@ -354,7 +354,7 @@ int main(int argc, char **argv)
 		problem_data[t].neighbour = &problem_data[(t+1)%nthreads];
 	}
 
-	starpu_pthread_create(&progress_thread, NULL, progress_func, NULL);
+	STARPU_PTHREAD_CREATE(&progress_thread, NULL, progress_func, NULL);
 
 	STARPU_PTHREAD_MUTEX_LOCK(&data_req_mutex);
 	while (!progress_thread_running)
@@ -363,14 +363,12 @@ int main(int argc, char **argv)
 
 	for (t = 0; t < nthreads; t++)
 	{
-		ret = starpu_pthread_create(&problem_data[t].thread, NULL, thread_func, &problem_data[t]);
-		STARPU_ASSERT(!ret);
+		STARPU_PTHREAD_CREATE(&problem_data[t].thread, NULL, thread_func, &problem_data[t]);
 	}
 
 	for (t = 0; t < nthreads; t++)
 	{
-		ret = starpu_pthread_join(problem_data[t].thread, &retval);
-		STARPU_ASSERT(!ret);
+		STARPU_PTHREAD_JOIN(problem_data[t].thread, &retval);
 		STARPU_ASSERT(retval == NULL);
 	}
 
@@ -379,8 +377,7 @@ int main(int argc, char **argv)
 	STARPU_PTHREAD_COND_SIGNAL(&data_req_cond);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&data_req_mutex);
 
-	ret = starpu_pthread_join(progress_thread, &retval);
-	STARPU_ASSERT(!ret);
+	STARPU_PTHREAD_JOIN(progress_thread, &retval);
 	STARPU_ASSERT(retval == NULL);
 
 	/* We check that the value in the "last" thread is valid */

+ 2 - 2
tests/experiments/latency/cuda_latency.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2011, 2013, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2013, 2016, 2017  CNRS
  *
  * 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
@@ -170,7 +170,7 @@ int main(int argc, char **argv)
 	for (id = 0; id < 2; id++)
 	{
 		thread_is_initialized[id] = 0;
-		starpu_pthread_create(&thread[0], NULL, launch_gpu_thread, &id);
+		STARPU_PTHREAD_CREATE(&thread[0], NULL, launch_gpu_thread, &id);
 
 		STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 		while (!thread_is_initialized[id])

+ 3 - 5
tests/main/multithreaded.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010-2011, 2013-2014, 2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2017  CNRS
  * Copyright (C) 2011  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -119,14 +119,12 @@ int main(int argc, char **argv)
 	unsigned t;
 	for (t = 0; t < nthreads; t++)
 	{
-		ret = starpu_pthread_create(&threads[t], NULL, thread_func, NULL);
-		STARPU_ASSERT(ret == 0);
+		STARPU_PTHREAD_CREATE(&threads[t], NULL, thread_func, NULL);
 	}
 
 	for (t = 0; t < nthreads; t++)
 	{
-		ret = starpu_pthread_join(threads[t], NULL);
-		STARPU_ASSERT(ret == 0);
+		STARPU_PTHREAD_JOIN(threads[t], NULL);
 	}
 
 	end = starpu_timing_now();

+ 4 - 8
tests/main/multithreaded_init.c

@@ -64,14 +64,12 @@ int main(int argc, char **argv)
 
 	for (i = 0; i < NUM_THREADS; ++i)
 	{
-		int ret = starpu_pthread_create(&threads[i], NULL, launch_starpu, NULL);
-		STARPU_ASSERT(ret == 0);
+		STARPU_PTHREAD_CREATE(&threads[i], NULL, launch_starpu, NULL);
 	}
 
 	for (i = 0; i < NUM_THREADS; ++i)
 	{
-		int ret = starpu_pthread_join(threads[i], NULL);
-		STARPU_ASSERT(ret == 0);
+		STARPU_PTHREAD_JOIN(threads[i], NULL);
 	}
 
 	end = starpu_timing_now();
@@ -84,14 +82,12 @@ int main(int argc, char **argv)
 
 	for (i = 0; i < NUM_THREADS; i++)
 	{
-		int ret = starpu_pthread_create(&threads[i], NULL, shutdown_starpu, NULL);
-		STARPU_ASSERT(ret == 0);
+		STARPU_PTHREAD_CREATE(&threads[i], NULL, shutdown_starpu, NULL);
 	}
 
 	for (i = 0; i < NUM_THREADS; i++)
 	{
-		int ret = starpu_pthread_join(threads[i], NULL);
-		STARPU_ASSERT(ret == 0);
+		STARPU_PTHREAD_JOIN(threads[i], NULL);
 	}
 
 	return EXIT_SUCCESS;