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

[UR][Tests] Add CTS options to set platforms and devices. #1085

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

szadam
Copy link
Contributor

@szadam szadam commented Nov 16, 2023

Add CTS options to set test platform name or test platforms count and test device name or test devices count.
Create CMake options for running CTS with limited devices count and platforms count.

@szadam szadam requested a review from a team as a code owner November 16, 2023 09:23
// Get the argument (test_devices_count) to limit test devices count.
u_long count_set = 0;
if (argc >= 3) {
count_set = std::strtoul(argv[2], nullptr, 10);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this always the second argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It depends on cts_exe.py scripts. In this case, it will always be the second argument.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but the gtest binary may be executed manually, the script can change etc. You shouldn't be hard-coding such assumptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed it. What about that?


To limit how many devices you want to run the CTS on,
use CMake option UR_TEST_DEVICES_COUNT. If you want to run

Choose a reason for hiding this comment

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

could we make it a runtime option instead of a CMAKE one? imagine the case where users have the binaries for the CTS, and have different types of systems (single CPU, 4xGPU, CPU + 2xGPU, etc). They would have to build the binaries for each configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we could change it in the next step.

Choose a reason for hiding this comment

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

thanks @szadam . could you share why it couldn't be done as part of this PR? Main reason I'm asking is because I have already run into this problem, where I was running the tests in a multi-device system, and it took me a while to figure out the issue was that the tests were built only for 1 device, so I would expect more people to run into the same problem, so addressing sooner would be great.

Copy link
Contributor

Choose a reason for hiding this comment

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

if you run the tests directly through their binary, you can use the --test_devices_count 1 cli option that @szadam is adding. If you are using ctest, this patch will automatically reduce the number of devices it will run with to 1. You don't need to set the cmake option.

There's another patch that @szadam is working on, #992, that will solve the broader problem of devices/platforms having the same names.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think what @jandres742 is proposing is implemented for OpenCL patch (here: https://github.com/oneapi-src/unified-runtime/pull/993/files#diff-d1f50b1ed696f085259b2a9c7d274ae3414700a1cea60f9945677cdae39e25cfR186) and it looks neat as well. The CMake option, though, has, I think, the added value (as Piotr mentioned) that it sets the default value of 1 and still can be overridden with the CLI param.

BTW, Adam has a new version (still on a private branch; to be polished): szadam@ef74282#diff-d1f50b1ed696f085259b2a9c7d274ae3414700a1cea60f9945677cdae39e25cf

Choose a reason for hiding this comment

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

thanks @pbalcer and @lukaszstolarczuk for the details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the late response. I am preparing a new solution/version as Lukas said. I will push it today.

@szadam szadam force-pushed the limit_devices_count branch 2 times, most recently from c85bf47 to 1db5146 Compare November 21, 2023 09:19
@@ -199,6 +201,22 @@ DevicesEnvironment::DevicesEnvironment(int argc, char **argv)
error = "Could not find any devices associated with the platform";
return;
}
// Get the argument (test_devices_count) to limit test devices count.
u_long count_set = 0;
for (int i = 1; i < argc; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for (int i = 1; i < argc; ++i) {
for (int i = 1; i < argc - 1; ++i) {

and drop the && i + 1 < argc in the if below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. It will work too.

@jandres742
Copy link

+1

@szadam szadam marked this pull request as ready for review November 28, 2023 20:45
@szadam szadam force-pushed the limit_devices_count branch 2 times, most recently from 7874c1c to 6a0f1d9 Compare November 29, 2023 00:01
@szadam szadam changed the title [UR][Tests] Add a CMake option to limit the test devices count in CTS [UR][Tests] Add CTS options to set platforms and devices. Nov 29, 2023
@@ -4,6 +4,8 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set(UR_CONFORMANCE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
option(UR_TEST_DEVICES_COUNT "Count of devices on which CTS will be run" 1)
option(UR_TEST_PLATFORMS_COUNT "Count of platform on which CTS will be run" 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

platforms (plural)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

all available devices/platforms, set 0. The default value is 1.
If you run binaries for the tests, you can use the parameter
`--platforms_count=COUNT/--devices_count=COUNT`.
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps split this code into two, like:

...you can use the parameter --platforms... or --devices....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

`--platforms_count=COUNT/--devices_count=COUNT`.
To set test device/platform name you want to run the CTS on, use
parameter `--platform=NAME/--device=NAME`.
Copy link
Contributor

Choose a reason for hiding this comment

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

same here - split the code block into two

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

`--platforms_count=COUNT/--devices_count=COUNT`.
To set test device/platform name you want to run the CTS on, use
parameter `--platform=NAME/--device=NAME`.
Copy link
Contributor

Choose a reason for hiding this comment

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

as discussed, what if two platforms have the same name...? (e.g. "CUDA BACKEND" as the name of the platform 😉 ). Perhaps it's not something we want to solve in this PR, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now, the tests are not adapted to be run on multiple platforms. They would require major modifications, which are not part of this PR. In the case where we have two platforms or devices with the same name, we should simply set their counter to 1, just set their counter to 1 for the tests to pass without any problem.

@@ -20,9 +20,13 @@

parser = ArgumentParser()
parser.add_argument("--test_command", help="Ctest test case")
parser.add_argument("--test_devices_count", type=str, help="Number of devices on which tests will be run")
parser.add_argument("--test_platforms_count", type=str, help="Number of devices on which tests will be run")
Copy link
Contributor

Choose a reason for hiding this comment

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

copy-pasted description, pls adjust

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@fabiomestre fabiomestre changed the base branch from adapters to main December 5, 2023 16:49
@fabiomestre
Copy link
Contributor

I have updated the target branch of this PR from the adapters branch to the main branch.
Development in UR is moving back to main. The adapters branch will soon be deleted.

szadam and others added 2 commits December 6, 2023 10:33
@pbalcer pbalcer merged commit 861d95d into oneapi-src:main Dec 7, 2023
51 checks passed
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.

6 participants