-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from fwyzard/implement_cupla
Add rawtodigi implementation using the Cupla backend
- Loading branch information
Showing
9 changed files
with
732 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*~ | ||
main-* | ||
debug-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,60 @@ | ||
CXXFLAGS := -O2 -std=c++17 | ||
CXX := g++ | ||
TARGETS = naive cuda cupla-cuda cupla-serial | ||
|
||
CUDAFLAGS := -O2 -std=c++14 --expt-relaxed-constexpr | ||
NVCC:= nvcc | ||
.PHONY: default all debug clean $(TARGETS) | ||
|
||
CXX := g++-7 | ||
CXX_FLAGS := -O2 -std=c++14 -ftemplate-depth-512 | ||
CXX_DEBUG := -g | ||
|
||
NVCC := /usr/local/cuda-10.0/bin/nvcc -ccbin $(CXX) | ||
NVCC_FLAGS := -O2 -std=c++14 --expt-relaxed-constexpr | ||
NVCC_DEBUG := -g -lineinfo | ||
|
||
ALPAKA_BASE := $(HOME)/src/alpaka/alpaka | ||
CUPLA_BASE := $(HOME)/src/alpaka/cupla | ||
CUPLA_FLAGS := -DALPAKA_DEBUG=0 -DCUPLA_STREAM_ASYNC_ENABLED=1 -I$(ALPAKA_BASE)/include -I$(CUPLA_BASE)/include -L$(CUPLA_BASE)/lib | ||
|
||
default: naive | ||
|
||
naive: | ||
$(CXX) $(CXXFLAGS) -DDIGI_NAIVE -o main-naive main.cc | ||
all: $(TARGETS) | ||
|
||
debug: $(TARGETS:%=debug-%) | ||
|
||
clean: | ||
rm -f $(TARGETS:%=main-%) $(TARGETS:%=debug-%) | ||
|
||
# Naive CPU implementation | ||
naive: main-naive | ||
|
||
main-naive: main.cc rawtodigi_naive.h | ||
$(CXX) $(CXX_FLAGS) -DDIGI_NAIVE -o main-naive main.cc | ||
|
||
debug-naive: main.cc rawtodigi_naive.h | ||
$(CXX) $(CXX_FLAGS) -DDIGI_NAIVE $(CXX_DEBUG) -o debug-naive main.cc | ||
|
||
# CUDA implementation | ||
cuda: main-cuda | ||
|
||
main-cuda: main.cc rawtodigi_cuda.cu rawtodigi_cuda.h | ||
$(NVCC) $(NVCC_FLAGS) -DDIGI_CUDA -o main-cuda main.cc rawtodigi_cuda.cu | ||
|
||
debug-cuda: main.cc rawtodigi_cuda.cu rawtodigi_cuda.h | ||
$(NVCC) $(NVCC_FLAGS) -DDIGI_CUDA $(NVCC_DEBUG) -o debug-cuda main.cc rawtodigi_cuda.cu | ||
|
||
# Alpaka/cupla implementation, with CUDA backend | ||
cupla-cuda: main-cupla-cuda | ||
|
||
main-cupla-cuda: main.cc rawtodigi_cupla.cc rawtodigi_cupla.h | ||
$(NVCC) -x cu -w $(NVCC_FLAGS) -DDIGI_CUPLA -DALPAKA_ACC_GPU_CUDA_ENABLED $(CUPLA_FLAGS) -lcupla-cuda -o main-cupla-cuda main.cc rawtodigi_cupla.cc | ||
|
||
debug-cupla-cuda: main.cc rawtodigi_cupla.cc rawtodigi_cupla.h | ||
$(NVCC) -x cu -w $(NVCC_FLAGS) -DDIGI_CUPLA -DALPAKA_ACC_GPU_CUDA_ENABLED $(CUPLA_FLAGS) -lcupla-cuda $(NVCC_DEBUG) -o debug-cupla-cuda main.cc rawtodigi_cupla.cc | ||
|
||
debug-naive: | ||
$(CXX) $(CXXFLAGS) -DDIGI_NAIVE -g -o main-naive main.cc | ||
# Alpaka/cupla implementation, with serial cpu backend | ||
cupla-serial: main-cupla-serial | ||
|
||
cuda: | ||
$(NVCC) $(CUDAFLAGS) -DDIGI_CUDA -o main-cuda main.cc rawtodigi_cuda.cu | ||
main-cupla-serial: main.cc rawtodigi_cupla.cc rawtodigi_cupla.h | ||
$(CXX) $(CXX_FLAGS) -DDIGI_CUPLA -DALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED $(CUPLA_FLAGS) -pthread -o main-cupla-serial main.cc rawtodigi_cupla.cc -lcupla-serial | ||
|
||
debug-cuda: | ||
$(NVCC) $(CUDAFLAGS) -DDIGI_CUDA -g -G -o main-cuda main.cc rawtodigi_cuda.cu | ||
debug-cupla-serial: main.cc rawtodigi_cupla.cc rawtodigi_cupla.h | ||
$(CXX) $(CXX_FLAGS) -DDIGI_CUPLA -DALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED $(CUPLA_FLAGS) -pthread $(CXX_DEBUG) -o debug-cupla-serial main.cc rawtodigi_cupla.cc -lcupla-serial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef HeterogeneousCore_CUDAUtilities_cuplaCheck_h | ||
#define HeterogeneousCore_CUDAUtilities_cuplaCheck_h | ||
|
||
#include <iostream> | ||
|
||
/* Do NOT include other headers that use CUDA runtime functions or variables | ||
* (see above) before this include. | ||
* The reason for this is that cupla renames CUDA host functions and device build in | ||
* variables by using macros and macro functions. | ||
* Do NOT include other specific includes such as `<cuda.h>` (driver functions, | ||
* etc.). | ||
*/ | ||
#include <cuda_to_cupla.hpp> | ||
|
||
inline | ||
bool cuplaCheck_(const char* file, int line, const char* cmd, cuplaError_t result) | ||
{ | ||
//std::cerr << file << ", line " << line << ": " << cmd << std::endl; | ||
if (result == cuplaSuccess) | ||
return true; | ||
|
||
const char* message = cuplaGetErrorString(result); | ||
std::cerr << file << ", line " << line << ": " << message << std::endl; | ||
abort(); | ||
return false; | ||
} | ||
|
||
#define cuplaCheck(ARG) (cuplaCheck_(__FILE__, __LINE__, #ARG, (ARG))) | ||
|
||
#endif // HeterogeneousCore_CUDAUtilities_cuplaCheck_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.