Skip to content

Commit d779c95

Browse files
committed
rebased with main and fixed conflicts
1 parent 5d5c810 commit d779c95

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

source/adapters/hip/device.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ struct ur_device_handle_t_ {
2626
ur_platform_handle_t Platform;
2727
hipCtx_t HIPContext;
2828
uint32_t DeviceIndex;
29+
int DeviceMaxLocalMem;
30+
int ManagedMemSupport;
2931

3032
public:
3133
ur_device_handle_t_(native_type HipDevice, hipCtx_t Context,
@@ -35,6 +37,13 @@ struct ur_device_handle_t_ {
3537

3638
~ur_device_handle_t_() noexcept(false) {
3739
UR_CHECK_ERROR(hipDevicePrimaryCtxRelease(HIPDevice));
40+
41+
UR_CHECK_ERROR(hipDeviceGetAttribute(
42+
&DeviceMaxLocalMem, hipDeviceAttributeMaxSharedMemoryPerBlock,
43+
HIPDevice));
44+
UR_CHECK_ERROR(hipDeviceGetAttribute(
45+
&ManagedMemSupport, hipDeviceAttributeManagedMemory,
46+
HIPDevice));
3847
}
3948

4049
native_type get() const noexcept { return HIPDevice; };
@@ -48,6 +57,10 @@ struct ur_device_handle_t_ {
4857
// Returns the index of the device relative to the other devices in the same
4958
// platform
5059
uint32_t getIndex() const noexcept { return DeviceIndex; };
60+
61+
int getDeviceMaxLocalMem() const noexcept { return DeviceMaxLocalMem; };
62+
63+
bool getManagedMemSupport() const noexcept { return ManagedMemSupport; };
5164
};
5265

5366
int getAttribute(ur_device_handle_t Device, hipDeviceAttribute_t Attribute);

source/adapters/hip/enqueue.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
423423
: (LocalMemSzPtrPI ? LocalMemSzPtrPI : nullptr);
424424

425425
if (LocalMemSzPtr) {
426-
int DeviceMaxLocalMem = 0;
427-
UR_CHECK_ERROR(hipDeviceGetAttribute(
428-
&DeviceMaxLocalMem, hipDeviceAttributeMaxSharedMemoryPerBlock,
429-
Dev->get()));
430-
426+
int DeviceMaxLocalMem = Dev->getDeviceMaxLocalMem();
431427
static const int EnvVal = std::atoi(LocalMemSzPtr);
432428
if (EnvVal <= 0 || EnvVal > DeviceMaxLocalMem) {
433429
setErrorMessage(LocalMemSzPtrUR ? "Invalid value specified for "

0 commit comments

Comments
 (0)