-
Notifications
You must be signed in to change notification settings - Fork 0
/
context.c
103 lines (82 loc) · 2.95 KB
/
context.c
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* The noreturn-function below implements the while-loop routine
that allows to execute ULT tasks. The task function cannot be
reached through function-call and does not belong to the original
CFG. Execution of the function occurs in an alternate stack and
has its own machine context. setjmp/longjmp allow to reach and to
leave ULT to and from its entry and exit points. */
#include "libgomp.h"
#include <assert.h>
void context_create_boot(struct gomp_task_context *, struct gomp_task_context *) __attribute__ ((noreturn));
void
context_create_boot(struct gomp_task_context *context_caller, struct gomp_task_context *context_creat)
{
int do_wake = 0;
struct gomp_thread *thr = NULL;
struct gomp_team *team = NULL;
struct gomp_task *task = NULL;
context_switch(context_creat, context_caller);
do
{
thr = gomp_thread ();
team = thr->ts.team;
task = thr->task;
if (thr->hold_team_lock)
{
do_wake = team->task_running_count +
!task->in_tied_task < team->nthreads;
gomp_mutex_unlock (&team->task_lock);
thr->hold_team_lock = false;
#if _LIBGOMP_TEAM_LOCK_TIMING_
thr->team_lock_time->lock_time += (RDTSC() - thr->team_lock_time->entry_time);
#endif
if (do_wake)
gomp_team_barrier_wake (&team->barrier, 1);
#if defined HAVE_TLS || defined USE_EMUTLS
if (gomp_ipi_var && ipi_mask > 0)
{
#if _LIBGOMP_TASK_SWITCH_AUDITING_
thr->task_switch_audit->interrupt_task_switch.number_of_ipi_syscall += 1;
thr->task_switch_audit->interrupt_task_switch.number_of_ipi_sent += gomp_count_1_bits(ipi_mask);
#endif
gomp_send_ipi();
}
#endif
}
if (thr->cached_state == NULL)
thr->cached_state = gomp_get_task_state(thr->global_task_state_group,
thr->local_task_state_list, task->icv.ult_stack_size);
#if _LIBGOMP_LIBGOMP_TIMING_
thr->libgomp_time->gomp_time += (RDTSC() - thr->libgomp_time->entry_time);
#endif
#if defined HAVE_TLS || defined USE_EMUTLS
if (gomp_ipi_var)
thr->in_libgomp = false;
#endif
task->fn(task->fn_data);
thr = gomp_thread ();
#if defined HAVE_TLS || defined USE_EMUTLS
if (gomp_ipi_var)
thr->in_libgomp = true;
#endif
#if _LIBGOMP_TASK_TIMING_
task->completion_time = RDTSC();
gomp_save_task_time(thr->prio_task_time, task->fn, task->kind, task->type, task->priority, (task->completion_time-task->creation_time));
#else
if (gomp_ipi_var && gomp_ipi_decision_model > 0.0)
{
task->completion_time = RDTSC();
gomp_save_task_time(thr->prio_task_time, task->fn, task->kind, task->type, task->priority, (task->completion_time-task->creation_time));
}
#endif
#if _LIBGOMP_LIBGOMP_TIMING_
thr->libgomp_time->entry_time = RDTSC();
#endif
thr->task = task->state->switch_task;
#if (_LIBGOMP_TASK_SWITCH_AUDITING_ && _LIBGOMP_IN_FLOW_TASK_SWITCH_AUDITING_)
gomp_save_inflow_task_switch (thr->task_switch_audit, task, task->state->switch_task);
#endif
context_switch(&task->state->context, &task->state->switch_task->state->context);
}
while(1);
assert(0);
}