Skip to content

Commit 698417a

Browse files
[SYCL] Drop 'acc' in favor of 'fpga' from ONEAPI_DEVICE_SELECTOR (#12614)
As per the ONEAPI_DEVICE_SELECTOR [documentation](https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md#oneapi_device_selector), the device type can only be cpu, gpu, or fpga (or any combination of those). Currently, 'acc' is also accepted by ONEAPI_DEVICE_SELECTOR as a valid device type, which is incorrect. This PR modifies drops support of 'acc' in ONEAPI_DEVICE_SELECTOR in favor of 'fpga'. We have already updated existing test cases (#12551), testing scripts (#12596 ) to use 'fpga' with ONEAPI_DEVICE_SELECTOR.
1 parent 170be1f commit 698417a

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed

sycl/source/detail/allowlist.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
166166
// valid. E.g., for BackendName key, the allowed values are only ones
167167
// described in SyclBeMap
168168
ValidateEnumValues(BackendNameKeyName, getSyclBeMap());
169-
ValidateEnumValues(DeviceTypeKeyName, getSyclDeviceTypeMap());
169+
ValidateEnumValues(DeviceTypeKeyName,
170+
getSyclDeviceTypeMap(true /*Enable 'acc'*/));
170171

171172
if (Key == DeviceVendorIdKeyName) {
172173
// DeviceVendorId should have hex format
@@ -380,7 +381,8 @@ void applyAllowList(std::vector<sycl::detail::pi::PiDevice> &PiDevices,
380381
Device, PI_DEVICE_INFO_TYPE, sizeof(sycl::detail::pi::PiDeviceType),
381382
&PiDevType, nullptr);
382383
sycl::info::device_type DeviceType = pi::cast<info::device_type>(PiDevType);
383-
for (const auto &SyclDeviceType : getSyclDeviceTypeMap()) {
384+
for (const auto &SyclDeviceType :
385+
getSyclDeviceTypeMap(true /*Enable 'acc'*/)) {
384386
if (SyclDeviceType.second == DeviceType) {
385387
const auto &DeviceTypeValue = SyclDeviceType.first;
386388
DeviceDesc[DeviceTypeKeyName] = DeviceTypeValue;

sycl/source/detail/config.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,16 @@ void dumpConfig() {
165165
// TODO: host device type will be removed once sycl_ext_oneapi_filter_selector
166166
// is removed.
167167
const std::array<std::pair<std::string, info::device_type>, 6> &
168-
getSyclDeviceTypeMap() {
168+
getSyclDeviceTypeMap(bool supportAcc) {
169169
static const std::array<std::pair<std::string, info::device_type>, 6>
170-
SyclDeviceTypeMap = {{{"host", info::device_type::host},
171-
{"cpu", info::device_type::cpu},
172-
{"gpu", info::device_type::gpu},
173-
{"acc", info::device_type::accelerator},
174-
{"fpga", info::device_type::accelerator},
175-
{"*", info::device_type::all}}};
170+
SyclDeviceTypeMap = {
171+
{{"host", info::device_type::host},
172+
{"cpu", info::device_type::cpu},
173+
{"gpu", info::device_type::gpu},
174+
/* Duplicate entries are fine as this map is one-directional.*/
175+
{supportAcc ? "acc" : "fpga", info::device_type::accelerator},
176+
{"fpga", info::device_type::accelerator},
177+
{"*", info::device_type::all}}};
176178
return SyclDeviceTypeMap;
177179
}
178180

sycl/source/detail/config.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,10 @@ template <> class SYCLConfig<SYCL_PARALLEL_FOR_RANGE_ROUNDING_PARAMS> {
232232
};
233233

234234
// Array is used by SYCL_DEVICE_ALLOWLIST and ONEAPI_DEVICE_SELECTOR.
235+
// The 'supportAcc' parameter is used by SYCL_DEVICE_ALLOWLIST which,
236+
// unlike ONEAPI_DEVICE_SELECTOR, also accepts 'acc' as a valid device type.
235237
const std::array<std::pair<std::string, info::device_type>, 6> &
236-
getSyclDeviceTypeMap();
238+
getSyclDeviceTypeMap(bool supportAcc = false);
237239

238240
// Array is used by SYCL_DEVICE_FILTER and SYCL_DEVICE_ALLOWLIST and
239241
// ONEAPI_DEVICE_SELECTOR
@@ -514,7 +516,7 @@ template <> class SYCLConfig<SYCL_REDUCTION_PREFERRED_WORKGROUP_SIZE> {
514516
return Result;
515517

516518
std::string ValueStr{ValueRaw};
517-
auto DeviceTypeMap = getSyclDeviceTypeMap();
519+
auto DeviceTypeMap = getSyclDeviceTypeMap(true /*Enable 'acc'*/);
518520

519521
// Iterate over all configurations.
520522
size_t Start = 0, End = 0;

sycl/source/detail/device_filter.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,13 @@ static void Parse_ODS_Device(ods_target &Target,
9393
std::string_view TopDeviceStr = DeviceSubTuple[0];
9494

9595
// Handle explicit device type (e.g. 'gpu').
96-
auto DeviceTypeMap =
97-
getSyclDeviceTypeMap(); // <-- std::array<std::pair<std::string,
98-
// info::device::type>>
96+
auto DeviceTypeMap = getSyclDeviceTypeMap(
97+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
98+
true /*Enable 'acc'*/
99+
#endif
100+
); // <-- std::array<std::pair<std::string,
101+
// info::device::type>>
102+
99103
auto It =
100104
std::find_if(std::begin(DeviceTypeMap), std::end(DeviceTypeMap),
101105
[&](auto DtPair) { return TopDeviceStr == DtPair.first; });
@@ -262,7 +266,11 @@ Parse_ONEAPI_DEVICE_SELECTOR(const std::string &envString) {
262266
std::ostream &operator<<(std::ostream &Out, const ods_target &Target) {
263267
Out << Target.Backend;
264268
if (Target.DeviceType) {
265-
auto DeviceTypeMap = getSyclDeviceTypeMap();
269+
auto DeviceTypeMap = getSyclDeviceTypeMap(
270+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
271+
true /*Enable 'acc'*/
272+
#endif
273+
);
266274
auto Match = std::find_if(
267275
DeviceTypeMap.begin(), DeviceTypeMap.end(),
268276
[&](auto Pair) { return (Pair.second == Target.DeviceType); });
@@ -335,11 +343,12 @@ device_filter::device_filter(const std::string &FilterString) {
335343
if (TripleValueID >= Tokens.size()) {
336344
DeviceType = info::device_type::all;
337345
} else {
338-
auto Iter = std::find_if(std::begin(getSyclDeviceTypeMap()),
339-
std::end(getSyclDeviceTypeMap()), FindElement);
346+
auto Iter = std::find_if(
347+
std::begin(getSyclDeviceTypeMap(true /*Enable 'acc'*/)),
348+
std::end(getSyclDeviceTypeMap(true /*Enable 'acc'*/)), FindElement);
340349
// If no match is found, set device_type 'all',
341350
// which actually means 'any device_type' will be a match.
342-
if (Iter == getSyclDeviceTypeMap().end())
351+
if (Iter == getSyclDeviceTypeMap(true /*Enable 'acc'*/).end())
343352
DeviceType = info::device_type::all;
344353
else {
345354
DeviceType = Iter->second;

sycl/unittests/allowlist/ParseAllowList.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ TEST(ParseAllowListTests, CheckAllValidBackendNameValuesAreProcessed) {
178178

179179
TEST(ParseAllowListTests, CheckAllValidDeviceTypeValuesAreProcessed) {
180180
std::string AllowList;
181-
for (const auto &SyclDeviceType : sycl::detail::getSyclDeviceTypeMap()) {
181+
for (const auto &SyclDeviceType :
182+
sycl::detail::getSyclDeviceTypeMap(true /*Enable 'acc'*/)) {
182183
if (!AllowList.empty())
183184
AllowList += "|";
184185
AllowList += "DeviceType:" + SyclDeviceType.first;

0 commit comments

Comments
 (0)