Skip to content

Introduce External/OpenCL subsuite prototype #231

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions External/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ add_subdirectory(ffmpeg)
add_subdirectory(skidmarks10)
add_subdirectory(sollve_vv)
add_subdirectory(smoke)
add_subdirectory(OpenCL)
49 changes: 49 additions & 0 deletions External/OpenCL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
include(External)

llvm_externals_find(TEST_SUITE_OPENCL_ROOT "opencl" "OpenCL prerequisites")
message(STATUS "TEST_SUITE_OPENCL_ROOT: ${TEST_SUITE_OPENCL_ROOT}")
get_filename_component(OPENCL_CLANG_PATH ${CMAKE_CXX_COMPILER} DIRECTORY)
string(REGEX REPLACE "bin$" "lib" OPENCL_LIB_PATH "${OPENCL_CLANG_PATH}")
message(STATUS "OPENCL_CLANG_PATH: ${OPENCL_CLANG_PATH}")
message(STATUS "OPENCL_LIB_PATH: ${OPENCL_LIB_PATH}")

macro(create_local_test TestName TestSources TestData VariantCPPFLAGS VariantLDFLAGS VariantLibs)
set(_sources "${TestSources}")
set(_executable ${TestName})
set(_data "${TestData}")
llvm_test_run(WORKDIR %S
EXECUTABLE "LD_LIBRARY_PATH=${OPENCL_LIB_PATH}" ./${_executable} > %o
)
set(REFERENCE_OUTPUT)
# Verify reference output if it exists.
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${TestName}.reference_output)
set(REFERENCE_OUTPUT ${TestName}.reference_output)
llvm_test_verify(WORKDIR %S
%b/${FPCMP} %o ${REFERENCE_OUTPUT}
)
llvm_test_executable(${_executable} "${_sources}")
llvm_test_data(${_executable} ${_data} ${REFERENCE_OUTPUT})
else()
llvm_test_executable(${_executable} "${_sources}")
llvm_test_data(${_executable} ${_data})
endif()
target_compile_options(${_executable} PUBLIC ${VariantCPPFLAGS})
target_link_options(${_executable} PUBLIC ${VariantLDFLAGS})
if(VariantLibs)
target_link_libraries(${_executable} ${VariantLibs})
endif()
add_dependencies(opencl-tests-simple-${TestName} ${_executable})
endmacro()

if(TEST_SUITE_OPENCL_ROOT)
add_custom_target(opencl-tests-simple COMMENT "Build all simple OpenCL tests")
# Add common OpenCL related flags
list(APPEND LDFLAGS -lOpenCL -L${OPENCL_LIB_PATH})
add_subdirectory(tests)
message(STATUS "OPENCL_SIMPLE_TESTS_LIST: ${OPENCL_SIMPLE_TESTS_LIST}")
add_custom_target(check-opencl-simple COMMENT "Run all simple OpenCL tests"
COMMAND ${TEST_SUITE_LIT} ${TEST_SUITE_LIT_FLAGS} ${OPENCL_SIMPLE_TESTS_LIST}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS opencl-tests-simple
USES_TERMINAL)
endif()
39 changes: 39 additions & 0 deletions External/OpenCL/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
OpenCL Tests
==========

OpenCL tests are enabled if cmake is invoked with
-DTEST_SUITE_EXTERNALS_DIR=<externals path> and specified externals directory contains at least one ROCm installation.

Expected externals directory structure:
Externals/
opencl/
opencl[-version]/ -- OpenCL compiler installation, which should, at the very least, have the following components:
include/CL/ -- header files including opencl.h
bin/ -- binaries including clang/clang++ (and clinfo for convenience)
lib/ -- libraries including libOpenCL.so and implementation specifics (like libamdocl64.so, libhsa-runtime64.so, librocprofiler-register.so, libamd_comgr.so.2)
lib/clang/NN/include/ -- some clang related inclues and libs
lib/clang/NN/lib/ -- libclang_rt.builtins-x86_64.a

[export AMDGPU_ARCHS=gfx906;gfx908 # List of AMDGPU archs to compile, not used at the moment]
export EXTERNAL_DIR=/your/Externals/path # Path to Exteranls with the OpenCL compiler
export CLANG_DIR=/your/clang/bin # Path to llvm-test-suite build
export TEST_SUITE_DIR=/path/to/test-suite-sources # Path to llvm-test-suite sources

Configure, build and run tests:

```
$ mkdir build-llvm-test-suite
$ cd build-llvm-test-suite

$ export EXTERNAL_DIR=/repos/Temp/LlvmTestSuite/Externals
$ export TEST_SUITE_DIR=/repos/llvm-test-suite
$ export CLANG_DIR=$EXTERNAL_DIR/opencl/opencl-6.3.0-14740

$ cmake -G Ninja -DTEST_SUITE_EXTERNALS_DIR=$EXTERNAL_DIR -DAMDGPU_ARCHS=$AMDGPU_ARCHS -DCMAKE_CXX_COMPILER="$CLANG_DIR/bin/amdclang++" -DCMAKE_C_COMPILER="$CLANG_DIR/bin/amdclang" $TEST_SUITE_DIR

$ ninja opencl-tests-simple # To build all the tests
$ ninja opencl-tests-simple-HelloWorld # To build a apecific test
$ ninja check-opencl-simple # To build & run all the tests
$ ninja check-opencl-simple-HelloWorld # To build & run a specific test
```

Loading