@@ -185,47 +185,33 @@ debug: CUDA_FLAGS = $(CUDA_DEBUG_FLAGS)
185185debug : HIP_FLAGS = $(HIP_DEBUG_FLAGS )
186186debug : all
187187
188- # Profile builds - build with profiling flags and generate profile data
188+ # Profile builds with actual profiling
189189.PHONY : profile
190190profile : CUDA_FLAGS = $(CUDA_FLAGS ) -lineinfo
191191profile : HIP_FLAGS = $(HIP_FLAGS ) -g
192192profile : all
193193 @echo " Generating profile data..."
194194 @mkdir -p $(PROFILE_DIR )
195- ifeq ($(BUILD_CUDA ) ,1)
196- @echo "Running CUDA profiling..."
197- @for target in $(CUDA_TARGETS ); do \
195+ ifeq ($(BUILD_HIP ) ,1)
196+ @echo "Running HIP profiling..."
197+ @for target in $(HIP_TARGETS ); do \
198198 if [ -f $$target ]; then \
199199 echo "Profiling $$target..."; \
200- basename_target=$$(basename $$target); \
201- if command -v nsys >/dev/null 2>&1; then \
202- nsys profile --output=$(PROFILE_DIR)/$$basename_target.nsys-rep $$target 2>/dev/null || echo "nsys profiling completed"; \
203- elif command -v nvprof >/dev/null 2>&1; then \
204- nvprof --log-file $(PROFILE_DIR)/$$basename_target.nvprof $$target 2>/dev/null || echo "nvprof profiling completed"; \
205- else \
206- echo "No CUDA profiler available (nsys/nvprof)"; \
207- fi; \
200+ rocprof -o $(PROFILE_DIR)/$$(basename $$target).csv $$target 2>/dev/null || echo "rocprof completed"; \
208201 fi; \
209202 done
210203endif
211- ifeq ($(BUILD_HIP ) ,1)
212- @echo "Running HIP profiling..."
213- @for target in $(HIP_TARGETS) $(CPP_TARGETS ); do \
204+ ifeq ($(BUILD_CUDA ) ,1)
205+ @echo "Running CUDA profiling..."
206+ @for target in $(CUDA_TARGETS ); do \
214207 if [ -f $$target ]; then \
215208 echo "Profiling $$target..."; \
216- basename_target=$$(basename $$target); \
217- if command -v rocprof >/dev/null 2>&1; then \
218- rocprof --output-file $(PROFILE_DIR)/$$basename_target.csv $$target 2>/dev/null || echo "rocprof profiling completed"; \
219- else \
220- echo "rocprof not available - saving timing data instead"; \
221- echo "Profiling $$target at $$(date)" > $(PROFILE_DIR)/$$basename_target.profile; \
222- time $$target >> $(PROFILE_DIR)/$$basename_target.profile 2>&1 || echo "Timing completed"; \
223- fi; \
209+ nvprof --csv -o $(PROFILE_DIR)/$$(basename $$target).csv $$target 2>/dev/null || echo "nvprof completed"; \
224210 fi; \
225211 done
226212endif
227213 @echo "Profile data saved to $(PROFILE_DIR)/"
228- @ls -la $(PROFILE_DIR)/ 2>/dev/null || echo "Profile directory created but no files generated"
214+ @ls -la $(PROFILE_DIR)/
229215
230216# Clean
231217.PHONY : clean
0 commit comments