Page MenuHomePhabricator

[OPENMP] Codegen for 'firstprivate' clause in 'task' directive.

Authored by ABataev on Apr 30 2015, 6:05 AM.



For tasks codegen for private/firstprivate variables are different rather than for other directives.

  1. Build an internal structure of privates for each private variable:
struct .kmp_privates_t. {
  Ty1 var1;
  Tyn varn;
  1. Add a new field to kmp_task_t type with list of privates.
struct kmp_task_t {
void *              shareds;
kmp_routine_entry_t routine;
kmp_int32           part_id;
kmp_routine_entry_t destructors;
.kmp_privates_t.    privates;
  1. Create a function with destructors calls for all privates after end of task region.
kmp_int32 .omp_task_destructor.(kmp_int32 gtid, kmp_task_t *tt) {
  return 0;
  1. Perform initialization of all firstprivate fields (by simple copying for POD data, copy constructor calls for classes) + provide address of a destructor function after kmpc_omp_task_alloc() and before kmpc_omp_task() calls.
kmp_task_t *new_task = __kmpc_omp_task_alloc(ident_t *, kmp_int32 gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds, kmp_routine_entry_t *task_entry);

CopyConstructor(new_task->privates.var1, *new_task->shareds.var1_ref);
new_task->shareds.var1_ref = &new_task->privates.var1;
CopyConstructor(new_task->privates.varn, *new_task->shareds.varn_ref);
new_task->shareds.varn_ref = &new_task->privates.varn;

new_task->destructors = .omp_task_destructor.;
kmp_int32 __kmpc_omp_task(ident_t *, kmp_int32 gtid, kmp_task_t *new_task)

Diff Detail


Event Timeline

ABataev updated this revision to Diff 24699.Apr 30 2015, 6:05 AM
ABataev retitled this revision from to [OPENMP] Codegen for 'firstprivate' clause in 'task' directive..
ABataev updated this object.
ABataev edited the test plan for this revision. (Show Details)
ABataev added reviewers: rjmccall, hfinkel.
ABataev added subscribers: fraggamuffin, ejstotzer, Unknown Object (MLST).
emaste added a subscriber: emaste.Apr 30 2015, 8:49 AM
This revision was automatically updated to reflect the committed changes.