Skip to content

Commit 1c4fd2e

Browse files
committed
Fix review comments
1 parent 0062013 commit 1c4fd2e

File tree

12 files changed

+29
-14
lines changed

12 files changed

+29
-14
lines changed

offload/include/omptarget.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ int omp_get_num_devices(void);
281281
int omp_get_device_num(void);
282282
int omp_get_initial_device(void);
283283
size_t
284-
omp_get_groupprivate_limit(int device_num,
285-
omp_access_t access_group = omp_access_cgroup);
284+
omp_get_groupprivate_limit(int DeviceNum,
285+
omp_access_t AccessGroup = omp_access_cgroup);
286286
void *omp_target_alloc(size_t Size, int DeviceNum);
287287
void omp_target_free(void *DevicePtr, int DeviceNum);
288288
int omp_target_is_present(const void *Ptr, int DeviceNum);

offload/liboffload/API/Device.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def ol_device_info_t : Enum {
4343
TaggedEtor<"ADDRESS_BITS", "uint32_t", "Number of bits used to represent an address in device memory">,
4444
TaggedEtor<"MAX_MEM_ALLOC_SIZE", "uint64_t", "The maximum size of memory object allocation in bytes">,
4545
TaggedEtor<"GLOBAL_MEM_SIZE", "uint64_t", "The size of global device memory in bytes">,
46+
TaggedEtor<"WORK_GROUP_SHARED_MEM_SIZE", "uint64_t", "The maximum size of shared memory per work group in bytes">,
4647
];
4748
list<TaggedEtor> fp_configs = !foreach(type, ["Single", "Double", "Half"], TaggedEtor<type # "_FP_CONFIG", "ol_device_fp_capability_flags_t", type # " precision floating point capability">);
4849
list<TaggedEtor> native_vec_widths = !foreach(type, ["char","short","int","long","float","double","half"], TaggedEtor<"NATIVE_VECTOR_WIDTH_" # type, "uint32_t", "Native vector width for " # type>);

offload/liboffload/src/OffloadImpl.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,14 @@ Error olGetDeviceInfoImplDetail(ol_device_handle_t Device,
495495
return Info.write(static_cast<uint32_t>(Value));
496496
}
497497

498+
case OL_DEVICE_INFO_WORK_GROUP_SHARED_MEM_SIZE: {
499+
// Uint64 values
500+
if (!std::holds_alternative<uint64_t>(Entry->Value))
501+
return makeError(ErrorCode::BACKEND_FAILURE,
502+
"plugin returned incorrect type");
503+
return Info.write(std::get<uint64_t>(Entry->Value));
504+
}
505+
498506
case OL_DEVICE_INFO_MAX_WORK_SIZE_PER_DIMENSION:
499507
case OL_DEVICE_INFO_MAX_WORK_GROUP_SIZE_PER_DIMENSION: {
500508
// {x, y, z} triples
@@ -590,6 +598,7 @@ Error olGetDeviceInfoImplDetailHost(ol_device_handle_t Device,
590598
return Info.write<uint32_t>(std::numeric_limits<uintptr_t>::digits);
591599
case OL_DEVICE_INFO_MAX_MEM_ALLOC_SIZE:
592600
case OL_DEVICE_INFO_GLOBAL_MEM_SIZE:
601+
case OL_DEVICE_INFO_WORK_GROUP_SHARED_MEM_SIZE:
593602
return Info.write<uint64_t>(0);
594603
default:
595604
return createOffloadError(ErrorCode::INVALID_ENUMERATION,

offload/libomptarget/OpenMP/API.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ EXTERN size_t omp_get_groupprivate_limit(int DeviceNum,
8383
if (DeviceNum == omp_get_initial_device())
8484
return 0;
8585

86+
if (AccessGroup != omp_access_cgroup)
87+
return 0;
88+
8689
auto DeviceOrErr = PM->getDevice(DeviceNum);
8790
if (!DeviceOrErr)
8891
FATAL_MESSAGE(DeviceNum, "%s", toString(DeviceOrErr.takeError()).c_str());

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,9 +2198,6 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
21982198
}
21992199
}
22002200

2201-
// Supports block shared memory natively.
2202-
HasNativeBlockSharedMem = true;
2203-
22042201
return Plugin::success();
22052202
}
22062203

offload/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,8 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
808808
/// Get the total shared memory per block that can be used in any kernel.
809809
uint32_t getMaxBlockSharedMemSize() const { return MaxBlockSharedMemSize; }
810810

811-
/// Indicate whether the device has native block shared memory.
812-
bool hasNativeBlockSharedMem() const { return HasNativeBlockSharedMem; }
811+
/// Indicate whether the device supports block shared memory natively.
812+
bool hasNativeBlockSharedMem() const { return MaxBlockSharedMemSize > 0; }
813813

814814
/// Set the context of the device if needed, before calling device-specific
815815
/// functions. Plugins may implement this function as a no-op if not needed.
@@ -1269,11 +1269,8 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
12691269
std::atomic<bool> OmptInitialized;
12701270
#endif
12711271

1272-
/// The total per-block shared memory that a kernel may use.
1272+
/// The total per-block native shared memory that a kernel may use.
12731273
uint32_t MaxBlockSharedMemSize = 0;
1274-
1275-
/// Whether the device has native block shared memory.
1276-
bool HasNativeBlockSharedMem = false;
12771274
};
12781275

12791276
/// Class implementing common functionalities of offload plugins. Each plugin

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,6 @@ struct CUDADeviceTy : public GenericDeviceTy {
393393
return Err;
394394
MaxBlockSharedMemSize = MaxSharedMem;
395395

396-
// Supports block shared memory natively.
397-
HasNativeBlockSharedMem = true;
398-
399396
return Plugin::success();
400397
}
401398

offload/tools/deviceinfo/llvm-offload-device-info.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ ol_result_t printDevice(std::ostream &S, ol_device_handle_t D) {
205205
S, D, OL_DEVICE_INFO_MAX_MEM_ALLOC_SIZE, "Max Mem Allocation Size", "B"));
206206
OFFLOAD_ERR(printDeviceValue<uint64_t>(S, D, OL_DEVICE_INFO_GLOBAL_MEM_SIZE,
207207
"Global Mem Size", "B"));
208+
OFFLOAD_ERR(printDeviceValue<uint64_t>(S, D, OL_DEVICE_INFO_WORK_GROUP_SHARED_MEM_SIZE,
209+
"Work Group Shared Mem Size", "B"));
208210
OFFLOAD_ERR(
209211
(printDeviceValue<ol_device_fp_capability_flags_t, PrintKind::FP_FLAGS>(
210212
S, D, OL_DEVICE_INFO_SINGLE_FP_CONFIG,

offload/unittests/OffloadAPI/device/olGetDeviceInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ OL_DEVICE_INFO_TEST_DEVICE_VALUE_GT(GlobalMemSize, uint64_t,
217217
OL_DEVICE_INFO_GLOBAL_MEM_SIZE, 0);
218218
OL_DEVICE_INFO_TEST_HOST_SUCCESS(GlobalMemSize, uint64_t,
219219
OL_DEVICE_INFO_GLOBAL_MEM_SIZE);
220+
OL_DEVICE_INFO_TEST_DEVICE_VALUE_GT(SharedMemSize, uint64_t,
221+
OL_DEVICE_INFO_WORK_GROUP_SHARED_MEM_SIZE, 0);
222+
OL_DEVICE_INFO_TEST_HOST_SUCCESS(SharedMemSize, uint64_t,
223+
OL_DEVICE_INFO_WORK_GROUP_SHARED_MEM_SIZE);
220224

221225
TEST_P(olGetDeviceInfoTest, InvalidNullHandleDevice) {
222226
ol_device_type_t DeviceType;

offload/unittests/OffloadAPI/device/olGetDeviceInfoSize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ OL_DEVICE_INFO_SIZE_TEST_EQ(MaxMemAllocSize, uint64_t,
7171
OL_DEVICE_INFO_MAX_MEM_ALLOC_SIZE);
7272
OL_DEVICE_INFO_SIZE_TEST_EQ(GlobalMemSize, uint64_t,
7373
OL_DEVICE_INFO_GLOBAL_MEM_SIZE);
74+
OL_DEVICE_INFO_SIZE_TEST_EQ(SharedMemSize, uint64_t,
75+
OL_DEVICE_INFO_WORK_GROUP_SHARED_MEM_SIZE);
7476

7577
TEST_P(olGetDeviceInfoSizeTest, SuccessMaxWorkGroupSizePerDimension) {
7678
size_t Size = 0;

0 commit comments

Comments
 (0)