File: tm_thread_pool.h

package info (click to toggle)
openmpi 5.0.8-4
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 201,684 kB
  • sloc: ansic: 613,078; makefile: 42,353; sh: 11,194; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,179; python: 1,859; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (50 lines) | stat: -rw-r--r-- 1,134 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef THREAD_POOL_H
#define THREAD_POOL_H

#include <pthread.h>
#include <hwloc.h>
#include "ompi_config.h"


typedef struct _work_t{
  int nb_args;
  void (*task)(int nb_args, void **args, int thread_id);
  void **args;
  struct _work_t *next;
  pthread_cond_t work_done;
  pthread_mutex_t mutex;
  int done;
  int thread_id;
}work_t;

typedef struct {
  int id;
  hwloc_topology_t topology;
  work_t *working_list;
  pthread_cond_t *cond_var;
  pthread_mutex_t *list_lock;
}local_thread_t;


typedef struct _thread_pool_t{
  int nb_threads;
  pthread_t *thread_list;
  work_t *working_list;
  pthread_cond_t *cond_var;
  pthread_mutex_t *list_lock;
  local_thread_t *local;
  hwloc_topology_t topology;
}thread_pool_t;

OMPI_HIDDEN int tm_get_nb_threads(void);
OMPI_HIDDEN int tm_submit_work(work_t *work, int thread_id);
OMPI_HIDDEN void tm_wait_work_completion(work_t *work);
OMPI_HIDDEN void tm_terminate_thread_pool(void);
OMPI_HIDDEN work_t *tm_create_work(int nb_args, void **args, void (int, void **, int));
OMPI_HIDDEN int tm_test_main(void);
OMPI_HIDDEN void tm_destroy_work(work_t *work);




#endif /* THREAD_POOL_H */