Skip to content

Commit ea59485

Browse files
committed
Updated Makefile of module9
1 parent 7543909 commit ea59485

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

modules/module9/examples/02_error_handling_hip.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <map>
1212
#include <mutex>
1313
#include <thread>
14+
#include <iomanip>
1415

1516
#define CHECK_HIP(call) do { \
1617
hipError_t error = call; \
@@ -196,7 +197,7 @@ class GPUHealthChecker {
196197
class SafeMemoryManager {
197198
private:
198199
std::map<void*, size_t> allocated_ptrs_;
199-
std::mutex alloc_mutex_;
200+
mutable std::mutex alloc_mutex_;
200201
size_t total_allocated_;
201202
ErrorLogger& logger_;
202203

modules/module9/examples/Makefile

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ OPTIONAL_HIP_LIBS =
4343

4444
# Check for optional libraries only when building (not during clean)
4545
ifneq ($(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
4750
ifeq ($(shell echo 'int main(){return 0;}' | $(CXX) -x c -lnvml - -o /dev/null 2>/dev/null && echo "found"), found)
4851
OPTIONAL_CUDA_LIBS += -lnvml
@@ -62,6 +65,29 @@ $(info cuDNN library not found - compiling without cuDNN support)
6265
endif
6366
endif
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
6692
BUILD_DIR = build
6793
PROFILE_DIR = profiles
@@ -92,9 +118,15 @@ CUDA_TARGETS = $(CUDA_SOURCES:%.cu=$(BUILD_DIR)/%)
92118
HIP_TARGETS = $(HIP_SOURCES:%.cpp=$(BUILD_DIR)/%)
93119
CPP_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)
118150
cuda: setup $(ACTIVE_CUDA_TARGETS)
119151
else
120152
cuda: setup
121-
@echo "CUDA build requested but no NVIDIA GPU detected"
153+
@echo "ℹ Skipping CUDA build - no NVIDIA GPU detected"
122154
endif
123155

124156
# Build HIP production applications
@@ -127,7 +159,7 @@ ifeq ($(BUILD_HIP),1)
127159
hip: setup $(ACTIVE_HIP_TARGETS)
128160
else
129161
hip: setup
130-
@echo "HIP build requested but no AMD GPU detected"
162+
@echo "ℹ Skipping HIP build - no AMD GPU detected"
131163
endif
132164

133165
# Build common C++ applications

0 commit comments

Comments
 (0)