forked from UoB-HPC/BabelStream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpenMP.make
99 lines (82 loc) · 2.5 KB
/
OpenMP.make
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
97
98
99
ifndef COMPILER
define compiler_help
Set COMPILER to change flags (defaulting to GNU).
Available compilers are:
CLANG CRAY GNU GNU_PPC INTEL XL PGI NEC ARMCLANG AOMP
Note: GCC on PPC requires -mcpu=native instead of -march=native so we have a special case for it
endef
$(info $(compiler_help))
COMPILER=GNU
endif
ifndef TARGET
define target_help
Set TARGET to change device (defaulting to CPU).
Available targets are:
CPU NVIDIA AMD INTEL_GPU
endef
$(info $(target_help))
TARGET=CPU
endif
ifeq ("$(COMPILER)", "CLANG")
ifdef TARGET
ifeq ("$(TARGET)", "NVIDIA")
ifndef NVARCH
define nvarch_help
Set NVARCH to select sm_?? version.
Default: sm_60
endef
$(info $(nvarch_help))
NVARCH=sm_60
endif
endif
endif
endif
COMPILER_ARMCLANG = armclang++
COMPILER_GNU = g++
COMPILER_GNU_PPC = g++
COMPILER_INTEL = icpc
COMPILER_CRAY = CC
COMPILER_CLANG = clang++
COMPILER_XL = xlc++
COMPILER_PGI = pgc++
COMPILER_NEC = /opt/nec/ve/bin/nc++
COMPILER_AOMP = clang++
CXX = $(COMPILER_$(COMPILER))
FLAGS_GNU = -O3 -std=c++11 -march=native
FLAGS_GNU_PPC = -O3 -std=c++11 -mcpu=native
FLAGS_INTEL = -O3 -std=c++11
FLAGS_CRAY = -O3 -std=c++11
FLAGS_CLANG = -O3 -std=c++11
FLAGS_XL = -O5 -qarch=auto -qtune=auto -std=c++11
FLAGS_PGI = -O3 -std=c++11
FLAGS_NEC = -O4 -finline -std=c++11
FLAGS_ARMCLANG = -O3 -std=c++11
FLAGS_AOMP = -O3 -std=c++11
CXXFLAGS = $(FLAGS_$(COMPILER))
# OpenMP flags for CPUs
OMP_ARMCLANG_CPU = -fopenmp
OMP_GNU_CPU = -fopenmp
OMP_GNU_PPC_CPU = -fopenmp
OMP_INTEL_CPU = -qopenmp
OMP_CRAY_CPU = -fopenmp
OMP_CLANG_CPU = -fopenmp=libomp
OMP_XL_CPU = -qsmp=omp -qthreaded
OMP_PGI_CPU = -mp
OMP_NEC_CPU = -fopenmp
# OpenMP flags for NVIDIA
OMP_CRAY_NVIDIA = -DOMP_TARGET_GPU
OMP_CLANG_NVIDIA = -DOMP_TARGET_GPU -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=$(NVARCH)
OMP_GNU_NVIDIA = -DOMP_TARGET_GPU -fopenmp -foffload=nvptx-none
OMP_GNU_AMD = -DOMP_TARGET_GPU -fopenmp -foffload=amdgcn-amdhsa
OMP_INTEL_CPU = -xHOST -qopt-streaming-stores=always -qopenmp
OMP_INTEL_INTEL_GPU = -DOMP_TARGET_GPU -qnextgen -fiopenmp -fopenmp-targets=spir64
OMP_AOMP_GPU = -DOMP_TARGET_GPU -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906
ifndef OMP_$(COMPILER)_$(TARGET)
$(error Targeting $(TARGET) with $(COMPILER) not supported)
endif
OMP = $(OMP_$(COMPILER)_$(TARGET))
omp-stream: main.cpp OMPStream.cpp
$(CXX) $(CXXFLAGS) -DOMP $^ $(OMP) $(EXTRA_FLAGS) -o $@
.PHONY: clean
clean:
rm -f omp-stream