Makefile 1.23 KB
Newer Older
incardon's avatar
incardon committed
1 2
include ../../example.mk

incardon's avatar
incardon committed
3 4 5 6 7 8 9 10
### This is a trick to avoid "Command not found if you no not have NVCC compiler". In practice the normal C++ compiler is used
### internally the example disable with the preprocessor its code if not compiled with nvcc 
CUDA_CC=
CUDA_CC_LINK=
ifeq (, $(shell which nvcc))
        CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH)
        INCLUDE_PATH_NVCC=
        CUDA_CC_LINK=mpic++
11
	CUDA_OPTIONS=
incardon's avatar
incardon committed
12 13 14
else
        CUDA_CC=nvcc
        CUDA_CC_LINK=nvcc
15
	CUDA_OPTIONS=-use_fast_math  -arch=sm_61 -lineinfo
incardon's avatar
incardon committed
16 17
endif

Pietro Incardona's avatar
Pietro Incardona committed
18
ifeq ($(PROFILE),ON)
incardon's avatar
incardon committed
19 20
        CUDA_CC=scorep --nocompiler  --cuda --mpp=mpi nvcc
        CUDA_CC_LINK=scorep --nocompiler  --cuda --mpp=mpi nvcc
Pietro Incardona's avatar
Pietro Incardona committed
21
else
incardon's avatar
incardon committed
22 23
	CUDA_CC:=$(CUDA_CC)
	CUDA_CC_LINK:=$(CUDA_CC)
Pietro Incardona's avatar
Pietro Incardona committed
24 25
endif

incardon's avatar
incardon committed
26 27 28 29 30 31 32 33 34 35
LDIR =
OPT=

OBJ = main.o

sph_dlb:
sph_dlb_test: OPT += -DTEST_RUN
sph_dlb_test: sph_dlb

%.o: %.cu
36
	$(CUDA_CC) -O3 $(OPT) $(CUDA_OPTIONS)  -g -c --std=c++11 -o $@ $< $(INCLUDE_PATH_NVCC)
incardon's avatar
incardon committed
37 38

%.o: %.cpp
incardon's avatar
incardon committed
39
	$(CC) -O3 $(OPT) -g -c --std=c++11 -o $@ $< $(INCLUDE_PATH)
incardon's avatar
incardon committed
40 41

sph_dlb: $(OBJ)
incardon's avatar
incardon committed
42
	$(CUDA_CC_LINK) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
incardon's avatar
incardon committed
43

Pietro Incardona's avatar
Pietro Incardona committed
44 45 46
sph_dlb2: $(OBJ)
	$(CUDA_CC_LINK) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)

incardon's avatar
incardon committed
47 48 49 50 51 52 53 54 55 56
all: sph_dlb

run: sph_dlb_test
	mpirun -np 2 ./sph_dlb

.PHONY: clean all run

clean:
	rm -f *.o *~ core sph_dlb