Skip to content
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

[SYCL] Add '--ignore-device-selectors' CLI option to sycl-ls and improve warning messages #12718

Merged
merged 7 commits into from
Feb 23, 2024

Conversation

uditagarwal97
Copy link
Contributor

@uditagarwal97 uditagarwal97 commented Feb 14, 2024

This PR adds a '--ignore-device-selectors' CLI option to sycl-ls that prints all platforms available in the user's system, irrespective of the DPCPP filter environment variables like ONEAPI_DEVICE_SELECTOR.

@uditagarwal97 uditagarwal97 changed the title [SYCL][DRAFT] Add '--discard-filter' CLI option to sycl-ls and improve warning messages [SYCL] Add '--discard-filter' CLI option to sycl-ls and improve warning messages Feb 15, 2024
@uditagarwal97 uditagarwal97 marked this pull request as ready for review February 15, 2024 17:55
@uditagarwal97 uditagarwal97 requested a review from a team as a code owner February 15, 2024 17:55
} else {
// Parse CLI options.
for (int i = 1; i < argc; i++) {
if (std::string(argv[i]) == "--verbose")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd do

using namespace std::literals;
if (argv[i] == "--verbose"sv)

instead.

@@ -1,3 +1,18 @@
-- Check that sycl-ls exits with 0 exit code.
-- Check that sycl-ls exits with 0 exit code.
Copy link
Contributor

Choose a reason for hiding this comment

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

That's slightly inaccurate - you're verifying the output as well.

Comment on lines 193 to 202
// Restore filter related environment variables that we unset earlier.
static void restoreFilterEnvVars() {
for (auto it : FilterEnvVars) {
#ifdef _WIN32
_putenv_s(it.first.c_str(), it.second.c_str());
#else
setenv(it.first.c_str(), it.second.c_str(), 1);
#endif
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIUC, setenv is not supported by MSVC and that's why I used _putenv_s for windows. Some other tests also use a similar approach: https://github.com/intel/llvm/blob/sycl/sycl/include/sycl/ext/intel/fpga_device_selector.hpp#L38

Copy link
Contributor

Choose a reason for hiding this comment

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

What I meant is we don't need to restore at all. sycl-ls process is going to die anywhere and its environment won't affect anyone.

Comment on lines +206 to +209
if (argc == 1) {
verbose = false;
DiscardFilters = false;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we use any command line options parsing libraries anywhere in sycl?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do use LLVM's CLI support (https://llvm.org/docs/CommandLine.html) at a couple of places but I'm not sure if we should use that here because we just have two CLI options for sycl-ls and both of them are just boolean flags.

@cperkinsintel
Copy link
Contributor

Do we really need this option? Why not just modify sycl-ls so that's what it always does? ( ie. always shows all the devices, regardless of the filter).

If there are real use cases for using ONEAPI_DEVICE_SELECTOR in conjunction with sycl-ls, then maybe this could be reversed to have a --allow-filter flag.

@uditagarwal97
Copy link
Contributor Author

Do we really need this option? Why not just modify sycl-ls so that's what it always does? ( ie. always shows all the devices, regardless of the filter).

If there are real use cases for using ONEAPI_DEVICE_SELECTOR in conjunction with sycl-ls, then maybe this could be reversed to have a --allow-filter flag.

I mostly agree with that. My only concern with changing the default behavior of sycl-ls is that it might be ABI-breaking (is it?), if we have any customer application using ONEAPI_DEVICE_SELECTOR or SYCL_DEVICE_ALLOWLIST along with sycl-ls.

@uditagarwal97
Copy link
Contributor Author

Tagging @jbrodman @gmlueck to get additional feedback regarding changing the default behavior of sycl-ls.

@gmlueck
Copy link
Contributor

gmlueck commented Feb 20, 2024

I mostly agree with that. My only concern with changing the default behavior of sycl-ls is that it might be ABI-breaking (is it?), if we have any customer application using ONEAPI_DEVICE_SELECTOR or SYCL_DEVICE_ALLOWLIST along with sycl-ls.

It would probably be safer to wait until a major release before changing the default behavior.

I think our plan is to move the handling of ONEAPI_DEVICE_SELECTOR into the unified runtime at some point, and I think the unified runtime will provide two APIs: one that retrieves the filtered device list and another that retrieves the unfiltered list. When that happens, sycl-ls can use the new API to get the unfiltered list.

Be careful with documenting this option. I presume sycl-ls will always respect Level Zero environment variables like ZE_AFFINITY_MASK, and some people might consider this a "filter".

@uditagarwal97 uditagarwal97 changed the title [SYCL] Add '--discard-filter' CLI option to sycl-ls and improve warning messages [SYCL] Add '--ignore-device-selectors' CLI option to sycl-ls and improve warning messages Feb 21, 2024
@uditagarwal97
Copy link
Contributor Author

@cperkinsintel The only thing changed since your last review is re-naming of "--discard-filters" to "--ignore-device-selectors".

The failure in pre-commit on Windows is unrelated: it looks like a driver issue on our runners. I've seen similar failures on other PRs as well: https://github.com/intel/llvm/actions/runs/7995620747/job/21837754530

Copy link
Contributor

@cperkinsintel cperkinsintel left a comment

Choose a reason for hiding this comment

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

lets go to mars!

@uditagarwal97
Copy link
Contributor Author

@intel/llvm-gatekeepers the PR is ready!

@steffenlarsen
Copy link
Contributor

Windows Gen12:

Failed Tests (8):
  SYCL :: Assert/assert_in_kernels_win.cpp
  SYCL :: Assert/assert_in_multiple_tus_one_ndebug_win.cpp
  SYCL :: Assert/assert_in_multiple_tus_win.cpp
  SYCL :: Assert/assert_in_one_kernel_win.cpp
  SYCL :: Assert/assert_in_simultaneous_kernels_win.cpp
  SYCL :: Assert/assert_in_simultaneously_multiple_tus.cpp
  SYCL :: Assert/assert_in_simultaneously_multiple_tus_one_ndebug.cpp
  SYCL :: Plugin/sycl-ls-unified-runtime.cpp

Reported in #12797 and #12798

@steffenlarsen steffenlarsen merged commit 6e3aa21 into intel:sycl Feb 23, 2024
10 of 11 checks passed
@uditagarwal97 uditagarwal97 deleted the add_sycl_ls branch March 21, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants