Skip to content

Commit

Permalink
[UR][Tests] Add a parameter to select how many devices the CTS will r…
Browse files Browse the repository at this point in the history
…un on
  • Loading branch information
szadam committed Oct 24, 2023
1 parent 6469f85 commit e57a6c1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
7 changes: 5 additions & 2 deletions scripts/devcloud-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# See LICENSE.TXT
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#This script build and run CTS on devcloud

workspace=$1
compiler_c=$2
compiler_cxx=$3
Expand All @@ -28,11 +30,12 @@ cmake \
-DCMAKE_BUILD_TYPE=${build_type} \
-DUR_BUILD_TESTS=ON \
-DUR_FORMAT_CPP_STYLE=OFF \
-DUR_BUILD_ADAPTER_L0=ON
-DUR_BUILD_ADAPTER_L0=ON \
-DNUMBER_OF_DEVICES=1

cmake --build ${workspace}/build -j $(nproc)

# Temporarily disabling platform test for L0, because of hang
# See issue: #824
cd ${workspace}/build
ctest -C ${build_type} --output-on-failure -L "conformance" -E "platform-adapter_level_zero" --timeout 180 -VV
ctest -C ${build_type} --output-on-failure -L "conformance" -E "platform-adapter_level_zero" --timeout 180
3 changes: 2 additions & 1 deletion test/conformance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set(UR_CONFORMANCE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
option(NUMBER_OF_DEVICES "Liczba urządzeń do testów" 1)

function(add_test_adapter name adapter)
set(TEST_TARGET_NAME test-${name})
Expand All @@ -12,7 +13,7 @@ function(add_test_adapter name adapter)
add_test(NAME ${TEST_NAME}
COMMAND ${CMAKE_COMMAND}
-D TEST_FILE=${Python3_EXECUTABLE}
-D TEST_ARGS="${UR_CONFORMANCE_TEST_DIR}/cts_exe.py --test_command ${CMAKE_BINARY_DIR}/bin/${TEST_TARGET_NAME}"
-D TEST_ARGS="${UR_CONFORMANCE_TEST_DIR}/cts_exe.py --test_command ${CMAKE_BINARY_DIR}/bin/${TEST_TARGET_NAME} --NUMBER_OF_DEVICES=${NUMBER_OF_DEVICES}"
-D MODE=stdout
-D MATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${name}_${adapter}.match
-P ${PROJECT_SOURCE_DIR}/cmake/match.cmake
Expand Down
4 changes: 4 additions & 0 deletions test/conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ this solution will no longer be necessary.
When you fix any test, the match file must be updated
Empty match files indicate that there are no failing tests
in a particular group for the corresponding adapter.

There is an argument NUMBER_OF_DEVICES that allow you to choose
how many devices(GPU) you want to run the tests on. If you
want to run test on all available devices, set it to "0".
4 changes: 3 additions & 1 deletion test/conformance/cts_exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

parser = ArgumentParser()
parser.add_argument("--test_command", help="Ctest test case")
parser.add_argument("--NUMBER_OF_DEVICES", type=str, help="Number of devices")
args = parser.parse_args()
result = subprocess.Popen([args.test_command, '--gtest_brief=1'], stdout=subprocess.PIPE,

result = subprocess.Popen([args.test_command, '--gtest_brief=1', args.NUMBER_OF_DEVICES], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, text=True) # nosec B603

pat = re.compile(r'\[( )*FAILED( )*\]')
Expand Down
11 changes: 11 additions & 0 deletions test/conformance/source/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See LICENSE.TXT
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <algorithm>
#include <cstring>
#include <fstream>

Expand All @@ -14,6 +15,7 @@

#include <uur/environment.h>
#include <uur/utils.h>
#include <ur_util.hpp>

namespace uur {

Expand Down Expand Up @@ -199,6 +201,15 @@ DevicesEnvironment::DevicesEnvironment(int argc, char **argv)
error = "Could not find any devices associated with the platform";
return;
}
// Get the argument (NUMBER_OF_DEVICES) to run tests on the wanted number of devices
int count_set = 0;
count_set = std::atoi(argv[2]);
if (count_set < 0 || count_set > std::numeric_limits<uint32_t>::max()) {
error = "Invalid NUMBER_OF_DEVICES argument";
return;
} else if (count_set > 0) {
count = std::min(count, static_cast<uint32_t>(count_set));
}
devices.resize(count);
if (urDeviceGet(platform, UR_DEVICE_TYPE_ALL, count, devices.data(),
nullptr)) {
Expand Down

0 comments on commit e57a6c1

Please sign in to comment.