diff --git a/.github/workflows/build-rocm-examples-reusable.yml b/.github/workflows/build-rocm-examples-reusable.yml index fe8b7bf13b..26bfac8574 100644 --- a/.github/workflows/build-rocm-examples-reusable.yml +++ b/.github/workflows/build-rocm-examples-reusable.yml @@ -74,6 +74,7 @@ jobs: echo "PATH=${ROCM_PATH}/bin:${ROCM_PATH}/llvm/bin:${PATH}" >> $GITHUB_ENV echo "LD_LIBRARY_PATH=${ROCM_PATH}/lib:${ROCM_PATH}/llvm/lib:${ROCM_PATH}/lib/rocprofiler-systems" >> $GITHUB_ENV echo "ENABLE_OPENMP=OFF" >> $GITHUB_ENV + echo "HIPCC_COMPILE_FLAGS_APPEND=--offload-arch=${{ matrix.gpu_config.gpu_target }}" >> $GITHUB_ENV - name: Install TheRock tarball if: ${{ matrix.install_method == 'tarball' }} @@ -104,8 +105,15 @@ jobs: echo "PATH=${ROCM_PATH}/bin:${ROCM_PATH}/llvm/bin:${PATH}" >> $GITHUB_ENV echo "LD_LIBRARY_PATH=${ROCM_PATH}/lib:${ROCM_PATH}/llvm/lib:${ROCM_PATH}/lib/rocprofiler-systems" >> $GITHUB_ENV echo "ENABLE_OPENMP=ON" >> $GITHUB_ENV + echo "HIPCC_COMPILE_FLAGS_APPEND=--offload-arch=${{ matrix.gpu_config.gpu_target }}" >> $GITHUB_ENV + + - name: Makefile build + run: | + ./Scripts/configure.sh --rocm-path="${ROCM_PATH}" + make -j HIP_ARCHITECTURES="${{ matrix.gpu_config.gpu_target }}" - name: CMake configure + if: ${{ !cancelled() }} run: | cmake -S . -B build -DCMAKE_HIP_ARCHITECTURES="${{ matrix.gpu_config.gpu_target }}" -DCMAKE_BUILD_RPATH="${ROCM_PATH}/lib" -DROCM_EXAMPLES_ENABLE_OPENMP="${ENABLE_OPENMP}" 2> >(tee cmake_error.log >&2) @@ -141,17 +149,39 @@ jobs: fi - name: CMake build + if: ${{ !cancelled() }} run: | cmake --build build -j - - name: Upload build artifacts - if: success() + - name: Collect Makefile build artifacts + if: ${{ !cancelled() }} + run: | + mkdir -p /tmp/makefile_build + find . -name Makefile -not -path './build/*' | while IFS= read -r makefile; do + dir=$(dirname "$makefile") + example_name=$(grep '^EXAMPLE := ' "$makefile" 2>/dev/null | head -1 | sed 's/^EXAMPLE := //' || true) + if [ -n "${example_name}" ] && [ -x "${dir}/${example_name}" ]; then + mkdir -p "/tmp/makefile_build/${dir}" + cp "${dir}/${example_name}" "/tmp/makefile_build/${dir}/" + fi + done + + - name: Upload CMake build artifacts + if: ${{ !cancelled() }} uses: actions/upload-artifact@v4 with: name: rocm-examples-build-${{ inputs.distro }}-${{ matrix.gpu_config.gpu_target }}-${{ steps.sanity-check.outputs.rocm_version || steps.install-tarball.outputs.rocm_version }}-${{ matrix.install_method }} path: build/ + - name: Upload Makefile build artifacts + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: makefile-build-${{ inputs.distro }}-${{ matrix.gpu_config.gpu_target }}-${{ steps.sanity-check.outputs.rocm_version || steps.install-tarball.outputs.rocm_version }}-${{ matrix.install_method }} + path: /tmp/makefile_build/ + - name: Run tests + if: ${{ !cancelled() }} run: | python3 .github/build_tools/generate_skip_tests.py --target ${{ matrix.gpu_config.gpu_target }} --distro ${{ inputs.distro }} @@ -196,7 +226,7 @@ jobs: echo "
Failed tests output" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo '```' >> $GITHUB_STEP_SUMMARY - + awk ' /^[0-9]+\/[0-9]+ Testing: / { if (inblock && failed) print block; block = $0; inblock = 1; failed = 0; seen_result = 0; next } inblock { block = block "\n" $0 } @@ -205,7 +235,7 @@ jobs: /^-+$/ { if (inblock && seen_result) { if (failed) print block; inblock = 0 } } END { if (inblock && failed) print block } ' "${LAST_TEST_LOG}" >> $GITHUB_STEP_SUMMARY - + echo '```' >> $GITHUB_STEP_SUMMARY echo "
" >> $GITHUB_STEP_SUMMARY fi diff --git a/.gitignore b/.gitignore index 6c015456b0..b44f3447cd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ *.pdb CMakeUserPresets.json .cline_storage +config.mk diff --git a/Applications/Makefile b/Applications/Makefile index 0fa70928d1..a0dedbfaa6 100644 --- a/Applications/Makefile +++ b/Applications/Makefile @@ -26,8 +26,11 @@ EXAMPLES := \ fdtd \ floyd_warshall \ histogram \ - prefix_sum \ - sobel_filter + prefix_sum + +ifneq ($(wildcard /usr/include/GLFW/glfw3.h),) + EXAMPLES += sobel_filter +endif ifneq ($(GPU_RUNTIME), CUDA) EXAMPLES += \ diff --git a/Applications/sobel_filter/Makefile b/Applications/sobel_filter/Makefile index 7426b2121c..aad6d97bf0 100644 --- a/Applications/sobel_filter/Makefile +++ b/Applications/sobel_filter/Makefile @@ -25,6 +25,12 @@ COMMON_INCLUDE_DIR := ../../Common EXTERNAL_DIR := ../../External GPU_RUNTIME ?= HIP +# Dependency checking +REQUIRED_DEPS := GLFW3 +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include @@ -34,9 +40,9 @@ HIPCXX ?= $(ROCM_PATH)/bin/hipcc # Common variables and flags CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) -ICPPFLAGS := -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) $(shell pkg-config --cflags glfw3) +ICPPFLAGS := -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) $(GLFW3_CFLAGS) ILDFLAGS := -ILDLIBS := $(shell pkg-config --libs glfw3) -ldl +ILDLIBS := $(GLFW3_LIBS) -ldl ifeq ($(GPU_RUNTIME), CUDA) ICXXFLAGS += -x cu @@ -63,3 +69,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Common/find_filesystem.mk b/Common/find_filesystem.mk new file mode 100644 index 0000000000..005b24c67c --- /dev/null +++ b/Common/find_filesystem.mk @@ -0,0 +1,43 @@ +# MIT License +# +# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Detect whether linking std::experimental::filesystem requires -lstdc++fs. +# Older toolchains (GCC <= 8 / SLES default) ship the implementation in a +# separate static library; GCC >= 9 has it merged into libstdc++ proper. +# +# Mirrors the behavior of Common/FindFilesystem.cmake for the Make build path. +# +# Usage in leaf Makefiles: +# include $(COMMON_INCLUDE_DIR)/find_filesystem.mk +# ... +# ILDLIBS := -lrocdecode ... $(CXX_FS_LIB) +# +# Output variable: +# CXX_FS_LIB - either "-lstdc++fs" or empty. + +_FS_OK_BARE := $(shell { echo '#include '; echo 'int main(){std::experimental::filesystem::path p; return 0;}'; } | $${CXX:-c++} -x c++ -std=c++17 - -o /dev/null 2>/dev/null && echo 1 || echo 0) +ifeq ($(_FS_OK_BARE),0) + _FS_OK_WITH_LIB := $(shell { echo '#include '; echo 'int main(){std::experimental::filesystem::path p; return 0;}'; } | $${CXX:-c++} -x c++ -std=c++17 - -lstdc++fs -o /dev/null 2>/dev/null && echo 1 || echo 0) + ifeq ($(_FS_OK_WITH_LIB),1) + CXX_FS_LIB := -lstdc++fs + endif +endif diff --git a/Common/require_deps.mk b/Common/require_deps.mk new file mode 100644 index 0000000000..cffa10f643 --- /dev/null +++ b/Common/require_deps.mk @@ -0,0 +1,135 @@ +# MIT License +# +# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Dependency checker for rocm-examples Makefile build system +# +# Usage in example Makefiles: +# REQUIRED_DEPS := FFMPEG OPENCV +# include $(COMMON_INCLUDE_DIR)/require_deps.mk +# +# Before including, set COMMON_INCLUDE_DIR (already standard in all examples). +# +# This file works in two modes: +# 1. Fast path: includes config.mk (generated by configure.sh) from the repo root +# 2. Fallback: uses inline pkg-config checks for standalone builds +# +# After including, check SKIP_BUILD. This composes with filter_hip_architectures.mk +# which also sets SKIP_BUILD. +# +# Output variables: +# SKIP_BUILD - set to 1 if any required dependency is missing +# MISSING_DEPS - list of missing dependency names + +# Locate the repository root relative to COMMON_INCLUDE_DIR +_REPO_ROOT := $(dir $(COMMON_INCLUDE_DIR)) + +# Try to include the pre-generated config.mk (silent if absent) +-include $(_REPO_ROOT)/config.mk + +# If config.mk was not found, run inline fallback detection. +# We detect this by checking if HAVE_FFMPEG is defined (it's always written by configure.sh). +ifndef HAVE_FFMPEG + # Fallback: detect dependencies via pkg-config / file existence + + # FFmpeg (pkg-config + link test to catch missing -dev packages) + _FFMPEG_CHECK := $(shell pkg-config --exists libavcodec libavformat libavutil 2>/dev/null \ + && echo 'int main(){return 0;}' | $${CC:-cc} -x c - $$(pkg-config --libs libavcodec libavformat libavutil) -o /dev/null 2>/dev/null \ + && echo 1 || echo 0) + HAVE_FFMPEG := $(_FFMPEG_CHECK) + ifeq ($(HAVE_FFMPEG),1) + FFMPEG_CFLAGS := $(shell pkg-config --cflags libavcodec libavformat libavutil 2>/dev/null) + FFMPEG_LIBS := $(shell pkg-config --libs libavcodec libavformat libavutil 2>/dev/null || echo "-lavcodec -lavformat -lavutil") + else + FFMPEG_CFLAGS := + FFMPEG_LIBS := + endif + + # OpenCV (pkg-config + link test) + _OPENCV_CHECK := $(shell (pkg-config --exists opencv4 2>/dev/null && echo 'int main(){return 0;}' | $${CC:-cc} -x c - $$(pkg-config --libs opencv4) -o /dev/null 2>/dev/null && echo 1) \ + || (pkg-config --exists opencv 2>/dev/null && echo 'int main(){return 0;}' | $${CC:-cc} -x c - $$(pkg-config --libs opencv) -o /dev/null 2>/dev/null && echo 1) \ + || echo 0) + HAVE_OPENCV := $(_OPENCV_CHECK) + ifeq ($(HAVE_OPENCV),1) + OPENCV_CFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) + OPENCV_LIBS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv) + else + OPENCV_CFLAGS := + OPENCV_LIBS := + endif + + # GLFW3 (pkg-config + link test) + _GLFW3_CHECK := $(shell pkg-config --exists glfw3 2>/dev/null \ + && echo 'int main(){return 0;}' | $${CC:-cc} -x c - $$(pkg-config --libs glfw3) -o /dev/null 2>/dev/null \ + && echo 1 || echo 0) + HAVE_GLFW3 := $(_GLFW3_CHECK) + ifeq ($(HAVE_GLFW3),1) + GLFW3_CFLAGS := $(shell pkg-config --cflags glfw3 2>/dev/null) + GLFW3_LIBS := $(shell pkg-config --libs glfw3 2>/dev/null) + else + GLFW3_CFLAGS := + GLFW3_LIBS := + endif + + # Vulkan (pkg-config + link test) + _VULKAN_CHECK := $(shell pkg-config --exists vulkan 2>/dev/null \ + && echo 'int main(){return 0;}' | $${CC:-cc} -x c - $$(pkg-config --libs vulkan) -o /dev/null 2>/dev/null \ + && echo 1 || echo 0) + HAVE_VULKAN := $(_VULKAN_CHECK) + ifeq ($(HAVE_VULKAN),1) + VULKAN_CFLAGS := $(shell pkg-config --cflags vulkan 2>/dev/null) + VULKAN_LIBS := $(shell pkg-config --libs vulkan 2>/dev/null || echo "-lvulkan") + else + VULKAN_CFLAGS := + VULKAN_LIBS := + endif + + # libdw (elfutils) + _LIBDW_CHECK := $(shell pkg-config --exists libdw 2>/dev/null && echo 1 || echo 0) + ifeq ($(_LIBDW_CHECK),0) + _LIBDW_CHECK := $(if $(or $(wildcard /usr/include/elfutils/libdw.h),$(wildcard /usr/include/dwarf.h)),1,0) + endif + HAVE_LIBDW := $(_LIBDW_CHECK) + + # amd_comgr + ROCM_PATH ?= /opt/rocm + _AMD_COMGR_CHECK := $(if $(or $(wildcard $(ROCM_PATH)/include/amd_comgr/amd_comgr.h),$(wildcard $(ROCM_PATH)/lib/libamd_comgr.so)),1,0) + ifeq ($(_AMD_COMGR_CHECK),0) + _AMD_COMGR_CHECK := $(shell pkg-config --exists amd_comgr 2>/dev/null && echo 1 || echo 0) + endif + HAVE_AMD_COMGR := $(_AMD_COMGR_CHECK) + + # glslangValidator + _GLSLANG_CHECK := $(shell command -v glslangValidator >/dev/null 2>&1 && echo 1 || echo 0) + HAVE_GLSLANG_VALIDATOR := $(_GLSLANG_CHECK) + +endif # ifndef HAVE_FFMPEG + +# Check REQUIRED_DEPS against HAVE_ flags +MISSING_DEPS := +$(foreach dep,$(REQUIRED_DEPS),\ + $(if $(filter 1,$(HAVE_$(dep))),,\ + $(eval MISSING_DEPS += $(dep)))) + +ifneq ($(MISSING_DEPS),) + SKIP_BUILD := 1 + $(info $(EXAMPLE): Skipping build — missing dependencies: $(MISSING_DEPS)) +endif diff --git a/Dockerfiles/almalinux-8.Dockerfile b/Dockerfiles/almalinux-8.Dockerfile index d56d178b80..19a5a7ffe7 100644 --- a/Dockerfiles/almalinux-8.Dockerfile +++ b/Dockerfiles/almalinux-8.Dockerfile @@ -22,6 +22,7 @@ RUN dnf install -y dnf-plugins-core && \ git \ curl \ nasm \ + pkgconf-pkg-config \ python3.11 \ python3.11-pip \ elfutils-devel \ @@ -86,7 +87,7 @@ RUN mkdir -p /opt/vulkan-sdk && \ ENV PATH="${VULKAN_SDK}/bin:${PATH}" ENV LD_LIBRARY_PATH="${VULKAN_SDK}/lib:${LD_LIBRARY_PATH}" ENV VK_ADD_LAYER_PATH="${VULKAN_SDK}/share/vulkan/explicit_layer.d" -ENV PKG_CONFIG_PATH="${VULKAN_SDK}/share/pkgconfig:${VULKAN_SDK}/lib/pkgconfig" +ENV PKG_CONFIG_PATH="${VULKAN_SDK}/share/pkgconfig:${VULKAN_SDK}/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig" # Build FFmpeg from source (not available in RHEL 8 repos) WORKDIR /tmp diff --git a/HIP-Basic/Makefile b/HIP-Basic/Makefile index 95606788ed..9f83aaff18 100644 --- a/HIP-Basic/Makefile +++ b/HIP-Basic/Makefile @@ -36,16 +36,21 @@ EXAMPLES := \ moving_average \ multi_gpu_data_transfer \ occupancy \ - opengl_interop \ runtime_compilation \ saxpy \ shared_memory \ streams \ static_host_library \ texture_management \ - vulkan_interop \ warp_shuffle +ifneq ($(wildcard /usr/include/GLFW/glfw3.h),) + EXAMPLES += opengl_interop + ifneq ($(wildcard /usr/include/vulkan/vulkan.h),) + EXAMPLES += vulkan_interop + endif +endif + # Only supported on HIP (not CUDA). ifneq ($(GPU_RUNTIME), CUDA) EXAMPLES += \ diff --git a/HIP-Basic/opengl_interop/Makefile b/HIP-Basic/opengl_interop/Makefile index 059027042e..0c5fa7f302 100644 --- a/HIP-Basic/opengl_interop/Makefile +++ b/HIP-Basic/opengl_interop/Makefile @@ -25,6 +25,12 @@ COMMON_INCLUDE_DIR := ../../Common EXTERNAL_DIR := ../../External GPU_RUNTIME ?= HIP +# Dependency checking +REQUIRED_DEPS := GLFW3 +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include @@ -34,9 +40,9 @@ HIPCXX ?= $(ROCM_PATH)/bin/hipcc # Common variables and flags CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) -ICPPFLAGS := -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) $(shell pkg-config --cflags glfw3) +ICPPFLAGS := -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) $(GLFW3_CFLAGS) ILDFLAGS := -ILDLIBS := $(shell pkg-config --libs glfw3) -ldl +ILDLIBS := $(GLFW3_LIBS) -ldl ifeq ($(GPU_RUNTIME), CUDA) ICXXFLAGS += -x cu @@ -65,3 +71,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/HIP-Basic/vulkan_interop/Makefile b/HIP-Basic/vulkan_interop/Makefile index d8bc49e9fd..0f64df6a50 100644 --- a/HIP-Basic/vulkan_interop/Makefile +++ b/HIP-Basic/vulkan_interop/Makefile @@ -24,6 +24,12 @@ EXAMPLE := hip_vulkan_interop COMMON_INCLUDE_DIR := ../../Common GPU_RUNTIME ?= HIP +# Dependency checking +REQUIRED_DEPS := GLFW3 VULKAN GLSLANG_VALIDATOR +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm CUDA_INSTALL_DIR ?= /usr/local/cuda @@ -36,9 +42,9 @@ CUDACXX ?= $(CUDA_INSTALL_DIR)/bin/nvcc # Common variables and flags CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) -ICPPFLAGS := -I $(COMMON_INCLUDE_DIR) $(shell pkg-config --cflags glfw3 vulkan) +ICPPFLAGS := -I $(COMMON_INCLUDE_DIR) $(GLFW3_CFLAGS) $(VULKAN_CFLAGS) ILDFLAGS := -ILDLIBS := $(shell pkg-config --libs glfw3) +ILDLIBS := $(GLFW3_LIBS) IGLSLFLAGS := -V100 ifeq ($(GPU_RUNTIME), CUDA) @@ -72,3 +78,9 @@ clean: $(RM) $(EXAMPLE) sinewave.frag.spv.h sinewave.vert.spv.h .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/HIP-Doc/Programming-Guide/HIP-C++-Language-Extensions/template_warp_size_reduction/.gitignore b/HIP-Doc/Programming-Guide/HIP-C++-Language-Extensions/template_warp_size_reduction/.gitignore index de263d7ab4..717e001251 100644 --- a/HIP-Doc/Programming-Guide/HIP-C++-Language-Extensions/template_warp_size_reduction/.gitignore +++ b/HIP-Doc/Programming-Guide/HIP-C++-Language-Extensions/template_warp_size_reduction/.gitignore @@ -1 +1 @@ -hip_warp_size_reduction +hip_template_warp_size_reduction diff --git a/HIP-Doc/Programming-Guide/HIP-C++-Language-Extensions/warp_size_reduction/.gitignore b/HIP-Doc/Programming-Guide/HIP-C++-Language-Extensions/warp_size_reduction/.gitignore index 717e001251..de263d7ab4 100644 --- a/HIP-Doc/Programming-Guide/HIP-C++-Language-Extensions/warp_size_reduction/.gitignore +++ b/HIP-Doc/Programming-Guide/HIP-C++-Language-Extensions/warp_size_reduction/.gitignore @@ -1 +1 @@ -hip_template_warp_size_reduction +hip_warp_size_reduction diff --git a/HIP-Doc/Programming-Guide/Porting-CUDA-code-to-HIP/identifying_host_device_compilation_pass/Makefile b/HIP-Doc/Programming-Guide/Porting-CUDA-code-to-HIP/identifying_host_device_compilation_pass/Makefile index a714864626..2f7db8d9d1 100644 --- a/HIP-Doc/Programming-Guide/Porting-CUDA-code-to-HIP/identifying_host_device_compilation_pass/Makefile +++ b/HIP-Doc/Programming-Guide/Porting-CUDA-code-to-HIP/identifying_host_device_compilation_pass/Makefile @@ -20,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -EXAMPLE := hip_calling_global_functions +EXAMPLE := hip_identifying_host_device_compilation_pass GPU_RUNTIME ?= HIP # HIP variables diff --git a/HIP-Doc/Tutorials/Programming-Patterns/bfs/.gitignore b/HIP-Doc/Tutorials/Programming-Patterns/bfs/.gitignore index a38f964b41..e66eec3ac7 100644 --- a/HIP-Doc/Tutorials/Programming-Patterns/bfs/.gitignore +++ b/HIP-Doc/Tutorials/Programming-Patterns/bfs/.gitignore @@ -1 +1,2 @@ -hip_bfs \ No newline at end of file +hip_bfs +graphgen diff --git a/HIP-Doc/Tutorials/Programming-Patterns/bfs/Makefile b/HIP-Doc/Tutorials/Programming-Patterns/bfs/Makefile index 9465e1bf2e..fdff26125a 100644 --- a/HIP-Doc/Tutorials/Programming-Patterns/bfs/Makefile +++ b/HIP-Doc/Tutorials/Programming-Patterns/bfs/Makefile @@ -25,7 +25,7 @@ GRAPHGEN := graphgen GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include HIPCXX ?= $(ROCM_PATH)/bin/hipcc diff --git a/HIP-Doc/Tutorials/Programming-Patterns/histogram_atomics/Makefile b/HIP-Doc/Tutorials/Programming-Patterns/histogram_atomics/Makefile index acce95a503..ca6360c2af 100644 --- a/HIP-Doc/Tutorials/Programming-Patterns/histogram_atomics/Makefile +++ b/HIP-Doc/Tutorials/Programming-Patterns/histogram_atomics/Makefile @@ -24,7 +24,7 @@ EXAMPLE := hip_histogram_atomics GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include HIPCXX ?= $(ROCM_PATH)/bin/hipcc diff --git a/HIP-Doc/Tutorials/Programming-Patterns/image_convolution/Makefile b/HIP-Doc/Tutorials/Programming-Patterns/image_convolution/Makefile index 4fda9962cd..3e07b7ee54 100644 --- a/HIP-Doc/Tutorials/Programming-Patterns/image_convolution/Makefile +++ b/HIP-Doc/Tutorials/Programming-Patterns/image_convolution/Makefile @@ -24,7 +24,7 @@ EXAMPLE := hip_image_convolution GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include HIPCXX ?= $(ROCM_PATH)/bin/hipcc diff --git a/HIP-Doc/Tutorials/Programming-Patterns/kmeans/Makefile b/HIP-Doc/Tutorials/Programming-Patterns/kmeans/Makefile index 6627c745f8..f5a5b828c6 100644 --- a/HIP-Doc/Tutorials/Programming-Patterns/kmeans/Makefile +++ b/HIP-Doc/Tutorials/Programming-Patterns/kmeans/Makefile @@ -24,7 +24,7 @@ EXAMPLE := hip_kmeans GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include HIPCXX ?= $(ROCM_PATH)/bin/hipcc diff --git a/HIP-Doc/Tutorials/Programming-Patterns/matrix_multiplication/Makefile b/HIP-Doc/Tutorials/Programming-Patterns/matrix_multiplication/Makefile index bda6474285..563ed975b6 100644 --- a/HIP-Doc/Tutorials/Programming-Patterns/matrix_multiplication/Makefile +++ b/HIP-Doc/Tutorials/Programming-Patterns/matrix_multiplication/Makefile @@ -24,7 +24,7 @@ EXAMPLE := hip_matrix_multiply GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include HIPCXX ?= $(ROCM_PATH)/bin/hipcc diff --git a/Libraries/MIGraphX/migraphx/cpp_dynamic_batch/Makefile b/Libraries/MIGraphX/migraphx/cpp_dynamic_batch/Makefile index ade6817991..dcb67c8f2d 100644 --- a/Libraries/MIGraphX/migraphx/cpp_dynamic_batch/Makefile +++ b/Libraries/MIGraphX/migraphx/cpp_dynamic_batch/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include MIGRAPHX_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/MIGraphX/migraphx/cpp_parse_load_save/Makefile b/Libraries/MIGraphX/migraphx/cpp_parse_load_save/Makefile index 2efc67c2cd..dfca8cfa38 100644 --- a/Libraries/MIGraphX/migraphx/cpp_parse_load_save/Makefile +++ b/Libraries/MIGraphX/migraphx/cpp_parse_load_save/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include MIGRAPHX_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/MIGraphX/migraphx/custom_op_hip_kernel/Makefile b/Libraries/MIGraphX/migraphx/custom_op_hip_kernel/Makefile index 15bbe5e55c..c16a5eeb80 100644 --- a/Libraries/MIGraphX/migraphx/custom_op_hip_kernel/Makefile +++ b/Libraries/MIGraphX/migraphx/custom_op_hip_kernel/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include MIGRAPHX_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/MIGraphX/migraphx/custom_op_miopen_kernel/Makefile b/Libraries/MIGraphX/migraphx/custom_op_miopen_kernel/Makefile index 6aaea417c4..d41ff35729 100644 --- a/Libraries/MIGraphX/migraphx/custom_op_miopen_kernel/Makefile +++ b/Libraries/MIGraphX/migraphx/custom_op_miopen_kernel/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include MIGRAPHX_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/MIGraphX/migraphx/custom_op_rocblas_kernel/Makefile b/Libraries/MIGraphX/migraphx/custom_op_rocblas_kernel/Makefile index cab26acb73..6750e99ccb 100644 --- a/Libraries/MIGraphX/migraphx/custom_op_rocblas_kernel/Makefile +++ b/Libraries/MIGraphX/migraphx/custom_op_rocblas_kernel/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include MIGRAPHX_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/MIGraphX/vision/cpp_mnist/Makefile b/Libraries/MIGraphX/vision/cpp_mnist/Makefile index 4552280eda..750df57fd8 100644 --- a/Libraries/MIGraphX/vision/cpp_mnist/Makefile +++ b/Libraries/MIGraphX/vision/cpp_mnist/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include MIGRAPHX_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/MIVisionX/canny/Makefile b/Libraries/MIVisionX/canny/Makefile index ba765adc45..deb3692525 100644 --- a/Libraries/MIVisionX/canny/Makefile +++ b/Libraries/MIVisionX/canny/Makefile @@ -25,7 +25,7 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External # ROCm installation directory -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm # MIVisionX and OpenCV include directories MIVISIONX_INCLUDE_DIR := $(ROCM_PATH)/include/mivisionx diff --git a/Libraries/MIVisionX/mv_objdetect/Makefile b/Libraries/MIVisionX/mv_objdetect/Makefile index d769074dfa..41816125c7 100644 --- a/Libraries/MIVisionX/mv_objdetect/Makefile +++ b/Libraries/MIVisionX/mv_objdetect/Makefile @@ -25,7 +25,7 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External # ROCm installation directory -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm # Batch size configuration (can be overridden: make BATCH_SIZE=4) BATCH_SIZE := 1 diff --git a/Libraries/MIVisionX/opencv_orb/Makefile b/Libraries/MIVisionX/opencv_orb/Makefile index 3a9c644600..3d1d05e232 100644 --- a/Libraries/MIVisionX/opencv_orb/Makefile +++ b/Libraries/MIVisionX/opencv_orb/Makefile @@ -25,7 +25,7 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External # ROCm installation directory -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm # MIVisionX and OpenCV include directories MIVISIONX_INCLUDE_DIR := $(ROCM_PATH)/include/mivisionx diff --git a/Libraries/Makefile b/Libraries/Makefile index f8d6ae443f..b709ec1fc7 100644 --- a/Libraries/Makefile +++ b/Libraries/Makefile @@ -31,26 +31,59 @@ LIBRARIES := \ hipRAND ifneq ($(GPU_RUNTIME), CUDA) + +ROCM_PATH ?= /opt/rocm +INCLUDE_DIR := $(ROCM_PATH)/include + LIBRARIES += \ hipBLASLt \ - hipTensor \ - MIGraphX \ - MIVisionX \ RCCL \ - rocAL \ - rocALUTION \ rocBLAS \ - rocCV \ - rocDecode \ rocFFT \ - rocJPEG \ rocPRIM \ rocProfiler-SDK \ rocSOLVER \ rocSPARSE \ rocThrust \ - rocWMMA \ - RPP + rocWMMA + +ifneq ($(wildcard $(INCLUDE_DIR)/rocdecode/rocdecode.h),) +LIBRARIES += rocDecode +endif + +ifneq ($(wildcard $(INCLUDE_DIR)/rocjpeg/rocjpeg.h),) +LIBRARIES += rocJPEG +endif + +# Only build libraries whose headers are present +ifneq ($(wildcard $(INCLUDE_DIR)/hiptensor/hiptensor.hpp),) +LIBRARIES += hipTensor +endif + +ifneq ($(wildcard $(INCLUDE_DIR)/migraphx/migraphx.hpp),) +LIBRARIES += MIGraphX +endif + +ifneq ($(wildcard $(INCLUDE_DIR)/mivisionx/VX/vx.h),) +LIBRARIES += MIVisionX +endif + +ifneq ($(wildcard $(INCLUDE_DIR)/rocal/rocal_api.h),) +LIBRARIES += rocAL +endif + +ifneq ($(wildcard $(INCLUDE_DIR)/rocalution/rocalution.hpp),) +LIBRARIES += rocALUTION +endif + +ifneq ($(wildcard $(INCLUDE_DIR)/roccv/core/tensor.hpp),) +LIBRARIES += rocCV +endif + +ifneq ($(wildcard $(INCLUDE_DIR)/rpp/rpp.h),) +LIBRARIES += RPP +endif + endif all: $(LIBRARIES) diff --git a/Libraries/RCCL/allgather/Makefile b/Libraries/RCCL/allgather/Makefile index cfd04efed0..c69fa9bb74 100644 --- a/Libraries/RCCL/allgather/Makefile +++ b/Libraries/RCCL/allgather/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RCCL_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/RCCL/allreduce/Makefile b/Libraries/RCCL/allreduce/Makefile index 2953d0aace..976ca9f243 100644 --- a/Libraries/RCCL/allreduce/Makefile +++ b/Libraries/RCCL/allreduce/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RCCL_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/RCCL/broadcast/Makefile b/Libraries/RCCL/broadcast/Makefile index 06fdeee3bb..75ce2d41c5 100644 --- a/Libraries/RCCL/broadcast/Makefile +++ b/Libraries/RCCL/broadcast/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RCCL_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/RCCL/buffer_registration/Makefile b/Libraries/RCCL/buffer_registration/Makefile index 0f2cca70f8..44aca85d19 100644 --- a/Libraries/RCCL/buffer_registration/Makefile +++ b/Libraries/RCCL/buffer_registration/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RCCL_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/RCCL/device_api/Makefile b/Libraries/RCCL/device_api/Makefile index daaf2f8222..d186480c8e 100644 --- a/Libraries/RCCL/device_api/Makefile +++ b/Libraries/RCCL/device_api/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RCCL_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/RCCL/gradient_allreduce/Makefile b/Libraries/RCCL/gradient_allreduce/Makefile index 7389216a15..f3e2d40a6e 100644 --- a/Libraries/RCCL/gradient_allreduce/Makefile +++ b/Libraries/RCCL/gradient_allreduce/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RCCL_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/RCCL/reduce/Makefile b/Libraries/RCCL/reduce/Makefile index 4fe2873c16..f7e5fcfb20 100644 --- a/Libraries/RCCL/reduce/Makefile +++ b/Libraries/RCCL/reduce/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RCCL_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/RCCL/reducescatter/Makefile b/Libraries/RCCL/reducescatter/Makefile index 1908bb077e..48cfe0c8b4 100644 --- a/Libraries/RCCL/reducescatter/Makefile +++ b/Libraries/RCCL/reducescatter/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RCCL_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/RCCL/send_recv/Makefile b/Libraries/RCCL/send_recv/Makefile index 0245fe25f0..db82af86a5 100644 --- a/Libraries/RCCL/send_recv/Makefile +++ b/Libraries/RCCL/send_recv/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RCCL_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/RPP/box_filter/Makefile b/Libraries/RPP/box_filter/Makefile index f55f3c40ab..78951ae3e5 100644 --- a/Libraries/RPP/box_filter/Makefile +++ b/Libraries/RPP/box_filter/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RPP_INCLUDE_DIR := $(HIP_INCLUDE_DIR) @@ -36,7 +42,7 @@ HIPCXX ?= $(ROCM_PATH)/bin/hipcc # Common variables and flags CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) -OPENCV_INCLUDE := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) +OPENCV_INCLUDE := $(OPENCV_CFLAGS) ICPPFLAGS := -isystem $(RPP_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) \ $(OPENCV_INCLUDE) -I $(ROCM_PATH)/include/rpp \ -DEXAMPLE_DATA_DIR=\"$(CURDIR)/../data/images\" @@ -63,3 +69,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/RPP/brightness/Makefile b/Libraries/RPP/brightness/Makefile index 279b310c1f..af3337adff 100644 --- a/Libraries/RPP/brightness/Makefile +++ b/Libraries/RPP/brightness/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RPP_INCLUDE_DIR := $(HIP_INCLUDE_DIR) @@ -36,7 +42,7 @@ HIPCXX ?= $(ROCM_PATH)/bin/hipcc # Common variables and flags CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) -OPENCV_INCLUDE := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) +OPENCV_INCLUDE := $(OPENCV_CFLAGS) ICPPFLAGS := -isystem $(RPP_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) \ $(OPENCV_INCLUDE) -I $(ROCM_PATH)/include/rpp \ -DEXAMPLE_DATA_DIR=\"$(CURDIR)/../data/images\" @@ -63,3 +69,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/RPP/contrast/Makefile b/Libraries/RPP/contrast/Makefile index 159222df41..c884c939d0 100644 --- a/Libraries/RPP/contrast/Makefile +++ b/Libraries/RPP/contrast/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RPP_INCLUDE_DIR := $(HIP_INCLUDE_DIR) @@ -36,7 +42,7 @@ HIPCXX ?= $(ROCM_PATH)/bin/hipcc # Common variables and flags CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) -OPENCV_INCLUDE := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) +OPENCV_INCLUDE := $(OPENCV_CFLAGS) ICPPFLAGS := -isystem $(RPP_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) \ $(OPENCV_INCLUDE) -I $(ROCM_PATH)/include/rpp \ -DEXAMPLE_DATA_DIR=\"$(CURDIR)/../data/images\" @@ -63,3 +69,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/RPP/flip/Makefile b/Libraries/RPP/flip/Makefile index 52575ac696..d94b0bd5a3 100644 --- a/Libraries/RPP/flip/Makefile +++ b/Libraries/RPP/flip/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RPP_INCLUDE_DIR := $(HIP_INCLUDE_DIR) @@ -36,7 +42,7 @@ HIPCXX ?= $(ROCM_PATH)/bin/hipcc # Common variables and flags CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) -OPENCV_INCLUDE := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) +OPENCV_INCLUDE := $(OPENCV_CFLAGS) ICPPFLAGS := -isystem $(RPP_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) \ $(OPENCV_INCLUDE) -I $(ROCM_PATH)/include/rpp \ -DEXAMPLE_DATA_DIR=\"$(CURDIR)/../data/images\" @@ -63,3 +69,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/RPP/gamma_correction/Makefile b/Libraries/RPP/gamma_correction/Makefile index 68f8a39e4a..cce2398106 100644 --- a/Libraries/RPP/gamma_correction/Makefile +++ b/Libraries/RPP/gamma_correction/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RPP_INCLUDE_DIR := $(HIP_INCLUDE_DIR) @@ -36,7 +42,7 @@ HIPCXX ?= $(ROCM_PATH)/bin/hipcc # Common variables and flags CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) -OPENCV_INCLUDE := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) +OPENCV_INCLUDE := $(OPENCV_CFLAGS) ICPPFLAGS := -isystem $(RPP_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) \ $(OPENCV_INCLUDE) -I $(ROCM_PATH)/include/rpp \ -DEXAMPLE_DATA_DIR=\"$(CURDIR)/../data/images\" @@ -63,3 +69,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/RPP/resize/Makefile b/Libraries/RPP/resize/Makefile index 6b3ba10795..a6d5b968ce 100644 --- a/Libraries/RPP/resize/Makefile +++ b/Libraries/RPP/resize/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include RPP_INCLUDE_DIR := $(HIP_INCLUDE_DIR) @@ -36,7 +42,7 @@ HIPCXX ?= $(ROCM_PATH)/bin/hipcc # Common variables and flags CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) -OPENCV_INCLUDE := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) +OPENCV_INCLUDE := $(OPENCV_CFLAGS) ICPPFLAGS := -isystem $(RPP_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) \ $(OPENCV_INCLUDE) -I $(ROCM_PATH)/include/rpp \ -DEXAMPLE_DATA_DIR=\"$(CURDIR)/../data/images\" @@ -63,3 +69,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/hipBLASLt/gemm_clamp_bias/Makefile b/Libraries/hipBLASLt/gemm_clamp_bias/Makefile index 032b8223cf..8e4f7491e4 100644 --- a/Libraries/hipBLASLt/gemm_clamp_bias/Makefile +++ b/Libraries/hipBLASLt/gemm_clamp_bias/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include HIPBLASLT_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/rocAL/basic/Makefile b/Libraries/rocAL/basic/Makefile index 63c949240b..d172a2f83c 100644 --- a/Libraries/rocAL/basic/Makefile +++ b/Libraries/rocAL/basic/Makefile @@ -25,7 +25,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCAL_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/rocal diff --git a/Libraries/rocAL/dataloader/Makefile b/Libraries/rocAL/dataloader/Makefile index f9f0a1f2a3..d334165713 100644 --- a/Libraries/rocAL/dataloader/Makefile +++ b/Libraries/rocAL/dataloader/Makefile @@ -25,7 +25,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCAL_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/rocal diff --git a/Libraries/rocAL/image_augmentation/Makefile b/Libraries/rocAL/image_augmentation/Makefile index be2b8f14d8..fd9c8dfc52 100644 --- a/Libraries/rocAL/image_augmentation/Makefile +++ b/Libraries/rocAL/image_augmentation/Makefile @@ -25,7 +25,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCAL_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/rocal diff --git a/Libraries/rocAL/video/Makefile b/Libraries/rocAL/video/Makefile index bdf1d2a8c9..c33d3d0c5d 100644 --- a/Libraries/rocAL/video/Makefile +++ b/Libraries/rocAL/video/Makefile @@ -25,7 +25,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCAL_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/rocal diff --git a/Libraries/rocCV/bilateral_filter/Makefile b/Libraries/rocCV/bilateral_filter/Makefile index db7bc5d877..5791c6c858 100644 --- a/Libraries/rocCV/bilateral_filter/Makefile +++ b/Libraries/rocCV/bilateral_filter/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv @@ -34,8 +40,8 @@ ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv HIPCXX ?= $(ROCM_PATH)/bin/hipcc # OpenCV variables -OPENCV_CXXFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) -OPENCV_LDFLAGS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv) +OPENCV_CXXFLAGS := $(OPENCV_CFLAGS) +OPENCV_LDFLAGS := $(OPENCV_LIBS) # Common variables and flags CXX_STD := c++20 @@ -64,3 +70,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocCV/bnd_box/Makefile b/Libraries/rocCV/bnd_box/Makefile index 2c287bf69e..f2e8b33986 100644 --- a/Libraries/rocCV/bnd_box/Makefile +++ b/Libraries/rocCV/bnd_box/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv @@ -34,8 +40,8 @@ ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv HIPCXX ?= $(ROCM_PATH)/bin/hipcc # OpenCV variables -OPENCV_CXXFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) -OPENCV_LDFLAGS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv) +OPENCV_CXXFLAGS := $(OPENCV_CFLAGS) +OPENCV_LDFLAGS := $(OPENCV_LIBS) # Common variables and flags CXX_STD := c++20 @@ -64,3 +70,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocCV/center_crop/Makefile b/Libraries/rocCV/center_crop/Makefile index e387de774d..2ce98226a4 100644 --- a/Libraries/rocCV/center_crop/Makefile +++ b/Libraries/rocCV/center_crop/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv @@ -34,8 +40,8 @@ ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv HIPCXX ?= $(ROCM_PATH)/bin/hipcc # OpenCV variables -OPENCV_CXXFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) -OPENCV_LDFLAGS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv) +OPENCV_CXXFLAGS := $(OPENCV_CFLAGS) +OPENCV_LDFLAGS := $(OPENCV_LIBS) # Common variables and flags CXX_STD := c++20 @@ -64,3 +70,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocCV/composite/Makefile b/Libraries/rocCV/composite/Makefile index 6545e373fe..07f7c0cd72 100644 --- a/Libraries/rocCV/composite/Makefile +++ b/Libraries/rocCV/composite/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv @@ -34,8 +40,8 @@ ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv HIPCXX ?= $(ROCM_PATH)/bin/hipcc # OpenCV variables -OPENCV_CXXFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) -OPENCV_LDFLAGS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv) +OPENCV_CXXFLAGS := $(OPENCV_CFLAGS) +OPENCV_LDFLAGS := $(OPENCV_LIBS) # Common variables and flags CXX_STD := c++20 @@ -64,3 +70,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocCV/copy_make_border/Makefile b/Libraries/rocCV/copy_make_border/Makefile index 90fd3ce8c4..5f4c5708a4 100644 --- a/Libraries/rocCV/copy_make_border/Makefile +++ b/Libraries/rocCV/copy_make_border/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv @@ -34,8 +40,8 @@ ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv HIPCXX ?= $(ROCM_PATH)/bin/hipcc # OpenCV variables -OPENCV_CXXFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) -OPENCV_LDFLAGS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv) +OPENCV_CXXFLAGS := $(OPENCV_CFLAGS) +OPENCV_LDFLAGS := $(OPENCV_LIBS) # Common variables and flags CXX_STD := c++20 @@ -64,3 +70,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocCV/cropandresize/Makefile b/Libraries/rocCV/cropandresize/Makefile index fdb17c5b86..e8a8949b71 100644 --- a/Libraries/rocCV/cropandresize/Makefile +++ b/Libraries/rocCV/cropandresize/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv @@ -34,8 +40,8 @@ ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv HIPCXX ?= $(ROCM_PATH)/bin/hipcc # OpenCV variables -OPENCV_CXXFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) -OPENCV_LDFLAGS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv) +OPENCV_CXXFLAGS := $(OPENCV_CFLAGS) +OPENCV_LDFLAGS := $(OPENCV_LIBS) # Common variables and flags CXX_STD := c++20 @@ -64,3 +70,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocCV/custom_crop/Makefile b/Libraries/rocCV/custom_crop/Makefile index 22c9b768f8..1e33a7ddf3 100644 --- a/Libraries/rocCV/custom_crop/Makefile +++ b/Libraries/rocCV/custom_crop/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv @@ -34,8 +40,8 @@ ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv HIPCXX ?= $(ROCM_PATH)/bin/hipcc # OpenCV variables -OPENCV_CXXFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) -OPENCV_LDFLAGS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv) +OPENCV_CXXFLAGS := $(OPENCV_CFLAGS) +OPENCV_LDFLAGS := $(OPENCV_LIBS) # Common variables and flags CXX_STD := c++20 @@ -64,3 +70,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocCV/gamma_contrast/Makefile b/Libraries/rocCV/gamma_contrast/Makefile index 6be7a4a790..7a8e96016b 100644 --- a/Libraries/rocCV/gamma_contrast/Makefile +++ b/Libraries/rocCV/gamma_contrast/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv @@ -34,8 +40,8 @@ ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv HIPCXX ?= $(ROCM_PATH)/bin/hipcc # OpenCV variables -OPENCV_CXXFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) -OPENCV_LDFLAGS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv) +OPENCV_CXXFLAGS := $(OPENCV_CFLAGS) +OPENCV_LDFLAGS := $(OPENCV_LIBS) # Common variables and flags CXX_STD := c++20 @@ -64,3 +70,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocCV/normalize/Makefile b/Libraries/rocCV/normalize/Makefile index aed0d88616..703404df0e 100644 --- a/Libraries/rocCV/normalize/Makefile +++ b/Libraries/rocCV/normalize/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv @@ -34,8 +40,8 @@ ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv HIPCXX ?= $(ROCM_PATH)/bin/hipcc # OpenCV variables -OPENCV_CXXFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) -OPENCV_LDFLAGS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv) +OPENCV_CXXFLAGS := $(OPENCV_CFLAGS) +OPENCV_LDFLAGS := $(OPENCV_LIBS) # Common variables and flags CXX_STD := c++20 @@ -64,3 +70,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocCV/warp_perspective/Makefile b/Libraries/rocCV/warp_perspective/Makefile index c76f1983ad..df6903132f 100644 --- a/Libraries/rocCV/warp_perspective/Makefile +++ b/Libraries/rocCV/warp_perspective/Makefile @@ -25,8 +25,14 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := OPENCV +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv @@ -34,8 +40,8 @@ ROCCV_INCLUDE_DIR := $(HIP_INCLUDE_DIR)/roccv HIPCXX ?= $(ROCM_PATH)/bin/hipcc # OpenCV variables -OPENCV_CXXFLAGS := $(shell pkg-config --cflags opencv4 2>/dev/null || pkg-config --cflags opencv) -OPENCV_LDFLAGS := $(shell pkg-config --libs opencv4 2>/dev/null || pkg-config --libs opencv) +OPENCV_CXXFLAGS := $(OPENCV_CFLAGS) +OPENCV_LDFLAGS := $(OPENCV_LIBS) # Common variables and flags CXX_STD := c++20 @@ -64,3 +70,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocDecode/rocdec_decode/Makefile b/Libraries/rocDecode/rocdec_decode/Makefile index 1370172dca..dcd37556c9 100644 --- a/Libraries/rocDecode/rocdec_decode/Makefile +++ b/Libraries/rocDecode/rocdec_decode/Makefile @@ -25,6 +25,10 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Load dependency detection (FFmpeg is optional for this example) +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +include $(COMMON_INCLUDE_DIR)/find_filesystem.mk # HIP variables ROCM_PATH ?= /opt/rocm @@ -45,8 +49,7 @@ CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) ICPPFLAGS := -isystem $(ROCDECODE_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) ILDFLAGS := -L $(ROCM_PATH)/lib -ILDLIBS := -lrocdecode - +ILDLIBS := -lrocdecode $(CXX_FS_LIB) ifeq ($(GPU_RUNTIME), HIP) CXXFLAGS ?= -Wall -Wextra CPPFLAGS += -D__HIP_PLATFORM_AMD__ @@ -59,11 +62,10 @@ ifeq ($(GPU_RUNTIME), HIP) CPPFLAGS += -DENABLE_HOST_DECODE=0 endif - # Optional FFmpeg - FFMPEG_FOUND := $(shell pkg-config --exists libavcodec libavformat libavutil 2>/dev/null && echo 1) - ifeq ($(FFMPEG_FOUND),1) - ICPPFLAGS += $(shell pkg-config --cflags libavcodec libavformat libavutil) - ILDLIBS += $(shell pkg-config --libs libavcodec libavformat libavutil) + # Optional FFmpeg (uses HAVE_FFMPEG from config.mk / require_deps.mk) + ifeq ($(HAVE_FFMPEG),1) + ICPPFLAGS += $(FFMPEG_CFLAGS) + ILDLIBS += $(FFMPEG_LIBS) endif COMPILER := $(HIPCXX) diff --git a/Libraries/rocDecode/video_decode/Makefile b/Libraries/rocDecode/video_decode/Makefile index 122b7f2ec6..0e2e896895 100644 --- a/Libraries/rocDecode/video_decode/Makefile +++ b/Libraries/rocDecode/video_decode/Makefile @@ -25,6 +25,13 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := FFMPEG +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +include $(COMMON_INCLUDE_DIR)/find_filesystem.mk +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm UTILS_DIR := ${ROCM_PATH}/share/rocdecode/utils @@ -46,8 +53,7 @@ CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) ICPPFLAGS := -isystem $(ROCDECODE_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) -I .. -I $(UTILS_DIR) -I $(UTILS_DIR)/rocvideodecode ILDFLAGS := -L $(ROCM_PATH)/lib -ILDLIBS := -lrocdecode -lrocprofiler-register -lavcodec -lavformat -lavutil -lpthread - +ILDLIBS := -lrocdecode -lrocprofiler-register -lavcodec -lavformat -lavutil -lpthread $(CXX_FS_LIB) ifeq ($(GPU_RUNTIME), HIP) CXXFLAGS ?= -Wall -Wextra CPPFLAGS += -D__HIP_PLATFORM_AMD__ @@ -99,3 +105,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocDecode/video_decode_batch/Makefile b/Libraries/rocDecode/video_decode_batch/Makefile index 443a12f067..e8d0c2f857 100644 --- a/Libraries/rocDecode/video_decode_batch/Makefile +++ b/Libraries/rocDecode/video_decode_batch/Makefile @@ -25,6 +25,13 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := FFMPEG +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +include $(COMMON_INCLUDE_DIR)/find_filesystem.mk +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm UTILS_DIR := ${ROCM_PATH}/share/rocdecode/utils @@ -39,7 +46,7 @@ CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) ICPPFLAGS := -isystem $(ROCDECODE_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) -I $(UTILS_DIR) -I $(UTILS_DIR)/rocvideodecode ILDFLAGS := -L $(ROCM_PATH)/lib -ILDLIBS := -lrocdecode -lrocprofiler-register -lavcodec -lavformat -lavutil -lpthread -lstdc++fs +ILDLIBS := -lrocdecode -lrocprofiler-register -lavcodec -lavformat -lavutil -lpthread $(CXX_FS_LIB) ifeq ($(GPU_RUNTIME), HIP) CXXFLAGS ?= -Wall -Wextra @@ -79,3 +86,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocDecode/video_decode_mem/Makefile b/Libraries/rocDecode/video_decode_mem/Makefile index 42dade041d..4cab6d7e84 100644 --- a/Libraries/rocDecode/video_decode_mem/Makefile +++ b/Libraries/rocDecode/video_decode_mem/Makefile @@ -25,6 +25,13 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := FFMPEG +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +include $(COMMON_INCLUDE_DIR)/find_filesystem.mk +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm UTILS_DIR := ${ROCM_PATH}/share/rocdecode/utils @@ -39,8 +46,7 @@ CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) ICPPFLAGS := -isystem $(ROCDECODE_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) -I $(UTILS_DIR) -I $(UTILS_DIR)/rocvideodecode ILDFLAGS := -L $(ROCM_PATH)/lib -ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil - +ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil $(CXX_FS_LIB) ifeq ($(GPU_RUNTIME), HIP) CXXFLAGS ?= -Wall -Wextra CPPFLAGS += -D__HIP_PLATFORM_AMD__ @@ -79,3 +85,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocDecode/video_decode_multi_files/Makefile b/Libraries/rocDecode/video_decode_multi_files/Makefile index 5807bbf620..972347265a 100644 --- a/Libraries/rocDecode/video_decode_multi_files/Makefile +++ b/Libraries/rocDecode/video_decode_multi_files/Makefile @@ -25,6 +25,13 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := FFMPEG +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +include $(COMMON_INCLUDE_DIR)/find_filesystem.mk +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm UTILS_DIR := ${ROCM_PATH}/share/rocdecode/utils @@ -39,8 +46,7 @@ CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) ICPPFLAGS := -isystem $(ROCDECODE_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) -I $(UTILS_DIR) -I $(UTILS_DIR)/rocvideodecode ILDFLAGS := -L $(ROCM_PATH)/lib -ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil - +ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil $(CXX_FS_LIB) ifeq ($(GPU_RUNTIME), HIP) CXXFLAGS ?= -Wall -Wextra CPPFLAGS += -D__HIP_PLATFORM_AMD__ @@ -79,3 +85,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocDecode/video_decode_perf/Makefile b/Libraries/rocDecode/video_decode_perf/Makefile index c8e42d4a4a..3c7e76bd2d 100644 --- a/Libraries/rocDecode/video_decode_perf/Makefile +++ b/Libraries/rocDecode/video_decode_perf/Makefile @@ -25,6 +25,13 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := FFMPEG +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +include $(COMMON_INCLUDE_DIR)/find_filesystem.mk +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm UTILS_DIR := ${ROCM_PATH}/share/rocdecode/utils @@ -46,8 +53,7 @@ CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) ICPPFLAGS := -isystem $(ROCDECODE_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) -I $(UTILS_DIR) -I $(UTILS_DIR)/rocvideodecode ILDFLAGS := -L $(ROCM_PATH)/lib -ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil -lpthread - +ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil -lpthread $(CXX_FS_LIB) ifeq ($(GPU_RUNTIME), HIP) CXXFLAGS ?= -Wall -Wextra CPPFLAGS += -D__HIP_PLATFORM_AMD__ @@ -99,3 +105,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocDecode/video_decode_pic_files/Makefile b/Libraries/rocDecode/video_decode_pic_files/Makefile index 99a4ed3662..c6ad3a65fb 100644 --- a/Libraries/rocDecode/video_decode_pic_files/Makefile +++ b/Libraries/rocDecode/video_decode_pic_files/Makefile @@ -25,6 +25,13 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := FFMPEG +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +include $(COMMON_INCLUDE_DIR)/find_filesystem.mk +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm UTILS_DIR := ${ROCM_PATH}/share/rocdecode/utils @@ -46,8 +53,7 @@ CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) ICPPFLAGS := -isystem $(ROCDECODE_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) -I $(UTILS_DIR) -I $(UTILS_DIR)/rocvideodecode ILDFLAGS := -L $(ROCM_PATH)/lib -ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil - +ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil $(CXX_FS_LIB) ifeq ($(GPU_RUNTIME), HIP) CXXFLAGS ?= -Wall -Wextra CPPFLAGS += -D__HIP_PLATFORM_AMD__ @@ -99,3 +105,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocDecode/video_decode_raw/Makefile b/Libraries/rocDecode/video_decode_raw/Makefile index ad53cd435a..2dcc9a8cae 100644 --- a/Libraries/rocDecode/video_decode_raw/Makefile +++ b/Libraries/rocDecode/video_decode_raw/Makefile @@ -25,6 +25,8 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +include $(COMMON_INCLUDE_DIR)/find_filesystem.mk + # HIP variables ROCM_PATH ?= /opt/rocm UTILS_DIR := ${ROCM_PATH}/share/rocdecode/utils @@ -39,8 +41,7 @@ CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) ICPPFLAGS := -isystem $(ROCDECODE_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) -I $(UTILS_DIR) -I $(UTILS_DIR)/rocvideodecode ILDFLAGS := -L $(ROCM_PATH)/lib -ILDLIBS := -lrocdecode -lpthread - +ILDLIBS := -lrocdecode -lpthread $(CXX_FS_LIB) ifeq ($(GPU_RUNTIME), HIP) CXXFLAGS ?= -Wall -Wextra CPPFLAGS += -D__HIP_PLATFORM_AMD__ diff --git a/Libraries/rocDecode/video_decode_rgb/Makefile b/Libraries/rocDecode/video_decode_rgb/Makefile index e88e7c3953..432351275b 100644 --- a/Libraries/rocDecode/video_decode_rgb/Makefile +++ b/Libraries/rocDecode/video_decode_rgb/Makefile @@ -25,6 +25,13 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := FFMPEG +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +include $(COMMON_INCLUDE_DIR)/find_filesystem.mk +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm UTILS_DIR := ${ROCM_PATH}/share/rocdecode/utils @@ -39,8 +46,7 @@ CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) ICPPFLAGS := -isystem $(ROCDECODE_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) -I $(UTILS_DIR) -I $(UTILS_DIR)/rocvideodecode ILDFLAGS := -L $(ROCM_PATH)/lib -ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil -lswresample -lpthread - +ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil -lswresample -lpthread $(CXX_FS_LIB) ifeq ($(GPU_RUNTIME), HIP) CXXFLAGS ?= -Wall -Wextra CPPFLAGS += -D__HIP_PLATFORM_AMD__ @@ -79,3 +85,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocDecode/video_to_sequence/Makefile b/Libraries/rocDecode/video_to_sequence/Makefile index ac4e9d8484..81de793e3e 100644 --- a/Libraries/rocDecode/video_to_sequence/Makefile +++ b/Libraries/rocDecode/video_to_sequence/Makefile @@ -25,6 +25,13 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP +# Dependency checking +REQUIRED_DEPS := FFMPEG +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +include $(COMMON_INCLUDE_DIR)/find_filesystem.mk +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm UTILS_DIR := ${ROCM_PATH}/share/rocdecode/utils @@ -39,8 +46,7 @@ CXX_STD := c++17 ICXXFLAGS := -std=$(CXX_STD) ICPPFLAGS := -isystem $(ROCDECODE_INCLUDE_DIR) -I $(COMMON_INCLUDE_DIR) -I $(EXTERNAL_DIR) -I $(UTILS_DIR) -I $(UTILS_DIR)/rocvideodecode ILDFLAGS := -L $(ROCM_PATH)/lib -ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil -lswresample -lpthread - +ILDLIBS := -lrocdecode -lavcodec -lavformat -lavutil -lswresample -lpthread $(CXX_FS_LIB) ifeq ($(GPU_RUNTIME), HIP) CXXFLAGS ?= -Wall -Wextra CPPFLAGS += -D__HIP_PLATFORM_AMD__ @@ -79,3 +85,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocFFT/multi_gpu/Makefile b/Libraries/rocFFT/multi_gpu/Makefile index b8d1b82832..4d941f48f9 100644 --- a/Libraries/rocFFT/multi_gpu/Makefile +++ b/Libraries/rocFFT/multi_gpu/Makefile @@ -30,7 +30,7 @@ ifneq ($(GPU_RUNTIME), HIP) endif # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCFFT_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/rocJPEG/rocjpeg_decode/Makefile b/Libraries/rocJPEG/rocjpeg_decode/Makefile index 2e9d34043d..eff7920274 100644 --- a/Libraries/rocJPEG/rocjpeg_decode/Makefile +++ b/Libraries/rocJPEG/rocjpeg_decode/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCJPEG_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/rocJPEG/rocjpeg_decode_batched/Makefile b/Libraries/rocJPEG/rocjpeg_decode_batched/Makefile index 2cafc4be12..04b3a4e973 100644 --- a/Libraries/rocJPEG/rocjpeg_decode_batched/Makefile +++ b/Libraries/rocJPEG/rocjpeg_decode_batched/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCJPEG_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/rocJPEG/rocjpeg_decode_perf/Makefile b/Libraries/rocJPEG/rocjpeg_decode_perf/Makefile index 4ce0031a1b..99a071bdb9 100644 --- a/Libraries/rocJPEG/rocjpeg_decode_perf/Makefile +++ b/Libraries/rocJPEG/rocjpeg_decode_perf/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include ROCJPEG_INCLUDE_DIR := $(HIP_INCLUDE_DIR) diff --git a/Libraries/rocProfiler-SDK/Makefile b/Libraries/rocProfiler-SDK/Makefile index 75cc0bd744..58e465dda6 100644 --- a/Libraries/rocProfiler-SDK/Makefile +++ b/Libraries/rocProfiler-SDK/Makefile @@ -28,9 +28,15 @@ EXAMPLES := \ counter_collection \ external_correlation_id_request \ intercept_table \ - openmp_target \ pc_sampling +ifneq ($(ENABLE_OPENMP), OFF) + _ROCM_DIR := $(or $(ROCM_PATH),/opt/rocm) + ifneq ($(wildcard $(_ROCM_DIR)/bin/amdclang++),) + EXAMPLES += openmp_target + endif +endif + all: $(EXAMPLES) clean: TARGET=clean diff --git a/Libraries/rocProfiler-SDK/code_object_isa_decode/Makefile b/Libraries/rocProfiler-SDK/code_object_isa_decode/Makefile index 0e319df016..4f47a0eff2 100644 --- a/Libraries/rocProfiler-SDK/code_object_isa_decode/Makefile +++ b/Libraries/rocProfiler-SDK/code_object_isa_decode/Makefile @@ -25,6 +25,12 @@ COMMON_INCLUDE_DIR := ../../../Common EXTERNAL_DIR := ../../../External GPU_RUNTIME ?= HIP +# Dependency checking +REQUIRED_DEPS := LIBDW AMD_COMGR +include $(COMMON_INCLUDE_DIR)/require_deps.mk + +ifneq ($(SKIP_BUILD),1) + # HIP variables ROCM_PATH ?= /opt/rocm @@ -60,3 +66,9 @@ clean: $(RM) $(EXAMPLE) .PHONY: clean + +else +all: +clean: +.PHONY: all clean +endif diff --git a/Libraries/rocProfiler-SDK/code_object_tracing/Makefile b/Libraries/rocProfiler-SDK/code_object_tracing/Makefile index c8345c161d..e79ef8c2f0 100644 --- a/Libraries/rocProfiler-SDK/code_object_tracing/Makefile +++ b/Libraries/rocProfiler-SDK/code_object_tracing/Makefile @@ -60,7 +60,7 @@ $(CLIENT_LIB): client.cpp $(COMMON_INCLUDE_DIR)/rocprofiler_utils.hpp $(COMPILER) $(ICXXFLAGS) $(ICPPFLAGS) -fPIC -shared -o $@ $< $(ILDFLAGS) $(ILDLIBS) $(EXAMPLE): $(CLIENT_LIB) main.cpp - $(COMPILER) $(ICXXFLAGS) $(ICPPFLAGS) $(ILDFLAGS) -o $@ main.cpp -L. -l$(EXAMPLE)_client -Wl,-rpath,'$$ORIGIN' + $(COMPILER) $(ICXXFLAGS) $(ICPPFLAGS) $(ILDFLAGS) -o $@ main.cpp -L. -l$(EXAMPLE)_client -Wl,-rpath,'$$ORIGIN' -lpthread clean: $(RM) $(EXAMPLE) $(CLIENT_LIB) diff --git a/Makefile b/Makefile index 353de12032..9ecf498016 100644 --- a/Makefile +++ b/Makefile @@ -30,10 +30,13 @@ SUB_PROJECTS := \ all: $(SUB_PROJECTS) +configure: + ./Scripts/configure.sh --rocm-path="$(or $(ROCM_PATH),/opt/rocm)" + clean: TARGET=clean clean: all $(SUB_PROJECTS): $(MAKE) -C $@ $(TARGET) -.PHONY: all clean $(SUB_PROJECTS) +.PHONY: all configure clean $(SUB_PROJECTS) diff --git a/README.md b/README.md index cef8ec0667..cb2f35fd20 100644 --- a/README.md +++ b/README.md @@ -51,12 +51,15 @@ See [CMake build options](#cmake-build-options) for an overview of build options #### Make -Beware that only a subset of the examples support building via Make. +Only a subset of the examples support building via Make. Some examples depend on external libraries (e.g. FFmpeg, OpenCV, GLFW3, Vulkan). Run `configure.sh` before building to detect which dependencies are available — examples with missing dependencies will be skipped automatically. - `$ git clone https://github.com/ROCm/rocm-examples.git` - `$ cd rocm-examples` +- `$ ./configure.sh` - `$ make` (on ROCm) or `$ make ROCM_EXAMPLES_GPU_LANGUAGE=CUDA` (on CUDA) +The configure script writes a `config.mk` file that each Makefile includes to check for required dependencies. To rebuild after installing new libraries, re-run `./configure.sh` and then `make clean && make`. + ### Linux with Docker Alternatively, instead of installing the prerequisites on the system, the [Dockerfiles](https://github.com/ROCm/rocm-examples/tree/amd-staging/Dockerfiles/) in this repository can be used to build images that provide all required prerequisites. Note, that the ROCm kernel GPU driver still needs to be installed on the host system. diff --git a/Scripts/configure.sh b/Scripts/configure.sh new file mode 100755 index 0000000000..97e995aa38 --- /dev/null +++ b/Scripts/configure.sh @@ -0,0 +1,211 @@ +#!/bin/sh +# MIT License +# +# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# configure.sh - Dependency detection for rocm-examples Makefile build system +# +# Probes for external dependencies and writes a config.mk file that individual +# example Makefiles include to decide whether to build or skip. +# +# Usage: +# ./configure.sh [--rocm-path=DIR] +# +# Output: +# config.mk in the repository root + +set -e + +ROCM_PATH="/opt/rocm" + +for arg in "$@"; do + case "$arg" in + --rocm-path=*) + ROCM_PATH="${arg#--rocm-path=}" + ;; + --help|-h) + echo "Usage: $0 [--rocm-path=DIR]" + echo " --rocm-path=DIR Path to ROCm installation (default: /opt/rocm)" + exit 0 + ;; + *) + echo "Unknown option: $arg" >&2 + exit 1 + ;; + esac +done + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" +CONFIG_MK="${REPO_ROOT}/config.mk" + +echo "configure: detecting dependencies (ROCm path: ${ROCM_PATH})" + +# Helper: check via pkg-config +pkg_check() { + pkg-config --exists "$@" 2>/dev/null +} + +# Helper: get pkg-config cflags +pkg_cflags() { + pkg-config --cflags "$@" 2>/dev/null || true +} + +# Helper: get pkg-config libs +pkg_libs() { + pkg-config --libs "$@" 2>/dev/null || true +} + +# Helper: verify that libraries from pkg-config can actually be linked. +# On some distros (e.g. SLES), .pc files exist but -dev packages are missing. +# Tries CC, cc, gcc, clang in order; if none found, assumes not linkable. +can_link() { + _libs="$(pkg_libs "$@")" + if [ -z "$_libs" ]; then + return 1 + fi + _test_cc="" + for _try_cc in "${CC}" cc gcc clang "${ROCM_PATH}/lib/llvm/bin/clang"; do + [ -z "$_try_cc" ] && continue + if command -v "$_try_cc" >/dev/null 2>&1; then + _test_cc="$_try_cc" + break + fi + done + if [ -z "$_test_cc" ]; then + # No C compiler found — conservatively say not linkable + return 1 + fi + echo "int main(){return 0;}" | "$_test_cc" -x c - $_libs -o /dev/null 2>/dev/null +} + +# Start writing config.mk +cat > "${CONFIG_MK}" << 'HEADER' +# Auto-generated by configure.sh - do not edit +# Re-run ./configure.sh to regenerate +HEADER + +echo "" >> "${CONFIG_MK}" + +# --- FFmpeg (libavcodec, libavformat, libavutil) --- +HAVE_FFMPEG=0 +FFMPEG_CFLAGS="" +FFMPEG_LIBS="" +if pkg_check libavcodec libavformat libavutil && can_link libavcodec libavformat libavutil; then + HAVE_FFMPEG=1 + FFMPEG_CFLAGS="$(pkg_cflags libavcodec libavformat libavutil)" + FFMPEG_LIBS="$(pkg_libs libavcodec libavformat libavutil)" +fi +echo " FFmpeg: $([ ${HAVE_FFMPEG} -eq 1 ] && echo yes || echo no)" +cat >> "${CONFIG_MK}" << EOF +HAVE_FFMPEG := ${HAVE_FFMPEG} +FFMPEG_CFLAGS := ${FFMPEG_CFLAGS} +FFMPEG_LIBS := ${FFMPEG_LIBS} +EOF + +# --- OpenCV --- +HAVE_OPENCV=0 +OPENCV_CFLAGS="" +OPENCV_LIBS="" +if pkg_check opencv4 && can_link opencv4; then + HAVE_OPENCV=1 + OPENCV_CFLAGS="$(pkg_cflags opencv4)" + OPENCV_LIBS="$(pkg_libs opencv4)" +elif pkg_check opencv && can_link opencv; then + HAVE_OPENCV=1 + OPENCV_CFLAGS="$(pkg_cflags opencv)" + OPENCV_LIBS="$(pkg_libs opencv)" +fi +echo " OpenCV: $([ ${HAVE_OPENCV} -eq 1 ] && echo yes || echo no)" +cat >> "${CONFIG_MK}" << EOF +HAVE_OPENCV := ${HAVE_OPENCV} +OPENCV_CFLAGS := ${OPENCV_CFLAGS} +OPENCV_LIBS := ${OPENCV_LIBS} +EOF + +# --- GLFW3 --- +HAVE_GLFW3=0 +GLFW3_CFLAGS="" +GLFW3_LIBS="" +if pkg_check glfw3 && can_link glfw3; then + HAVE_GLFW3=1 + GLFW3_CFLAGS="$(pkg_cflags glfw3)" + GLFW3_LIBS="$(pkg_libs glfw3)" +fi +echo " GLFW3: $([ ${HAVE_GLFW3} -eq 1 ] && echo yes || echo no)" +cat >> "${CONFIG_MK}" << EOF +HAVE_GLFW3 := ${HAVE_GLFW3} +GLFW3_CFLAGS := ${GLFW3_CFLAGS} +GLFW3_LIBS := ${GLFW3_LIBS} +EOF + +# --- Vulkan --- +HAVE_VULKAN=0 +VULKAN_CFLAGS="" +VULKAN_LIBS="" +if pkg_check vulkan && can_link vulkan; then + HAVE_VULKAN=1 + VULKAN_CFLAGS="$(pkg_cflags vulkan)" + VULKAN_LIBS="$(pkg_libs vulkan)" +fi +echo " Vulkan: $([ ${HAVE_VULKAN} -eq 1 ] && echo yes || echo no)" +cat >> "${CONFIG_MK}" << EOF +HAVE_VULKAN := ${HAVE_VULKAN} +VULKAN_CFLAGS := ${VULKAN_CFLAGS} +VULKAN_LIBS := ${VULKAN_LIBS} +EOF + +# --- libdw (elfutils) --- +HAVE_LIBDW=0 +if pkg_check libdw; then + HAVE_LIBDW=1 +elif [ -f /usr/include/elfutils/libdw.h ] || [ -f /usr/include/dwarf.h ]; then + HAVE_LIBDW=1 +fi +echo " libdw: $([ ${HAVE_LIBDW} -eq 1 ] && echo yes || echo no)" +cat >> "${CONFIG_MK}" << EOF +HAVE_LIBDW := ${HAVE_LIBDW} +EOF + +# --- amd_comgr --- +HAVE_AMD_COMGR=0 +if [ -f "${ROCM_PATH}/include/amd_comgr/amd_comgr.h" ] || [ -f "${ROCM_PATH}/lib/libamd_comgr.so" ]; then + HAVE_AMD_COMGR=1 +elif pkg_check amd_comgr; then + HAVE_AMD_COMGR=1 +fi +echo " amd_comgr: $([ ${HAVE_AMD_COMGR} -eq 1 ] && echo yes || echo no)" +cat >> "${CONFIG_MK}" << EOF +HAVE_AMD_COMGR := ${HAVE_AMD_COMGR} +EOF + +# --- glslangValidator --- +HAVE_GLSLANG_VALIDATOR=0 +if command -v glslangValidator >/dev/null 2>&1; then + HAVE_GLSLANG_VALIDATOR=1 +fi +echo " glslangValidator: $([ ${HAVE_GLSLANG_VALIDATOR} -eq 1 ] && echo yes || echo no)" +cat >> "${CONFIG_MK}" << EOF +HAVE_GLSLANG_VALIDATOR := ${HAVE_GLSLANG_VALIDATOR} +EOF + +echo "" +echo "configure: wrote ${CONFIG_MK}" diff --git a/Tools/ROCgdb/.gitignore b/Tools/ROCgdb/.gitignore new file mode 100644 index 0000000000..911507903e --- /dev/null +++ b/Tools/ROCgdb/.gitignore @@ -0,0 +1 @@ +rocgdb-matmul diff --git a/Tools/ROCgdb/Makefile b/Tools/ROCgdb/Makefile index b4622bb883..95186fbf53 100644 --- a/Tools/ROCgdb/Makefile +++ b/Tools/ROCgdb/Makefile @@ -26,7 +26,7 @@ EXTERNAL_DIR := ../../External GPU_RUNTIME := HIP # HIP variables -ROCM_PATH := /opt/rocm +ROCM_PATH ?= /opt/rocm HIP_INCLUDE_DIR := $(ROCM_PATH)/include HIPCXX ?= $(ROCM_PATH)/bin/hipcc