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/examples/codegen/CMakeLists.txt b/examples/codegen/CMakeLists.txt index ddaabcc34f..4896d3a721 100644 --- a/examples/codegen/CMakeLists.txt +++ b/examples/codegen/CMakeLists.txt @@ -43,5 +43,5 @@ if(LLVM_FOUND AND PkgConfig_FOUND AND LLVMSPIRVLib_FOUND) ) endif() else() - message(STATUS "The environment did not satisfy dependency requirements (LLVM, PkgConfig, LLVMSPIRVLib) for codegen example (skipping target).") + message(FATAL_ERROR "The environment did not satisfy dependency requirements (LLVM, PkgConfig, LLVMSPIRVLib) for codegen example (skipping target).") endif() diff --git a/scripts/generate_code.py b/scripts/generate_code.py index a6436f2a0a..9c427c3780 100644 --- a/scripts/generate_code.py +++ b/scripts/generate_code.py @@ -315,6 +315,25 @@ def _mako_info_hpp(path, namespace, tags, version, specs, meta): specs=specs, meta=meta) +""" +Entry-point: + generates linker version scripts +""" +def _mako_linker_scripts(path, ext, namespace, tags, version, specs, meta): + name = "adapter" + filename = f"{name}.{ext}.in" + fin = os.path.join(templates_dir, f"{filename}.mako") + fout = os.path.join(path, filename) + print("Generating %s..." % fout) + return util.makoWrite( + fin, fout, + name=name, + ver=version, + namespace=namespace, + tags=tags, + specs=specs, + meta=meta) + """ Entry-point: generates lib code @@ -349,6 +368,8 @@ def generate_adapters(path, section, namespace, tags, version, specs, meta): loc = 0 loc += _mako_null_adapter_cpp(dstpath, namespace, tags, version, specs, meta) + loc += _mako_linker_scripts(dstpath, "map", namespace, tags, version, specs, meta) + loc += _mako_linker_scripts(dstpath, "def", namespace, tags, version, specs, meta) print("Generated %s lines of code.\n"%loc) """ diff --git a/scripts/templates/adapter.def.in.mako b/scripts/templates/adapter.def.in.mako new file mode 100644 index 0000000000..7304682440 --- /dev/null +++ b/scripts/templates/adapter.def.in.mako @@ -0,0 +1,11 @@ +<%! +import re +from templates import helper as th +%><% + n=namespace +%>\ +LIBRARY @TARGET_LIBNAME@ +EXPORTS +%for tbl in th.get_pfntables(specs, meta, n, tags): + ${tbl['export']['name']} +%endfor diff --git a/scripts/templates/adapter.map.in.mako b/scripts/templates/adapter.map.in.mako new file mode 100644 index 0000000000..d03871f867 --- /dev/null +++ b/scripts/templates/adapter.map.in.mako @@ -0,0 +1,14 @@ +<%! +import re +from templates import helper as th +%><% + n=namespace +%>\ +@TARGET_LIBNAME@ { + global: +%for tbl in th.get_pfntables(specs, meta, n, tags): + ${tbl['export']['name']}; +%endfor + local: + *; +}; diff --git a/source/adapters/adapter.def.in b/source/adapters/adapter.def.in index bfe14a6a03..de0b4fa8ee 100644 --- a/source/adapters/adapter.def.in +++ b/source/adapters/adapter.def.in @@ -1,12 +1,11 @@ LIBRARY @TARGET_LIBNAME@ EXPORTS + urGetGlobalProcAddrTable urGetBindlessImagesExpProcAddrTable urGetCommandBufferExpProcAddrTable urGetContextProcAddrTable - urGetDeviceProcAddrTable urGetEnqueueProcAddrTable urGetEventProcAddrTable - urGetGlobalProcAddrTable urGetKernelProcAddrTable urGetMemProcAddrTable urGetPhysicalMemProcAddrTable @@ -14,7 +13,8 @@ EXPORTS urGetProgramProcAddrTable urGetQueueProcAddrTable urGetSamplerProcAddrTable + urGetUSMProcAddrTable urGetUSMExpProcAddrTable urGetUsmP2PExpProcAddrTable - urGetUSMProcAddrTable urGetVirtualMemProcAddrTable + urGetDeviceProcAddrTable diff --git a/source/adapters/adapter.map.in b/source/adapters/adapter.map.in index cbb5c6c4cb..4379e1f7de 100644 --- a/source/adapters/adapter.map.in +++ b/source/adapters/adapter.map.in @@ -1,12 +1,11 @@ @TARGET_LIBNAME@ { global: + urGetGlobalProcAddrTable; urGetBindlessImagesExpProcAddrTable; urGetCommandBufferExpProcAddrTable; urGetContextProcAddrTable; - urGetDeviceProcAddrTable; urGetEnqueueProcAddrTable; urGetEventProcAddrTable; - urGetGlobalProcAddrTable; urGetKernelProcAddrTable; urGetMemProcAddrTable; urGetPhysicalMemProcAddrTable; @@ -14,10 +13,11 @@ urGetProgramProcAddrTable; urGetQueueProcAddrTable; urGetSamplerProcAddrTable; + urGetUSMProcAddrTable; urGetUSMExpProcAddrTable; urGetUsmP2PExpProcAddrTable; - urGetUSMProcAddrTable; urGetVirtualMemProcAddrTable; + urGetDeviceProcAddrTable; local: *; }; 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/cuda/device.cpp b/source/adapters/cuda/device.cpp index 76984ca744..a4877236ae 100644 --- a/source/adapters/cuda/device.cpp +++ b/source/adapters/cuda/device.cpp @@ -501,12 +501,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue( static_cast(hDevice->getMaxChosenLocalMem())); } else { - int LocalMemSize = 0; - UR_CHECK_ERROR(cuDeviceGetAttribute( - &LocalMemSize, CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK, - hDevice->get())); - detail::ur::assertion(LocalMemSize >= 0); - return ReturnValue(static_cast(LocalMemSize)); + return ReturnValue( + static_cast(hDevice->getMaxCapacityLocalMem())); } } case UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT: { diff --git a/source/adapters/cuda/device.hpp b/source/adapters/cuda/device.hpp index 919f813e4e..5ad70672e9 100644 --- a/source/adapters/cuda/device.hpp +++ b/source/adapters/cuda/device.hpp @@ -45,6 +45,9 @@ struct ur_device_handle_t_ { UR_CHECK_ERROR(cuDeviceGetAttribute( &MaxRegsPerBlock, CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK, cuDevice)); + UR_CHECK_ERROR(cuDeviceGetAttribute( + &MaxCapacityLocalMem, + CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN, cuDevice)); // Set local mem max size if env var is present static const char *LocalMemSizePtrUR = @@ -56,9 +59,6 @@ struct ur_device_handle_t_ { : (LocalMemSizePtrPI ? LocalMemSizePtrPI : nullptr); if (LocalMemSizePtr) { - cuDeviceGetAttribute( - &MaxCapacityLocalMem, - CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK_OPTIN, cuDevice); MaxChosenLocalMem = std::atoi(LocalMemSizePtr); MaxLocalMemSizeChosen = true; } diff --git a/source/adapters/cuda/enqueue.cpp b/source/adapters/cuda/enqueue.cpp index 6e6515908e..5761f24e0a 100644 --- a/source/adapters/cuda/enqueue.cpp +++ b/source/adapters/cuda/enqueue.cpp @@ -284,9 +284,15 @@ setKernelParams(const ur_context_handle_t Context, CudaImplicitOffset); } - if (Context->getDevice()->maxLocalMemSizeChosen()) { + auto Device = Context->getDevice(); + if (LocalSize > static_cast(Device->getMaxCapacityLocalMem())) { + setErrorMessage("Excessive allocation of local memory on the device", + UR_RESULT_ERROR_ADAPTER_SPECIFIC); + return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + } + + if (Device->maxLocalMemSizeChosen()) { // Set up local memory requirements for kernel. - auto Device = Context->getDevice(); if (Device->getMaxChosenLocalMem() < 0) { bool EnvVarHasURPrefix = std::getenv("UR_CUDA_MAX_LOCAL_MEM_SIZE") != nullptr; @@ -297,11 +303,6 @@ setKernelParams(const ur_context_handle_t Context, UR_RESULT_ERROR_ADAPTER_SPECIFIC); return UR_RESULT_ERROR_ADAPTER_SPECIFIC; } - if (LocalSize > static_cast(Device->getMaxCapacityLocalMem())) { - setErrorMessage("Too much local memory allocated for device", - UR_RESULT_ERROR_ADAPTER_SPECIFIC); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; - } if (LocalSize > static_cast(Device->getMaxChosenLocalMem())) { bool EnvVarHasURPrefix = std::getenv("UR_CUDA_MAX_LOCAL_MEM_SIZE") != nullptr; @@ -319,6 +320,10 @@ setKernelParams(const ur_context_handle_t Context, UR_CHECK_ERROR(cuFuncSetAttribute( CuFunc, CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES, Device->getMaxChosenLocalMem())); + + } else { + UR_CHECK_ERROR(cuFuncSetAttribute( + CuFunc, CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES, LocalSize)); } } catch (ur_result_t Err) { 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/source/adapters/opencl/adapter.cpp b/source/adapters/opencl/adapter.cpp index 10713b9ff9..65c5676bf9 100644 --- a/source/adapters/opencl/adapter.cpp +++ b/source/adapters/opencl/adapter.cpp @@ -12,21 +12,17 @@ struct ur_adapter_handle_t_ { std::atomic RefCount = 0; + std::mutex Mutex; }; ur_adapter_handle_t_ adapter{}; UR_APIEXPORT ur_result_t UR_APICALL urInit(ur_device_init_flags_t, ur_loader_config_handle_t) { - cl_ext::ExtFuncPtrCache = new cl_ext::ExtFuncPtrCacheT(); return UR_RESULT_SUCCESS; } UR_APIEXPORT ur_result_t UR_APICALL urTearDown(void *) { - if (cl_ext::ExtFuncPtrCache) { - delete cl_ext::ExtFuncPtrCache; - cl_ext::ExtFuncPtrCache = nullptr; - } return UR_RESULT_SUCCESS; } @@ -34,6 +30,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGet(uint32_t NumEntries, ur_adapter_handle_t *phAdapters, uint32_t *pNumAdapters) { if (NumEntries > 0 && phAdapters) { + std::lock_guard Lock{adapter.Mutex}; + if (adapter.RefCount++ == 0) { + cl_ext::ExtFuncPtrCache = std::make_unique(); + } + *phAdapters = &adapter; } @@ -50,7 +51,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterRetain(ur_adapter_handle_t) { } UR_APIEXPORT ur_result_t UR_APICALL urAdapterRelease(ur_adapter_handle_t) { - --adapter.RefCount; + std::lock_guard Lock{adapter.Mutex}; + if (--adapter.RefCount == 0) { + cl_ext::ExtFuncPtrCache.reset(); + } return UR_RESULT_SUCCESS; } diff --git a/source/adapters/opencl/common.hpp b/source/adapters/opencl/common.hpp index 926c9988f3..aa1f39bd4c 100644 --- a/source/adapters/opencl/common.hpp +++ b/source/adapters/opencl/common.hpp @@ -272,7 +272,7 @@ struct ExtFuncPtrCacheT { // piTeardown to avoid issues with static destruction order (a user application // might have static objects that indirectly access this cache in their // destructor). -inline ExtFuncPtrCacheT *ExtFuncPtrCache; +inline std::unique_ptr ExtFuncPtrCache; // USM helper function to get an extension function pointer template diff --git a/source/adapters/opencl/enqueue.cpp b/source/adapters/opencl/enqueue.cpp index 29c5ad672e..5f41878182 100644 --- a/source/adapters/opencl/enqueue.cpp +++ b/source/adapters/opencl/enqueue.cpp @@ -350,9 +350,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueReadHostPipe( return mapCLErrorToUR(CLErr); } - clEnqueueReadHostPipeINTEL_fn FuncPtr = nullptr; + cl_ext::clEnqueueReadHostPipeINTEL_fn FuncPtr = nullptr; ur_result_t RetVal = - cl_ext::getExtFuncFromContext( + cl_ext::getExtFuncFromContext( CLContext, cl_ext::ExtFuncPtrCache->clEnqueueReadHostPipeINTELCache, cl_ext::EnqueueReadHostPipeName, &FuncPtr); @@ -382,9 +382,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueWriteHostPipe( return mapCLErrorToUR(CLErr); } - clEnqueueWriteHostPipeINTEL_fn FuncPtr = nullptr; + cl_ext::clEnqueueWriteHostPipeINTEL_fn FuncPtr = nullptr; ur_result_t RetVal = - cl_ext::getExtFuncFromContext( + cl_ext::getExtFuncFromContext( CLContext, cl_ext::ExtFuncPtrCache->clEnqueueWriteHostPipeINTELCache, cl_ext::EnqueueWriteHostPipeName, &FuncPtr); diff --git a/source/adapters/opencl/kernel.cpp b/source/adapters/opencl/kernel.cpp index 80b1502854..fdc4e84b87 100644 --- a/source/adapters/opencl/kernel.cpp +++ b/source/adapters/opencl/kernel.cpp @@ -9,6 +9,8 @@ //===----------------------------------------------------------------------===// #include "common.hpp" +#include + UR_APIEXPORT ur_result_t UR_APICALL urKernelCreate(ur_program_handle_t hProgram, const char *pKernelName, ur_kernel_handle_t *phKernel) { diff --git a/source/adapters/opencl/program.cpp b/source/adapters/opencl/program.cpp index 0beca23dab..7f46b52cfa 100644 --- a/source/adapters/opencl/program.cpp +++ b/source/adapters/opencl/program.cpp @@ -316,20 +316,58 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramSetSpecializationConstants( CL_RETURN_ON_FAILURE(clGetProgramInfo(CLProg, CL_PROGRAM_CONTEXT, sizeof(Ctx), &Ctx, &RetSize)); - cl_ext::clSetProgramSpecializationConstant_fn F = nullptr; - const ur_result_t URResult = cl_ext::getExtFuncFromContext( - Ctx, cl_ext::ExtFuncPtrCache->clSetProgramSpecializationConstantCache, - cl_ext::SetProgramSpecializationConstantName, &F); + std::unique_ptr> DevicesInCtx; + cl_adapter::getDevicesFromContext(cl_adapter::cast(Ctx), + DevicesInCtx); - if (URResult != UR_RESULT_SUCCESS) { - return URResult; - } + cl_platform_id CurPlatform; + clGetDeviceInfo((*DevicesInCtx)[0], CL_DEVICE_PLATFORM, + sizeof(cl_platform_id), &CurPlatform, nullptr); + + oclv::OpenCLVersion PlatVer; + cl_adapter::getPlatformVersion(CurPlatform, PlatVer); + + bool UseExtensionLookup = false; + if (PlatVer < oclv::V2_2) { + UseExtensionLookup = true; + } else { + for (cl_device_id Dev : *DevicesInCtx) { + oclv::OpenCLVersion DevVer; - for (uint32_t i = 0; i < count; ++i) { - CL_RETURN_ON_FAILURE(F(CLProg, pSpecConstants[i].id, pSpecConstants[i].size, - pSpecConstants[i].pValue)); + cl_adapter::getDeviceVersion(Dev, DevVer); + + if (DevVer < oclv::V2_2) { + UseExtensionLookup = true; + break; + } + } } + if (UseExtensionLookup == false) { + for (uint32_t i = 0; i < count; ++i) { + CL_RETURN_ON_FAILURE(clSetProgramSpecializationConstant( + CLProg, pSpecConstants[i].id, pSpecConstants[i].size, + pSpecConstants[i].pValue)); + } + } else { + cl_ext::clSetProgramSpecializationConstant_fn + SetProgramSpecializationConstant = nullptr; + const ur_result_t URResult = cl_ext::getExtFuncFromContext< + decltype(SetProgramSpecializationConstant)>( + Ctx, cl_ext::ExtFuncPtrCache->clSetProgramSpecializationConstantCache, + cl_ext::SetProgramSpecializationConstantName, + &SetProgramSpecializationConstant); + + if (URResult != UR_RESULT_SUCCESS) { + return URResult; + } + + for (uint32_t i = 0; i < count; ++i) { + CL_RETURN_ON_FAILURE(SetProgramSpecializationConstant( + CLProg, pSpecConstants[i].id, pSpecConstants[i].size, + pSpecConstants[i].pValue)); + } + } return UR_RESULT_SUCCESS; } 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=\"$\"" -)