| 1 |
|
| 2 |
# |
| 3 |
# Makefile.hipfort: Include Makefile to set values LINKOPTS, CXX, and FC |
| 4 |
# to support compilation with HIPFORT. |
| 5 |
# |
| 6 |
# This file is meant to be included by other Makefiles. The includer must |
| 7 |
# set HIPFORT_HOME to the build or install location of HIPFORT. For example: |
| 8 |
# |
| 9 |
# HIPFORT_HOME ?= /opt/rocm/ |
| 10 |
# include $(HIPFORT_HOME)/share/hipfort/Makefile.hipfort |
| 11 |
# |
| 12 |
# If the caller does not set HIPFORT_ARCHGPU, this Makefile will call |
| 13 |
# a self-identification utility called myarchgpu. Please create an issue |
| 14 |
# in the hipfort repo if myarchgpu returns unknown. |
| 15 |
# |
| 16 |
# To avoid self identification set HIPFORT_ARCHGPU. Examples: |
| 17 |
# HIPFORT_ARCHGPU = amdgcn-gfx906 |
| 18 |
# HIPFORT_ARCHGPU = nvptx-sm_70 |
| 19 |
# |
| 20 |
|
| 21 |
HIPFORT_ARCHGPU ?= $(shell $(HIPFORT_HOME)/libexec/hipfort/myarchgpu) |
| 22 |
ARCH = $(firstword $(subst -, ,$(HIPFORT_ARCHGPU))) |
| 23 |
HIPFORT_COMPILER ?= gfortran |
| 24 |
CUDA_PATH=${CUDA_PATH:-/usr/local/cuda} |
| 25 |
ROCM_PATH=${ROCM_PATH:-/opt/rocm} |
| 26 |
DEVICE_LIB_PATH ?= $(ROCM_PATH)/lib |
| 27 |
HIP_CLANG_PATH ?= $(ROCM_PATH)/llvm/bin |
| 28 |
HIP_PLATFORM=${HIP_PLATFORM:-amd} |
| 29 |
|
| 30 |
MOD_DIR = $(HIPFORT_HOME)/include/hipfort/$(ARCH) |
| 31 |
LIB_DIR = $(HIPFORT_HOME)/lib |
| 32 |
|
| 33 |
GPU = $(strip $(subst ., ,$(suffix $(subst -,.,$(HIPFORT_ARCHGPU))))) |
| 34 |
ifeq (nvptx,$(findstring nvptx,$(HIPFORT_ARCHGPU))) |
| 35 |
UNAMEP = $(shell uname -p) |
| 36 |
LINKOPTS = -L$(LIB_DIR) -lhipfort-$(ARCH) -L$(CUDA_PATH)/targets/$(UNAMEP)-linux/lib $(LINKOPTS) -lcudart |
| 37 |
HIPCC_ENV = HIP_PLATFORM=nvidia |
| 38 |
HIPCC_OPTS = "--gpu-architecture=$(GPU)" |
| 39 |
else |
| 40 |
LINKOPTS = -L$(LIB_DIR) -lhipfort-$(ARCH) -L$(ROCM_PATH)/lib $(HIPCC_LIBS) -lamdhip64 -Wl,-rpath=$(ROCM_PATH)/lib |
| 41 |
HIPCC_ENV = HIP_PLATFORM=$(HIP_PLATFORM) DEVICE_LIB_PATH=$(DEVICE_LIB_PATH) HIP_CLANG_PATH=$(HIP_CLANG_PATH) |
| 42 |
HIPCC_OPTS = -fno-gpu-rdc -fPIC --offload-arch=$(GPU) |
| 43 |
endif |
| 44 |
|
| 45 |
LINKOPTS += -lstdc++ |
| 46 |
CXX = $(HIPCC_ENV) $(ROCM_PATH)/bin/hipcc $(HIPCC_OPTS) |
| 47 |
FC_OPTS = "-DHIPFORT_ARCH=\"$(ARCH)\"" |
| 48 |
FC = $(HIPFORT_COMPILER) -cpp -I$(MOD_DIR) $(FC_OPTS) |