Skip to content

[SYCL][UR] Fix device partition queries (2) #10592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2023
Merged
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
15 changes: 12 additions & 3 deletions sycl/plugins/unified_runtime/pi2ur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ inline pi_result ur2piDeviceInfoValue(ur_device_info_t ParamName,
*pValuePI = pValueUR->value.affinity_domain;
break;
}
case UR_DEVICE_PARTITION_BY_CSLICE: {
*pValuePI = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does it mean to return "0" value? why is this a literal "0" and not some enum value?

Copy link
Contributor

@pbalcer pbalcer Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UR_DEVICE_PARTITION_BY_CSLICE does not have a value in the corresponding UR union type (or, maybe more accurately, its value is empty). Because the PI's data is as an array of key-value pairs, there's no way to represent an absence of value for a key. That's why the 0 assignment is here, which matches the old behavior.

break;
}
default:
die("UR_DEVICE_INFO_PARTITION_TYPE query returned unsupported type");
}
Expand Down Expand Up @@ -1283,6 +1287,14 @@ inline pi_result piDevicePartition(
}

std::vector<ur_device_partition_property_t> UrProperties{};

// UR_DEVICE_PARTITION_BY_CSLICE doesn't have a value, so
// handle it outside the while loop below.
if (UrType == UR_DEVICE_PARTITION_BY_CSLICE) {
ur_device_partition_property_t UrProperty{};
UrProperty.type = UrType;
UrProperties.push_back(UrProperty);
}
while (*(++Properties)) {
ur_device_partition_property_t UrProperty;
UrProperty.type = UrType;
Expand All @@ -1301,9 +1313,6 @@ inline pi_result piDevicePartition(
UrProperty.value.affinity_domain = *Properties;
break;
}
case UR_DEVICE_PARTITION_BY_CSLICE: {
break;
}
default: {
die("Invalid properties for call to piDevicePartition");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
return UR_RESULT_SUCCESS;
}

if (Device->isCCS()) {
ur_device_partition_property_t cslice = {
UR_DEVICE_PARTITION_BY_CSLICE,
};

return ReturnValue(cslice);
}

return ReturnValue(Device->SubDeviceCreationProperty);
}
// Everything under here is not supported yet
Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/Plugin/level_zero_ext_intel_cslice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
// RUN: env SYCL_PI_LEVEL_ZERO_EXPOSE_CSLICE_IN_AFFINITY_PARTITIONING=1 \
// RUN: ZEX_NUMBER_OF_CCS=0:4 ZE_DEBUG=1 %{run} %t.out 2>&1 | FileCheck %s --check-prefixes=CHECK-PVC

// Same, but using immediate commandlists:
// Same, but without using immediate commandlists:

// RUN: env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 ZEX_NUMBER_OF_CCS=0:4 \
// RUN: env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 ZEX_NUMBER_OF_CCS=0:4 \
// RUN: ZE_DEBUG=1 %{run} %t.out 2>&1 | FileCheck %s --check-prefixes=CHECK-PVC

// RUN: env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1 SYCL_PI_LEVEL_ZERO_EXPOSE_CSLICE_IN_AFFINITY_PARTITIONING=1 \
// RUN: env SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=0 SYCL_PI_LEVEL_ZERO_EXPOSE_CSLICE_IN_AFFINITY_PARTITIONING=1 \
// RUN: ZEX_NUMBER_OF_CCS=0:4 ZE_DEBUG=1 %{run} %t.out 2>&1 | FileCheck %s --check-prefixes=CHECK-PVC

#include <sycl/sycl.hpp>
Expand Down