-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
56 lines (43 loc) · 1.58 KB
/
Makefile
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
# Copyright 2020 RICOS Co. Ltd.
#
# This file is a part of ricosjp/allgebra, distributed under Apache-2.0 License
# https://github.com/ricosjp/allgebra
#
#
# Detect the compute capability of system's GPU
#
# See also the official document
# https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#compute-capability
#
COMPUTE_CAPABILITY := $(shell allgebra_get_device_cc)
ifeq ($(COMPUTE_CAPABILITY),)
$(error "allgebra_get_device_cc failed to find GPU")
endif
# OpenMP Offloading Settings
CXX := clang++
CXX_FLAGS := -O3 -std=c++11 -lm
OMP_FLAGS := -fopenmp -fopenmp-targets=nvptx64 -Xopenmp-target -march=sm_$(COMPUTE_CAPABILITY)
# Additional CUDA libraries for cuBLAS example
CUDA_LIBS := -lcuda -lcublas -lcudart
.PHONY: test prof clean
TARGET := omp_offloading.out omp_offloading_cublas.out omp_offloading_math.out omp_offloading_control_thread.out
all: $(TARGET)
omp_offloading.out: omp_offloading.cpp
$(CXX) $(OMP_FLAGS) $(CXX_FLAGS) $< -o $@
omp_offloading_cublas.out: omp_offloading_cublas.cpp
$(CXX) $(OMP_FLAGS) $(CXX_FLAGS) $< -o $@ $(CUDA_LIBS)
omp_offloading_math.out: omp_offloading_math.cpp
$(CXX) $(OMP_FLAGS) $(CXX_FLAGS) $< -o $@
omp_offloading_control_thread.out: omp_offloading_control_thread.cpp
$(CXX) $(OMP_FLAGS) $(CXX_FLAGS) $< -o $@
test: $(TARGET)
./omp_offloading.out 1000000
./omp_offloading_cublas.out 1000000
./omp_offloading_math.out 1000000
./omp_offloading_control_thread.out 300
debug: $(TARGET)
LIBOMPTARGET_DEBUG=1 ./omp_offloading_cublas.out 1000000
prof: $(TARGET)
nsys nvprof ./omp_offloading_cublas.out 1000000
clean:
rm -rf *.out