This is an archive of the discontinued LLVM Phabricator instance.

[OPENMP]Add support for allocate vars in untied tasks.
ClosedPublic

Authored by ABataev on Aug 25 2020, 10:47 AM.

Details

Summary

Local vars, marked with pragma allocate, mustbe allocate by the call of
the runtime function and cannot be allocated as other local variables.
Instead, we allocate a space for the pointer in private record and store
the address, returned by kmpc_alloc call in this pointer.
So, for untied tasks

#pragma omp task untied
{
  S s;
   #pragma omp allocate(s) allocator(allocator)
  s = x;
}

compiler generates something like this:

struct task_with_privates {
  S *ptr;
};

void entry(task_with_privates *p) {
  S *s = p->s;
  switch(partid) {
  case 1:
    p->s = (S*)kmpc_alloc();
    kmpc_omp_task();
    br exit;
  case 2:
    *s = x;
    kmpc_omp_task();
    br exit;
  case 2:
    ~S(s);
    kmpc_free((void*)s);
    br exit;
  }
exit:
}

Diff Detail

Event Timeline

ABataev created this revision.Aug 25 2020, 10:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2020, 10:47 AM
ABataev requested review of this revision.Aug 25 2020, 10:47 AM
This revision is now accepted and ready to land.Sep 9 2020, 8:15 AM
This revision was automatically updated to reflect the committed changes.