Changeset View
Changeset View
Standalone View
Standalone View
openmp/libomptarget/DeviceRTL/src/Tasking.cpp
Show All 20 Lines | |||||
using namespace _OMP; | using namespace _OMP; | ||||
#pragma omp declare target | #pragma omp declare target | ||||
TaskDescriptorTy *__kmpc_omp_task_alloc(IdentTy *, uint32_t, int32_t, | TaskDescriptorTy *__kmpc_omp_task_alloc(IdentTy *, uint32_t, int32_t, | ||||
uint64_t TaskSizeInclPrivateValues, | uint64_t TaskSizeInclPrivateValues, | ||||
uint64_t SharedValuesSize, | uint64_t SharedValuesSize, | ||||
TaskFnTy TaskFn) { | TaskFnTy TaskFn) { | ||||
FunctionTracingRAII(); | |||||
auto TaskSizeInclPrivateValuesPadded = | auto TaskSizeInclPrivateValuesPadded = | ||||
utils::roundUp(TaskSizeInclPrivateValues, uint64_t(sizeof(void *))); | utils::roundUp(TaskSizeInclPrivateValues, uint64_t(sizeof(void *))); | ||||
auto TaskSizeTotal = TaskSizeInclPrivateValuesPadded + SharedValuesSize; | auto TaskSizeTotal = TaskSizeInclPrivateValuesPadded + SharedValuesSize; | ||||
TaskDescriptorTy *TaskDescriptor = (TaskDescriptorTy *)memory::allocGlobal( | TaskDescriptorTy *TaskDescriptor = (TaskDescriptorTy *)memory::allocGlobal( | ||||
TaskSizeTotal, "explicit task descriptor"); | TaskSizeTotal, "explicit task descriptor"); | ||||
TaskDescriptor->Payload = | TaskDescriptor->Payload = | ||||
utils::advance(TaskDescriptor, TaskSizeInclPrivateValuesPadded); | utils::advance(TaskDescriptor, TaskSizeInclPrivateValuesPadded); | ||||
TaskDescriptor->TaskFn = TaskFn; | TaskDescriptor->TaskFn = TaskFn; | ||||
return TaskDescriptor; | return TaskDescriptor; | ||||
} | } | ||||
int32_t __kmpc_omp_task(IdentTy *Loc, uint32_t TId, | int32_t __kmpc_omp_task(IdentTy *Loc, uint32_t TId, | ||||
TaskDescriptorTy *TaskDescriptor) { | TaskDescriptorTy *TaskDescriptor) { | ||||
FunctionTracingRAII(); | |||||
return __kmpc_omp_task_with_deps(Loc, TId, TaskDescriptor, 0, 0, 0, 0); | return __kmpc_omp_task_with_deps(Loc, TId, TaskDescriptor, 0, 0, 0, 0); | ||||
} | } | ||||
int32_t __kmpc_omp_task_with_deps(IdentTy *Loc, uint32_t TId, | int32_t __kmpc_omp_task_with_deps(IdentTy *Loc, uint32_t TId, | ||||
TaskDescriptorTy *TaskDescriptor, int32_t, | TaskDescriptorTy *TaskDescriptor, int32_t, | ||||
void *, int32_t, void *) { | void *, int32_t, void *) { | ||||
FunctionTracingRAII(); | |||||
state::DateEnvironmentRAII DERAII; | state::DateEnvironmentRAII DERAII; | ||||
TaskDescriptor->TaskFn(0, TaskDescriptor); | TaskDescriptor->TaskFn(0, TaskDescriptor); | ||||
memory::freeGlobal(TaskDescriptor, "explicit task descriptor"); | memory::freeGlobal(TaskDescriptor, "explicit task descriptor"); | ||||
return 0; | return 0; | ||||
} | } | ||||
void __kmpc_omp_task_begin_if0(IdentTy *Loc, uint32_t TId, | void __kmpc_omp_task_begin_if0(IdentTy *Loc, uint32_t TId, | ||||
TaskDescriptorTy *TaskDescriptor) { | TaskDescriptorTy *TaskDescriptor) { | ||||
FunctionTracingRAII(); | |||||
state::enterDataEnvironment(); | state::enterDataEnvironment(); | ||||
} | } | ||||
void __kmpc_omp_task_complete_if0(IdentTy *Loc, uint32_t TId, | void __kmpc_omp_task_complete_if0(IdentTy *Loc, uint32_t TId, | ||||
TaskDescriptorTy *TaskDescriptor) { | TaskDescriptorTy *TaskDescriptor) { | ||||
FunctionTracingRAII(); | |||||
state::exitDataEnvironment(); | state::exitDataEnvironment(); | ||||
memory::freeGlobal(TaskDescriptor, "explicit task descriptor"); | memory::freeGlobal(TaskDescriptor, "explicit task descriptor"); | ||||
} | } | ||||
void __kmpc_omp_wait_deps(IdentTy *Loc, uint32_t TId, int32_t, void *, int32_t, | void __kmpc_omp_wait_deps(IdentTy *Loc, uint32_t TId, int32_t, void *, int32_t, | ||||
void *) {} | void *) { | ||||
FunctionTracingRAII(); | |||||
} | |||||
void __kmpc_taskgroup(IdentTy *Loc, uint32_t TId) {} | void __kmpc_taskgroup(IdentTy *Loc, uint32_t TId) { FunctionTracingRAII(); } | ||||
void __kmpc_end_taskgroup(IdentTy *Loc, uint32_t TId) {} | void __kmpc_end_taskgroup(IdentTy *Loc, uint32_t TId) { FunctionTracingRAII(); } | ||||
int32_t __kmpc_omp_taskyield(IdentTy *Loc, uint32_t TId, int) { return 0; } | int32_t __kmpc_omp_taskyield(IdentTy *Loc, uint32_t TId, int) { | ||||
FunctionTracingRAII(); | |||||
return 0; | |||||
} | |||||
int32_t __kmpc_omp_taskwait(IdentTy *Loc, uint32_t TId) { return 0; } | int32_t __kmpc_omp_taskwait(IdentTy *Loc, uint32_t TId) { | ||||
FunctionTracingRAII(); | |||||
return 0; | |||||
} | |||||
void __kmpc_taskloop(IdentTy *Loc, uint32_t TId, | void __kmpc_taskloop(IdentTy *Loc, uint32_t TId, | ||||
TaskDescriptorTy *TaskDescriptor, int, | TaskDescriptorTy *TaskDescriptor, int, | ||||
uint64_t *LowerBound, uint64_t *UpperBound, int64_t, int, | uint64_t *LowerBound, uint64_t *UpperBound, int64_t, int, | ||||
int32_t, uint64_t, void *) { | int32_t, uint64_t, void *) { | ||||
FunctionTracingRAII(); | |||||
// Skip task entirely if empty iteration space. | // Skip task entirely if empty iteration space. | ||||
if (*LowerBound > *UpperBound) | if (*LowerBound > *UpperBound) | ||||
return; | return; | ||||
// The compiler has already stored lb and ub in the TaskDescriptorTy structure | // The compiler has already stored lb and ub in the TaskDescriptorTy structure | ||||
// as we are using a single task to execute the entire loop, we can leave | // as we are using a single task to execute the entire loop, we can leave | ||||
// the initial task_t untouched | // the initial task_t untouched | ||||
__kmpc_omp_task_with_deps(Loc, TId, TaskDescriptor, 0, 0, 0, 0); | __kmpc_omp_task_with_deps(Loc, TId, TaskDescriptor, 0, 0, 0, 0); | ||||
Show All 13 Lines |