Skip to content

Commit

Permalink
[SYCL] Remove querying for unsupported platforms (#15415)
Browse files Browse the repository at this point in the history
As discussed in #15368 this
functionality should not be exposed to the users.
  • Loading branch information
jchlanda authored Oct 3, 2024
1 parent e076c04 commit 4c223d1
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 114 deletions.
5 changes: 0 additions & 5 deletions sycl/include/sycl/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,6 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
/// \return a vector of all available SYCL platforms.
static std::vector<platform> get_platforms();

/// Returns all unsupported (non-SYCL) platforms in the system.
///
/// \return a vector of all unsupported non-SYCL platforms.
static std::vector<platform> get_unsupported_platforms();

/// Returns the backend associated with this platform.
///
/// \return the backend associated with this platform
Expand Down
18 changes: 0 additions & 18 deletions sycl/source/detail/platform_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,6 @@ std::vector<platform> platform_impl::getAdapterPlatforms(AdapterPtr &Adapter,
return Platforms;
}

std::vector<platform> platform_impl::get_unsupported_platforms() {
std::vector<platform> UnsupportedPlatforms;

std::vector<AdapterPtr> &Adapters = sycl::detail::ur::initializeUr();
// Ignore UR as it has to be supported.
for (auto &Adapter : Adapters) {
if (Adapter->hasBackend(backend::all)) {
continue; // skip UR
}
std::vector<platform> AdapterPlatforms =
getAdapterPlatforms(Adapter, /*Supported=*/false);
std::copy(AdapterPlatforms.begin(), AdapterPlatforms.end(),
std::back_inserter(UnsupportedPlatforms));
}

return UnsupportedPlatforms;
}

// This routine has the side effect of registering each platform's last device
// id into each adapter, which is used for device counting.
std::vector<platform> platform_impl::get_platforms() {
Expand Down
5 changes: 0 additions & 5 deletions sycl/source/detail/platform_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ class platform_impl {
/// \return a vector of all available SYCL platforms.
static std::vector<platform> get_platforms();

/// Returns all unsupported (non-SYCL) platforms in the system.
///
/// \return a vector of all unsupported (non-SYCL) platforms.
static std::vector<platform> get_unsupported_platforms();

// \return the Adapter associated with this platform.
const AdapterPtr &getAdapter() const { return MAdapter; }

Expand Down
4 changes: 0 additions & 4 deletions sycl/source/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ std::vector<platform> platform::get_platforms() {
return detail::platform_impl::get_platforms();
}

std::vector<platform> platform::get_unsupported_platforms() {
return detail::platform_impl::get_unsupported_platforms();
}

backend platform::get_backend() const noexcept { return impl->getBackend(); }

template <typename Param>
Expand Down
16 changes: 0 additions & 16 deletions sycl/test-e2e/Plugin/sycl-ls-banned.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion sycl/test-e2e/Plugin/sycl-ls.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: sycl-ls --verbose | awk '{print}/Unsupported Platforms:/{exit}' | grep "Device \[" | wc -l >%t.verbose.out
// RUN: sycl-ls --verbose | grep "Device \[" | wc -l >%t.verbose.out
// RUN: sycl-ls | wc -l >%t.concise.out
// RUN: diff %t.verbose.out %t.concise.out

Expand Down
1 change: 0 additions & 1 deletion sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -3545,7 +3545,6 @@ _ZN4sycl3_V17samplerC1EP11_cl_samplerRKNS0_7contextE
_ZN4sycl3_V17samplerC2ENS0_29coordinate_normalization_modeENS0_15addressing_modeENS0_14filtering_modeERKNS0_13property_listE
_ZN4sycl3_V17samplerC2EP11_cl_samplerRKNS0_7contextE
_ZN4sycl3_V18platform13get_platformsEv
_ZN4sycl3_V18platform25get_unsupported_platformsEv
_ZN4sycl3_V18platformC1EP15_cl_platform_id
_ZN4sycl3_V18platformC1ERKNS0_15device_selectorE
_ZN4sycl3_V18platformC1ERKNS0_6deviceE
Expand Down
1 change: 0 additions & 1 deletion sycl/test/abi/sycl_symbols_windows.dump
Original file line number Diff line number Diff line change
Expand Up @@ -4035,7 +4035,6 @@
?get_platform@context@_V1@sycl@@QEBA?AVplatform@23@XZ
?get_platform@device@_V1@sycl@@QEBA?AVplatform@23@XZ
?get_platforms@platform@_V1@sycl@@SA?AV?$vector@Vplatform@_V1@sycl@@V?$allocator@Vplatform@_V1@sycl@@@std@@@std@@XZ
?get_unsupported_platforms@platform@_V1@sycl@@SA?AV?$vector@Vplatform@_V1@sycl@@V?$allocator@Vplatform@_V1@sycl@@@std@@@std@@XZ
?get_pointer_device@_V1@sycl@@YA?AVdevice@12@PEBXAEBVcontext@12@@Z
?get_pointer_type@_V1@sycl@@YA?AW4alloc@usm@12@PEBXAEBVcontext@12@@Z
?get_precision@stream@_V1@sycl@@QEBA_KXZ
Expand Down
101 changes: 38 additions & 63 deletions sycl/tools/sycl-ls/sycl-ls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
// verbose (enabled with --verbose).
//
// In verbose mode it also prints, which devices would be chosen by various SYCL
// device selectors. If the system has unsupported platforms (for instance
// CUDA's OpenCL) those will also be listed in verbose mode, under "Unsupported
// Platforms".
// device selectors.
//
#include <sycl/sycl.hpp>

Expand Down Expand Up @@ -124,8 +122,7 @@ std::array<int, 2> GetNumberOfSubAndSubSubDevices(const device &Device) {
}

static void printDeviceInfo(const device &Device, bool Verbose,
const std::string &Prepend,
bool IsUnsupported = false) {
const std::string &Prepend) {
auto DeviceVersion = Device.get_info<info::device::version>();
auto DeviceName = Device.get_info<info::device::name>();
auto DeviceVendor = Device.get_info<info::device::vendor>();
Expand Down Expand Up @@ -160,23 +157,19 @@ static void printDeviceInfo(const device &Device, bool Verbose,
<< std::endl;
}

// We don't expect to find info on aspects, device's sub-group size or
// architecture on non supported devices.
if (!IsUnsupported) {
std::cout << Prepend << "Aspects :";
std::cout << Prepend << "Aspects :";
#define __SYCL_ASPECT(ASPECT, ID) \
if (Device.has(aspect::ASPECT)) \
std::cout << " " << #ASPECT;
#include <sycl/info/aspects.def>
std::cout << std::endl;
auto sg_sizes = Device.get_info<info::device::sub_group_sizes>();
std::cout << Prepend << "info::device::sub_group_sizes:";
for (auto size : sg_sizes)
std::cout << " " << size;
std::cout << std::endl;
std::cout << Prepend << "Architecture: " << getArchName(Device)
<< std::endl;
}
std::cout << std::endl;
auto sg_sizes = Device.get_info<info::device::sub_group_sizes>();
std::cout << Prepend << "info::device::sub_group_sizes:";
for (auto size : sg_sizes)
std::cout << " " << size;
std::cout << std::endl;
std::cout << Prepend << "Architecture: " << getArchName(Device)
<< std::endl;
} else {
std::cout << Prepend << ", " << DeviceName << " " << DeviceVersion << " ["
<< DeviceDriverVersion << "]" << std::endl;
Expand Down Expand Up @@ -208,11 +201,8 @@ static int printUsageAndExit() {
<< std::endl;
std::cout << "\n Options:" << std::endl;
std::cout
<< "\t --verbose "
<< "\t Verbosely prints all the discovered platforms. "
<< "It also lists the device chosen by various SYCL device "
"selectors. If the system contains unsupported platforms, those will "
"also be listed in verbose mode, under \"Unsupported Platforms\"."
<< "\t --verbose " << "\t Verbosely prints all the discovered platforms. "
<< "It also lists the device chosen by various SYCL device selectors."
<< std::endl;
std::cout
<< "\t --ignore-device-selectors "
Expand Down Expand Up @@ -327,38 +317,6 @@ static int unsetFilterEnvVarsAndFork() {
}
#endif

// NOTE: This function can update DeviceNums.
static void printVerbosePlatformInfo(const std::vector<platform> &Platforms,
std::map<backend, size_t> &DeviceNums,
const bool SuppressNumberPrinting,
bool IsUnsupported = false) {
uint32_t PlatformNum = 0;
if (!SuppressNumberPrinting)
DeviceNums.clear();
for (const auto &Platform : Platforms) {
backend Backend = Platform.get_backend();
++PlatformNum;
auto PlatformVersion = Platform.get_info<info::platform::version>();
auto PlatformName = Platform.get_info<info::platform::name>();
auto PlatformVendor = Platform.get_info<info::platform::vendor>();
std::cout << "Platform [#" << PlatformNum << "]:" << std::endl;
std::cout << " Version : " << PlatformVersion << std::endl;
std::cout << " Name : " << PlatformName << std::endl;
std::cout << " Vendor : " << PlatformVendor << std::endl;

const auto &Devices = Platform.get_devices();
std::cout << " Devices : " << Devices.size() << std::endl;
for (const auto &Device : Devices) {
if (!SuppressNumberPrinting) {
std::cout << " Device [#" << DeviceNums[Backend]
<< "]:" << std::endl;
++DeviceNums[Backend];
}
printDeviceInfo(Device, true, " ", IsUnsupported);
}
}
}

int main(int argc, char **argv) {

if (argc == 1) {
Expand Down Expand Up @@ -428,14 +386,31 @@ int main(int argc, char **argv) {

if (verbose) {
std::cout << "\nPlatforms: " << Platforms.size() << std::endl;
printVerbosePlatformInfo(Platforms, DeviceNums, SuppressNumberPrinting);

const auto &UnsupportedPlatforms = platform::get_unsupported_platforms();
std::cout << "\nUnsupported Platforms: " << UnsupportedPlatforms.size()
<< std::endl;
printVerbosePlatformInfo(UnsupportedPlatforms, DeviceNums,
SuppressNumberPrinting, true);
std::cout << std::endl;
uint32_t PlatformNum = 0;
if (!SuppressNumberPrinting)
DeviceNums.clear();
for (const auto &Platform : Platforms) {
backend Backend = Platform.get_backend();
++PlatformNum;
auto PlatformVersion = Platform.get_info<info::platform::version>();
auto PlatformName = Platform.get_info<info::platform::name>();
auto PlatformVendor = Platform.get_info<info::platform::vendor>();
std::cout << "Platform [#" << PlatformNum << "]:" << std::endl;
std::cout << " Version : " << PlatformVersion << std::endl;
std::cout << " Name : " << PlatformName << std::endl;
std::cout << " Vendor : " << PlatformVendor << std::endl;

const auto &Devices = Platform.get_devices();
std::cout << " Devices : " << Devices.size() << std::endl;
for (const auto &Device : Devices) {
if (!SuppressNumberPrinting) {
std::cout << " Device [#" << DeviceNums[Backend]
<< "]:" << std::endl;
++DeviceNums[Backend];
}
printDeviceInfo(Device, true, " ");
}
}
} else {
return EXIT_SUCCESS;
}
Expand Down

0 comments on commit 4c223d1

Please sign in to comment.