Skip to content

Commit

Permalink
Revamp testing for cross-compilation validation
Browse files Browse the repository at this point in the history
Make sure packages built with cross-compilation can still be tested on
their target architecture afterwards.
  • Loading branch information
jakirkham committed May 8, 2024
1 parent 2739a02 commit d9c730c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 48 deletions.
12 changes: 4 additions & 8 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,12 @@ outputs:
- test.cpp
- test.cu
- CMakeLists.txt
- run_cmake_cuda_tests.sh # [linux]
- run_nvcc_tests.sh # [linux]
- run_nvcc_tests.bat # [win]
commands:
- {{ exists }} nvcc
- nvcc --version
- $CXX --verbose ${CXXFLAGS} -lcuda -lcudart_static test.cpp # [linux]
- cl /Tp test.cpp /link /LIBPATH:"%CONDA_PREFIX%\Library\lib" cudart_static.lib /out:test_nvcc.exe # [win]
- nvcc --verbose test.cu
- cmake ${CMAKE_ARGS} -S . -B ./build -G=Ninja
- cmake --build ./build -v
- bash ./run_cmake_cuda_tests.sh # [linux]
- ./run_nvcc_tests.sh # [linux]
- .\run_nvcc_tests.bat # [win]
- test -f $PREFIX/etc/conda/activate.d/~cuda-nvcc_activate.sh # [linux]
- test -f $PREFIX/etc/conda/deactivate.d/~cuda-nvcc_deactivate.sh # [linux]
about:
Expand Down
40 changes: 0 additions & 40 deletions recipe/run_cmake_cuda_tests.sh

This file was deleted.

18 changes: 18 additions & 0 deletions recipe/run_nvcc_tests.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@echo on

nvcc --version
if errorlevel 1 exit 1


cl /Tp test.cpp /link /LIBPATH:"%CONDA_PREFIX%\Library\lib" cudart_static.lib /out:test_nvcc.exe
if errorlevel 1 exit 1

nvcc --verbose test.cu
if errorlevel 1 exit 1


cmake %CMAKE_ARGS% -S . -B ./build -G=Ninja
if errorlevel 1 exit 1

cmake --build ./build -v
if errorlevel 1 exit 1
70 changes: 70 additions & 0 deletions recipe/run_nvcc_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash
set -e
set -x

kernel_name="$(uname -s)"
if [[ "${kernel_name}" != "Linux" ]]
then
echo "Unknown OS. Expected Linux, but found ${kernel_name}"
exit 1
fi

processor_name="$(uname -m)"
case "${processor_name}" in
"x86_64") test_platform="linux-64" ;;
"aarch64") test_platform="linux-aarch64" ;;
"ppc64le") test_platform="linux-ppc64le" ;;
*) echo "Unknown architecture: ${processor_name}" && exit 1 ;;
esac

if [[ "${test_platform}" != "${target_platform}" ]]
then
echo "Skipping NVCC testing as current platform is ${test_platform}, whereas; NVCC is built for ${target_platform}."
exit 0
fi

cmake_version=$(cmake --version | grep version | awk '{print $3}')

nvcc --version

$CXX --verbose ${CXXFLAGS} -lcuda -lcudart_static test.cpp

nvcc --verbose test.cu

cmake ${CMAKE_ARGS} -S . -B ./build -G=Ninja
cmake --build ./build -v

if [[ "${target_platform}" == "linux-ppc64le" ]]
then
echo "Skipping CMake tests on ${target_platform} due to known issues."
exit 0
fi

mkdir -p cmake-tests
git clone -b v${cmake_version} --depth 1 https://gitlab.kitware.com/cmake/cmake.git cmake-tests
cmake -S cmake-tests -B cmake-tests/build -DCMake_TEST_HOST_CMAKE=ON -DCMake_TEST_CUDA=nvcc -G "Ninja"
cd cmake-tests/build

# Test exclusion list:
# Requires cublas
# Cuda.ProperDeviceLibraries
#
# Requires curand
# *SharedRuntime*
#
# Requires execution on a machine with a CUDA GPU
# Cuda.ObjectLibrary
# Cuda.WithC
# Cuda.StubRPATH
# CudaOnly.ArchSpecial
# CudaOnly.GPUDebugFlag
# CudaOnly.SeparateCompilationPTX
# CudaOnly.WithDefs
# CudaOnly.CUBIN
# CudaOnly.Fatbin
# CudaOnly.OptixIR
# RunCMake.CUDA_architectures
# *Toolkit*
# Failing due to undefined symbol: __libc_dl_error_tsd, version GLIBC_PRIVATE
# Cuda.Complex
CUDAHOSTCXX=$CXX ctest -L CUDA --output-on-failure -j $(nproc) -E "(ProperDeviceLibraries|SharedRuntime|ObjectLibrary|WithC|StubRPATH|ArchSpecial|GPUDebugFlag|SeparateCompilationPTX|WithDefs|CUBIN|Fatbin|OptixIR|CUDA_architectures|Toolkit|Cuda.Complex)"

0 comments on commit d9c730c

Please sign in to comment.