Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/intel-llvm-mirror-base-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1dee8fc72d540109e13ea80193caa4432545790a
76c80a0fcc0a55a2820d068173f5bfa3756d375c
6 changes: 4 additions & 2 deletions include/ur_api.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions include/ur_print.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions scripts/core/device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ etors:
desc: "Memory Copy Accelerator"
- name: VPU
desc: "Vision Processing Unit"
- name: CUSTOM
desc: "Generic custom device type"
--- #--------------------------------------------------------------------------
type: function
desc: "Retrieves devices within a platform"
Expand Down
1 change: 1 addition & 0 deletions scripts/core/manifests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ device_types:
- $X_DEVICE_TYPE_FPGA
- $X_DEVICE_TYPE_MCA
- $X_DEVICE_TYPE_VPU
- $X_DEVICE_TYPE_CUSTOM
--- #--------------------------------------------------------------------------
type: manifest
name: cuda
Expand Down
7 changes: 6 additions & 1 deletion source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,13 @@ ur_result_t urDeviceGet(
bool isComposite =
isCombinedMode && (D->ZeDeviceProperties->flags &
ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE) == 0;
if (!isComposite)
if (!isComposite) {
MatchedDevices.push_back(D.get());
// For UR_DEVICE_TYPE_DEFAULT only a single device should be returned,
// so exit the loop after first proper match.
if (DeviceType == UR_DEVICE_TYPE_DEFAULT)
break;
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion source/adapters/level_zero/enqueued_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class EnqueuedPool {

EnqueuedPool(event_release_callback_t EventReleaseFn,
memory_free_callback_t MemFreeFn)
: EventReleaseFn(EventReleaseFn), MemFreeFn(MemFreeFn) {}
: EventReleaseFn(std::move(EventReleaseFn)),
MemFreeFn(std::move(MemFreeFn)) {}

~EnqueuedPool();
std::optional<Allocation> getBestFit(size_t Size, size_t Alignment,
Expand Down
10 changes: 4 additions & 6 deletions source/adapters/opencl/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ static ur_adapter_handle_t liveAdapter = nullptr;
ur_adapter_handle_t_::ur_adapter_handle_t_() : handle_base() {
#ifdef _MSC_VER

// Loading OpenCL.dll increments the libraries internal reference count.
auto handle = LoadLibraryA("OpenCL.dll");
// Retrieving handle of an already linked OpenCL.dll library doesn't increase
// the reference count.
auto handle = GetModuleHandleA("OpenCL.dll");
assert(handle);

#define CL_CORE_FUNCTION(FUNC) \
FUNC = reinterpret_cast<decltype(::FUNC) *>(GetProcAddress(handle, #FUNC));
#include "core_functions.def"
#undef CL_CORE_FUNCTION

// So we can safely decrement it here wihtout actually unloading OpenCL.dll.
FreeLibrary(handle);

#else // _MSC_VER

// Use the default shared object search order (RTLD_DEFAULT) since the
Expand Down
11 changes: 10 additions & 1 deletion source/adapters/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(ur_platform_handle_t hPlatform,
case UR_DEVICE_TYPE_VPU:
Type = CL_DEVICE_TYPE_ACCELERATOR;
break;
case UR_DEVICE_TYPE_CUSTOM:
Type = CL_DEVICE_TYPE_CUSTOM;
break;
case UR_DEVICE_TYPE_DEFAULT:
Type = CL_DEVICE_TYPE_DEFAULT;
break;
Expand All @@ -47,11 +50,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(ur_platform_handle_t hPlatform,
uint32_t DeviceNumIter = 0;
for (uint32_t i = 0; i < AllDevicesNum; i++) {
cl_device_type DevTy = hPlatform->Devices[i]->Type;
if (DevTy == Type || Type == CL_DEVICE_TYPE_ALL) {
if (DevTy == Type || Type == CL_DEVICE_TYPE_ALL ||
Type == CL_DEVICE_TYPE_DEFAULT) {
if (phDevices) {
phDevices[DeviceNumIter] = hPlatform->Devices[i].get();
}
DeviceNumIter++;
// For default, the first device is the only returned device.
if (Type == CL_DEVICE_TYPE_DEFAULT)
break;
}
}
if (pNumDevices) {
Expand Down Expand Up @@ -141,6 +148,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
URDeviceType = UR_DEVICE_TYPE_GPU;
} else if (CLType & CL_DEVICE_TYPE_ACCELERATOR) {
URDeviceType = UR_DEVICE_TYPE_FPGA;
} else if (CLType & CL_DEVICE_TYPE_CUSTOM) {
URDeviceType = UR_DEVICE_TYPE_CUSTOM;
}

return ReturnValue(URDeviceType);
Expand Down
11 changes: 3 additions & 8 deletions source/loader/layers/sanitizer/msan/msan_shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,9 @@ ur_result_t MsanShadowMemoryCPU::Setup() {
uptr End = kMemoryLayout[i].end;
uptr Size = End - Start;
MappingDesc::Type Type = kMemoryLayout[i].type;
bool InitOrigins = true;

bool IsMap = Type == MappingDesc::SHADOW ||
(InitOrigins && Type == MappingDesc::ORIGIN);
bool IsProtect = Type == MappingDesc::INVALID ||
(!InitOrigins && Type == MappingDesc::ORIGIN);
bool IsMap = Type == MappingDesc::SHADOW || Type == MappingDesc::ORIGIN;
bool IsProtect = Type == MappingDesc::INVALID;

if (IsMap) {
if (MmapFixedNoReserve(Start, Size) == 0) {
Expand Down Expand Up @@ -124,9 +121,7 @@ ur_result_t MsanShadowMemoryCPU::Destory() {
uptr End = kMemoryLayout[i].end;
uptr Size = End - Start;
MappingDesc::Type Type = kMemoryLayout[i].type;
bool InitOrigins = true;
bool IsMap = Type == MappingDesc::SHADOW ||
(InitOrigins && Type == MappingDesc::ORIGIN);
bool IsMap = Type == MappingDesc::SHADOW || Type == MappingDesc::ORIGIN;
if (IsMap) {
if (Munmap(Start, Size)) {
return UR_RESULT_ERROR_UNKNOWN;
Expand Down
2 changes: 1 addition & 1 deletion source/loader/layers/validation/ur_valddi.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions source/loader/ur_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
case UR_DEVICE_TYPE_CPU:
case UR_DEVICE_TYPE_FPGA:
case UR_DEVICE_TYPE_MCA:
case UR_DEVICE_TYPE_CUSTOM:
break;
default:
return UR_RESULT_ERROR_INVALID_ENUMERATION;
Expand Down Expand Up @@ -647,10 +648,15 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
[&](ur_device_handle_t urDeviceHandle) {
// obtain and record device type from platform (squash
// errors)
ur_device_type_t hardwareType = ::UR_DEVICE_TYPE_DEFAULT;
urDeviceGetInfo(urDeviceHandle, UR_DEVICE_INFO_TYPE,
sizeof(ur_device_type_t), &hardwareType,
0);
ur_device_type_t hardwareType;
ur_result_t res = urDeviceGetInfo(
urDeviceHandle, UR_DEVICE_INFO_TYPE,
sizeof(ur_device_type_t), &hardwareType, 0);
// ignore failures and just assume the default hw type
if (res != UR_RESULT_SUCCESS) {
hardwareType = ::UR_DEVICE_TYPE_DEFAULT;
}

return DeviceSpec{DevicePartLevel::ROOT, hardwareType,
deviceCount++, DeviceIdTypeALL,
DeviceIdTypeALL, urDeviceHandle};
Expand Down
4 changes: 2 additions & 2 deletions source/loader/ur_libapi.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions source/loader/ur_manifests.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions source/ur_api.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/conformance/device/urDeviceGet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ UUR_PLATFORM_TEST_SUITE_WITH_PARAM(
urDeviceGetTestWithDeviceTypeParam,
::testing::Values(UR_DEVICE_TYPE_DEFAULT, UR_DEVICE_TYPE_GPU,
UR_DEVICE_TYPE_CPU, UR_DEVICE_TYPE_FPGA,
UR_DEVICE_TYPE_MCA, UR_DEVICE_TYPE_VPU),
UR_DEVICE_TYPE_MCA, UR_DEVICE_TYPE_VPU,
UR_DEVICE_TYPE_CUSTOM),
uur::platformTestWithParamPrinter<ur_device_type_t>);

TEST_P(urDeviceGetTestWithDeviceTypeParam, Success) {
Expand Down