Skip to content

Commit

Permalink
rebased with main and fixed conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
konradkusiak97 committed Jan 31, 2024
1 parent 5d5c810 commit d779c95
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 13 additions & 0 deletions source/adapters/hip/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ struct ur_device_handle_t_ {
ur_platform_handle_t Platform;
hipCtx_t HIPContext;
uint32_t DeviceIndex;
int DeviceMaxLocalMem;
int ManagedMemSupport;

public:
ur_device_handle_t_(native_type HipDevice, hipCtx_t Context,
Expand All @@ -35,6 +37,13 @@ struct ur_device_handle_t_ {

~ur_device_handle_t_() noexcept(false) {
UR_CHECK_ERROR(hipDevicePrimaryCtxRelease(HIPDevice));

UR_CHECK_ERROR(hipDeviceGetAttribute(
&DeviceMaxLocalMem, hipDeviceAttributeMaxSharedMemoryPerBlock,
HIPDevice));
UR_CHECK_ERROR(hipDeviceGetAttribute(
&ManagedMemSupport, hipDeviceAttributeManagedMemory,
HIPDevice));
}

native_type get() const noexcept { return HIPDevice; };
Expand All @@ -48,6 +57,10 @@ struct ur_device_handle_t_ {
// Returns the index of the device relative to the other devices in the same
// platform
uint32_t getIndex() const noexcept { return DeviceIndex; };

int getDeviceMaxLocalMem() const noexcept { return DeviceMaxLocalMem; };

bool getManagedMemSupport() const noexcept { return ManagedMemSupport; };
};

int getAttribute(ur_device_handle_t Device, hipDeviceAttribute_t Attribute);
6 changes: 1 addition & 5 deletions source/adapters/hip/enqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
: (LocalMemSzPtrPI ? LocalMemSzPtrPI : nullptr);

if (LocalMemSzPtr) {
int DeviceMaxLocalMem = 0;
UR_CHECK_ERROR(hipDeviceGetAttribute(
&DeviceMaxLocalMem, hipDeviceAttributeMaxSharedMemoryPerBlock,
Dev->get()));

int DeviceMaxLocalMem = Dev->getDeviceMaxLocalMem();
static const int EnvVal = std::atoi(LocalMemSzPtr);
if (EnvVal <= 0 || EnvVal > DeviceMaxLocalMem) {
setErrorMessage(LocalMemSzPtrUR ? "Invalid value specified for "
Expand Down

0 comments on commit d779c95

Please sign in to comment.