# Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # 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. # # Location of common libraries LIB_DIR = /usr/lib/aarch64-linux-gnu # NOTE: This directory PATH will be moved from "tegra" to "nvidia". TEGRA_LIB_DIR ?= /usr/lib/aarch64-linux-gnu/tegra # Location of the CUDA Toolkit CUDA_PATH ?= /usr/local/cuda # Location of NVSCI header NVSCI_HEADER_DIR ?= /usr/include/nvsci_headers NVSCI_LIB_DIR = $(TEGRA_LIB_DIR) GCC ?= g++ NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(GCC) # internal flags NVCCFLAGS := CCFLAGS := LDFLAGS := # Extra user flags EXTRA_NVCCFLAGS ?= EXTRA_LDFLAGS ?= EXTRA_CCFLAGS ?= override abi := aarch64 LDFLAGS += --dynamic-linker=/lib/ld-linux-aarch64.so.1 # Debug build flags dbg = 0 ifeq ($(dbg),1) NVCCFLAGS += -g -G TARGET := debug else TARGET := release endif ALL_CCFLAGS := ALL_CCFLAGS += $(NVCCFLAGS) ALL_CCFLAGS += $(EXTRA_NVCCFLAGS) ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS)) ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS)) ALL_LDFLAGS := ALL_LDFLAGS += $(ALL_CCFLAGS) ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS)) ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS)) ################################################################################ # Common includes and paths INCLUDES := -I./ LIBRARIES := -L$(LIB_DIR) CUDA_SEARCH_PATH ?= $(CUDA_PATH)/lib64/stubs CUDA_SEARCH_PATH += $(CUDA_PATH)/lib/stubs CUDA_SEARCH_PATH += $(CUDA_PATH)/targets/aarch64-linux/lib/stubs CUDALIB ?= $(shell find -L $(CUDA_SEARCH_PATH) -maxdepth 1 -name libcuda.so 2> /dev/null) ifeq ("$(CUDALIB)","") $(error ERROR - libcuda.so not found, CUDA Driver is not installed or CUDA_PATH is not correctly set.) else CUDALIB := $(shell echo $(CUDALIB) | sed "s/ .*//" | sed "s/\/libcuda.so//" ) LIBRARIES += -L$(CUDALIB) -lcuda -lrt endif # Includes and paths for NVSCI libraries NVSCIBUFHEADER := $(shell find -L $(NVSCI_HEADER_DIR) -name nvscibuf.h -print 2>/dev/null) NVSCISYNCHEADER := $(shell find -L $(NVSCI_HEADER_DIR) -name nvscisync.h -print 2>/dev/null) NVSCISTREAMHEADER := $(shell find -L $(NVSCI_HEADER_DIR) -name nvscistream.h -print 2>/dev/null) NVSCIEVENTHEADER := $(shell find -L $(NVSCI_HEADER_DIR) -name nvscievent.h -print 2>/dev/null) NVSCIIPCHEADER := $(shell find -L $(NVSCI_HEADER_DIR) -name nvsciipc.h -print 2>/dev/null) ifeq ("$(NVSCIBUFHEADER)","") $(error ERROR - nvscibuf.h not found in $(NVSCI_HEADER_DIR)) endif ifeq ("$(NVSCISYNCHEADER)","") $(error ERROR - nvscisync.h not found in $(NVSCI_HEADER_DIR)) endif ifeq ("$(NVSCISTREAMHEADER)","") $(error ERROR - nvscistream.h not found in $(NVSCI_HEADER_DIR)) endif ifeq ("$(NVSCIEVENTHEADER)","") $(error ERROR - nvscievent.h not found in $(NVSCI_HEADER_DIR)) endif ifeq ("$(NVSCIIPCHEADER)","") $(error ERROR - nvsciipc.h not found in $(NVSCI_HEADER_DIR)) endif INCLUDES += -I$(NVSCI_HEADER_DIR) LIBRARIES += -L$(NVSCI_LIB_DIR) -lnvscibuf -lnvscisync -lnvscievent -lnvsciipc -lnvscistream ALL_CCFLAGS += --std=c++11 --threads 0 # CUDA code generation flags # Gencode arguments SMS ?= 53 61 70 72 75 80 86 87 ifeq ($(GENCODE_FLAGS),) # Generate SASS code for each SM architecture listed in $(SMS) $(foreach sm,$(SMS),$(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm))) # Generate PTX code from the highest SM architecture in $(SMS) to guarantee forward-compatibility HIGHEST_SM := $(lastword $(sort $(SMS))) ifneq ($(HIGHEST_SM),) GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM) endif endif ################################################################################ # Target rules OUTPUT := nvscistream_event_sample all: build build: $(OUTPUT) OBJ := main.o OBJ += block_common.o OBJ += block_c2c.o OBJ += block_consumer_uc1.o OBJ += block_ipc.o OBJ += block_limiter.o OBJ += block_multicast.o OBJ += block_pool.o OBJ += block_presentsync.o OBJ += block_producer_uc1.o OBJ += block_queue.o OBJ += block_returnsync.o OBJ += event_loop_service.o OBJ += event_loop_threads.o OBJ += util.o %.o: %.c $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $< $(OUTPUT): $(OBJ) $(NVCC) $(ALL_LDFLAGS) $(GENCODE_FLAGS) -o $@ $+ $(LIBRARIES) run: build $(OUTPUT) testrun: build clean: rm -f $(OBJ) $(OUTPUT) clobber: clean