@@ -116,15 +116,31 @@ override CUDA_HOME = $(patsubst %%/bin/nvcc,%%,$(shell which nvcc 2>/dev/null))
116116# Set HIP_HOME from the path to hipcc, if it exists
117117override HIP_HOME = $(patsubst %% /bin/hipcc,%% ,$(shell which hipcc 2>/dev/null) )
118118
119- # Configure CUDA_INC (for CURAND and NVTX) and NVTX if a CUDA installation exists
120- # (FIXME? Is there any equivalent of NVTX FOR HIP? What should be configured if both CUDA and HIP are installed?)
121- ifneq ($(CUDA_HOME ) ,)
122- USE_NVTX ?=-DUSE_NVTX
123- CUDA_INC = -I$(CUDA_HOME ) /include/
119+ # Configure CUDA_INC (for CURAND and NVTX) and NVTX if a CUDA installation exists (see #965)
120+ ifeq ($(CUDA_HOME ) ,)
121+ # CUDA_HOME is empty (nvcc not found)
122+ override CUDA_INC =
123+ else ifeq ($(wildcard $(CUDA_HOME)/include/),)
124+ # CUDA_HOME is defined (nvcc was found) but $(CUDA_HOME)/include/ does not exist?
125+ override CUDA_INC =
124126else
127+ CUDA_INC = -I$(CUDA_HOME ) /include/
128+ endif
129+ # ##$(info CUDA_INC=$(CUDA_INC))
130+
131+ # Configure NVTX if a CUDA include directory exists and NVTX headers exist (see #965)
132+ ifeq ($(CUDA_INC ) ,)
133+ # $(CUDA_HOME)/include/ does not exist
125134 override USE_NVTX =
126- override CUDA_INC =
135+ else ifeq ($(wildcard $(CUDA_HOME)/include/nvtx3/nvToolsExt.h),)
136+ # $(CUDA_HOME)/include/ exists but NVTX headers do not exist?
137+ override USE_NVTX =
138+ else
139+ # $(CUDA_HOME)/include/nvtx.h exists: use NVTX
140+ # (NB: the option to disable NVTX if 'USE_NVTX=' is defined has been removed)
141+ override USE_NVTX =-DUSE_NVTX
127142endif
143+ # ##$(info USE_NVTX=$(USE_NVTX))
128144
129145# NB: NEW LOGIC FOR ENABLING AND DISABLING CUDA OR HIP BUILDS (AV Feb-Mar 2024)
130146# - In the old implementation, by default the C++ targets for one specific AVX were always built together with either CUDA or HIP.
@@ -424,13 +440,18 @@ endif
424440# (NB: allow HASCURAND=hasCurand even if $(GPUCC) does not point to nvcc: assume CUDA_HOME was defined correctly...)
425441ifeq ($(HASCURAND ) ,)
426442 ifeq ($(GPUCC),) # CPU-only build
427- ifneq ($(CUDA_HOME),)
443+ ifeq ($(CUDA_INC),)
444+ # $(CUDA_HOME)/include/ does not exist (see #965)
445+ override HASCURAND = hasNoCurand
446+ else ifeq ($(wildcard $(CUDA_HOME)/include/curand.h),)
447+ # $(CUDA_HOME)/include/ exists but CURAND headers do not exist? (see #965)
448+ override HASCURAND = hasNoCurand
449+ else
428450 # By default, assume that curand is installed if a CUDA installation exists
429451 override HASCURAND = hasCurand
430- else
431- override HASCURAND = hasNoCurand
432452 endif
433453 else ifeq ($(findstring nvcc,$(GPUCC)),nvcc) # Nvidia GPU build
454+ # By default, assume that curand is installed if a CUDA build is requested
434455 override HASCURAND = hasCurand
435456 else # non-Nvidia GPU build
436457 override HASCURAND = hasNoCurand
0 commit comments