From 93bdb8181ed0ef535cc10971eb240b61193e87b5 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 31 Oct 2023 17:40:36 +0000 Subject: [PATCH] [CUDA][HIP] Move adapter specific testing out of CTS This patch moves the `test-adapter-cuda` and `test-adapter-hip` test suites out of the `test/conformance` directory. The goal of this move is to ensure that all adapters will be tested with the same set and number of conformance tests, making conformance pass rates directly comparable between adapters. Up to now the CUDA and HIP adapters have included additional unit tests of internals which skews pass rates. --- .github/workflows/cmake.yml | 4 ++ source/adapters/cuda/CMakeLists.txt | 2 - source/adapters/hip/CMakeLists.txt | 2 - test/CMakeLists.txt | 1 + test/adapters/CMakeLists.txt | 46 +++++++++++++++++++ test/adapters/cuda/CMakeLists.txt | 27 +++++++++++ .../adapters/cuda/context_tests.cpp | 0 .../adapters/cuda/fixtures.h | 0 .../adapters/cuda/kernel_tests.cpp | 0 .../adapters/cuda/memory_tests.cpp | 0 .../cuda/urContextGetNativeHandle.cpp | 0 .../cuda/urDeviceCreateWithNativeHandle.cpp | 0 .../adapters/cuda/urDeviceGetNativeHandle.cpp | 0 .../cuda/urEventCreateWithNativeHandle.cpp | 0 .../adapters/cuda/urEventGetNativeHandle.cpp | 0 test/adapters/hip/CMakeLists.txt | 29 ++++++++++++ .../{conformance => }/adapters/hip/fixtures.h | 0 .../adapters/hip/test_context.cpp | 0 .../adapters/hip/urContextGetNativeHandle.cpp | 0 .../adapters/hip/urDeviceGetNativeHandle.cpp | 0 .../adapters/hip/urEventGetNativeHandle.cpp | 0 test/conformance/CMakeLists.txt | 39 +++++++--------- test/conformance/adapters/CMakeLists.txt | 12 ----- test/conformance/adapters/cuda/CMakeLists.txt | 24 ---------- test/conformance/adapters/hip/CMakeLists.txt | 26 ----------- 25 files changed, 123 insertions(+), 89 deletions(-) create mode 100644 test/adapters/CMakeLists.txt create mode 100644 test/adapters/cuda/CMakeLists.txt rename test/{conformance => }/adapters/cuda/context_tests.cpp (100%) rename test/{conformance => }/adapters/cuda/fixtures.h (100%) rename test/{conformance => }/adapters/cuda/kernel_tests.cpp (100%) rename test/{conformance => }/adapters/cuda/memory_tests.cpp (100%) rename test/{conformance => }/adapters/cuda/urContextGetNativeHandle.cpp (100%) rename test/{conformance => }/adapters/cuda/urDeviceCreateWithNativeHandle.cpp (100%) rename test/{conformance => }/adapters/cuda/urDeviceGetNativeHandle.cpp (100%) rename test/{conformance => }/adapters/cuda/urEventCreateWithNativeHandle.cpp (100%) rename test/{conformance => }/adapters/cuda/urEventGetNativeHandle.cpp (100%) create mode 100644 test/adapters/hip/CMakeLists.txt rename test/{conformance => }/adapters/hip/fixtures.h (100%) rename test/{conformance => }/adapters/hip/test_context.cpp (100%) rename test/{conformance => }/adapters/hip/urContextGetNativeHandle.cpp (100%) rename test/{conformance => }/adapters/hip/urDeviceGetNativeHandle.cpp (100%) rename test/{conformance => }/adapters/hip/urEventGetNativeHandle.cpp (100%) delete mode 100644 test/conformance/adapters/CMakeLists.txt delete mode 100644 test/conformance/adapters/cuda/CMakeLists.txt delete mode 100644 test/conformance/adapters/hip/CMakeLists.txt diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9edbd459d7..0a2684462d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -203,6 +203,10 @@ jobs: run: LD_LIBRARY_PATH=${{github.workspace}}/dpcpp_compiler/lib cmake --build ${{github.workspace}}/build -j $(nproc) + - name: Test adapter specific + working-directory: ${{github.workspace}}/build + run: ctest -C ${{matrix.build_type}} --output-on-failure -L "adapter-specific" --timeout 180 + # Temporarily disabling platform test for L0, because of hang # See issue: #824 - name: Test L0 adapter diff --git a/source/adapters/cuda/CMakeLists.txt b/source/adapters/cuda/CMakeLists.txt index 0b44ae0777..4a8c1d1f59 100644 --- a/source/adapters/cuda/CMakeLists.txt +++ b/source/adapters/cuda/CMakeLists.txt @@ -3,8 +3,6 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(CUDA_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "CUDA adapter directory") - set(TARGET_NAME ur_adapter_cuda) add_ur_adapter(${TARGET_NAME} diff --git a/source/adapters/hip/CMakeLists.txt b/source/adapters/hip/CMakeLists.txt index 4595bfbf84..7de1b5f501 100644 --- a/source/adapters/hip/CMakeLists.txt +++ b/source/adapters/hip/CMakeLists.txt @@ -3,8 +3,6 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(HIP_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "HIP adapter directory") - set(TARGET_NAME ur_adapter_hip) # Set default UR HIP platform to AMD diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1d7e84f0c3..49e13eb869 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,6 +16,7 @@ enable_testing() add_subdirectory(python) add_subdirectory(loader) +add_subdirectory(adapters) add_subdirectory(conformance) add_subdirectory(unified_malloc_framework) add_subdirectory(usm) diff --git a/test/adapters/CMakeLists.txt b/test/adapters/CMakeLists.txt new file mode 100644 index 0000000000..d87d774ede --- /dev/null +++ b/test/adapters/CMakeLists.txt @@ -0,0 +1,46 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +function(add_adapter_test name) + cmake_parse_arguments(args + "" # options + "FIXTURE" # one value keywords + "SOURCES;ENVIRONMENT" # multi value keywords + ${ARGN}) + + set(target test-adapter-${name}) + add_ur_executable(${target} ${args_SOURCES} + ${PROJECT_SOURCE_DIR}/test/conformance/source/environment.cpp + ${PROJECT_SOURCE_DIR}/test/conformance/source/main.cpp + ) + + set(fixtures "PLATFORM;DEVICES;KERNELS") + if(NOT args_FIXTURE IN_LIST fixtures) + message(FATAL_ERROR + "FIXTURE must be one of: ${fixtures}. Found: ${args_FIXTURE}") + endif() + + target_compile_definitions(${target} PRIVATE + ${args_FIXTURE}_ENVIRONMENT) + target_link_libraries(${target} PRIVATE + ${PROJECT_NAME}::loader + ${PROJECT_NAME}::headers + ${PROJECT_NAME}::testing + ${PROJECT_NAME}::common + GTest::gtest) + + add_test(NAME ${target} COMMAND $) + set_tests_properties(${target} PROPERTIES + LABELS "adapter-specific;${name}" + ENVIRONMENT "${args_ENVIRONMENT}") +endfunction() + +if(UR_BUILD_ADAPTER_CUDA) + add_subdirectory(cuda) +endif() + +if(UR_BUILD_ADAPTER_HIP) + add_subdirectory(hip) +endif() diff --git a/test/adapters/cuda/CMakeLists.txt b/test/adapters/cuda/CMakeLists.txt new file mode 100644 index 0000000000..fbc15b47e8 --- /dev/null +++ b/test/adapters/cuda/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_adapter_test(cuda + FIXTURE DEVICES + SOURCES + fixtures.h + context_tests.cpp + urContextGetNativeHandle.cpp + urDeviceGetNativeHandle.cpp + urDeviceCreateWithNativeHandle.cpp + urEventGetNativeHandle.cpp + urEventCreateWithNativeHandle.cpp + kernel_tests.cpp + memory_tests.cpp + ENVIRONMENT + "UR_ADAPTERS_FORCE_LOAD=\"$\"" +) + +target_include_directories(test-adapter-cuda PRIVATE + ${PROJECT_SOURCE_DIR}/source + ${PROJECT_SOURCE_DIR}/source/adapters/cuda +) + +target_link_libraries(test-adapter-cuda PRIVATE cudadrv) diff --git a/test/conformance/adapters/cuda/context_tests.cpp b/test/adapters/cuda/context_tests.cpp similarity index 100% rename from test/conformance/adapters/cuda/context_tests.cpp rename to test/adapters/cuda/context_tests.cpp diff --git a/test/conformance/adapters/cuda/fixtures.h b/test/adapters/cuda/fixtures.h similarity index 100% rename from test/conformance/adapters/cuda/fixtures.h rename to test/adapters/cuda/fixtures.h diff --git a/test/conformance/adapters/cuda/kernel_tests.cpp b/test/adapters/cuda/kernel_tests.cpp similarity index 100% rename from test/conformance/adapters/cuda/kernel_tests.cpp rename to test/adapters/cuda/kernel_tests.cpp diff --git a/test/conformance/adapters/cuda/memory_tests.cpp b/test/adapters/cuda/memory_tests.cpp similarity index 100% rename from test/conformance/adapters/cuda/memory_tests.cpp rename to test/adapters/cuda/memory_tests.cpp diff --git a/test/conformance/adapters/cuda/urContextGetNativeHandle.cpp b/test/adapters/cuda/urContextGetNativeHandle.cpp similarity index 100% rename from test/conformance/adapters/cuda/urContextGetNativeHandle.cpp rename to test/adapters/cuda/urContextGetNativeHandle.cpp diff --git a/test/conformance/adapters/cuda/urDeviceCreateWithNativeHandle.cpp b/test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp similarity index 100% rename from test/conformance/adapters/cuda/urDeviceCreateWithNativeHandle.cpp rename to test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp diff --git a/test/conformance/adapters/cuda/urDeviceGetNativeHandle.cpp b/test/adapters/cuda/urDeviceGetNativeHandle.cpp similarity index 100% rename from test/conformance/adapters/cuda/urDeviceGetNativeHandle.cpp rename to test/adapters/cuda/urDeviceGetNativeHandle.cpp diff --git a/test/conformance/adapters/cuda/urEventCreateWithNativeHandle.cpp b/test/adapters/cuda/urEventCreateWithNativeHandle.cpp similarity index 100% rename from test/conformance/adapters/cuda/urEventCreateWithNativeHandle.cpp rename to test/adapters/cuda/urEventCreateWithNativeHandle.cpp diff --git a/test/conformance/adapters/cuda/urEventGetNativeHandle.cpp b/test/adapters/cuda/urEventGetNativeHandle.cpp similarity index 100% rename from test/conformance/adapters/cuda/urEventGetNativeHandle.cpp rename to test/adapters/cuda/urEventGetNativeHandle.cpp diff --git a/test/adapters/hip/CMakeLists.txt b/test/adapters/hip/CMakeLists.txt new file mode 100644 index 0000000000..3496f71bd0 --- /dev/null +++ b/test/adapters/hip/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright (C) 2023 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_adapter_test(hip + FIXTURE DEVICES + SOURCES + fixtures.h + urContextGetNativeHandle.cpp + urDeviceGetNativeHandle.cpp + urEventGetNativeHandle.cpp + test_context.cpp + ENVIRONMENT + "UR_ADAPTERS_FORCE_LOAD=\"$\"" +) + +target_include_directories(test-adapter-hip PRIVATE + ${PROJECT_SOURCE_DIR}/source + ${PROJECT_SOURCE_DIR}/source/adapters/hip +) + +get_target_property(HIP_COMPILE_DEFINITIONS + ur_adapter_hip COMPILE_DEFINITIONS) +target_compile_definitions(test-adapter-hip PRIVATE + ${HIP_COMPILE_DEFINITIONS} +) + +target_link_libraries(test-adapter-hip PRIVATE rocmdrv) diff --git a/test/conformance/adapters/hip/fixtures.h b/test/adapters/hip/fixtures.h similarity index 100% rename from test/conformance/adapters/hip/fixtures.h rename to test/adapters/hip/fixtures.h diff --git a/test/conformance/adapters/hip/test_context.cpp b/test/adapters/hip/test_context.cpp similarity index 100% rename from test/conformance/adapters/hip/test_context.cpp rename to test/adapters/hip/test_context.cpp diff --git a/test/conformance/adapters/hip/urContextGetNativeHandle.cpp b/test/adapters/hip/urContextGetNativeHandle.cpp similarity index 100% rename from test/conformance/adapters/hip/urContextGetNativeHandle.cpp rename to test/adapters/hip/urContextGetNativeHandle.cpp diff --git a/test/conformance/adapters/hip/urDeviceGetNativeHandle.cpp b/test/adapters/hip/urDeviceGetNativeHandle.cpp similarity index 100% rename from test/conformance/adapters/hip/urDeviceGetNativeHandle.cpp rename to test/adapters/hip/urDeviceGetNativeHandle.cpp diff --git a/test/conformance/adapters/hip/urEventGetNativeHandle.cpp b/test/adapters/hip/urEventGetNativeHandle.cpp similarity index 100% rename from test/conformance/adapters/hip/urEventGetNativeHandle.cpp rename to test/adapters/hip/urEventGetNativeHandle.cpp diff --git a/test/conformance/CMakeLists.txt b/test/conformance/CMakeLists.txt index e90b74f4cd..9a273470eb 100644 --- a/test/conformance/CMakeLists.txt +++ b/test/conformance/CMakeLists.txt @@ -39,28 +39,22 @@ function(add_conformance_test name) ${PROJECT_NAME}::common GTest::gtest_main) - if(USE_LOCAL_TEST_CONFIGURATION) - add_test(NAME ${name} - COMMAND ${TEST_TARGET_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - else() - if(UR_BUILD_ADAPTER_CUDA) - add_test_adapter(${name} adapter_cuda) - endif() - if(UR_BUILD_ADAPTER_HIP) - add_test_adapter(${name} adapter_hip) - endif() - if(UR_BUILD_ADAPTER_L0) - add_test_adapter(${name} adapter_level_zero) - endif() - if(UR_BUILD_ADAPTER_OPENCL) - add_test_adapter(${name} adapter_opencl) - endif() - - if(NOT (UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_HIP - OR UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_OPENCL)) - add_test_adapter(${name} adapter_null) - endif() + if(UR_BUILD_ADAPTER_CUDA) + add_test_adapter(${name} adapter_cuda) + endif() + if(UR_BUILD_ADAPTER_HIP) + add_test_adapter(${name} adapter_hip) + endif() + if(UR_BUILD_ADAPTER_L0) + add_test_adapter(${name} adapter_level_zero) + endif() + if(UR_BUILD_ADAPTER_OPENCL) + add_test_adapter(${name} adapter_opencl) + endif() + + if(NOT (UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_HIP + OR UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_OPENCL)) + add_test_adapter(${name} adapter_null) endif() endfunction() @@ -83,7 +77,6 @@ function(add_conformance_test_with_platform_environment name) endfunction() add_subdirectory(testing) -add_subdirectory(adapters) add_subdirectory(runtime) add_subdirectory(platform) diff --git a/test/conformance/adapters/CMakeLists.txt b/test/conformance/adapters/CMakeLists.txt deleted file mode 100644 index 84e61864c9..0000000000 --- a/test/conformance/adapters/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (C) 2023 Intel Corporation -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -if(UR_BUILD_ADAPTER_CUDA) - add_subdirectory(cuda) -endif() - -if(UR_BUILD_ADAPTER_HIP) - add_subdirectory(hip) -endif() diff --git a/test/conformance/adapters/cuda/CMakeLists.txt b/test/conformance/adapters/cuda/CMakeLists.txt deleted file mode 100644 index 8b060686cf..0000000000 --- a/test/conformance/adapters/cuda/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) 2023 Intel Corporation -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -set(USE_LOCAL_TEST_CONFIGURATION ON) -add_conformance_test_with_devices_environment(adapter-cuda - fixtures.h - context_tests.cpp - urContextGetNativeHandle.cpp - urDeviceGetNativeHandle.cpp - urDeviceCreateWithNativeHandle.cpp - urEventGetNativeHandle.cpp - urEventCreateWithNativeHandle.cpp - kernel_tests.cpp - memory_tests.cpp -) -target_link_libraries(test-adapter-cuda PRIVATE cudadrv ur_adapter_cuda) -target_include_directories(test-adapter-cuda PRIVATE ${CUDA_DIR} "${CUDA_DIR}/../../" ) - -set_tests_properties(adapter-cuda PROPERTIES - LABELS "conformance:cuda" - ENVIRONMENT "UR_ADAPTERS_FORCE_LOAD=\"$\"" - ) diff --git a/test/conformance/adapters/hip/CMakeLists.txt b/test/conformance/adapters/hip/CMakeLists.txt deleted file mode 100644 index 1e40639d21..0000000000 --- a/test/conformance/adapters/hip/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (C) 2023 Intel Corporation -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -set(USE_LOCAL_TEST_CONFIGURATION ON) -add_conformance_test_with_devices_environment(adapter-hip - fixtures.h - urContextGetNativeHandle.cpp - urDeviceGetNativeHandle.cpp - urEventGetNativeHandle.cpp - test_context.cpp -) -target_link_libraries(test-adapter-hip PRIVATE rocmdrv) -target_include_directories(test-adapter-hip PRIVATE ${HIP_DIR} "${HIP_DIR}/../../") - -if(UR_HIP_PLATFORM STREQUAL "AMD") - target_compile_definitions(test-adapter-hip PRIVATE __HIP_PLATFORM_AMD__) -else() - target_compile_definitions(test-adapter-hip PRIVATE __HIP_PLATFORM_NVIDIA__) -endif() - -set_tests_properties(adapter-hip PROPERTIES - LABELS "conformance:hip" - ENVIRONMENT "UR_ADAPTERS_FORCE_LOAD=\"$\"" -)