added Makefile

This commit is contained in:
Evghenii
2013-11-13 13:40:08 +01:00
parent 1f13a236bf
commit 2dd7128db5
2 changed files with 53 additions and 1 deletions

View File

@@ -0,0 +1,52 @@
PROG=main_cu
ISPC_SRC=kernels1.ispc
CXX_SRC=main_cu.cpp common.cpp
CXX=g++
CXXFLAGS=-O3 -I$(CUDATK)/include
LD=g++
LDFLAGS=-lcuda
ISPC=ispc
ISPCFLAGS=-O3 --math-lib=default --target=nvptx64,avx
LLVM32 = $(HOME)/usr/local/llvm/bin-3.2
LLVM = $(HOME)/usr/local/llvm/bin-3.3
PTXGEN = $(HOME)/ptxgen
LLVM32DIS=$(LLVM32)/bin/llvm-dis
.SUFFIXES: .bc .o .ptx .cu _ispc_nvptx64.bc
ISPC_OBJ=$(ISPC_SRC:%.ispc=%_ispc.o)
ISPC_BC=$(ISPC_SRC:%.ispc=%_ispc_nvptx64.bc)
PTXSRC=$(ISPC_SRC:%.ispc=%_ispc_nvptx64.ptx)
CXX_OBJ=$(CXX_SRC:%.cpp=%.o)
all: $(PROG)
$(PROG): $(CXX_OBJ) kernel.ptx
/bin/cp kernel.ptx __kernels.ptx
$(LD) -o $@ $(CXX_OBJ) $(LDFLAGS)
%.o: %.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<
%_ispc_nvptx64.bc: %.ispc
$(ISPC) $(ISPCFLAGS) --emit-llvm -o `basename $< .ispc`_ispc.bc -h `basename $< .ispc`_ispc.h $< --emit-llvm
%.ptx: %.bc
$(LLVM32DIS) $<
$(PTXGEN) `basename $< .bc`.ll > $@
kernel.ptx: $(PTXSRC)
cat $^ > kernel.ptx
clean:
/bin/rm -rf *.ptx *.bc *.ll $(PROG)

View File

@@ -327,7 +327,7 @@ extern "C"
const char * func_name,
void **func_args)
{
const std::vector<char> module_str = readBinary("kernel.ptx");
const std::vector<char> module_str = readBinary("__kernels.ptx");
const char * module = &module_str[0];
CUmodule cudaModule = loadModule(module);
CUfunction cudaFunction = getFunction(cudaModule, func_name);