forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
threadgroup.h
48 lines (37 loc) · 1.47 KB
/
threadgroup.h
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
// This file is a part of Julia. License is MIT: http://julialang.org/license
#ifndef THREADGROUP_H
#define THREADGROUP_H
#include <stdint.h>
#include "uv.h"
// for the barrier
typedef struct {
volatile int sense;
} ti_thread_sense_t;
// thread group
typedef struct {
int16_t *tid_map, num_threads, added_threads;
uint8_t num_sockets, num_cores, num_threads_per_core;
// fork/join/barrier
volatile uint8_t group_sense;
ti_thread_sense_t **thread_sense;
void *envelope;
// to let threads sleep
uv_mutex_t alarm_lock;
uv_cond_t alarm;
uint64_t sleep_threshold;
} ti_threadgroup_t;
int ti_threadgroup_create(uint8_t num_sockets, uint8_t num_cores,
uint8_t num_threads_per_core,
ti_threadgroup_t **newtg);
int ti_threadgroup_addthread(ti_threadgroup_t *tg, int16_t ext_tid,
int16_t *tgtid);
int ti_threadgroup_initthread(ti_threadgroup_t *tg, int16_t ext_tid);
int ti_threadgroup_member(ti_threadgroup_t *tg, int16_t ext_tid,
int16_t *tgtid);
int ti_threadgroup_size(ti_threadgroup_t *tg, int16_t *tgsize);
int ti_threadgroup_fork(ti_threadgroup_t *tg, int16_t ext_tid,
void **bcast_val);
int ti_threadgroup_join(ti_threadgroup_t *tg, int16_t ext_tid);
int ti_threadgroup_destroy(ti_threadgroup_t *tg);
extern ti_threadgroup_t *tgworld;
#endif /* THREADGROUP_H */