Skip to content

Commit

Permalink
Merge pull request #7419 from fwyzard/IB/CMSSW_12_1_X/master_update_c…
Browse files Browse the repository at this point in the history
…uda-compatible-runtime

Update cuda-compatible-runtime to add kernel checks
  • Loading branch information
smuzaffar committed Nov 25, 2021
2 parents 80a4eb0 + bb1cc87 commit c890ac8
Showing 1 changed file with 50 additions and 9 deletions.
59 changes: 50 additions & 9 deletions cuda-compatible-runtime.spec
@@ -1,26 +1,67 @@
### RPM external cuda-compatible-runtime 1.0

%define branch master
%define commit 18d5a51bfb32fbb7b765dd2eecd14e193cce8126
%define commit bfe5537537428ab4a72ae929c77977a55501c576

Source: git+https://:@gitlab.cern.ch:8443/cms-patatrack/%{n}.git?obj=%{branch}/%{commit}&export=%{n}&filter=./test.c&output=/%{n}-%{realversion}.tgz
Source: git+https://:@gitlab.cern.ch:8443/cms-patatrack/%{n}.git?obj=%{branch}/%{commit}&export=%{n}&filter=./test.cu&output=/%{n}-%{realversion}.tgz
Requires: cuda
AutoReq: no

%prep
%setup -n %{n}

%build
## INCLUDE cuda-flags
# defines nvcc_stdcxx and cuda_flags_4

rm -rf %{_builddir}/build && mkdir %{_builddir}/build
gcc -std=c99 -O2 -Wall test.c -I $CUDA_ROOT/include -L $CUDA_ROOT/lib64 -L $CUDA_ROOT/lib64/stubs -l cudart_static -l cuda -ldl -lrt -pthread -static-libgcc -o %{_builddir}/build/cuda-compatible-runtime # || true
if
$CUDA_ROOT/bin/nvcc %{nvcc_stdcxx} -O2 -g %{cuda_flags_4} test.cu -I $CUDA_ROOT/include -L $CUDA_ROOT/lib64 -L $CUDA_ROOT/lib64/stubs --cudart static -ldl -lrt --compiler-options '-Wall -pthread' -o %{_builddir}/build/cuda-compatible-runtime
then
true
else
# CUDA is not supported by this architecture or compiler version
cat > %{_builddir}/build/cuda-compatible-runtime << @EOF_
#! /bin/bash

%install
VERBOSE=false

mkdir %{i}/test
if [ -f %{_builddir}/build/cuda-compatible-runtime ]; then
cp %{_builddir}/build/cuda-compatible-runtime %{i}/test/cuda-compatible-runtime
else
ln -s /usr/bin/false %{i}/test/cuda-compatible-runtime
function usage() {
cat << @EOF
Usage: \$0 [-h|-v]

Options:
-h Print a help message and exits.
-v Be more verbose.
@EOF
}

for ARG in "\$@"; do
case "\$ARG" in
-h)
usage
exit 0
;;
-v)
VERBOSE=true
;;
*)
echo "\$0: invalid option '\$ARG'"
echo
usage
exit 1
;;
esac
done

\$VERBOSE && echo "CUDA ${CUDA_VERSION} is not compatible with GCC ${GCC_VERSION}"
exit 1
@EOF_
chmod +x %{_builddir}/build/cuda-compatible-runtime
fi

%install
mkdir %{i}/test
cp %{_builddir}/build/cuda-compatible-runtime %{i}/test/cuda-compatible-runtime

%post

0 comments on commit c890ac8

Please sign in to comment.