utils.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2012-2013 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012 Centre National de la Recherche Scientifique
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #ifndef __COMMON_UTILS_H__
  18. #define __COMMON_UTILS_H__
  19. #include <starpu.h>
  20. #include <common/config.h>
  21. #include <sys/stat.h>
  22. #include <string.h>
  23. #include <pthread.h>
  24. #include <stdlib.h>
  25. #include <math.h>
  26. #ifdef STARPU_SIMGRID
  27. #include <xbt/synchro_core.h>
  28. #include <msg/msg.h>
  29. #endif
  30. #ifdef STARPU_HAVE_HELGRIND_H
  31. #include <valgrind/helgrind.h>
  32. #else
  33. #define VALGRIND_HG_MUTEX_LOCK_PRE(mutex, istrylock) ((void)0)
  34. #define VALGRIND_HG_MUTEX_LOCK_POST(mutex) ((void)0)
  35. #define VALGRIND_HG_MUTEX_UNLOCK_PRE(mutex) ((void)0)
  36. #define VALGRIND_HG_MUTEX_UNLOCK_POST(mutex) ((void)0)
  37. #define DO_CREQ_v_WW(_creqF, _ty1F, _arg1F, _ty2F, _arg2F) ((void)0)
  38. #define DO_CREQ_v_W(_creqF, _ty1F, _arg1F) ((void)0)
  39. #define ANNOTATE_HAPPENS_BEFORE(obj) ((void)0)
  40. #define ANNOTATE_HAPPENS_AFTER(obj) ((void)0)
  41. #define ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) ((void)0)
  42. #define ANNOTATE_RWLOCK_RELEASED(lock, is_w) ((void)0)
  43. #endif
  44. #define _STARPU_VALGRIND_HG_SPIN_LOCK_PRE(lock) \
  45. DO_CREQ_v_WW(_VG_USERREQ__HG_PTHREAD_SPIN_LOCK_PRE, \
  46. struct _starpu_spinlock *, lock, long, 0)
  47. #define _STARPU_VALGRIND_HG_SPIN_LOCK_POST(lock) \
  48. DO_CREQ_v_W(_VG_USERREQ__HG_PTHREAD_SPIN_LOCK_POST, \
  49. struct _starpu_spinlock *, lock)
  50. #define _STARPU_VALGRIND_HG_SPIN_UNLOCK_PRE(lock) \
  51. DO_CREQ_v_W(_VG_USERREQ__HG_PTHREAD_SPIN_INIT_OR_UNLOCK_PRE, \
  52. struct _starpu_spinlock *, lock)
  53. #define _STARPU_VALGRIND_HG_SPIN_UNLOCK_POST(lock) \
  54. DO_CREQ_v_W(_VG_USERREQ__HG_PTHREAD_SPIN_INIT_OR_UNLOCK_POST, \
  55. struct _starpu_spinlock *, lock)
  56. #ifdef STARPU_VERBOSE
  57. # define _STARPU_DEBUG(fmt, args ...) do { if (!getenv("STARPU_SILENT")) {fprintf(stderr, "[starpu][%s] " fmt ,__func__ ,##args); fflush(stderr); }} while(0)
  58. #else
  59. # define _STARPU_DEBUG(fmt, args ...) do { } while (0)
  60. #endif
  61. #ifdef STARPU_VERBOSE0
  62. # define _STARPU_LOG_IN() do { if (!getenv("STARPU_SILENT")) {fprintf(stderr, "[starpu][%ld][%s] -->\n", pthread_self(), __func__ ); }} while(0)
  63. # define _STARPU_LOG_OUT() do { if (!getenv("STARPU_SILENT")) {fprintf(stderr, "[starpu][%ld][%s] <--\n", pthread_self(), __func__ ); }} while(0)
  64. # define _STARPU_LOG_OUT_TAG(outtag) do { if (!getenv("STARPU_SILENT")) {fprintf(stderr, "[starpu][%ld][%s] <-- (%s)\n", pthread_self(), __func__, outtag); }} while(0)
  65. #else
  66. # define _STARPU_LOG_IN()
  67. # define _STARPU_LOG_OUT()
  68. # define _STARPU_LOG_OUT_TAG(outtag)
  69. #endif
  70. #define _STARPU_DISP(fmt, args ...) do { if (!getenv("STARPU_SILENT")) {fprintf(stderr, "[starpu][%s] " fmt ,__func__ ,##args); }} while(0)
  71. #define _STARPU_ERROR(fmt, args ...) \
  72. do { \
  73. fprintf(stderr, "\n\n[starpu][%s] Error: " fmt ,__func__ ,##args); \
  74. fprintf(stderr, "\n\n"); \
  75. STARPU_ABORT(); \
  76. } while (0)
  77. #define _STARPU_IS_ZERO(a) (fpclassify(a) == FP_ZERO)
  78. #ifdef STARPU_SIMGRID
  79. typedef xbt_mutex_t _starpu_pthread_mutex_t;
  80. #else
  81. typedef pthread_mutex_t _starpu_pthread_mutex_t;
  82. #endif
  83. int _starpu_mkpath(const char *s, mode_t mode);
  84. void _starpu_mkpath_and_check(const char *s, mode_t mode);
  85. int _starpu_check_mutex_deadlock(_starpu_pthread_mutex_t *mutex);
  86. char *_starpu_get_home_path(void);
  87. void _starpu_gethostname(char *hostname, size_t size);
  88. /* If FILE is currently on a comment line, eat it. */
  89. void _starpu_drop_comments(FILE *f);
  90. struct _starpu_job;
  91. /* Returns the symbol associated to that job if any. */
  92. const char *_starpu_job_get_model_name(struct _starpu_job *j);
  93. struct starpu_codelet;
  94. /* Returns the symbol associated to that job if any. */
  95. const char *_starpu_codelet_get_model_name(struct starpu_codelet *cl);
  96. struct _starpu_pthread_args {
  97. void *(*f)(void*);
  98. void *arg;
  99. };
  100. int _starpu_simgrid_thread_start(int argc, char *argv[]);
  101. #ifdef STARPU_SIMGRID
  102. #define _STARPU_PTHREAD_CREATE_ON(name, thread, attr, routine, threadarg, where) do {\
  103. struct _starpu_pthread_args *_args = malloc(sizeof(*_args)); \
  104. xbt_dynar_t _hosts; \
  105. _args->f = routine; \
  106. _args->arg = threadarg; \
  107. _hosts = MSG_hosts_as_dynar(); \
  108. MSG_process_create((name), _starpu_simgrid_thread_start, _args, \
  109. xbt_dynar_get_as(_hosts, (where), msg_host_t)); \
  110. xbt_dynar_free(&_hosts); \
  111. } while (0)
  112. #else
  113. #define _STARPU_PTHREAD_CREATE_ON(name, thread, attr, routine, arg, where) do {\
  114. int p_ret = pthread_create((thread), (attr), (routine), (arg)); \
  115. if (STARPU_UNLIKELY(p_ret != 0)) { \
  116. fprintf(stderr, \
  117. "%s:%d pthread_create: %s\n", \
  118. __FILE__, __LINE__, strerror(p_ret)); \
  119. } \
  120. } while (0)
  121. #endif
  122. #define _STARPU_PTHREAD_CREATE(name, thread, attr, routine, arg) \
  123. _STARPU_PTHREAD_CREATE_ON(name, thread, attr, routine, arg, 0)
  124. /*
  125. * Encapsulation of the pthread_key_* functions.
  126. */
  127. #ifdef STARPU_SIMGRID
  128. typedef int _starpu_pthread_key_t;
  129. int _starpu_pthread_key_create(_starpu_pthread_key_t *key);
  130. #define _STARPU_PTHREAD_KEY_CREATE(key, destr) _starpu_pthread_key_create(key)
  131. int _starpu_pthread_key_delete(_starpu_pthread_key_t key);
  132. #define _STARPU_PTHREAD_KEY_DELETE(key) _starpu_pthread_key_delete(key)
  133. int _starpu_pthread_setspecific(_starpu_pthread_key_t key, void *ptr);
  134. #define _STARPU_PTHREAD_SETSPECIFIC(key, ptr) _starpu_pthread_setspecific(key, ptr)
  135. void *_starpu_pthread_getspecific(_starpu_pthread_key_t key);
  136. #define _STARPU_PTHREAD_GETSPECIFIC(key) _starpu_pthread_getspecific(key)
  137. #else
  138. typedef pthread_key_t _starpu_pthread_key_t;
  139. #define _STARPU_PTHREAD_KEY_CREATE(key, destr) do { \
  140. int p_ret = pthread_key_create((key), (destr)); \
  141. if (STARPU_UNLIKELY(p_ret != 0)) { \
  142. fprintf(stderr, \
  143. "%s:%d pthread_key_create: %s\n", \
  144. __FILE__, __LINE__, strerror(p_ret)); \
  145. } \
  146. } while (0)
  147. #define _STARPU_PTHREAD_KEY_DELETE(key) do { \
  148. int p_ret = pthread_key_delete((key)); \
  149. if (STARPU_UNLIKELY(p_ret != 0)) { \
  150. fprintf(stderr, \
  151. "%s:%d pthread_key_delete: %s\n", \
  152. __FILE__, __LINE__, strerror(p_ret)); \
  153. } \
  154. } while (0)
  155. #define _STARPU_PTHREAD_SETSPECIFIC(key, ptr) do { \
  156. int p_ret = pthread_setspecific((key), (ptr)); \
  157. if (STARPU_UNLIKELY(p_ret != 0)) { \
  158. fprintf(stderr, \
  159. "%s:%d pthread_setspecific: %s\n", \
  160. __FILE__, __LINE__, strerror(p_ret)); \
  161. }; \
  162. } while (0)
  163. #define _STARPU_PTHREAD_GETSPECIFIC(key) pthread_getspecific((key))
  164. #endif
  165. /*
  166. * Encapsulation of the pthread_mutex_* functions.
  167. */
  168. #ifdef STARPU_SIMGRID
  169. #define _STARPU_PTHREAD_MUTEX_INITIALIZER NULL
  170. #define _STARPU_PTHREAD_MUTEX_INIT(mutex, attr) do { \
  171. (*mutex) = xbt_mutex_init(); \
  172. } while (0)
  173. #else
  174. #define _STARPU_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  175. #define _STARPU_PTHREAD_MUTEX_INIT(mutex, attr) do { \
  176. int p_ret = pthread_mutex_init((mutex), (attr)); \
  177. if (STARPU_UNLIKELY(p_ret)) { \
  178. fprintf(stderr, \
  179. "%s:%d pthread_mutex_init: %s\n", \
  180. __FILE__, __LINE__, strerror(p_ret)); \
  181. STARPU_ABORT(); \
  182. } \
  183. } while (0)
  184. #endif
  185. #ifdef STARPU_SIMGRID
  186. #define _STARPU_PTHREAD_MUTEX_DESTROY(mutex) do { \
  187. if (*mutex) \
  188. xbt_mutex_destroy((*mutex)); \
  189. } while (0)
  190. #else
  191. #define _STARPU_PTHREAD_MUTEX_DESTROY(mutex) do { \
  192. int p_ret = pthread_mutex_destroy(mutex); \
  193. if (STARPU_UNLIKELY(p_ret)) { \
  194. fprintf(stderr, \
  195. "%s:%d pthread_mutex_destroy: %s\n", \
  196. __FILE__, __LINE__, strerror(p_ret)); \
  197. STARPU_ABORT(); \
  198. } \
  199. } while(0)
  200. #endif
  201. #ifdef STARPU_SIMGRID
  202. #define _STARPU_PTHREAD_MUTEX_LOCK(mutex) do { \
  203. if (!(*mutex)) _STARPU_PTHREAD_MUTEX_INIT((mutex), NULL); \
  204. xbt_mutex_acquire((*mutex)); \
  205. } while (0)
  206. #else
  207. #define _STARPU_PTHREAD_MUTEX_LOCK(mutex) do { \
  208. int p_ret = pthread_mutex_lock(mutex); \
  209. if (STARPU_UNLIKELY(p_ret)) { \
  210. fprintf(stderr, \
  211. "%s:%d pthread_mutex_lock: %s\n", \
  212. __FILE__, __LINE__, strerror(p_ret)); \
  213. STARPU_ABORT(); \
  214. } \
  215. } while (0)
  216. #endif
  217. #ifdef STARPU_SIMGRID
  218. #define _STARPU_PTHREAD_MUTEX_TRYLOCK(mutex) (xbt_mutex_acquire(*mutex), 0)
  219. #else
  220. #define _STARPU_PTHREAD_MUTEX_TRYLOCK(mutex) pthread_mutex_trylock(mutex)
  221. #endif
  222. #ifdef STARPU_SIMGRID
  223. #define _STARPU_PTHREAD_MUTEX_UNLOCK(mutex) do { \
  224. xbt_mutex_release((*mutex)); \
  225. } while (0)
  226. #else
  227. #define _STARPU_PTHREAD_MUTEX_UNLOCK(mutex) do { \
  228. int p_ret = pthread_mutex_unlock(mutex); \
  229. if (STARPU_UNLIKELY(p_ret)) { \
  230. fprintf(stderr, \
  231. "%s:%d pthread_mutex_unlock: %s\n", \
  232. __FILE__, __LINE__, strerror(p_ret)); \
  233. STARPU_ABORT(); \
  234. } \
  235. } while (0)
  236. #endif
  237. #ifdef STARPU_SIMGRID
  238. typedef xbt_mutex_t _starpu_pthread_rwlock_t;
  239. #else
  240. typedef pthread_rwlock_t _starpu_pthread_rwlock_t;
  241. #endif
  242. /*
  243. * Encapsulation of the pthread_rwlock_* functions.
  244. */
  245. #ifdef STARPU_SIMGRID
  246. #define _STARPU_PTHREAD_RWLOCK_INIT(rwlock, attr) _STARPU_PTHREAD_MUTEX_INIT(rwlock, attr)
  247. #else
  248. #define _STARPU_PTHREAD_RWLOCK_INIT(rwlock, attr) do { \
  249. int p_ret = pthread_rwlock_init((rwlock), (attr)); \
  250. if (STARPU_UNLIKELY(p_ret)) { \
  251. fprintf(stderr, \
  252. "%s:%d pthread_rwlock_init: %s\n", \
  253. __FILE__, __LINE__, strerror(p_ret)); \
  254. STARPU_ABORT(); \
  255. } \
  256. } while (0)
  257. #endif
  258. #ifdef STARPU_SIMGRID
  259. #define _STARPU_PTHREAD_RWLOCK_RDLOCK(rwlock) _STARPU_PTHREAD_MUTEX_LOCK(rwlock)
  260. #else
  261. #define _STARPU_PTHREAD_RWLOCK_RDLOCK(rwlock) do { \
  262. int p_ret = pthread_rwlock_rdlock(rwlock); \
  263. if (STARPU_UNLIKELY(p_ret)) { \
  264. fprintf(stderr, \
  265. "%s:%d pthread_rwlock_rdlock: %s\n", \
  266. __FILE__, __LINE__, strerror(p_ret)); \
  267. STARPU_ABORT(); \
  268. } \
  269. } while (0)
  270. #endif
  271. #ifdef STARPU_SIMGRID
  272. #define _STARPU_PTHREAD_RWLOCK_WRLOCK(rwlock) _STARPU_PTHREAD_MUTEX_LOCK(rwlock)
  273. #else
  274. #define _STARPU_PTHREAD_RWLOCK_WRLOCK(rwlock) do { \
  275. int p_ret = pthread_rwlock_wrlock(rwlock); \
  276. if (STARPU_UNLIKELY(p_ret)) { \
  277. fprintf(stderr, \
  278. "%s:%d pthread_rwlock_wrlock: %s\n", \
  279. __FILE__, __LINE__, strerror(p_ret)); \
  280. STARPU_ABORT(); \
  281. } \
  282. } while (0)
  283. #endif
  284. #ifdef STARPU_SIMGRID
  285. #define _STARPU_PTHREAD_RWLOCK_UNLOCK(rwlock) _STARPU_PTHREAD_MUTEX_UNLOCK(rwlock)
  286. #else
  287. #define _STARPU_PTHREAD_RWLOCK_UNLOCK(rwlock) do { \
  288. int p_ret = pthread_rwlock_unlock(rwlock); \
  289. if (STARPU_UNLIKELY(p_ret)) { \
  290. fprintf(stderr, \
  291. "%s:%d pthread_rwlock_unlock: %s\n", \
  292. __FILE__, __LINE__, strerror(p_ret)); \
  293. STARPU_ABORT(); \
  294. } \
  295. } while (0)
  296. #endif
  297. #ifdef STARPU_SIMGRID
  298. #define _STARPU_PTHREAD_RWLOCK_DESTROY(rwlock) _STARPU_PTHREAD_MUTEX_DESTROY(rwlock)
  299. #else
  300. #define _STARPU_PTHREAD_RWLOCK_DESTROY(rwlock) do { \
  301. int p_ret = pthread_rwlock_destroy(rwlock); \
  302. if (STARPU_UNLIKELY(p_ret)) { \
  303. fprintf(stderr, \
  304. "%s:%d pthread_rwlock_destroy: %s\n", \
  305. __FILE__, __LINE__, strerror(p_ret)); \
  306. STARPU_ABORT(); \
  307. } \
  308. } while (0)
  309. #endif
  310. #ifdef STARPU_SIMGRID
  311. typedef xbt_cond_t _starpu_pthread_cond_t;
  312. #else
  313. typedef pthread_cond_t _starpu_pthread_cond_t;
  314. #endif
  315. /*
  316. * Encapsulation of the pthread_cond_* functions.
  317. */
  318. #ifdef STARPU_SIMGRID
  319. #define _STARPU_PTHREAD_COND_INITIALIZER NULL
  320. #define _STARPU_PTHREAD_COND_INIT(cond, attr) do { \
  321. (*cond) = xbt_cond_init(); \
  322. } while (0)
  323. #else
  324. #define _STARPU_PTHREAD_COND_INITIALIZER PTHREAD_COND_INITIALIZER
  325. #define _STARPU_PTHREAD_COND_INIT(cond, attr) do { \
  326. int p_ret = pthread_cond_init((cond), (attr)); \
  327. if (STARPU_UNLIKELY(p_ret)) { \
  328. fprintf(stderr, \
  329. "%s:%d pthread_cond_init: %s\n", \
  330. __FILE__, __LINE__, strerror(p_ret)); \
  331. STARPU_ABORT(); \
  332. } \
  333. } while (0)
  334. #endif
  335. #ifdef STARPU_SIMGRID
  336. #define _STARPU_PTHREAD_COND_DESTROY(cond) do { \
  337. if (*cond) \
  338. xbt_cond_destroy((*cond)); \
  339. } while (0)
  340. #else
  341. #define _STARPU_PTHREAD_COND_DESTROY(cond) do { \
  342. int p_ret = pthread_cond_destroy(cond); \
  343. if (STARPU_UNLIKELY(p_ret)) { \
  344. fprintf(stderr, \
  345. "%s:%d pthread_cond_destroy: %s\n", \
  346. __FILE__, __LINE__, strerror(p_ret)); \
  347. STARPU_ABORT(); \
  348. } \
  349. } while (0)
  350. #endif
  351. #ifdef STARPU_SIMGRID
  352. #define _STARPU_PTHREAD_COND_SIGNAL(cond) do { \
  353. if (!*cond) \
  354. _STARPU_PTHREAD_COND_INIT(cond, NULL); \
  355. xbt_cond_signal((*cond)); \
  356. } while (0)
  357. #else
  358. #define _STARPU_PTHREAD_COND_SIGNAL(cond) do { \
  359. int p_ret = pthread_cond_signal(cond); \
  360. if (STARPU_UNLIKELY(p_ret)) { \
  361. fprintf(stderr, \
  362. "%s:%d pthread_cond_signal: %s\n", \
  363. __FILE__, __LINE__, strerror(p_ret)); \
  364. STARPU_ABORT(); \
  365. } \
  366. } while (0)
  367. #endif
  368. #ifdef STARPU_SIMGRID
  369. #define _STARPU_PTHREAD_COND_BROADCAST(cond) do { \
  370. if (!*cond) \
  371. _STARPU_PTHREAD_COND_INIT(cond, NULL); \
  372. xbt_cond_broadcast((*cond)); \
  373. } while (0)
  374. #else
  375. #define _STARPU_PTHREAD_COND_BROADCAST(cond) do { \
  376. int p_ret = pthread_cond_broadcast(cond); \
  377. if (STARPU_UNLIKELY(p_ret)) { \
  378. fprintf(stderr, \
  379. "%s:%d pthread_cond_broadcast: %s\n", \
  380. __FILE__, __LINE__, strerror(p_ret)); \
  381. STARPU_ABORT(); \
  382. } \
  383. } while (0)
  384. #endif
  385. #ifdef STARPU_SIMGRID
  386. #define _STARPU_PTHREAD_COND_WAIT(cond, mutex) do { \
  387. if (!*cond) \
  388. _STARPU_PTHREAD_COND_INIT(cond, NULL); \
  389. xbt_cond_wait((*cond), (*mutex)); \
  390. } while (0)
  391. #else
  392. #define _STARPU_PTHREAD_COND_WAIT(cond, mutex) do { \
  393. int p_ret = pthread_cond_wait((cond), (mutex)); \
  394. if (STARPU_UNLIKELY(p_ret)) { \
  395. fprintf(stderr, \
  396. "%s:%d pthread_cond_wait: %s\n", \
  397. __FILE__, __LINE__, strerror(p_ret)); \
  398. STARPU_ABORT(); \
  399. } \
  400. } while (0)
  401. #endif
  402. #define _starpu_pthread_barrier_t pthread_barrier_t
  403. /*
  404. * Encapsulation of the pthread_barrier_* functions.
  405. */
  406. #define _STARPU_PTHREAD_BARRIER_INIT(barrier, attr, count) do { \
  407. int p_ret = pthread_barrier_init((barrier), (attr), (count)); \
  408. if (STARPU_UNLIKELY(p_ret)) { \
  409. fprintf(stderr, \
  410. "%s:%d pthread_barrier_init: %s\n", \
  411. __FILE__, __LINE__, strerror(p_ret)); \
  412. STARPU_ABORT(); \
  413. } \
  414. } while (0)
  415. #define _STARPU_PTHREAD_BARRIER_DESTROY(barrier) do { \
  416. int p_ret = pthread_barrier_destroy((barrier)); \
  417. if (STARPU_UNLIKELY(p_ret)) { \
  418. fprintf(stderr, \
  419. "%s:%d pthread_barrier_destroy: %s\n", \
  420. __FILE__, __LINE__, strerror(p_ret)); \
  421. STARPU_ABORT(); \
  422. } \
  423. } while (0)
  424. #define _STARPU_PTHREAD_BARRIER_WAIT(barrier) do { \
  425. int p_ret = pthread_barrier_wait(barrier); \
  426. if (STARPU_UNLIKELY(!((p_ret == 0) || (p_ret == PTHREAD_BARRIER_SERIAL_THREAD)))) { \
  427. fprintf(stderr, \
  428. "%s:%d pthread_barrier_wait: %s\n", \
  429. __FILE__, __LINE__, strerror(p_ret)); \
  430. STARPU_ABORT(); \
  431. } \
  432. } while (0)
  433. #ifdef HAVE_PTHREAD_SPIN_LOCK
  434. typedef pthread_spinlock_t _starpu_pthread_spinlock_t;
  435. #endif
  436. #endif // __COMMON_UTILS_H__