# SPDX-FileCopyrightText: Copyright (c) 2026 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.

TEST ?= qr_gpu
SOURCE = qr.cpp
CXX = nvc++
EXE = exe

NO_SYNC ?= 0 # Do not sync after each linalg/cuBLAS call
VERBOSE ?= 0

ifeq ($(TEST), qr_gpu)
  CXXFLAGS ?= -stdpar -cudalib=cublas
  ifeq ($(NO_SYNC),1)
    CXXFLAGS += -D_NO_SYNC
  endif
else ifeq ($(TEST), qr_multicore)
  CXXFLAGS ?= -stdpar=multicore -lblas -llapack
else ifeq ($(TEST), qr_seq)
  CXXFLAGS ?= -stdpar
else ifeq ($(TEST), qr_cublas)
  SOURCE = qr_cublas.cpp
  CXXFLAGS ?= -cudalib=cublas -x cu
  ifeq ($(NO_SYNC),1)
    CXXFLAGS += -D_NO_SYNC
  endif
endif

ifeq ($(VERBOSE),1)
  CXXFLAGS += -D_VERBOSE
endif

all: build run verify

build: $(SOURCE)
	$(CXX) $(CXXFLAGS) -o $(TEST).$(EXE) --c++17 $<

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

verify:

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