Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reimplement parmap using futex based barriers.
[simgrid.git] / src / xbt / parmap_private.h
1 /* Copyright (c) 2004, 2005, 2007, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef _XBT_THREADPOOL_PRIVATE_H
8 #define _XBT_THREADPOOL_PRIVATE_H
9
10 #include "xbt/parmap.h"
11 #include "xbt/xbt_os_thread.h"
12 #include "xbt/sysdep.h"
13 #include "xbt/dynar.h"
14 #include "xbt/log.h"
15
16
17 typedef enum{
18   PARMAP_WORK = 0,
19   PARMAP_DESTROY
20 } e_xbt_parmap_flag_t;
21
22 typedef struct s_xbt_barrier{
23   int futex;
24   unsigned int thread_count;
25   unsigned int threads_to_wait;
26 } s_xbt_barrier_t, *xbt_barrier_t;
27
28 /* Wait for at least num_threads threads to arrive to the barrier */
29 void xbt_barrier_init(xbt_barrier_t barrier, unsigned int threads_to_wait);
30 void xbt_barrier_wait(xbt_barrier_t barrier);
31
32
33 typedef struct s_xbt_parmap {
34   e_xbt_parmap_flag_t status;
35   xbt_barrier_t workers_ready;
36   xbt_barrier_t workers_done;
37   unsigned int num_workers;
38   unsigned int workers_max_id;
39   void_f_pvoid_t fun;
40   xbt_dynar_t data;
41 } s_xbt_parmap_t;
42
43
44 #endif