Skip to content

[SYCL] Drop 'acc' in favor of 'fpga' from ONEAPI_DEVICE_SELECTOR #12614

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 5 commits into from
Feb 8, 2024
Merged
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
6 changes: 4 additions & 2 deletions sycl/source/detail/allowlist.cpp
Original file line number Diff line number Diff line change
@@ -166,7 +166,8 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
// valid. E.g., for BackendName key, the allowed values are only ones
// described in SyclBeMap
ValidateEnumValues(BackendNameKeyName, getSyclBeMap());
ValidateEnumValues(DeviceTypeKeyName, getSyclDeviceTypeMap());
ValidateEnumValues(DeviceTypeKeyName,
getSyclDeviceTypeMap(true /*Enable 'acc'*/));

if (Key == DeviceVendorIdKeyName) {
// DeviceVendorId should have hex format
@@ -380,7 +381,8 @@ void applyAllowList(std::vector<sycl::detail::pi::PiDevice> &PiDevices,
Device, PI_DEVICE_INFO_TYPE, sizeof(sycl::detail::pi::PiDeviceType),
&PiDevType, nullptr);
sycl::info::device_type DeviceType = pi::cast<info::device_type>(PiDevType);
for (const auto &SyclDeviceType : getSyclDeviceTypeMap()) {
for (const auto &SyclDeviceType :
getSyclDeviceTypeMap(true /*Enable 'acc'*/)) {
if (SyclDeviceType.second == DeviceType) {
const auto &DeviceTypeValue = SyclDeviceType.first;
DeviceDesc[DeviceTypeKeyName] = DeviceTypeValue;
16 changes: 9 additions & 7 deletions sycl/source/detail/config.cpp
Original file line number Diff line number Diff line change
@@ -165,14 +165,16 @@ void dumpConfig() {
// TODO: host device type will be removed once sycl_ext_oneapi_filter_selector
// is removed.
const std::array<std::pair<std::string, info::device_type>, 6> &
getSyclDeviceTypeMap() {
getSyclDeviceTypeMap(bool supportAcc) {
static const std::array<std::pair<std::string, info::device_type>, 6>
SyclDeviceTypeMap = {{{"host", info::device_type::host},
{"cpu", info::device_type::cpu},
{"gpu", info::device_type::gpu},
{"acc", info::device_type::accelerator},
{"fpga", info::device_type::accelerator},
{"*", info::device_type::all}}};
SyclDeviceTypeMap = {
{{"host", info::device_type::host},
{"cpu", info::device_type::cpu},
{"gpu", info::device_type::gpu},
/* Duplicate entries are fine as this map is one-directional.*/
{supportAcc ? "acc" : "fpga", info::device_type::accelerator},
{"fpga", info::device_type::accelerator},
{"*", info::device_type::all}}};
return SyclDeviceTypeMap;
}

6 changes: 4 additions & 2 deletions sycl/source/detail/config.hpp
Original file line number Diff line number Diff line change
@@ -232,8 +232,10 @@ template <> class SYCLConfig<SYCL_PARALLEL_FOR_RANGE_ROUNDING_PARAMS> {
};

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

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

std::string ValueStr{ValueRaw};
auto DeviceTypeMap = getSyclDeviceTypeMap();
auto DeviceTypeMap = getSyclDeviceTypeMap(true /*Enable 'acc'*/);

// Iterate over all configurations.
size_t Start = 0, End = 0;
23 changes: 16 additions & 7 deletions sycl/source/detail/device_filter.cpp
Original file line number Diff line number Diff line change
@@ -93,9 +93,13 @@ static void Parse_ODS_Device(ods_target &Target,
std::string_view TopDeviceStr = DeviceSubTuple[0];

// Handle explicit device type (e.g. 'gpu').
auto DeviceTypeMap =
getSyclDeviceTypeMap(); // <-- std::array<std::pair<std::string,
// info::device::type>>
auto DeviceTypeMap = getSyclDeviceTypeMap(
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
true /*Enable 'acc'*/
#endif
); // <-- std::array<std::pair<std::string,
// info::device::type>>

auto It =
std::find_if(std::begin(DeviceTypeMap), std::end(DeviceTypeMap),
[&](auto DtPair) { return TopDeviceStr == DtPair.first; });
@@ -262,7 +266,11 @@ Parse_ONEAPI_DEVICE_SELECTOR(const std::string &envString) {
std::ostream &operator<<(std::ostream &Out, const ods_target &Target) {
Out << Target.Backend;
if (Target.DeviceType) {
auto DeviceTypeMap = getSyclDeviceTypeMap();
auto DeviceTypeMap = getSyclDeviceTypeMap(
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
true /*Enable 'acc'*/
#endif
);
auto Match = std::find_if(
DeviceTypeMap.begin(), DeviceTypeMap.end(),
[&](auto Pair) { return (Pair.second == Target.DeviceType); });
@@ -335,11 +343,12 @@ device_filter::device_filter(const std::string &FilterString) {
if (TripleValueID >= Tokens.size()) {
DeviceType = info::device_type::all;
} else {
auto Iter = std::find_if(std::begin(getSyclDeviceTypeMap()),
std::end(getSyclDeviceTypeMap()), FindElement);
auto Iter = std::find_if(
std::begin(getSyclDeviceTypeMap(true /*Enable 'acc'*/)),
std::end(getSyclDeviceTypeMap(true /*Enable 'acc'*/)), FindElement);
// If no match is found, set device_type 'all',
// which actually means 'any device_type' will be a match.
if (Iter == getSyclDeviceTypeMap().end())
if (Iter == getSyclDeviceTypeMap(true /*Enable 'acc'*/).end())
DeviceType = info::device_type::all;
else {
DeviceType = Iter->second;
3 changes: 2 additions & 1 deletion sycl/unittests/allowlist/ParseAllowList.cpp
Original file line number Diff line number Diff line change
@@ -178,7 +178,8 @@ TEST(ParseAllowListTests, CheckAllValidBackendNameValuesAreProcessed) {

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