# SPDX-FileCopyrightText: Copyright (c) 2019 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NvidiaProprietary
#
# NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
# property and proprietary rights in and to this material, related
# documentation and any modifications thereto. Any use, reproduction,
# disclosure or distribution of this material and related documentation
# without an express license agreement from NVIDIA CORPORATION or
# its affiliates is strictly prohibited.

TESTNO = 1
FC ?= nvfortran
OBJ = o
EXE = out
UNAME := $(shell uname -a)
ifeq ($(findstring _NT, $(UNAME)), _NT)
	OBJ = obj
	EXE = exe
endif

MAIN = t$(TESTNO).CUF
TEST = wmma$(TESTNO)
FILE = wmma$(TESTNO).CUF

FCFLAGS ?= -cuda

ifeq ($(findstring x86_64, $(UNAME)), x86_64)
	WMMAUTILS=check_mod.$(OBJ) vector_types.$(OBJ) ../Utils/avx.s
	WMMAPP=-DX8664
else
	WMMAUTILS=check_mod.$(OBJ) vector_types.$(OBJ)
	WMMAPP=
endif

all: build run verify

build: $(MAIN) $(FILE)
	$(FC) $(FCFLAGS) -c $(WMMAPP) ../Utils/vector_types.F90
	$(FC) $(FCFLAGS) -c ../Utils/check_mod.f90
	$(FC) $(FCFLAGS) -I../Utils -o $(TEST).$(EXE) $(MAIN) $(FILE) $(WMMAUTILS)

run: $(TEST).$(EXE)
	$(RUN) ./$(TEST).$(EXE)

verify:

clean:
	@echo 'Cleaning up...'
	@rm -rf *.$(EXE) *.dwf *.pdb *.mod *.$(OBJ)
