-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.h
78 lines (64 loc) · 2.76 KB
/
state.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef GOMP_FREE_STATE_H
#define GOMP_FREE_STATE_H 1
/* Default per-task stack size. */
#define ULT_STACK_SIZE 524288
/* Default per-thread initial number of free states. */
#define NUM_INIT_STATE 1024
/* Default per-thread additional number of free states @run-time. */
#define NUM_ADD_STATE 64
/* This structure maintains the execution context associated to a task. */
struct gomp_task_state
{
/* Cache-line distantiation. */
char __pad__[64];
/* Points to the next "gomp_task_state" structure to be freed upon completion. */
struct gomp_task_state *next_to_free;
/* Points to the next "gomp_task_state" structure in the free-list. */
struct gomp_task_state *next;
/* CPU registers. */
struct gomp_task_context context;
/* Task to which switch back upon completion of the current one. */
struct gomp_task *switch_task;
/* To keep track of which task we have been resumed from. */
struct gomp_task *switch_from_task;
/* Size in bytes of the allocated stack. */
size_t stack_size;
/* Alternate stack where the associated task operates on. */
void *stack;
};
/* This structure handles a "gomp_task_state" list. */
struct gomp_task_state_list
{
/* Cache-line distantiation. */
char __pad__[64];
/* Number of "gomp_task_state" structures enqueued. */
volatile unsigned list_size;
/* Points to the first "gomp_task_state" structure. */
volatile struct gomp_task_state *list;
/* Points to the first "gomp_task_state" structure to be freed. */
struct gomp_task_state *list_to_free;
};
/* This structure handles a global and a predefined number
of per-thread "gomp_task_state_list" structures. */
struct gomp_task_state_list_group
{
/* Indicates whether this group has been already initialized. */
volatile bool initialized;
/* The whole number of allocated tasks. */
volatile unsigned allocated_tasks;
/* Needed to exclusively operates on the global list. */
gomp_spinlock_t global_list_lock;
/* Number of available "thread_list" structure. */
unsigned thread_list_number;
/* Array of per-thread lists. */
struct gomp_task_state_list **thread_list;
/* Global list. */
struct gomp_task_state_list global_list;
};
/* state.c */
extern int gomp_task_state_list_init(struct gomp_task_state_list_group *, unsigned, struct gomp_task_icv *);
extern int gomp_task_state_list_group_init(struct gomp_task_state_list_group *, unsigned, struct gomp_task_icv *);
extern void gomp_task_state_list_group_end(struct gomp_task_state_list_group *);
extern struct gomp_task_state *gomp_get_task_state(struct gomp_task_state_list_group *, struct gomp_task_state_list *, unsigned long);
extern void gomp_free_task_state(struct gomp_task_state_list_group *, struct gomp_task_state_list *, struct gomp_task_state *);
#endif /* GOMP_FREE_STATE_H */