17 #include "kmp_wait_release.h"
18 #include "kmp_taskdeps.h"
20 #include "ompt-specific.h"
32 #ifdef KMP_SUPPORT_GRAPH_OUTPUT
33 static std::atomic<kmp_int32> kmp_node_id_seed = ATOMIC_VAR_INIT(0);
36 static void __kmp_init_node(kmp_depnode_t *node) {
37 node->dn.successors = NULL;
40 for (
int i = 0; i < MAX_MTX_DEPS; ++i)
41 node->dn.mtx_locks[i] = NULL;
42 node->dn.mtx_num_locks = 0;
43 __kmp_init_lock(&node->dn.lock);
44 KMP_ATOMIC_ST_RLX(&node->dn.nrefs, 1);
45 #ifdef KMP_SUPPORT_GRAPH_OUTPUT
46 node->dn.id = KMP_ATOMIC_INC(&kmp_node_id_seed);
50 static inline kmp_depnode_t *__kmp_node_ref(kmp_depnode_t *node) {
51 KMP_ATOMIC_INC(&node->dn.nrefs);
55 enum { KMP_DEPHASH_OTHER_SIZE = 97, KMP_DEPHASH_MASTER_SIZE = 997 };
57 size_t sizes[] = { 997, 2003, 4001, 8191, 16001, 32003, 64007, 131071, 270029 };
58 const size_t MAX_GEN = 8;
60 static inline kmp_int32 __kmp_dephash_hash(kmp_intptr_t addr,
size_t hsize) {
63 return ((addr >> 6) ^ (addr >> 2)) % hsize;
66 static kmp_dephash_t *__kmp_dephash_extend(kmp_info_t *thread,
67 kmp_dephash_t *current_dephash) {
70 size_t gen = current_dephash->generation + 1;
72 return current_dephash;
73 size_t new_size = sizes[gen];
75 kmp_int32 size_to_allocate =
76 new_size *
sizeof(kmp_dephash_entry_t *) +
sizeof(kmp_dephash_t);
79 h = (kmp_dephash_t *)__kmp_fast_allocate(thread, size_to_allocate);
81 h = (kmp_dephash_t *)__kmp_thread_malloc(thread, size_to_allocate);
85 h->nelements = current_dephash->nelements;
86 h->buckets = (kmp_dephash_entry **)(h + 1);
90 for (
size_t i = 0; i < current_dephash->size; i++) {
91 kmp_dephash_entry_t *next, *entry;
92 for (entry = current_dephash->buckets[i]; entry; entry = next) {
93 next = entry->next_in_bucket;
96 kmp_int32 new_bucket = __kmp_dephash_hash(entry->addr, h->size);
97 entry->next_in_bucket = h->buckets[new_bucket];
98 if (entry->next_in_bucket) {
101 h->buckets[new_bucket] = entry;
107 __kmp_fast_free(thread, current_dephash);
109 __kmp_thread_free(thread, current_dephash);
115 static kmp_dephash_t *__kmp_dephash_create(kmp_info_t *thread,
116 kmp_taskdata_t *current_task) {
121 if (current_task->td_flags.tasktype == TASK_IMPLICIT)
122 h_size = KMP_DEPHASH_MASTER_SIZE;
124 h_size = KMP_DEPHASH_OTHER_SIZE;
127 h_size *
sizeof(kmp_dephash_entry_t *) +
sizeof(kmp_dephash_t);
130 h = (kmp_dephash_t *)__kmp_fast_allocate(thread, size);
132 h = (kmp_dephash_t *)__kmp_thread_malloc(thread, size);
139 h->buckets = (kmp_dephash_entry **)(h + 1);
141 for (
size_t i = 0; i < h_size; i++)
147 #define ENTRY_LAST_INS 0
148 #define ENTRY_LAST_MTXS 1
150 static kmp_dephash_entry *
151 __kmp_dephash_find(kmp_info_t *thread, kmp_dephash_t **hash, kmp_intptr_t addr) {
152 kmp_dephash_t *h = *hash;
153 if (h->nelements != 0
154 && h->nconflicts/h->size >= 1) {
155 *hash = __kmp_dephash_extend(thread, h);
158 kmp_int32 bucket = __kmp_dephash_hash(addr, h->size);
160 kmp_dephash_entry_t *entry;
161 for (entry = h->buckets[bucket]; entry; entry = entry->next_in_bucket)
162 if (entry->addr == addr)
168 entry = (kmp_dephash_entry_t *)__kmp_fast_allocate(
169 thread,
sizeof(kmp_dephash_entry_t));
171 entry = (kmp_dephash_entry_t *)__kmp_thread_malloc(
172 thread,
sizeof(kmp_dephash_entry_t));
175 entry->last_out = NULL;
176 entry->last_ins = NULL;
177 entry->last_mtxs = NULL;
178 entry->last_flag = ENTRY_LAST_INS;
179 entry->mtx_lock = NULL;
180 entry->next_in_bucket = h->buckets[bucket];
181 h->buckets[bucket] = entry;
183 if (entry->next_in_bucket)
189 static kmp_depnode_list_t *__kmp_add_node(kmp_info_t *thread,
190 kmp_depnode_list_t *list,
191 kmp_depnode_t *node) {
192 kmp_depnode_list_t *new_head;
195 new_head = (kmp_depnode_list_t *)__kmp_fast_allocate(
196 thread,
sizeof(kmp_depnode_list_t));
198 new_head = (kmp_depnode_list_t *)__kmp_thread_malloc(
199 thread,
sizeof(kmp_depnode_list_t));
202 new_head->node = __kmp_node_ref(node);
203 new_head->next = list;
208 static inline void __kmp_track_dependence(kmp_int32 gtid, kmp_depnode_t *source,
210 kmp_task_t *sink_task) {
211 #ifdef KMP_SUPPORT_GRAPH_OUTPUT
212 kmp_taskdata_t *task_source = KMP_TASK_TO_TASKDATA(source->dn.task);
215 kmp_taskdata_t *task_sink = KMP_TASK_TO_TASKDATA(sink_task);
217 __kmp_printf(
"%d(%s) -> %d(%s)\n", source->dn.id,
218 task_source->td_ident->psource, sink->dn.id,
219 task_sink->td_ident->psource);
221 #if OMPT_SUPPORT && OMPT_OPTIONAL
225 if (ompt_enabled.ompt_callback_task_dependence) {
226 kmp_taskdata_t *task_source = KMP_TASK_TO_TASKDATA(source->dn.task);
227 ompt_data_t *sink_data;
229 sink_data = &(KMP_TASK_TO_TASKDATA(sink_task)->ompt_task_info.task_data);
231 sink_data = &__kmp_threads[gtid]->th.ompt_thread_info.task_data;
233 ompt_callbacks.ompt_callback(ompt_callback_task_dependence)(
234 &(task_source->ompt_task_info.task_data), sink_data);
239 static inline kmp_int32
240 __kmp_depnode_link_successor(kmp_int32 gtid, kmp_info_t *thread,
241 kmp_task_t *task, kmp_depnode_t *node,
242 kmp_depnode_list_t *plist) {
245 kmp_int32 npredecessors = 0;
247 for (kmp_depnode_list_t *p = plist; p; p = p->next) {
248 kmp_depnode_t *dep = p->node;
250 KMP_ACQUIRE_DEPNODE(gtid, dep);
252 __kmp_track_dependence(gtid, dep, node, task);
253 dep->dn.successors = __kmp_add_node(thread, dep->dn.successors, node);
254 KA_TRACE(40, (
"__kmp_process_deps: T#%d adding dependence from %p to "
256 gtid, KMP_TASK_TO_TASKDATA(dep->dn.task),
257 KMP_TASK_TO_TASKDATA(task)));
260 KMP_RELEASE_DEPNODE(gtid, dep);
263 return npredecessors;
266 static inline kmp_int32 __kmp_depnode_link_successor(kmp_int32 gtid,
269 kmp_depnode_t *source,
270 kmp_depnode_t *sink) {
273 kmp_int32 npredecessors = 0;
276 KMP_ACQUIRE_DEPNODE(gtid, sink);
278 __kmp_track_dependence(gtid, sink, source, task);
279 sink->dn.successors = __kmp_add_node(thread, sink->dn.successors, source);
280 KA_TRACE(40, (
"__kmp_process_deps: T#%d adding dependence from %p to "
282 gtid, KMP_TASK_TO_TASKDATA(sink->dn.task),
283 KMP_TASK_TO_TASKDATA(task)));
286 KMP_RELEASE_DEPNODE(gtid, sink);
288 return npredecessors;
291 template <
bool filter>
292 static inline kmp_int32
293 __kmp_process_deps(kmp_int32 gtid, kmp_depnode_t *node, kmp_dephash_t **hash,
294 bool dep_barrier, kmp_int32 ndeps,
295 kmp_depend_info_t *dep_list, kmp_task_t *task) {
296 KA_TRACE(30, (
"__kmp_process_deps<%d>: T#%d processing %d dependencies : "
297 "dep_barrier = %d\n",
298 filter, gtid, ndeps, dep_barrier));
300 kmp_info_t *thread = __kmp_threads[gtid];
301 kmp_int32 npredecessors = 0;
302 for (kmp_int32 i = 0; i < ndeps; i++) {
303 const kmp_depend_info_t *dep = &dep_list[i];
305 if (filter && dep->base_addr == 0)
308 kmp_dephash_entry_t *info =
309 __kmp_dephash_find(thread, hash, dep->base_addr);
310 kmp_depnode_t *last_out = info->last_out;
311 kmp_depnode_list_t *last_ins = info->last_ins;
312 kmp_depnode_list_t *last_mtxs = info->last_mtxs;
314 if (dep->flags.out) {
315 if (last_ins || last_mtxs) {
316 if (info->last_flag == ENTRY_LAST_INS) {
318 __kmp_depnode_link_successor(gtid, thread, task, node, last_ins);
321 __kmp_depnode_link_successor(gtid, thread, task, node, last_mtxs);
323 __kmp_depnode_list_free(thread, last_ins);
324 __kmp_depnode_list_free(thread, last_mtxs);
325 info->last_ins = NULL;
326 info->last_mtxs = NULL;
329 __kmp_depnode_link_successor(gtid, thread, task, node, last_out);
331 __kmp_node_deref(thread, last_out);
336 info->last_out = NULL;
338 info->last_out = __kmp_node_ref(node);
340 }
else if (dep->flags.in) {
344 __kmp_depnode_link_successor(gtid, thread, task, node, last_mtxs);
345 __kmp_node_deref(thread, last_out);
346 info->last_out = NULL;
347 if (info->last_flag == ENTRY_LAST_MTXS && last_ins) {
349 __kmp_depnode_list_free(thread, last_ins);
350 info->last_ins = NULL;
355 __kmp_depnode_link_successor(gtid, thread, task, node, last_out);
357 info->last_flag = ENTRY_LAST_INS;
358 info->last_ins = __kmp_add_node(thread, info->last_ins, node);
360 KMP_DEBUG_ASSERT(dep->flags.mtx == 1);
364 __kmp_depnode_link_successor(gtid, thread, task, node, last_ins);
365 __kmp_node_deref(thread, last_out);
366 info->last_out = NULL;
367 if (info->last_flag == ENTRY_LAST_INS && last_mtxs) {
369 __kmp_depnode_list_free(thread, last_mtxs);
370 info->last_mtxs = NULL;
375 __kmp_depnode_link_successor(gtid, thread, task, node, last_out);
377 info->last_flag = ENTRY_LAST_MTXS;
378 info->last_mtxs = __kmp_add_node(thread, info->last_mtxs, node);
379 if (info->mtx_lock == NULL) {
380 info->mtx_lock = (kmp_lock_t *)__kmp_allocate(
sizeof(kmp_lock_t));
381 __kmp_init_lock(info->mtx_lock);
383 KMP_DEBUG_ASSERT(node->dn.mtx_num_locks < MAX_MTX_DEPS);
386 for (m = 0; m < MAX_MTX_DEPS; ++m) {
388 if (node->dn.mtx_locks[m] < info->mtx_lock) {
389 KMP_DEBUG_ASSERT(node->dn.mtx_locks[node->dn.mtx_num_locks] == NULL);
390 for (
int n = node->dn.mtx_num_locks; n > m; --n) {
392 KMP_DEBUG_ASSERT(node->dn.mtx_locks[n - 1] != NULL);
393 node->dn.mtx_locks[n] = node->dn.mtx_locks[n - 1];
395 node->dn.mtx_locks[m] = info->mtx_lock;
399 KMP_DEBUG_ASSERT(m < MAX_MTX_DEPS);
400 node->dn.mtx_num_locks++;
403 KA_TRACE(30, (
"__kmp_process_deps<%d>: T#%d found %d predecessors\n", filter,
404 gtid, npredecessors));
405 return npredecessors;
408 #define NO_DEP_BARRIER (false)
409 #define DEP_BARRIER (true)
412 static bool __kmp_check_deps(kmp_int32 gtid, kmp_depnode_t *node,
413 kmp_task_t *task, kmp_dephash_t **hash,
414 bool dep_barrier, kmp_int32 ndeps,
415 kmp_depend_info_t *dep_list,
416 kmp_int32 ndeps_noalias,
417 kmp_depend_info_t *noalias_dep_list) {
420 kmp_taskdata_t *taskdata = KMP_TASK_TO_TASKDATA(task);
422 KA_TRACE(20, (
"__kmp_check_deps: T#%d checking dependencies for task %p : %d "
423 "possibly aliased dependencies, %d non-aliased dependencies : "
424 "dep_barrier=%d .\n",
425 gtid, taskdata, ndeps, ndeps_noalias, dep_barrier));
429 for (i = 0; i < ndeps; i++) {
430 if (dep_list[i].base_addr != 0) {
431 for (
int j = i + 1; j < ndeps; j++) {
432 if (dep_list[i].base_addr == dep_list[j].base_addr) {
433 dep_list[i].flags.in |= dep_list[j].flags.in;
434 dep_list[i].flags.out |=
435 (dep_list[j].flags.out ||
436 (dep_list[i].flags.in && dep_list[j].flags.mtx) ||
437 (dep_list[i].flags.mtx && dep_list[j].flags.in));
438 dep_list[i].flags.mtx =
439 dep_list[i].flags.mtx | dep_list[j].flags.mtx &&
440 !dep_list[i].flags.out;
441 dep_list[j].base_addr = 0;
444 if (dep_list[i].flags.mtx) {
446 if (n_mtxs < MAX_MTX_DEPS && task != NULL) {
449 dep_list[i].flags.in = 1;
450 dep_list[i].flags.out = 1;
451 dep_list[i].flags.mtx = 0;
461 node->dn.npredecessors = -1;
467 npredecessors = __kmp_process_deps<true>(gtid, node, hash, dep_barrier, ndeps,
469 npredecessors += __kmp_process_deps<false>(
470 gtid, node, hash, dep_barrier, ndeps_noalias, noalias_dep_list, task);
472 node->dn.task = task;
482 node->dn.npredecessors.fetch_add(npredecessors) + npredecessors;
484 KA_TRACE(20, (
"__kmp_check_deps: T#%d found %d predecessors for task %p \n",
485 gtid, npredecessors, taskdata));
489 return npredecessors > 0 ? true :
false;
509 kmp_task_t *new_task, kmp_int32 ndeps,
510 kmp_depend_info_t *dep_list,
511 kmp_int32 ndeps_noalias,
512 kmp_depend_info_t *noalias_dep_list) {
514 kmp_taskdata_t *new_taskdata = KMP_TASK_TO_TASKDATA(new_task);
515 KA_TRACE(10, (
"__kmpc_omp_task_with_deps(enter): T#%d loc=%p task=%p\n", gtid,
516 loc_ref, new_taskdata));
518 kmp_info_t *thread = __kmp_threads[gtid];
519 kmp_taskdata_t *current_task = thread->th.th_current_task;
522 if (ompt_enabled.enabled) {
523 OMPT_STORE_RETURN_ADDRESS(gtid);
524 if (!current_task->ompt_task_info.frame.enter_frame.ptr)
525 current_task->ompt_task_info.frame.enter_frame.ptr =
526 OMPT_GET_FRAME_ADDRESS(0);
527 if (ompt_enabled.ompt_callback_task_create) {
528 ompt_data_t task_data = ompt_data_none;
529 ompt_callbacks.ompt_callback(ompt_callback_task_create)(
530 current_task ? &(current_task->ompt_task_info.task_data) : &task_data,
531 current_task ? &(current_task->ompt_task_info.frame) : NULL,
532 &(new_taskdata->ompt_task_info.task_data),
533 ompt_task_explicit | TASK_TYPE_DETAILS_FORMAT(new_taskdata), 1,
534 OMPT_LOAD_RETURN_ADDRESS(gtid));
537 new_taskdata->ompt_task_info.frame.enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);
542 if (ndeps + ndeps_noalias > 0 &&
543 ompt_enabled.ompt_callback_dependences) {
546 int ompt_ndeps = ndeps + ndeps_noalias;
547 ompt_dependence_t *ompt_deps = (ompt_dependence_t *)KMP_OMPT_DEPS_ALLOC(
548 thread, (ndeps + ndeps_noalias) *
sizeof(ompt_dependence_t));
550 KMP_ASSERT(ompt_deps != NULL);
552 for (i = 0; i < ndeps; i++) {
553 ompt_deps[i].variable.ptr = (
void *)dep_list[i].base_addr;
554 if (dep_list[i].flags.in && dep_list[i].flags.out)
555 ompt_deps[i].dependence_type = ompt_dependence_type_inout;
556 else if (dep_list[i].flags.out)
557 ompt_deps[i].dependence_type = ompt_dependence_type_out;
558 else if (dep_list[i].flags.in)
559 ompt_deps[i].dependence_type = ompt_dependence_type_in;
560 else if (dep_list[i].flags.mtx)
561 ompt_deps[i].dependence_type = ompt_dependence_type_mutexinoutset;
563 for (i = 0; i < ndeps_noalias; i++) {
564 ompt_deps[ndeps + i].variable.ptr = (
void *)noalias_dep_list[i].base_addr;
565 if (noalias_dep_list[i].flags.in && noalias_dep_list[i].flags.out)
566 ompt_deps[ndeps + i].dependence_type = ompt_dependence_type_inout;
567 else if (noalias_dep_list[i].flags.out)
568 ompt_deps[ndeps + i].dependence_type = ompt_dependence_type_out;
569 else if (noalias_dep_list[i].flags.in)
570 ompt_deps[ndeps + i].dependence_type = ompt_dependence_type_in;
571 else if (noalias_dep_list[i].flags.mtx)
572 ompt_deps[ndeps + i].dependence_type =
573 ompt_dependence_type_mutexinoutset;
575 ompt_callbacks.ompt_callback(ompt_callback_dependences)(
576 &(new_taskdata->ompt_task_info.task_data), ompt_deps, ompt_ndeps);
579 KMP_OMPT_DEPS_FREE(thread, ompt_deps);
584 bool serial = current_task->td_flags.team_serial ||
585 current_task->td_flags.tasking_ser ||
586 current_task->td_flags.final;
587 kmp_task_team_t *task_team = thread->th.th_task_team;
588 serial = serial && !(task_team && task_team->tt.tt_found_proxy_tasks);
590 if (!serial && (ndeps > 0 || ndeps_noalias > 0)) {
592 if (current_task->td_dephash == NULL)
593 current_task->td_dephash = __kmp_dephash_create(thread, current_task);
596 kmp_depnode_t *node =
597 (kmp_depnode_t *)__kmp_fast_allocate(thread,
sizeof(kmp_depnode_t));
599 kmp_depnode_t *node =
600 (kmp_depnode_t *)__kmp_thread_malloc(thread,
sizeof(kmp_depnode_t));
603 __kmp_init_node(node);
604 new_taskdata->td_depnode = node;
606 if (__kmp_check_deps(gtid, node, new_task, ¤t_task->td_dephash,
607 NO_DEP_BARRIER, ndeps, dep_list, ndeps_noalias,
609 KA_TRACE(10, (
"__kmpc_omp_task_with_deps(exit): T#%d task had blocking "
611 "loc=%p task=%p, return: TASK_CURRENT_NOT_QUEUED\n",
612 gtid, loc_ref, new_taskdata));
614 if (ompt_enabled.enabled) {
615 current_task->ompt_task_info.frame.enter_frame = ompt_data_none;
618 return TASK_CURRENT_NOT_QUEUED;
621 KA_TRACE(10, (
"__kmpc_omp_task_with_deps(exit): T#%d ignored dependencies "
622 "for task (serialized)"
624 gtid, loc_ref, new_taskdata));
627 KA_TRACE(10, (
"__kmpc_omp_task_with_deps(exit): T#%d task had no blocking "
629 "loc=%p task=%p, transferring to __kmp_omp_task\n",
630 gtid, loc_ref, new_taskdata));
632 kmp_int32 ret = __kmp_omp_task(gtid, new_task,
true);
634 if (ompt_enabled.enabled) {
635 current_task->ompt_task_info.frame.enter_frame = ompt_data_none;
642 void __ompt_taskwait_dep_finish(kmp_taskdata_t *current_task,
643 ompt_data_t *taskwait_task_data) {
644 if (ompt_enabled.ompt_callback_task_schedule) {
645 ompt_data_t task_data = ompt_data_none;
646 ompt_callbacks.ompt_callback(ompt_callback_task_schedule)(
647 current_task ? &(current_task->ompt_task_info.task_data) : &task_data,
648 ompt_task_switch, taskwait_task_data);
649 ompt_callbacks.ompt_callback(ompt_callback_task_schedule)(
650 taskwait_task_data, ompt_task_complete,
651 current_task ? &(current_task->ompt_task_info.task_data) : &task_data);
653 current_task->ompt_task_info.frame.enter_frame.ptr = NULL;
654 *taskwait_task_data = ompt_data_none;
670 kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias,
671 kmp_depend_info_t *noalias_dep_list) {
672 KA_TRACE(10, (
"__kmpc_omp_wait_deps(enter): T#%d loc=%p\n", gtid, loc_ref));
674 if (ndeps == 0 && ndeps_noalias == 0) {
675 KA_TRACE(10, (
"__kmpc_omp_wait_deps(exit): T#%d has no dependencies to "
676 "wait upon : loc=%p\n",
681 kmp_info_t *thread = __kmp_threads[gtid];
682 kmp_taskdata_t *current_task = thread->th.th_current_task;
690 ompt_data_t *taskwait_task_data = &thread->th.ompt_thread_info.task_data;
691 KMP_ASSERT(taskwait_task_data->ptr == NULL);
692 if (ompt_enabled.enabled) {
693 if (!current_task->ompt_task_info.frame.enter_frame.ptr)
694 current_task->ompt_task_info.frame.enter_frame.ptr =
695 OMPT_GET_FRAME_ADDRESS(0);
696 if (ompt_enabled.ompt_callback_task_create) {
697 ompt_data_t task_data = ompt_data_none;
698 ompt_callbacks.ompt_callback(ompt_callback_task_create)(
699 current_task ? &(current_task->ompt_task_info.task_data) : &task_data,
700 current_task ? &(current_task->ompt_task_info.frame) : NULL,
702 ompt_task_explicit | ompt_task_undeferred | ompt_task_mergeable, 1,
703 OMPT_GET_RETURN_ADDRESS(0));
709 if (ndeps + ndeps_noalias > 0 && ompt_enabled.ompt_callback_dependences) {
712 int ompt_ndeps = ndeps + ndeps_noalias;
713 ompt_dependence_t *ompt_deps = (ompt_dependence_t *)KMP_OMPT_DEPS_ALLOC(
714 thread, (ndeps + ndeps_noalias) *
sizeof(ompt_dependence_t));
716 KMP_ASSERT(ompt_deps != NULL);
718 for (i = 0; i < ndeps; i++) {
719 ompt_deps[i].variable.ptr = (
void *)dep_list[i].base_addr;
720 if (dep_list[i].flags.in && dep_list[i].flags.out)
721 ompt_deps[i].dependence_type = ompt_dependence_type_inout;
722 else if (dep_list[i].flags.out)
723 ompt_deps[i].dependence_type = ompt_dependence_type_out;
724 else if (dep_list[i].flags.in)
725 ompt_deps[i].dependence_type = ompt_dependence_type_in;
726 else if (dep_list[i].flags.mtx)
727 ompt_deps[ndeps + i].dependence_type =
728 ompt_dependence_type_mutexinoutset;
730 for (i = 0; i < ndeps_noalias; i++) {
731 ompt_deps[ndeps + i].variable.ptr = (
void *)noalias_dep_list[i].base_addr;
732 if (noalias_dep_list[i].flags.in && noalias_dep_list[i].flags.out)
733 ompt_deps[ndeps + i].dependence_type = ompt_dependence_type_inout;
734 else if (noalias_dep_list[i].flags.out)
735 ompt_deps[ndeps + i].dependence_type = ompt_dependence_type_out;
736 else if (noalias_dep_list[i].flags.in)
737 ompt_deps[ndeps + i].dependence_type = ompt_dependence_type_in;
738 else if (noalias_dep_list[i].flags.mtx)
739 ompt_deps[ndeps + i].dependence_type =
740 ompt_dependence_type_mutexinoutset;
742 ompt_callbacks.ompt_callback(ompt_callback_dependences)(
743 taskwait_task_data, ompt_deps, ompt_ndeps);
746 KMP_OMPT_DEPS_FREE(thread, ompt_deps);
755 bool ignore = current_task->td_flags.team_serial ||
756 current_task->td_flags.tasking_ser ||
757 current_task->td_flags.final;
758 ignore = ignore && thread->th.th_task_team != NULL &&
759 thread->th.th_task_team->tt.tt_found_proxy_tasks == FALSE;
760 ignore = ignore || current_task->td_dephash == NULL;
763 KA_TRACE(10, (
"__kmpc_omp_wait_deps(exit): T#%d has no blocking "
764 "dependencies : loc=%p\n",
767 __ompt_taskwait_dep_finish(current_task, taskwait_task_data);
772 kmp_depnode_t node = {0};
773 __kmp_init_node(&node);
775 if (!__kmp_check_deps(gtid, &node, NULL, ¤t_task->td_dephash,
776 DEP_BARRIER, ndeps, dep_list, ndeps_noalias,
778 KA_TRACE(10, (
"__kmpc_omp_wait_deps(exit): T#%d has no blocking "
779 "dependencies : loc=%p\n",
782 __ompt_taskwait_dep_finish(current_task, taskwait_task_data);
787 int thread_finished = FALSE;
788 kmp_flag_32 flag((std::atomic<kmp_uint32> *)&node.dn.npredecessors, 0U);
789 while (node.dn.npredecessors > 0) {
790 flag.execute_tasks(thread, gtid, FALSE,
791 &thread_finished USE_ITT_BUILD_ARG(NULL),
792 __kmp_task_stealing_constraint);
796 __ompt_taskwait_dep_finish(current_task, taskwait_task_data);
798 KA_TRACE(10, (
"__kmpc_omp_wait_deps(exit): T#%d finished waiting : loc=%p\n",
kmp_int32 __kmpc_omp_task_with_deps(ident_t *loc_ref, kmp_int32 gtid, kmp_task_t *new_task, kmp_int32 ndeps, kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list)
void __kmpc_omp_wait_deps(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps, kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list)