-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[OpenMP][Offload] Add offload runtime support for dyn_groupprivate clause #152831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: users/kevinsala/omp-dyn-groupprivate-codegen-pr
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,6 +158,35 @@ void SharedMemorySmartStackTy::pop(void *Ptr, uint64_t Bytes) { | |
memory::freeGlobal(Ptr, "Slow path shared memory deallocation"); | ||
} | ||
|
||
struct DynCGroupMemTy { | ||
void init(KernelLaunchEnvironmentTy *KLE, void *NativeDynCGroup) { | ||
Size = 0; | ||
Ptr = nullptr; | ||
IsFallback = false; | ||
Comment on lines
+163
to
+165
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move to field initializers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the |
||
if (!KLE) | ||
return; | ||
|
||
Size = KLE->DynCGroupMemSize; | ||
if (void *Fallback = KLE->DynCGroupMemFallback) { | ||
Ptr = static_cast<char *>(Fallback) + Size * omp_get_team_num(); | ||
IsFallback = true; | ||
} else { | ||
Ptr = static_cast<char *>(NativeDynCGroup); | ||
} | ||
} | ||
|
||
char *getPtr(size_t Offset) const { return Ptr + Offset; } | ||
bool isFallback() const { return IsFallback; } | ||
size_t getSize() const { return Size; } | ||
|
||
private: | ||
char *Ptr; | ||
size_t Size; | ||
bool IsFallback; | ||
}; | ||
|
||
[[clang::loader_uninitialized]] static Local<DynCGroupMemTy> DynCGroupMem; | ||
|
||
} // namespace | ||
|
||
void *memory::getDynamicBuffer() { return DynamicSharedBuffer; } | ||
|
@@ -246,13 +275,18 @@ int returnValIfLevelIsActive(int Level, int Val, int DefaultVal, | |
} // namespace | ||
|
||
void state::init(bool IsSPMD, KernelEnvironmentTy &KernelEnvironment, | ||
KernelLaunchEnvironmentTy &KernelLaunchEnvironment) { | ||
KernelLaunchEnvironmentTy *KLE) { | ||
SharedMemorySmartStack.init(IsSPMD); | ||
|
||
if (KLE == reinterpret_cast<KernelLaunchEnvironmentTy *>(~0)) | ||
KLE = nullptr; | ||
|
||
if (mapping::isInitialThreadInLevel0(IsSPMD)) { | ||
DynCGroupMem.init(KLE, DynamicSharedBuffer); | ||
TeamState.init(IsSPMD); | ||
ThreadStates = nullptr; | ||
KernelEnvironmentPtr = &KernelEnvironment; | ||
KernelLaunchEnvironmentPtr = &KernelLaunchEnvironment; | ||
KernelLaunchEnvironmentPtr = KLE; | ||
} | ||
} | ||
|
||
|
@@ -430,6 +464,17 @@ int omp_get_team_num() { return mapping::getBlockIdInKernel(); } | |
int omp_get_initial_device(void) { return -1; } | ||
|
||
int omp_is_initial_device(void) { return 0; } | ||
|
||
void *omp_get_dyn_groupprivate_ptr(size_t Offset, int *IsFallback, | ||
omp_access_t) { | ||
if (IsFallback != nullptr) | ||
*IsFallback = DynCGroupMem.isFallback(); | ||
return DynCGroupMem.getPtr(Offset); | ||
} | ||
|
||
size_t omp_get_dyn_groupprivate_size(omp_access_t) { | ||
return DynCGroupMem.getSize(); | ||
} | ||
} | ||
|
||
extern "C" { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,7 +107,7 @@ enum TargetAllocTy : int32_t { | |
|
||
inline KernelArgsTy CTorDTorKernelArgs = {1, 0, nullptr, nullptr, | ||
nullptr, nullptr, nullptr, nullptr, | ||
0, {0,0,0}, {1, 0, 0}, {1, 0, 0}, 0}; | ||
0, {0,0,0,0}, {1, 0, 0}, {1, 0, 0}, 0}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would make sense to add comments to what these fields mean. Line 110 is full of magic constants. |
||
|
||
struct DeviceTy; | ||
|
||
|
@@ -273,10 +273,22 @@ struct __tgt_target_non_contig { | |
extern "C" { | ||
#endif | ||
|
||
/// The OpenMP access group type. The criterion for grupping tasks using a | ||
/// specific grouping property. | ||
enum omp_access_t { | ||
/// Groups the tasks based on the contention group to which they belong. | ||
omp_access_cgroup = 0, | ||
/// Groups the tasks based on the parallel region to which they bind. | ||
omp_access_pteam = 1, | ||
}; | ||
|
||
void ompx_dump_mapping_tables(void); | ||
int omp_get_num_devices(void); | ||
int omp_get_device_num(void); | ||
int omp_get_initial_device(void); | ||
size_t | ||
omp_get_groupprivate_limit(int device_num, | ||
omp_access_t access_group = omp_access_cgroup); | ||
void *omp_target_alloc(size_t Size, int DeviceNum); | ||
void omp_target_free(void *DevicePtr, int DeviceNum); | ||
int omp_target_is_present(const void *Ptr, int DeviceNum); | ||
|
Uh oh!
There was an error while loading. Please reload this page.