Skip to content

Commit 39c7ff2

Browse files
authored
Fix 2 GPU tests that rely on specifics of the CUDA API (#29080)
Fixes 2 GPU tests that rely on the specific of the CUDA API to work with CUDA 13 * `gpuAddNums.chpl` is a low-level mock implemention of how the Chapel runtime works, and needs to use a new API with CUDA 13 * `mathKernels.chpl` builds cuda code manually with clang and relies on certain compiler flags to be passed. Where these paths are got more complicated in CUDA 13, so has been adjusted to share logic with `printchplenv` [Reviewed by @benharsh]
2 parents 452e361 + cddd354 commit 39c7ff2

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

test/gpu/native/cudaOnly/gpuAddNums/gpuAddNums.chpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ extern {
3939
char name[128];
4040
checkCudaErrors(cuDeviceGetName(name, 128, device), 4);
4141

42+
#if CUDA_VERSION >= 13000
43+
CUctxCreateParams ctxCreateParams = {0};
44+
checkCudaErrors(cuCtxCreate(&context, &ctxCreateParams, CU_CTX_BLOCKING_SYNC, device), 5);
45+
#else
4246
checkCudaErrors(cuCtxCreate(&context, CU_CTX_BLOCKING_SYNC, device), 5);
47+
#endif
4348
}
4449

4550
checkCudaErrors(cuModuleLoadData(&cudaModule, chpl_gpuBinary), 6);

test/gpu/native/studies/math/mathKernels.precomp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
24

35
chpl=$3
46
chpl_home=$($chpl --print-chpl-home)
@@ -8,6 +10,8 @@ gpu_arch=$($chpl_home/util/printchplenv --value --only CHPL_GPU_ARCH)
810
cuda_path=$($chpl_home/util/printchplenv --value --only CHPL_CUDA_PATH)
911
nvcc_compiler=$cuda_path/bin/nvcc
1012

13+
chpl_system_compile=$($chpl_home/util/printchplenv --value --only CHPL_TARGET_SYSTEM_COMPILE_ARGS)
14+
1115
NVCC_FLAGS=""
1216
CLANG_FLAGS="--offload-arch=${gpu_arch}"
1317
if [[ "$llvm_version" -ge 15 ]]; then
@@ -24,9 +28,9 @@ build_for_func() {
2428
$nvcc_compiler $DEFINES_nvcc -O3 --use_fast_math $NVCC_FLAGS -c mathKernels.cu -o mathKernels_cu_$func.o
2529
$nvcc_compiler -O3 --use_fast_math mathKernels_cu_$func.o -o mathKernelsDlinked_$func.o -dlink
2630

27-
local DEFINES_clang="$COMMON_DEFINES -Dmk_PREFIX=cu_clang_${func}_ -Dmk_LABEL=\"clang\" -D__STRICT_ANSI__=1"
31+
local DEFINES_clang="$COMMON_DEFINES -Dmk_PREFIX=cu_clang_${func}_ -Dmk_LABEL=\"clang\""
2832
# build the clang version
29-
$compiler $DEFINES_clang -I$cuda_path/include -O3 -ffast-math $CLANG_FLAGS -c mathKernels.cu -o mathKernels_clang_$func.o
33+
$compiler $DEFINES_clang $chpl_system_compile -O3 -ffast-math $CLANG_FLAGS -c mathKernels.cu -o mathKernels_clang_$func.o
3034
}
3135
build_for_func tanhf
3236
build_for_func sqrtf

0 commit comments

Comments
 (0)