@@ -43,6 +43,9 @@ OPTIONAL_HIP_LIBS =
4343
4444# Check for optional libraries only when building (not during clean)
4545ifneq ($(MAKECMDGOALS ) ,clean)
46+
47+ # NVIDIA-specific library checks (only when building for NVIDIA GPUs)
48+ ifeq ($(BUILD_CUDA ) ,1)
4649# Check for NVML availability by trying to compile a simple test
4750ifeq ($(shell echo 'int main() {return 0;}' | $(CXX ) -x c -lnvml - -o /dev/null 2>/dev/null && echo "found"), found)
4851OPTIONAL_CUDA_LIBS += -lnvml
@@ -62,6 +65,29 @@ $(info cuDNN library not found - compiling without cuDNN support)
6265endif
6366endif
6467
68+ # AMD-specific library checks (only when building for AMD GPUs)
69+ ifeq ($(BUILD_HIP ) ,1)
70+ # Check for MIOpen availability by trying to compile a simple test
71+ ifeq ($(shell echo 'int main() {return 0;}' | $(CXX ) -x c -lMIOpen - -o /dev/null 2>/dev/null && echo "found"), found)
72+ OPTIONAL_HIP_LIBS += -lMIOpen
73+ HIP_FLAGS += -DUSE_MIOPEN
74+ $(info MIOpen library found - enabling MIOpen support)
75+ else
76+ $(info MIOpen library not found - compiling without MIOpen support)
77+ endif
78+
79+ # Check for rocALUTION availability
80+ ifeq ($(shell echo 'int main() {return 0;}' | $(CXX ) -x c -lrocalution - -o /dev/null 2>/dev/null && echo "found"), found)
81+ OPTIONAL_HIP_LIBS += -lrocalution
82+ HIP_FLAGS += -DUSE_ROCALUTION
83+ $(info rocALUTION library found - enabling rocALUTION support)
84+ else
85+ $(info rocALUTION library not found - compiling without rocALUTION support)
86+ endif
87+ endif
88+
89+ endif
90+
6591# Directories
6692BUILD_DIR = build
6793PROFILE_DIR = profiles
@@ -92,9 +118,15 @@ CUDA_TARGETS = $(CUDA_SOURCES:%.cu=$(BUILD_DIR)/%)
92118HIP_TARGETS = $(HIP_SOURCES:%.cpp=$(BUILD_DIR ) /% )
93119CPP_TARGETS = $(CPP_SOURCES:%.cpp=$(BUILD_DIR ) /% )
94120
95- # Default target
121+ # Default target - build only for detected GPU vendor
96122.PHONY : all
97- all : setup cuda hip common
123+ ifeq ($(BUILD_CUDA ) ,1)
124+ all : setup cuda common
125+ else ifeq ($(BUILD_HIP),1)
126+ all : setup hip common
127+ else
128+ all : setup common
129+ endif
98130
99131# Setup directories for production deployment
100132.PHONY : setup
@@ -118,7 +150,7 @@ ifeq ($(BUILD_CUDA),1)
118150cuda : setup $(ACTIVE_CUDA_TARGETS )
119151else
120152cuda : setup
121- @echo " ⚠ CUDA build requested but no NVIDIA GPU detected"
153+ @echo " ℹ Skipping CUDA build - no NVIDIA GPU detected"
122154endif
123155
124156# Build HIP production applications
@@ -127,7 +159,7 @@ ifeq ($(BUILD_HIP),1)
127159hip : setup $(ACTIVE_HIP_TARGETS )
128160else
129161hip : setup
130- @echo " ⚠ HIP build requested but no AMD GPU detected"
162+ @echo " ℹ Skipping HIP build - no AMD GPU detected"
131163endif
132164
133165# Build common C++ applications
0 commit comments