Przeglądaj źródła

use starpu_pthread_self() instead of pthread_self

Nathalie Furmento 8 lat temu
rodzic
commit
cbac70e22c
5 zmienionych plików z 14 dodań i 15 usunięć
  1. 1 1
      src/common/fxt.c
  2. 3 4
      src/common/utils.h
  3. 6 6
      src/core/sched_ctx.h
  4. 1 1
      src/core/topology.c
  5. 3 3
      src/core/workers.c

+ 1 - 1
src/common/fxt.c

@@ -72,7 +72,7 @@ long _starpu_gettid(void)
 #elif defined(_WIN32) && !defined(__CYGWIN__)
 	return (long) GetCurrentThreadId();
 #else
-	return (long) pthread_self();
+	return (long) starpu_pthread_self();
 #endif
 #endif
 }

+ 3 - 4
src/common/utils.h

@@ -24,7 +24,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <math.h>
-#include <pthread.h>
 #ifdef STARPU_HAVE_SCHED_YIELD
 #include <sched.h>
 #endif
@@ -97,9 +96,9 @@
 #endif
 
 #ifdef STARPU_EXTRA_VERBOSE
-#  define _STARPU_LOG_IN()             do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] -->\n", pthread_self(), __starpu_func__,__FILE__,  __LINE__); }} while(0)
-#  define _STARPU_LOG_OUT()            do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] <--\n", pthread_self(), __starpu_func__, __FILE__,  __LINE__); }} while(0)
-#  define _STARPU_LOG_OUT_TAG(outtag)  do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] <-- (%s)\n", pthread_self(), __starpu_func__, __FILE__, __LINE__, outtag); }} while(0)
+#  define _STARPU_LOG_IN()             do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] -->\n", starpu_pthread_self(), __starpu_func__,__FILE__,  __LINE__); }} while(0)
+#  define _STARPU_LOG_OUT()            do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] <--\n", starpu_pthread_self(), __starpu_func__, __FILE__,  __LINE__); }} while(0)
+#  define _STARPU_LOG_OUT_TAG(outtag)  do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] <-- (%s)\n", starpu_pthread_self(), __starpu_func__, __FILE__, __LINE__, outtag); }} while(0)
 #else
 #  define _STARPU_LOG_IN()
 #  define _STARPU_LOG_OUT()

+ 6 - 6
src/core/sched_ctx.h

@@ -241,22 +241,22 @@ static inline struct _starpu_sched_ctx *_starpu_get_sched_ctx_struct(unsigned id
 static inline int _starpu_sched_ctx_check_write_locked(unsigned sched_ctx_id)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
-	return sched_ctx->lock_write_owner == pthread_self();
+	return sched_ctx->lock_write_owner == starpu_pthread_self();
 }
 #define STARPU_SCHED_CTX_CHECK_LOCK(sched_ctx_id) STARPU_ASSERT(_starpu_sched_ctx_check_write_locked((sched_ctx_id)))
 
 static inline void _starpu_sched_ctx_lock_write(unsigned sched_ctx_id)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
-	STARPU_ASSERT(sched_ctx->lock_write_owner != pthread_self());
+	STARPU_ASSERT(sched_ctx->lock_write_owner != starpu_pthread_self());
 	STARPU_PTHREAD_RWLOCK_WRLOCK(&sched_ctx->rwlock);
-	sched_ctx->lock_write_owner = pthread_self();
+	sched_ctx->lock_write_owner = starpu_pthread_self();
 }
 
 static inline void _starpu_sched_ctx_unlock_write(unsigned sched_ctx_id)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
-	STARPU_ASSERT(sched_ctx->lock_write_owner == pthread_self());
+	STARPU_ASSERT(sched_ctx->lock_write_owner == starpu_pthread_self());
 	sched_ctx->lock_write_owner = 0;
 	STARPU_PTHREAD_RWLOCK_UNLOCK(&sched_ctx->rwlock);
 }
@@ -264,14 +264,14 @@ static inline void _starpu_sched_ctx_unlock_write(unsigned sched_ctx_id)
 static inline void _starpu_sched_ctx_lock_read(unsigned sched_ctx_id)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
-	STARPU_ASSERT(sched_ctx->lock_write_owner != pthread_self());
+	STARPU_ASSERT(sched_ctx->lock_write_owner != starpu_pthread_self());
 	STARPU_PTHREAD_RWLOCK_RDLOCK(&sched_ctx->rwlock);
 }
 
 static inline void _starpu_sched_ctx_unlock_read(unsigned sched_ctx_id)
 {
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
-	STARPU_ASSERT(sched_ctx->lock_write_owner != pthread_self());
+	STARPU_ASSERT(sched_ctx->lock_write_owner != starpu_pthread_self());
 	STARPU_PTHREAD_RWLOCK_UNLOCK(&sched_ctx->rwlock);
 }
 

+ 1 - 1
src/core/topology.c

@@ -1673,7 +1673,7 @@ _starpu_bind_thread_on_cpu (
 	CPU_ZERO(&aff_mask);
 	CPU_SET(cpuid, &aff_mask);
 
-	starpu_pthread_t self = pthread_self();
+	starpu_pthread_t self = starpu_pthread_self();
 
 	ret = pthread_setaffinity_np(self, sizeof(aff_mask), &aff_mask);
 	if (ret)

+ 3 - 3
src/core/workers.c

@@ -1423,13 +1423,13 @@ static void _starpu_terminate_workers(struct _starpu_machine_config *pconfig)
 		struct _starpu_worker *worker = &pconfig->workers[workerid];
 
 		/* in case StarPU termination code is called from a callback,
- 		 * we have to check if pthread_self() is the worker itself */
+ 		 * we have to check if starpu_pthread_self() is the worker itself */
 		if (set && set->nworkers > 0)
 		{
 			if (set->started)
 			{
 #ifndef STARPU_SIMGRID
-				if (!pthread_equal(pthread_self(), set->worker_thread))
+				if (!pthread_equal(starpu_pthread_self(), set->worker_thread))
 #endif
 					status = starpu_pthread_join(set->worker_thread, NULL);
 				if (status)
@@ -1447,7 +1447,7 @@ static void _starpu_terminate_workers(struct _starpu_machine_config *pconfig)
 				goto out;
 
 #ifndef STARPU_SIMGRID
-			if (!pthread_equal(pthread_self(), worker->worker_thread))
+			if (!pthread_equal(starpu_pthread_self(), worker->worker_thread))
 #endif
 				status = starpu_pthread_join(worker->worker_thread, NULL);
 			if (status)