-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (53 loc) · 2.05 KB
/
Copy pathMakefile
File metadata and controls
67 lines (53 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
CC= nvcc
NVCC= nvcc
# Should point to Valgrind's and CUDA driver's lib/lib64 and include directory
LIB=
INCLUDE=
# Defaults for HLRS' Laki cluster
ifeq ($(SITE_PLATFORM_NAME),laki)
LIB=-L/usr/lib64/valgrind/ -L/opt/cuda/driver-5.0/lib64/
INCLUDE=-I/usr/include/valgrind/ -I/opt/cuda/driver-5.0/include
# Other cases
else
ifndef ($(LIB))
$(error Unknown platform. Point LIB and INCLUDE to VALGRIND/CUDA driver)
endif
endif
INCLUDE += -Isrc/
LINKFLAGS=-lcuda -lcudart -lpthread
# -std=gnu99 instead of -std=c99 to enable POSIX mutex
CFLAGS= -O3 -Xcompiler -std=gnu99
CUDACFLAGS= -g -G -O0 -arch sm_13
# Set to enable debug output
#DEBUGFLAG=-DCUDAGRIND_DEBUG
CUDAWRAP_OFILES = $(patsubst %.c,%.o,$(wildcard src/*.c))
CG_V_MAJOR = $(shell ./version.sh major)
CG_V_MINOR = $(shell ./version.sh minor)
CG_V_REV = $(shell ./version.sh revision)
.PHONY: all
all: libcudaWrap.so.$(CG_V_MAJOR).$(CG_V_MINOR).$(CG_V_REV) examples/example examples/example_rc
.PHONY: new
new: clean all
examples/example: examples/example.o
$(CC) $^ -o $@ $(LINKFLAGS) $(LIB)
examples/example_rc: examples/example_rc.o
$(CC) $^ -o $@ $(LINKFLAGS) $(LIB)
libcudaWrap.so.$(CG_V_MAJOR).$(CG_V_MINOR).$(CG_V_REV): $(CUDAWRAP_OFILES)
$(CC) $(CFLAGS) $(LIB) $^ -shared -Xlinker -soname -Xlinker libcudaWrap.so.$(CG_V_MAJOR) -o $@
ln -s -f libcudaWrap.so.$(CG_V_MAJOR).$(CG_V_MINOR).$(CG_V_REV) libcudaWrap.so.$(CG_V_MAJOR).$(CG_V_MINOR)
ln -s -f libcudaWrap.so.$(CG_V_MAJOR).$(CG_V_MINOR).$(CG_V_REV) libcudaWrap.so.$(CG_V_MAJOR)
ln -s -f libcudaWrap.so.$(CG_V_MAJOR).$(CG_V_MINOR).$(CG_V_REV) libcudaWrap.so
src/%.o: src/%.c
$(CC) -Xcompiler -fPIC $(CFLAGS) -c $(INCLUDE) $^ $(DEBUGFLAG) -o $@
%.o: %.c
$(CC) $(CFLAGS) -c $(INCLUDE) $^ $(DEBUGFLAG) -o $@
%.o: %.cu
$(NVCC) $(CUDACFLAGS) -c $(INCLUDE) $^ $(DEBUGFLAG) -o $@
.PHONY: clean
clean:
rm -f src/*.o
rm -f libcudaWrap.so.$(CG_V_MAJOR).$(CG_V_MINOR).$(CG_V_REV)
rm -f libcudaWrap.so.$(CG_V_MAJOR).$(CG_V_MINOR)
rm -f libcudaWrap.so.$(CG_V_MAJOR)
rm -f libcudaWrap.so
rm -f examples/example examples/example_rc examples/*.o