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, cncl_kind, __kmp_omp_cancellation) );
35 KMP_DEBUG_ASSERT(cncl_kind != cancel_noreq);
36 KMP_DEBUG_ASSERT(cncl_kind == cancel_parallel || cncl_kind == cancel_loop ||
37 cncl_kind == cancel_sections || cncl_kind == cancel_taskgroup);
38 KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
40 if (__kmp_omp_cancellation) {
48 kmp_team_t *this_team = this_thr->th.th_team;
49 KMP_DEBUG_ASSERT(this_team);
50 kmp_int32 old = KMP_COMPARE_AND_STORE_RET32(&(this_team->t.t_cancel_request), cancel_noreq, cncl_kind);
51 if (old == cancel_noreq || old == cncl_kind) {
60 case cancel_taskgroup:
65 kmp_taskgroup_t* taskgroup;
67 task = this_thr->th.th_current_task;
68 KMP_DEBUG_ASSERT( task );
70 taskgroup = task->td_taskgroup;
72 kmp_int32 old = KMP_COMPARE_AND_STORE_RET32(&(taskgroup->cancel_request), cancel_noreq, cncl_kind);
73 if (old == cancel_noreq || old == cncl_kind) {
93 KMP_DEBUG_ASSERT(!__kmp_omp_cancellation);
108 kmp_int32 __kmpc_cancellationpoint(
ident_t* loc_ref, kmp_int32 gtid, kmp_int32 cncl_kind) {
109 kmp_info_t *this_thr = __kmp_threads [ gtid ];
111 KC_TRACE( 10, (
"__kmpc_cancellationpoint: T#%d request %d OMP_CANCELLATION=%d\n", gtid, cncl_kind, __kmp_omp_cancellation) );
113 KMP_DEBUG_ASSERT(cncl_kind != cancel_noreq);
114 KMP_DEBUG_ASSERT(cncl_kind == cancel_parallel || cncl_kind == cancel_loop ||
115 cncl_kind == cancel_sections || cncl_kind == cancel_taskgroup);
116 KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
118 if (__kmp_omp_cancellation) {
120 case cancel_parallel:
122 case cancel_sections:
126 kmp_team_t *this_team = this_thr->th.th_team;
127 KMP_DEBUG_ASSERT(this_team);
128 if (this_team->t.t_cancel_request) {
129 if (cncl_kind == this_team->t.t_cancel_request) {
143 case cancel_taskgroup:
147 kmp_taskdata_t* task;
148 kmp_taskgroup_t* taskgroup;
150 task = this_thr->th.th_current_task;
151 KMP_DEBUG_ASSERT( task );
153 taskgroup = task->td_taskgroup;
157 return !!taskgroup->cancel_request;
172 KMP_DEBUG_ASSERT(!__kmp_omp_cancellation);
189 __kmpc_cancel_barrier(
ident_t *loc, kmp_int32 gtid) {
191 kmp_info_t *this_thr = __kmp_threads [ gtid ];
192 kmp_team_t *this_team = this_thr->th.th_team;
194 KMP_DEBUG_ASSERT(__kmp_get_gtid() == gtid);
200 if (__kmp_omp_cancellation) {
203 switch (this_team->t.t_cancel_request) {
204 case cancel_parallel:
209 this_team->t.t_cancel_request = cancel_noreq;
214 case cancel_sections:
219 this_team->t.t_cancel_request = cancel_noreq;
225 case cancel_taskgroup:
256 int __kmp_get_cancellation_status(
int cancel_kind) {
257 if (__kmp_omp_cancellation) {
258 kmp_info_t *this_thr = __kmp_entry_thread();
260 switch (cancel_kind) {
261 case cancel_parallel:
263 case cancel_sections:
265 kmp_team_t *this_team = this_thr->th.th_team;
266 return this_team->t.t_cancel_request == cancel_kind;
268 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)