1 /* 2 * kmp_taskdeps.cpp 3 */ 4 5 6 //===----------------------------------------------------------------------===// 7 // 8 // The LLVM Compiler Infrastructure 9 // 10 // This file is dual licensed under the MIT and the University of Illinois Open 11 // Source Licenses. See LICENSE.txt for details. 12 // 13 //===----------------------------------------------------------------------===// 14 15 16 //#define KMP_SUPPORT_GRAPH_OUTPUT 1 17 18 #include "kmp.h" 19 #include "kmp_io.h" 20 #include "kmp_wait_release.h" 21 22 #if OMP_40_ENABLED 23 24 // TODO: Improve memory allocation? keep a list of pre-allocated structures? 25 // allocate in blocks? re-use list finished list entries? 26 // TODO: don't use atomic ref counters for stack-allocated nodes. 27 // TODO: find an alternate to atomic refs for heap-allocated nodes? 28 // TODO: Finish graph output support 29 // TODO: kmp_lock_t seems a tad to big (and heavy weight) for this. Check other 30 // runtime locks 31 // TODO: Any ITT support needed? 32 33 #ifdef KMP_SUPPORT_GRAPH_OUTPUT 34 static kmp_int32 kmp_node_id_seed = 0; 35 #endif 36 37 static void __kmp_init_node(kmp_depnode_t *node) { 38 node->dn.task = NULL; // set to null initially, it will point to the right 39 // task once dependences have been processed 40 node->dn.successors = NULL; 41 __kmp_init_lock(&node->dn.lock); 42 node->dn.nrefs = 1; // init creates the first reference to the node 43 #ifdef KMP_SUPPORT_GRAPH_OUTPUT 44 node->dn.id = KMP_TEST_THEN_INC32(&kmp_node_id_seed); 45 #endif 46 } 47 48 static inline kmp_depnode_t *__kmp_node_ref(kmp_depnode_t *node) { 49 KMP_TEST_THEN_INC32(&node->dn.nrefs); 50 return node; 51 } 52 53 static inline void __kmp_node_deref(kmp_info_t *thread, kmp_depnode_t *node) { 54 if (!node) 55 return; 56 57 kmp_int32 n = KMP_TEST_THEN_DEC32(&node->dn.nrefs) - 1; 58 if (n == 0) { 59 KMP_ASSERT(node->dn.nrefs == 0); 60 #if USE_FAST_MEMORY 61 __kmp_fast_free(thread, node); 62 #else 63 __kmp_thread_free(thread, node); 64 #endif 65 } 66 } 67 68 #define KMP_ACQUIRE_DEPNODE(gtid, n) __kmp_acquire_lock(&(n)->dn.lock, (gtid)) 69 #define KMP_RELEASE_DEPNODE(gtid, n) __kmp_release_lock(&(n)->dn.lock, (gtid)) 70 71 static void __kmp_depnode_list_free(kmp_info_t *thread, kmp_depnode_list *list); 72 73 enum { KMP_DEPHASH_OTHER_SIZE = 97, KMP_DEPHASH_MASTER_SIZE = 997 }; 74 75 static inline kmp_int32 __kmp_dephash_hash(kmp_intptr_t addr, size_t hsize) { 76 // TODO alternate to try: set = (((Addr64)(addrUsefulBits * 9.618)) % 77 // m_num_sets ); 78 return ((addr >> 6) ^ (addr >> 2)) % hsize; 79 } 80 81 static kmp_dephash_t *__kmp_dephash_create(kmp_info_t *thread, 82 kmp_taskdata_t *current_task) { 83 kmp_dephash_t *h; 84 85 size_t h_size; 86 87 if (current_task->td_flags.tasktype == TASK_IMPLICIT) 88 h_size = KMP_DEPHASH_MASTER_SIZE; 89 else 90 h_size = KMP_DEPHASH_OTHER_SIZE; 91 92 kmp_int32 size = 93 h_size * sizeof(kmp_dephash_entry_t *) + sizeof(kmp_dephash_t); 94 95 #if USE_FAST_MEMORY 96 h = (kmp_dephash_t *)__kmp_fast_allocate(thread, size); 97 #else 98 h = (kmp_dephash_t *)__kmp_thread_malloc(thread, size); 99 #endif 100 h->size = h_size; 101 102 #ifdef KMP_DEBUG 103 h->nelements = 0; 104 h->nconflicts = 0; 105 #endif 106 h->buckets = (kmp_dephash_entry **)(h + 1); 107 108 for (size_t i = 0; i < h_size; i++) 109 h->buckets[i] = 0; 110 111 return h; 112 } 113 114 void __kmp_dephash_free_entries(kmp_info_t *thread, kmp_dephash_t *h) { 115 for (size_t i = 0; i < h->size; i++) { 116 if (h->buckets[i]) { 117 kmp_dephash_entry_t *next; 118 for (kmp_dephash_entry_t *entry = h->buckets[i]; entry; entry = next) { 119 next = entry->next_in_bucket; 120 __kmp_depnode_list_free(thread, entry->last_ins); 121 __kmp_node_deref(thread, entry->last_out); 122 #if USE_FAST_MEMORY 123 __kmp_fast_free(thread, entry); 124 #else 125 __kmp_thread_free(thread, entry); 126 #endif 127 } 128 h->buckets[i] = 0; 129 } 130 } 131 } 132 133 void __kmp_dephash_free(kmp_info_t *thread, kmp_dephash_t *h) { 134 __kmp_dephash_free_entries(thread, h); 135 #if USE_FAST_MEMORY 136 __kmp_fast_free(thread, h); 137 #else 138 __kmp_thread_free(thread, h); 139 #endif 140 } 141 142 static kmp_dephash_entry * 143 __kmp_dephash_find(kmp_info_t *thread, kmp_dephash_t *h, kmp_intptr_t addr) { 144 kmp_int32 bucket = __kmp_dephash_hash(addr, h->size); 145 146 kmp_dephash_entry_t *entry; 147 for (entry = h->buckets[bucket]; entry; entry = entry->next_in_bucket) 148 if (entry->addr == addr) 149 break; 150 151 if (entry == NULL) { 152 // create entry. This is only done by one thread so no locking required 153 #if USE_FAST_MEMORY 154 entry = (kmp_dephash_entry_t *)__kmp_fast_allocate( 155 thread, sizeof(kmp_dephash_entry_t)); 156 #else 157 entry = (kmp_dephash_entry_t *)__kmp_thread_malloc( 158 thread, sizeof(kmp_dephash_entry_t)); 159 #endif 160 entry->addr = addr; 161 entry->last_out = NULL; 162 entry->last_ins = NULL; 163 entry->next_in_bucket = h->buckets[bucket]; 164 h->buckets[bucket] = entry; 165 #ifdef KMP_DEBUG 166 h->nelements++; 167 if (entry->next_in_bucket) 168 h->nconflicts++; 169 #endif 170 } 171 return entry; 172 } 173 174 static kmp_depnode_list_t *__kmp_add_node(kmp_info_t *thread, 175 kmp_depnode_list_t *list, 176 kmp_depnode_t *node) { 177 kmp_depnode_list_t *new_head; 178 179 #if USE_FAST_MEMORY 180 new_head = (kmp_depnode_list_t *)__kmp_fast_allocate( 181 thread, sizeof(kmp_depnode_list_t)); 182 #else 183 new_head = (kmp_depnode_list_t *)__kmp_thread_malloc( 184 thread, sizeof(kmp_depnode_list_t)); 185 #endif 186 187 new_head->node = __kmp_node_ref(node); 188 new_head->next = list; 189 190 return new_head; 191 } 192 193 static void __kmp_depnode_list_free(kmp_info_t *thread, 194 kmp_depnode_list *list) { 195 kmp_depnode_list *next; 196 197 for (; list; list = next) { 198 next = list->next; 199 200 __kmp_node_deref(thread, list->node); 201 #if USE_FAST_MEMORY 202 __kmp_fast_free(thread, list); 203 #else 204 __kmp_thread_free(thread, list); 205 #endif 206 } 207 } 208 209 static inline void __kmp_track_dependence(kmp_depnode_t *source, 210 kmp_depnode_t *sink, 211 kmp_task_t *sink_task) { 212 #ifdef KMP_SUPPORT_GRAPH_OUTPUT 213 kmp_taskdata_t *task_source = KMP_TASK_TO_TASKDATA(source->dn.task); 214 // do not use sink->dn.task as that is only filled after the dependencies 215 // are already processed! 216 kmp_taskdata_t *task_sink = KMP_TASK_TO_TASKDATA(sink_task); 217 218 __kmp_printf("%d(%s) -> %d(%s)\n", source->dn.id, 219 task_source->td_ident->psource, sink->dn.id, 220 task_sink->td_ident->psource); 221 #endif 222 #if OMPT_SUPPORT && OMPT_TRACE 223 // OMPT tracks dependences between task (a=source, b=sink) in which 224 // task a blocks the execution of b through the ompt_new_dependence_callback 225 if (ompt_enabled && 226 ompt_callbacks.ompt_callback(ompt_event_task_dependence_pair)) { 227 kmp_taskdata_t *task_source = KMP_TASK_TO_TASKDATA(source->dn.task); 228 kmp_taskdata_t *task_sink = KMP_TASK_TO_TASKDATA(sink_task); 229 230 ompt_callbacks.ompt_callback(ompt_event_task_dependence_pair)( 231 task_source->ompt_task_info.task_id, task_sink->ompt_task_info.task_id); 232 } 233 #endif /* OMPT_SUPPORT && OMPT_TRACE */ 234 } 235 236 template <bool filter> 237 static inline kmp_int32 238 __kmp_process_deps(kmp_int32 gtid, kmp_depnode_t *node, kmp_dephash_t *hash, 239 bool dep_barrier, kmp_int32 ndeps, 240 kmp_depend_info_t *dep_list, kmp_task_t *task) { 241 KA_TRACE(30, ("__kmp_process_deps<%d>: T#%d processing %d dependencies : " 242 "dep_barrier = %d\n", 243 filter, gtid, ndeps, dep_barrier)); 244 245 kmp_info_t *thread = __kmp_threads[gtid]; 246 kmp_int32 npredecessors = 0; 247 for (kmp_int32 i = 0; i < ndeps; i++) { 248 const kmp_depend_info_t *dep = &dep_list[i]; 249 250 KMP_DEBUG_ASSERT(dep->flags.in); 251 252 if (filter && dep->base_addr == 0) 253 continue; // skip filtered entries 254 255 kmp_dephash_entry_t *info = 256 __kmp_dephash_find(thread, hash, dep->base_addr); 257 kmp_depnode_t *last_out = info->last_out; 258 259 if (dep->flags.out && info->last_ins) { 260 for (kmp_depnode_list_t *p = info->last_ins; p; p = p->next) { 261 kmp_depnode_t *indep = p->node; 262 if (indep->dn.task) { 263 KMP_ACQUIRE_DEPNODE(gtid, indep); 264 if (indep->dn.task) { 265 __kmp_track_dependence(indep, node, task); 266 indep->dn.successors = 267 __kmp_add_node(thread, indep->dn.successors, node); 268 KA_TRACE(40, ("__kmp_process_deps<%d>: T#%d adding dependence from " 269 "%p to %p\n", 270 filter, gtid, KMP_TASK_TO_TASKDATA(indep->dn.task), 271 KMP_TASK_TO_TASKDATA(task))); 272 npredecessors++; 273 } 274 KMP_RELEASE_DEPNODE(gtid, indep); 275 } 276 } 277 278 __kmp_depnode_list_free(thread, info->last_ins); 279 info->last_ins = NULL; 280 281 } else if (last_out && last_out->dn.task) { 282 KMP_ACQUIRE_DEPNODE(gtid, last_out); 283 if (last_out->dn.task) { 284 __kmp_track_dependence(last_out, node, task); 285 last_out->dn.successors = 286 __kmp_add_node(thread, last_out->dn.successors, node); 287 KA_TRACE( 288 40, 289 ("__kmp_process_deps<%d>: T#%d adding dependence from %p to %p\n", 290 filter, gtid, KMP_TASK_TO_TASKDATA(last_out->dn.task), 291 KMP_TASK_TO_TASKDATA(task))); 292 293 npredecessors++; 294 } 295 KMP_RELEASE_DEPNODE(gtid, last_out); 296 } 297 298 if (dep_barrier) { 299 // if this is a sync point in the serial sequence, then the previous 300 // outputs are guaranteed to be completed after 301 // the execution of this task so the previous output nodes can be cleared. 302 __kmp_node_deref(thread, last_out); 303 info->last_out = NULL; 304 } else { 305 if (dep->flags.out) { 306 __kmp_node_deref(thread, last_out); 307 info->last_out = __kmp_node_ref(node); 308 } else 309 info->last_ins = __kmp_add_node(thread, info->last_ins, node); 310 } 311 } 312 313 KA_TRACE(30, ("__kmp_process_deps<%d>: T#%d found %d predecessors\n", filter, 314 gtid, npredecessors)); 315 316 return npredecessors; 317 } 318 319 #define NO_DEP_BARRIER (false) 320 #define DEP_BARRIER (true) 321 322 // returns true if the task has any outstanding dependence 323 static bool __kmp_check_deps(kmp_int32 gtid, kmp_depnode_t *node, 324 kmp_task_t *task, kmp_dephash_t *hash, 325 bool dep_barrier, kmp_int32 ndeps, 326 kmp_depend_info_t *dep_list, 327 kmp_int32 ndeps_noalias, 328 kmp_depend_info_t *noalias_dep_list) { 329 int i; 330 331 #if KMP_DEBUG 332 kmp_taskdata_t *taskdata = KMP_TASK_TO_TASKDATA(task); 333 #endif 334 KA_TRACE(20, ("__kmp_check_deps: T#%d checking dependencies for task %p : %d " 335 "possibly aliased dependencies, %d non-aliased depedencies : " 336 "dep_barrier=%d .\n", 337 gtid, taskdata, ndeps, ndeps_noalias, dep_barrier)); 338 339 // Filter deps in dep_list 340 // TODO: Different algorithm for large dep_list ( > 10 ? ) 341 for (i = 0; i < ndeps; i++) { 342 if (dep_list[i].base_addr != 0) 343 for (int j = i + 1; j < ndeps; j++) 344 if (dep_list[i].base_addr == dep_list[j].base_addr) { 345 dep_list[i].flags.in |= dep_list[j].flags.in; 346 dep_list[i].flags.out |= dep_list[j].flags.out; 347 dep_list[j].base_addr = 0; // Mark j element as void 348 } 349 } 350 351 // doesn't need to be atomic as no other thread is going to be accessing this 352 // node just yet. 353 // npredecessors is set -1 to ensure that none of the releasing tasks queues 354 // this task before we have finished processing all the dependencies 355 node->dn.npredecessors = -1; 356 357 // used to pack all npredecessors additions into a single atomic operation at 358 // the end 359 int npredecessors; 360 361 npredecessors = __kmp_process_deps<true>(gtid, node, hash, dep_barrier, ndeps, 362 dep_list, task); 363 npredecessors += __kmp_process_deps<false>( 364 gtid, node, hash, dep_barrier, ndeps_noalias, noalias_dep_list, task); 365 366 node->dn.task = task; 367 KMP_MB(); 368 369 // Account for our initial fake value 370 npredecessors++; 371 372 // Update predecessors and obtain current value to check if there are still 373 // any outstandig dependences (some tasks may have finished while we processed 374 // the dependences) 375 npredecessors = KMP_TEST_THEN_ADD32(&node->dn.npredecessors, npredecessors) + 376 npredecessors; 377 378 KA_TRACE(20, ("__kmp_check_deps: T#%d found %d predecessors for task %p \n", 379 gtid, npredecessors, taskdata)); 380 381 // beyond this point the task could be queued (and executed) by a releasing 382 // task... 383 return npredecessors > 0 ? true : false; 384 } 385 386 void __kmp_release_deps(kmp_int32 gtid, kmp_taskdata_t *task) { 387 kmp_info_t *thread = __kmp_threads[gtid]; 388 kmp_depnode_t *node = task->td_depnode; 389 390 if (task->td_dephash) { 391 KA_TRACE( 392 40, ("__kmp_release_deps: T#%d freeing dependencies hash of task %p.\n", 393 gtid, task)); 394 __kmp_dephash_free(thread, task->td_dephash); 395 task->td_dephash = NULL; 396 } 397 398 if (!node) 399 return; 400 401 KA_TRACE(20, ("__kmp_release_deps: T#%d notifying successors of task %p.\n", 402 gtid, task)); 403 404 KMP_ACQUIRE_DEPNODE(gtid, node); 405 node->dn.task = 406 NULL; // mark this task as finished, so no new dependencies are generated 407 KMP_RELEASE_DEPNODE(gtid, node); 408 409 kmp_depnode_list_t *next; 410 for (kmp_depnode_list_t *p = node->dn.successors; p; p = next) { 411 kmp_depnode_t *successor = p->node; 412 kmp_int32 npredecessors = 413 KMP_TEST_THEN_DEC32(&successor->dn.npredecessors) - 1; 414 415 // successor task can be NULL for wait_depends or because deps are still 416 // being processed 417 if (npredecessors == 0) { 418 KMP_MB(); 419 if (successor->dn.task) { 420 KA_TRACE(20, ("__kmp_release_deps: T#%d successor %p of %p scheduled " 421 "for execution.\n", 422 gtid, successor->dn.task, task)); 423 __kmp_omp_task(gtid, successor->dn.task, false); 424 } 425 } 426 427 next = p->next; 428 __kmp_node_deref(thread, p->node); 429 #if USE_FAST_MEMORY 430 __kmp_fast_free(thread, p); 431 #else 432 __kmp_thread_free(thread, p); 433 #endif 434 } 435 436 __kmp_node_deref(thread, node); 437 438 KA_TRACE( 439 20, 440 ("__kmp_release_deps: T#%d all successors of %p notified of completion\n", 441 gtid, task)); 442 } 443 444 /*! 445 @ingroup TASKING 446 @param loc_ref location of the original task directive 447 @param gtid Global Thread ID of encountering thread 448 @param new_task task thunk allocated by __kmp_omp_task_alloc() for the ''new 449 task'' 450 @param ndeps Number of depend items with possible aliasing 451 @param dep_list List of depend items with possible aliasing 452 @param ndeps_noalias Number of depend items with no aliasing 453 @param noalias_dep_list List of depend items with no aliasing 454 455 @return Returns either TASK_CURRENT_NOT_QUEUED if the current task was not 456 suspendend and queued, or TASK_CURRENT_QUEUED if it was suspended and queued 457 458 Schedule a non-thread-switchable task with dependences for execution 459 */ 460 kmp_int32 __kmpc_omp_task_with_deps(ident_t *loc_ref, kmp_int32 gtid, 461 kmp_task_t *new_task, kmp_int32 ndeps, 462 kmp_depend_info_t *dep_list, 463 kmp_int32 ndeps_noalias, 464 kmp_depend_info_t *noalias_dep_list) { 465 466 kmp_taskdata_t *new_taskdata = KMP_TASK_TO_TASKDATA(new_task); 467 KA_TRACE(10, ("__kmpc_omp_task_with_deps(enter): T#%d loc=%p task=%p\n", gtid, 468 loc_ref, new_taskdata)); 469 470 kmp_info_t *thread = __kmp_threads[gtid]; 471 kmp_taskdata_t *current_task = thread->th.th_current_task; 472 473 #if OMPT_SUPPORT && OMPT_TRACE 474 /* OMPT grab all dependences if requested by the tool */ 475 if (ompt_enabled && ndeps + ndeps_noalias > 0 && 476 ompt_callbacks.ompt_callback(ompt_event_task_dependences)) { 477 kmp_int32 i; 478 479 new_taskdata->ompt_task_info.ndeps = ndeps + ndeps_noalias; 480 new_taskdata->ompt_task_info.deps = 481 (ompt_task_dependence_t *)KMP_OMPT_DEPS_ALLOC( 482 thread, (ndeps + ndeps_noalias) * sizeof(ompt_task_dependence_t)); 483 484 KMP_ASSERT(new_taskdata->ompt_task_info.deps != NULL); 485 486 for (i = 0; i < ndeps; i++) { 487 new_taskdata->ompt_task_info.deps[i].variable_addr = 488 (void *)dep_list[i].base_addr; 489 if (dep_list[i].flags.in && dep_list[i].flags.out) 490 new_taskdata->ompt_task_info.deps[i].dependence_flags = 491 ompt_task_dependence_type_inout; 492 else if (dep_list[i].flags.out) 493 new_taskdata->ompt_task_info.deps[i].dependence_flags = 494 ompt_task_dependence_type_out; 495 else if (dep_list[i].flags.in) 496 new_taskdata->ompt_task_info.deps[i].dependence_flags = 497 ompt_task_dependence_type_in; 498 } 499 for (i = 0; i < ndeps_noalias; i++) { 500 new_taskdata->ompt_task_info.deps[ndeps + i].variable_addr = 501 (void *)noalias_dep_list[i].base_addr; 502 if (noalias_dep_list[i].flags.in && noalias_dep_list[i].flags.out) 503 new_taskdata->ompt_task_info.deps[ndeps + i].dependence_flags = 504 ompt_task_dependence_type_inout; 505 else if (noalias_dep_list[i].flags.out) 506 new_taskdata->ompt_task_info.deps[ndeps + i].dependence_flags = 507 ompt_task_dependence_type_out; 508 else if (noalias_dep_list[i].flags.in) 509 new_taskdata->ompt_task_info.deps[ndeps + i].dependence_flags = 510 ompt_task_dependence_type_in; 511 } 512 } 513 #endif /* OMPT_SUPPORT && OMPT_TRACE */ 514 515 bool serial = current_task->td_flags.team_serial || 516 current_task->td_flags.tasking_ser || 517 current_task->td_flags.final; 518 #if OMP_45_ENABLED 519 kmp_task_team_t *task_team = thread->th.th_task_team; 520 serial = serial && !(task_team && task_team->tt.tt_found_proxy_tasks); 521 #endif 522 523 if (!serial && (ndeps > 0 || ndeps_noalias > 0)) { 524 /* if no dependencies have been tracked yet, create the dependence hash */ 525 if (current_task->td_dephash == NULL) 526 current_task->td_dephash = __kmp_dephash_create(thread, current_task); 527 528 #if USE_FAST_MEMORY 529 kmp_depnode_t *node = 530 (kmp_depnode_t *)__kmp_fast_allocate(thread, sizeof(kmp_depnode_t)); 531 #else 532 kmp_depnode_t *node = 533 (kmp_depnode_t *)__kmp_thread_malloc(thread, sizeof(kmp_depnode_t)); 534 #endif 535 536 __kmp_init_node(node); 537 new_taskdata->td_depnode = node; 538 539 if (__kmp_check_deps(gtid, node, new_task, current_task->td_dephash, 540 NO_DEP_BARRIER, ndeps, dep_list, ndeps_noalias, 541 noalias_dep_list)) { 542 KA_TRACE(10, ("__kmpc_omp_task_with_deps(exit): T#%d task had blocking " 543 "dependencies: " 544 "loc=%p task=%p, return: TASK_CURRENT_NOT_QUEUED\n", 545 gtid, loc_ref, new_taskdata)); 546 return TASK_CURRENT_NOT_QUEUED; 547 } 548 } else { 549 KA_TRACE(10, ("__kmpc_omp_task_with_deps(exit): T#%d ignored dependencies " 550 "for task (serialized)" 551 "loc=%p task=%p\n", 552 gtid, loc_ref, new_taskdata)); 553 } 554 555 KA_TRACE(10, ("__kmpc_omp_task_with_deps(exit): T#%d task had no blocking " 556 "dependencies : " 557 "loc=%p task=%p, transferring to __kmpc_omp_task\n", 558 gtid, loc_ref, new_taskdata)); 559 560 return __kmpc_omp_task(loc_ref, gtid, new_task); 561 } 562 563 /*! 564 @ingroup TASKING 565 @param loc_ref location of the original task directive 566 @param gtid Global Thread ID of encountering thread 567 @param ndeps Number of depend items with possible aliasing 568 @param dep_list List of depend items with possible aliasing 569 @param ndeps_noalias Number of depend items with no aliasing 570 @param noalias_dep_list List of depend items with no aliasing 571 572 Blocks the current task until all specifies dependencies have been fulfilled. 573 */ 574 void __kmpc_omp_wait_deps(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps, 575 kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias, 576 kmp_depend_info_t *noalias_dep_list) { 577 KA_TRACE(10, ("__kmpc_omp_wait_deps(enter): T#%d loc=%p\n", gtid, loc_ref)); 578 579 if (ndeps == 0 && ndeps_noalias == 0) { 580 KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no dependencies to " 581 "wait upon : loc=%p\n", 582 gtid, loc_ref)); 583 return; 584 } 585 586 kmp_info_t *thread = __kmp_threads[gtid]; 587 kmp_taskdata_t *current_task = thread->th.th_current_task; 588 589 // We can return immediately as: 590 // - dependences are not computed in serial teams (except with proxy tasks) 591 // - if the dephash is not yet created it means we have nothing to wait for 592 bool ignore = current_task->td_flags.team_serial || 593 current_task->td_flags.tasking_ser || 594 current_task->td_flags.final; 595 #if OMP_45_ENABLED 596 ignore = ignore && thread->th.th_task_team != NULL && 597 thread->th.th_task_team->tt.tt_found_proxy_tasks == FALSE; 598 #endif 599 ignore = ignore || current_task->td_dephash == NULL; 600 601 if (ignore) { 602 KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no blocking " 603 "dependencies : loc=%p\n", 604 gtid, loc_ref)); 605 return; 606 } 607 608 kmp_depnode_t node; 609 __kmp_init_node(&node); 610 611 if (!__kmp_check_deps(gtid, &node, NULL, current_task->td_dephash, 612 DEP_BARRIER, ndeps, dep_list, ndeps_noalias, 613 noalias_dep_list)) { 614 KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no blocking " 615 "dependencies : loc=%p\n", 616 gtid, loc_ref)); 617 return; 618 } 619 620 int thread_finished = FALSE; 621 kmp_flag_32 flag((volatile kmp_uint32 *)&(node.dn.npredecessors), 0U); 622 while (node.dn.npredecessors > 0) { 623 flag.execute_tasks(thread, gtid, FALSE, &thread_finished, 624 #if USE_ITT_BUILD 625 NULL, 626 #endif 627 __kmp_task_stealing_constraint); 628 } 629 630 KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d finished waiting : loc=%p\n", 631 gtid, loc_ref)); 632 } 633 634 #endif /* OMP_40_ENABLED */ 635