Skip to content

Commit

Permalink
Define in a central place the C++ standard ^C use for building host a…
Browse files Browse the repository at this point in the history
…nd device code with nvcc
  • Loading branch information
fwyzard committed Jun 14, 2020
1 parent a704c77 commit c465742
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 5 additions & 3 deletions cuda-flags.file
Expand Up @@ -15,9 +15,11 @@
# LLVM style for listing the supported CUDA compute architectures
%define llvm_cuda_arch %(echo $(for ARCH in %cuda_arch; do echo "$ARCH"; done) | sed -e"s/ /,/g")

# C++ standard to use for building host and device code with nvcc
%define nvcc_stdcxx -std=c++17

# enable C++17, and generate optimised code
%define cuda_flags_0 -std=c++17 -O3
# generate optimised code
%define cuda_flags_0 -O3

# generate debugging information for device code
%define cuda_flags_1 --generate-line-info --source-in-ptx
Expand All @@ -38,4 +40,4 @@
%define cuda_flags_6 --cudart shared

# collect all CUDA flags
%define cuda_flags %{cuda_flags_0} %{cuda_flags_1} %{cuda_flags_2} %{cuda_flags_3} %{cuda_flags_4} %{cuda_flags_5} %{cuda_flags_6}
%define nvcc_cuda_flags %{nvcc_stdcxx} %{cuda_flags_0} %{cuda_flags_1} %{cuda_flags_2} %{cuda_flags_3} %{cuda_flags_4} %{cuda_flags_5} %{cuda_flags_6}
6 changes: 3 additions & 3 deletions cuda-toolfile.spec
Expand Up @@ -6,7 +6,7 @@ Requires: cuda

%install
## INCLUDE cuda-flags
# defines cuda_flags
# defines nvcc_cuda_flags and nvcc_stdcxx

mkdir -p %{i}/etc/scram.d
cat << \EOF_TOOLFILE >%{i}/etc/scram.d/cuda-stubs.xml
Expand Down Expand Up @@ -36,10 +36,10 @@ cat << \EOF_TOOLFILE >%{i}/etc/scram.d/cuda.xml
<environment name="LIBDIR" default="$CUDA_BASE/lib64"/>
<environment name="INCLUDE" default="$CUDA_BASE/include"/>
</client>
<flags CUDA_FLAGS="%{cuda_flags}"/>
<flags CUDA_FLAGS="%{nvcc_cuda_flags}"/>
<flags CUDA_HOST_REM_CXXFLAGS="-std=%"/>
<flags CUDA_HOST_REM_CXXFLAGS="%potentially-evaluated-expression"/>
<flags CUDA_HOST_CXXFLAGS="-std=c++17"/>
<flags CUDA_HOST_CXXFLAGS="%{nvcc_stdcxx}"/>
<lib name="cudadevrt" type="cuda"/>
<runtime name="PATH" value="$CUDA_BASE/bin" type="path"/>
</tool>
Expand Down
6 changes: 3 additions & 3 deletions cupla.spec
Expand Up @@ -10,16 +10,16 @@ Requires: tbb

%build
## INCLUDE cuda-flags
# defines cuda_flags
# defines nvcc_cuda_flags and nvcc_stdcxx

mkdir build lib

# remove the version of Alpaka bundled with Cupla
rm -rf alpaka

CXXFLAGS="-DALPAKA_DEBUG=0 -I$CUDA_ROOT/include -I$TBB_ROOT/include -I$BOOST_ROOT/include -I$ALPAKA_ROOT/include -Iinclude"
HOST_FLAGS="-std=c++17 -O2 -pthread -fPIC -Wall -Wextra"
NVCC_FLAGS="%{cuda_flags}"
HOST_FLAGS="%{nvcc_stdcxx} -O2 -pthread -fPIC -Wall -Wextra"
NVCC_FLAGS="%{nvcc_cuda_flags}"
FILES=$(find src -type f -name *.cpp)

# build the serial CPU backend
Expand Down

0 comments on commit c465742

Please sign in to comment.