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