Skip to content

Commit

Permalink
Add externals for Cupla 0.2.0
Browse files Browse the repository at this point in the history
Cupla [Qapla'] is a simple user interface for the platform independent
parallel kernel acceleration library alpaka. It follows a similar
concept as the NVIDIA® CUDA® API by providing a software layer to
manage accelerator devices. alpaka is used as backend for cupla.

See https://github.com/ComputationalRadiationPhysics/cupla/blob/master/README.md
for more information.

See https://github.com/ComputationalRadiationPhysics/cupla/releases
forthe latest changes.
  • Loading branch information
fwyzard committed Feb 25, 2020
1 parent e6427d4 commit 795ca3e
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
49 changes: 49 additions & 0 deletions cupla-toolfile.spec
@@ -0,0 +1,49 @@
### RPM external cupla-toolfile 1.0
Requires: cupla

%prep

%build

%install

mkdir -p %i/etc/scram.d
cat << \EOF_TOOLFILE >%i/etc/scram.d/cupla.xml
<tool name="cupla" version="@TOOL_VERSION@">
<info url="https://github.com/ComputationalRadiationPhysics/cupla"/>
<use name="boost"/>
<client>
<environment name="CUPLA_BASE" default="@TOOL_ROOT@"/>
<environment name="INCLUDE" default="$CUPLA_BASE/include"/>
<environment name="LIBDIR" default="$CUPLA_BASE/lib"/>
</client>
</tool>
EOF_TOOLFILE

cat << \EOF_TOOLFILE >%i/etc/scram.d/cupla-serial.xml
<tool name="cupla-serial" version="@TOOL_VERSION@">
<use name="cupla"/>
<lib name="cupla-serial"/>
<flags CXXFLAGS="-DALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED -DCUPLA_STREAM_ASYNC_ENABLED=0"/>
</tool>
EOF_TOOLFILE

cat << \EOF_TOOLFILE >%i/etc/scram.d/cupla-tbb.xml
<tool name="cupla-tbb" version="@TOOL_VERSION@">
<use name="cupla"/>
<use name="tbb"/>
<lib name="cupla-tbb"/>
<flags CXXFLAGS="-DALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLED -DCUPLA_STREAM_ASYNC_ENABLED=1"/>
</tool>
EOF_TOOLFILE

cat << \EOF_TOOLFILE >%i/etc/scram.d/cupla-cuda.xml
<tool name="cupla-cuda" version="@TOOL_VERSION@">
<use name="cupla"/>
<use name="cuda"/>
<lib name="cupla-cuda"/>
<flags CXXFLAGS="-DALPAKA_ACC_GPU_CUDA_ENABLED -DCUPLA_STREAM_ASYNC_ENABLED=1"/>
</tool>
EOF_TOOLFILE

## IMPORT scram-tools-post
51 changes: 51 additions & 0 deletions cupla.spec
@@ -0,0 +1,51 @@
### RPM external cupla 0.2.0

Source: https://github.com/ComputationalRadiationPhysics/%{n}/archive/%{realversion}.tar.gz
Requires: alpaka
Requires: cuda
Requires: tbb

%prep
%setup -n %{n}-%{realversion}

%build
## INCLUDE cuda-flags
# this defines cuda_flags, used below

mkdir build lib

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

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

# build the serial CPU backend
mkdir build/serial
for FILE in $FILES; do
g++ -DALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED -DCUPLA_STREAM_ASYNC_ENABLED=0 $CXXFLAGS $HOST_FLAGS -c $FILE -o build/serial/$(basename $FILE).o
done
g++ $CXXFLAGS $HOST_FLAGS build/serial/*.o -shared -o lib/libcupla-serial.so

# build the TBB CPU backend
mkdir build/tbb
for FILE in $FILES; do
g++ -DALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLED -DCUPLA_STREAM_ASYNC_ENABLED=1 $CXXFLAGS $HOST_FLAGS -c $FILE -o build/tbb/$(basename $FILE).o
done
g++ $CXXFLAGS $HOST_FLAGS build/tbb/*.o -L$TBB_ROOT/lib -ltbb -shared -o lib/libcupla-tbb.so

# build the CUDA GPU backend
mkdir build/cuda
for FILE in $FILES; do
nvcc -DALPAKA_ACC_GPU_CUDA_ENABLED -DCUPLA_STREAM_ASYNC_ENABLED=1 $CXXFLAGS $NVCC_FLAGS -Xcompiler "$HOST_FLAGS" -x cu -c $FILE -o build/cuda/$(basename $FILE).o
done
g++ $CXXFLAGS $HOST_FLAGS build/cuda/*.o -L$CUDA_ROOT/lib64 -lcudart -shared -o lib/libcupla-cuda.so


%install
cp -ar include %{i}/include
cp -ar lib %{i}/lib

%post

0 comments on commit 795ca3e

Please sign in to comment.