30 kmp_int32 __kmpc_cancel(
ident_t *loc_ref, kmp_int32 gtid, kmp_int32 cncl_kind) {
31 kmp_info_t *this_thr = __kmp_threads[gtid];
33 KC_TRACE(10, (
"__kmpc_cancel: T#%d request %d OMP_CANCELLATION=%d\n", gtid,
34 cncl_kind, __kmp_omp_cancellation));
36 KMP_DEBUG_ASSERT(cncl_kind != cancel_noreq);
37 KMP_DEBUG_ASSERT(cncl_kind == cancel_parallel || cncl_kind == cancel_loop ||
38 cncl_kind == cancel_sections ||
39 cncl_kind == cancel_taskgroup);
40 KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
42 if (__kmp_omp_cancellation) {
50 kmp_team_t *this_team = this_thr->th.th_team;
51 KMP_DEBUG_ASSERT(this_team);
52 kmp_int32 old = KMP_COMPARE_AND_STORE_RET32(
53 &(this_team->t.t_cancel_request), cancel_noreq, cncl_kind);
54 if (old == cancel_noreq || old == cncl_kind) {
64 case cancel_taskgroup:
69 kmp_taskgroup_t *taskgroup;
71 task = this_thr->th.th_current_task;
72 KMP_DEBUG_ASSERT(task);
74 taskgroup = task->td_taskgroup;
76 kmp_int32 old = KMP_COMPARE_AND_STORE_RET32(
77 &(taskgroup->cancel_request), cancel_noreq, cncl_kind);
78 if (old == cancel_noreq || old == cncl_kind) {
97 KMP_DEBUG_ASSERT(!__kmp_omp_cancellation);
112 kmp_int32 __kmpc_cancellationpoint(
ident_t *loc_ref, kmp_int32 gtid,
113 kmp_int32 cncl_kind) {
114 kmp_info_t *this_thr = __kmp_threads[gtid];
117 (
"__kmpc_cancellationpoint: T#%d request %d OMP_CANCELLATION=%d\n",
118 gtid, cncl_kind, __kmp_omp_cancellation));
120 KMP_DEBUG_ASSERT(cncl_kind != cancel_noreq);
121 KMP_DEBUG_ASSERT(cncl_kind == cancel_parallel || cncl_kind == cancel_loop ||
122 cncl_kind == cancel_sections ||
123 cncl_kind == cancel_taskgroup);
124 KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
126 if (__kmp_omp_cancellation) {
128 case cancel_parallel:
130 case cancel_sections:
134 kmp_team_t *this_team = this_thr->th.th_team;
135 KMP_DEBUG_ASSERT(this_team);
136 if (this_team->t.t_cancel_request) {
137 if (cncl_kind == this_team->t.t_cancel_request) {
150 case cancel_taskgroup:
154 kmp_taskdata_t *task;
155 kmp_taskgroup_t *taskgroup;
157 task = this_thr->th.th_current_task;
158 KMP_DEBUG_ASSERT(task);
160 taskgroup = task->td_taskgroup;
163 return !!taskgroup->cancel_request;
176 KMP_DEBUG_ASSERT(!__kmp_omp_cancellation);
192 kmp_int32 __kmpc_cancel_barrier(
ident_t *loc, kmp_int32 gtid) {
194 kmp_info_t *this_thr = __kmp_threads[gtid];
195 kmp_team_t *this_team = this_thr->th.th_team;
197 KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
203 if (__kmp_omp_cancellation) {
206 switch (this_team->t.t_cancel_request) {
207 case cancel_parallel:
212 this_team->t.t_cancel_request = cancel_noreq;
217 case cancel_sections:
222 this_team->t.t_cancel_request = cancel_noreq;
227 case cancel_taskgroup:
258 int __kmp_get_cancellation_status(
int cancel_kind) {
259 if (__kmp_omp_cancellation) {
260 kmp_info_t *this_thr = __kmp_entry_thread();
262 switch (cancel_kind) {
263 case cancel_parallel:
265 case cancel_sections: {
266 kmp_team_t *this_team = this_thr->th.th_team;
267 return this_team->t.t_cancel_request == cancel_kind;
269 case cancel_taskgroup: {
270 kmp_taskdata_t *task;
271 kmp_taskgroup_t *taskgroup;
272 task = this_thr->th.th_current_task;
273 taskgroup = task->td_taskgroup;
274 return taskgroup && taskgroup->cancel_request;
KMP_EXPORT void __kmpc_barrier(ident_t *, kmp_int32 global_tid)