From 10b2376634e512f9e0ef06ff6b0c39de4a5cddca Mon Sep 17 00:00:00 2001 From: Tom Deakin Date: Fri, 24 Feb 2017 12:24:35 +0000 Subject: [PATCH] Add TARGET option to OpenMP Makefile --- OpenMP.make | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/OpenMP.make b/OpenMP.make index 0757f0d..cbcca54 100644 --- a/OpenMP.make +++ b/OpenMP.make @@ -3,6 +3,11 @@ ifndef COMPILER $(info Define a compiler to set common defaults, i.e make COMPILER=GNU) endif +ifndef TARGET +$(info No target defined. Specify CPU or GPU. Defaulting to CPU) +TARGET=CPU +endif + COMPILER_ = $(CXX) COMPILER_GNU = g++ COMPILER_INTEL = icpc @@ -31,14 +36,17 @@ OMP_TARGET_CRAY = OMP_TARGET_CLANG = -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda OMP_TARGET = $(OMP_TARGET_$(COMPILER)) +ifeq ($(TARGET), CPU) +OMP = $(OMP_$(COMPILER)) +else ifeq ($(TARGET), GPU) +OMP = $(OMP_TARGET_$(COMPILER)) +OMP += -DOMP_TARGET_GPU +endif + omp-stream: main.cpp OMPStream.cpp $(CXX) $(CXXFLAGS) -DOMP $^ $(OMP) $(EXTRA_FLAGS) -o $@ -omp-target-stream: main.cpp OMPStream.cpp - $(CXX) $(CXXFLAGS) -DOMP -DOMP_TARGET_GPU $^ $(OMP_TARGET) $(EXTRA_FLAGS) -o $@ - .PHONY: clean clean: rm -f omp-stream - rm -f omp-target-stream