Skip to content

Commit 20a96c6

Browse files
committed
Add fixes
1 parent fa3c742 commit 20a96c6

File tree

6 files changed

+33
-14
lines changed

6 files changed

+33
-14
lines changed

offload/DeviceRTL/include/DeviceTypes.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,13 @@ typedef enum omp_allocator_handle_t {
163163

164164
///}
165165

166+
/// The OpenMP access group type. The criterion for grupping tasks using a
167+
/// specific grouping property.
166168
enum omp_access_t {
169+
/// Groups the tasks based on the contention group to which they belong.
167170
omp_access_cgroup = 0,
171+
/// Groups the tasks based on the parallel region to which they bind.
172+
omp_access_pteam = 1,
168173
};
169174

170175
#endif

offload/DeviceRTL/src/State.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,15 @@ struct DynCGroupMemTy {
163163
Size = 0;
164164
Ptr = nullptr;
165165
IsFallback = false;
166-
if (KLE) {
167-
Size = KLE->DynCGroupMemSize;
168-
if (void *Fallback = KLE->DynCGroupMemFallback) {
169-
Ptr = static_cast<char *>(Fallback) + Size * omp_get_team_num();
170-
IsFallback = true;
171-
} else {
172-
Ptr = static_cast<char *>(NativeDynCGroup);
173-
}
166+
if (!KLE)
167+
return;
168+
169+
Size = KLE->DynCGroupMemSize;
170+
if (void *Fallback = KLE->DynCGroupMemFallback) {
171+
Ptr = static_cast<char *>(Fallback) + Size * omp_get_team_num();
172+
IsFallback = true;
173+
} else {
174+
Ptr = static_cast<char *>(NativeDynCGroup);
174175
}
175176
}
176177

@@ -466,7 +467,7 @@ int omp_is_initial_device(void) { return 0; }
466467

467468
void *omp_get_dyn_groupprivate_ptr(size_t Offset, int *IsFallback,
468469
omp_access_t) {
469-
if (IsFallback != NULL)
470+
if (IsFallback != nullptr)
470471
*IsFallback = DynCGroupMem.isFallback();
471472
return DynCGroupMem.getPtr(Offset);
472473
}

offload/include/omptarget.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,22 @@ struct __tgt_target_non_contig {
273273
extern "C" {
274274
#endif
275275

276-
typedef enum {
277-
omp_access_cgroup = 0,
278-
} omp_access_t;
276+
/// The OpenMP access group type. The criterion for grupping tasks using a
277+
/// specific grouping property.
278+
enum omp_access_t {
279+
/// Groups the tasks based on the contention group to which they belong.
280+
omp_access_cgroup = 0,
281+
/// Groups the tasks based on the parallel region to which they bind.
282+
omp_access_pteam = 1,
283+
};
279284

280285
void ompx_dump_mapping_tables(void);
281286
int omp_get_num_devices(void);
282287
int omp_get_device_num(void);
283288
int omp_get_initial_device(void);
284-
size_t omp_get_groupprivate_limit(int device_num, omp_access_t access_group = omp_access_cgroup);
289+
size_t
290+
omp_get_groupprivate_limit(int device_num,
291+
omp_access_t access_group = omp_access_cgroup);
285292
void *omp_target_alloc(size_t Size, int DeviceNum);
286293
void omp_target_free(void *DevicePtr, int DeviceNum);
287294
int omp_target_is_present(const void *Ptr, int DeviceNum);

offload/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,6 +3441,9 @@ Error AMDGPUKernelTy::launchImpl(GenericDeviceTy &GenericDevice,
34413441
KernelArgs.DynCGroupMem);
34423442
}
34433443

3444+
// Increase to the requested dynamic memory size for the device if needed.
3445+
DynBlockMemSize = std::max(DynBlockMemSize, GenericDevice.getDynamicMemorySize());
3446+
34443447
// Push the kernel launch into the stream.
34453448
return Stream->pushKernelLaunch(*this, AllArgs, NumThreads, NumBlocks,
34463449
getStaticBlockMemSize() + DynBlockMemSize,

offload/plugins-nextgen/cuda/src/rtl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,9 @@ Error CUDAKernelTy::launchImpl(GenericDeviceTy &GenericDevice,
13221322
if (GenericDevice.getRPCServer())
13231323
GenericDevice.Plugin.getRPCServer().Thread->notify();
13241324

1325+
// Increase to the requested dynamic memory size for the device if needed.
1326+
DynBlockMemSize = std::max(DynBlockMemSize, GenericDevice.getDynamicMemorySize());
1327+
13251328
// In case we require more memory than the current limit.
13261329
if (DynBlockMemSize >= MaxDynBlockMemSize) {
13271330
CUresult AttrResult = cuFuncSetAttribute(

openmp/runtime/src/kmp_csupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4517,7 +4517,7 @@ void omp_free(void *ptr, omp_allocator_handle_t allocator) {
45174517

45184518
void *omp_get_dyn_groupprivate_ptr(size_t offset, int *is_fallback,
45194519
omp_access_t access_group) {
4520-
if (is_fallback != NULL)
4520+
if (is_fallback != nullptr)
45214521
*is_fallback = 0;
45224522
return NULL;
45234523
}

0 commit comments

Comments
 (0)