File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ struct ur_device_handle_t_ {
26
26
ur_platform_handle_t Platform;
27
27
hipCtx_t HIPContext;
28
28
uint32_t DeviceIndex;
29
+ int DeviceMaxLocalMem;
30
+ int ManagedMemSupport;
29
31
30
32
public:
31
33
ur_device_handle_t_ (native_type HipDevice, hipCtx_t Context,
@@ -35,6 +37,13 @@ struct ur_device_handle_t_ {
35
37
36
38
~ur_device_handle_t_ () noexcept (false ) {
37
39
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));
38
47
}
39
48
40
49
native_type get () const noexcept { return HIPDevice; };
@@ -48,6 +57,10 @@ struct ur_device_handle_t_ {
48
57
// Returns the index of the device relative to the other devices in the same
49
58
// platform
50
59
uint32_t getIndex () const noexcept { return DeviceIndex; };
60
+
61
+ int getDeviceMaxLocalMem () const noexcept { return DeviceMaxLocalMem; };
62
+
63
+ bool getManagedMemSupport () const noexcept { return ManagedMemSupport; };
51
64
};
52
65
53
66
int getAttribute (ur_device_handle_t Device, hipDeviceAttribute_t Attribute);
Original file line number Diff line number Diff line change @@ -423,11 +423,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
423
423
: (LocalMemSzPtrPI ? LocalMemSzPtrPI : nullptr );
424
424
425
425
if (LocalMemSzPtr) {
426
- int DeviceMaxLocalMem = 0 ;
427
- UR_CHECK_ERROR (hipDeviceGetAttribute (
428
- &DeviceMaxLocalMem, hipDeviceAttributeMaxSharedMemoryPerBlock,
429
- Dev->get ()));
430
-
426
+ int DeviceMaxLocalMem = Dev->getDeviceMaxLocalMem ();
431
427
static const int EnvVal = std::atoi (LocalMemSzPtr);
432
428
if (EnvVal <= 0 || EnvVal > DeviceMaxLocalMem) {
433
429
setErrorMessage (LocalMemSzPtrUR ? " Invalid value specified for "
You can’t perform that action at this time.
0 commit comments