forked from szcompressor/FSZ
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
96 lines (75 loc) · 2.84 KB
/
Copy pathMakefile
File metadata and controls
96 lines (75 loc) · 2.84 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
NVCC ?= nvcc
ARCH ?=
CXXFLAGS ?= -O3 --std=c++17
ifeq ($(ARCH),)
ARCH := $(shell nvidia-smi --query-gpu=compute_cap --format=csv,noheader 2>/dev/null | head -n1 | tr -d .)
endif
ifeq ($(ARCH),)
ARCH := 80
endif
# Single-architecture build for the local GPU by default. Pass a list like
# ARCHS="80 90 100" for a fat binary; PTX for the newest entry is embedded
# so later GPU generations load it too.
ARCHS ?=
ifeq ($(ARCHS),)
GENCODE := -arch=sm_$(ARCH)
else
GENCODE := $(foreach a,$(ARCHS),-gencode arch=compute_$(a),code=sm_$(a))
GENCODE += -gencode arch=compute_$(lastword $(ARCHS)),code=compute_$(lastword $(ARCHS))
endif
ifeq ($(ARCHS)$(ARCH),80)
GENCODE += -maxrregcount=96
endif
ifeq ($(strip $(ARCHS)),80)
GENCODE += -maxrregcount=96
endif
INCLUDE := -Iinclude -Isrc
SRC := src/fsz.cu
HDRS := include/fsz/fsz.h include/fsz/fsz.hpp src/fsz_internal.cuh src/fsz_kernels.cuh
BUILD ?= build
LIB := $(BUILD)/libfsz.a
SHLIB := $(BUILD)/libfsz.so
TOOL := $(BUILD)/fsz
EXAMPLES := $(BUILD)/example_roundtrip $(BUILD)/example_hostptr
TESTS := $(BUILD)/test_roundtrip $(BUILD)/test_hostptr
.PHONY: all lib shared tool examples tests fortran clean install
all: lib tool examples tests
$(BUILD):
mkdir -p $(BUILD)
$(BUILD)/fsz.o: $(SRC) $(HDRS) | $(BUILD)
$(NVCC) $(CXXFLAGS) $(GENCODE) -c $(SRC) -o $@ $(INCLUDE) -Xcompiler -fPIC
$(LIB): $(BUILD)/fsz.o
ar rcs $@ $<
$(SHLIB): $(SRC) $(HDRS) | $(BUILD)
$(NVCC) $(CXXFLAGS) $(GENCODE) -shared $(SRC) -o $@ $(INCLUDE) -Xcompiler -fPIC
lib: $(LIB)
shared: $(SHLIB)
$(TOOL): tools/fsz.cu tools/fsz_file_format.hpp $(LIB)
$(NVCC) $(CXXFLAGS) $(GENCODE) $< -o $@ $(INCLUDE) -Itools $(LIB)
tool: $(TOOL)
$(BUILD)/example_%: examples/example_%.cu $(LIB)
$(NVCC) $(CXXFLAGS) $(GENCODE) $< -o $@ $(INCLUDE) $(LIB)
$(BUILD)/test_%: tests/test_%.cu $(LIB)
$(NVCC) $(CXXFLAGS) $(GENCODE) $< -o $@ $(INCLUDE) $(LIB)
examples: $(EXAMPLES)
tests: $(TESTS)
# Fortran interface (optional): builds the fsz module plus its example and
# test against the static library. Requires gfortran or a compatible FC.
ifeq ($(origin FC),default)
FC := gfortran
endif
CUDA_HOME ?= $(shell dirname $$(dirname $$(command -v nvcc)))
fortran: $(LIB) | $(BUILD)
$(FC) -O2 -J$(BUILD) -c fortran/fsz.f90 -o $(BUILD)/fsz_mod.o
$(FC) -O2 -I$(BUILD) fortran/example_fsz.f90 $(BUILD)/fsz_mod.o $(LIB) \
-o $(BUILD)/example_fortran -L$(CUDA_HOME)/lib64 -lcudart -lstdc++
$(FC) -O2 -I$(BUILD) fortran/test_fsz.f90 $(BUILD)/fsz_mod.o $(LIB) \
-o $(BUILD)/test_fortran -L$(CUDA_HOME)/lib64 -lcudart -lstdc++
PREFIX ?= /usr/local
install: $(LIB) $(TOOL)
install -d $(PREFIX)/bin $(PREFIX)/lib $(PREFIX)/include/fsz
install -m 755 $(TOOL) $(PREFIX)/bin/
install -m 644 $(LIB) $(PREFIX)/lib/
install -m 644 include/fsz/fsz.h include/fsz/fsz.hpp $(PREFIX)/include/fsz/
clean:
rm -rf $(BUILD)