Skip to content

Commit

Permalink
Add CLON12_WARP_IS_HARDWARE so WARP uses CL_DEVICE_TYPE_GPU instead o…
Browse files Browse the repository at this point in the history
…f CPU
  • Loading branch information
jenatali committed Mar 4, 2024
1 parent 989a95f commit 3486370
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ class Platform : public CLBase<Platform, cl_platform_id>
void DeviceInit();
void DeviceUninit();

const bool m_bWarpIsHardware;

protected:
ComPtr<IDXCoreAdapterList> m_spAdapters;
std::vector<std::unique_ptr<Device>> m_Devices;
Expand Down
2 changes: 1 addition & 1 deletion src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ cl_device_type Device::GetType() const noexcept
{
return CL_DEVICE_TYPE_ACCELERATOR | Default;
}
if (m_HWIDs.deviceID == 0x8c && m_HWIDs.vendorID == 0x1414)
if (m_HWIDs.deviceID == 0x8c && m_HWIDs.vendorID == 0x1414 && !g_Platform->m_bWarpIsHardware)
{
return CL_DEVICE_TYPE_CPU | Default;
}
Expand Down
11 changes: 11 additions & 0 deletions src/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,19 @@ clUnloadPlatformCompiler(cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2
return CL_SUCCESS;
}

static bool CheckWarpIsHardware()
{
char *warpIsHardwareStr = nullptr;
bool warpIsHardware = _dupenv_s(&warpIsHardwareStr, nullptr, "CLON12_WARP_IS_HARDWARE") == 0 &&
warpIsHardwareStr &&
strcmp(warpIsHardwareStr, "1") == 0;
free(warpIsHardwareStr);
return warpIsHardware;
}

#include "device.hpp"
Platform::Platform(cl_icd_dispatch* dispatch)
: m_bWarpIsHardware(CheckWarpIsHardware())
{
this->dispatch = dispatch;

Expand Down

0 comments on commit 3486370

Please sign in to comment.