-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[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" { | ||
|
Uh oh!
There was an error while loading. Please reload this page.