diff --git a/Makefile b/Makefile index 726e7a3536..216be0b1b8 100644 --- a/Makefile +++ b/Makefile @@ -586,9 +586,9 @@ endif CUDA_LIB_DIR_STUBS := $(CUDA_LIB_DIR)/stubs CUDA_BACKENDS = /gpu/cuda/ref /gpu/cuda/shared /gpu/cuda/gen ifneq ($(CUDA_LIB_DIR),) - $(cuda-all.c:%.c=$(OBJDIR)/%.o) $(cuda-all.c:%=%.tidy) $(cuda-all.c:%=%.tidy-fix) $(cuda-all.h:%=%.tidy-fix) : CPPFLAGS += -I$(CUDA_DIR)/include - $(cuda-all.cpp:%.cpp=$(OBJDIR)/%.o) $(cuda-all.cpp:%=%.tidy) $(cuda-all.cpp:%=%.tidy-fix) $(cuda-all.hpp:%=%.tidy-fix) : CPPFLAGS += -I$(CUDA_DIR)/include - $(cuda-all.cu:%.cu=$(OBJDIR)/%.o) : CPPFLAGS += -I$(CUDA_DIR)/include + $(cuda-all.c:%.c=$(OBJDIR)/%.o) $(cuda-all.c:%=%.tidy) $(cuda-all.c:%=%.tidy-fix) $(cuda-all.h:%=%.tidy-fix) : CPPFLAGS += -I$(CUDA_DIR)/include -DCEED_CUDA_DIR=\"$(CUDA_DIR)\" + $(cuda-all.cpp:%.cpp=$(OBJDIR)/%.o) $(cuda-all.cpp:%=%.tidy) $(cuda-all.cpp:%=%.tidy-fix) $(cuda-all.hpp:%=%.tidy-fix) : CPPFLAGS += -I$(CUDA_DIR)/include -DCEED_CUDA_DIR=\"$(CUDA_DIR)\" + $(cuda-all.cu:%.cu=$(OBJDIR)/%.o) : CPPFLAGS += -I$(CUDA_DIR)/include -DCEED_CUDA_DIR=\"$(CUDA_DIR)\" PKG_LIBS += -L$(abspath $(CUDA_LIB_DIR)) -lcudart -lnvrtc -lcuda -lcublas PKG_STUBS_LIBS += -L$(CUDA_LIB_DIR_STUBS) LIBCEED_CONTAINS_CXX = 1 diff --git a/backends/cuda/ceed-cuda-compile.cpp b/backends/cuda/ceed-cuda-compile.cpp index b82f06280e..3a5952908f 100644 --- a/backends/cuda/ceed-cuda-compile.cpp +++ b/backends/cuda/ceed-cuda-compile.cpp @@ -28,6 +28,8 @@ #include "ceed-cuda-common.h" +const char *CeedCudaDir = CEED_CUDA_DIR; + #define CeedChk_Nvrtc(ceed, x) \ do { \ nvrtcResult result = static_cast(x); \ @@ -389,8 +391,9 @@ static int CeedCompileCore_Cuda(Ceed ceed, const char *source, const char *name, // Compile wrapper kernel CeedCallCuda(ceed, cudaGetDeviceProperties(&prop, ceed_data->device_id)); - command = std::string(llvm_cxx) + " -flto=thin --cuda-gpu-arch=sm_" + std::to_string(prop.major) + std::to_string(prop.minor) + - " --cuda-device-only -emit-llvm -S " + filename_base + "_0_source.cu -o " + filename_base + "_1_wrapped.ll "; + command = std::string(llvm_cxx) + " --cuda-path=" + std::string(CeedCudaDir) + " -flto=thin --cuda-gpu-arch=sm_" + std::to_string(prop.major) + + std::to_string(prop.minor) + " --cuda-device-only -emit-llvm -S " + filename_base + "_0_source.cu -o " + filename_base + + "_1_wrapped.ll "; command += opts[4]; CeedCallSystem(ceed, command.c_str(), "JiT kernel source"); CeedCallSystem(ceed, (std::string("chmod 0777 ") + filename_base + "_1_wrapped.ll").c_str(), "update JiT file permissions");