Skip to content

Commit b71a1fb

Browse files
committed
cuda - save cuda lib dir and use with rust compilation
1 parent d6367d2 commit b71a1fb

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,9 @@ endif
586586
CUDA_LIB_DIR_STUBS := $(CUDA_LIB_DIR)/stubs
587587
CUDA_BACKENDS = /gpu/cuda/ref /gpu/cuda/shared /gpu/cuda/gen
588588
ifneq ($(CUDA_LIB_DIR),)
589-
$(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
590-
$(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
591-
$(cuda-all.cu:%.cu=$(OBJDIR)/%.o) : CPPFLAGS += -I$(CUDA_DIR)/include
589+
$(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_LIB=\"$(CUDA_LIB_DIR)\"
590+
$(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_LIB=\"$(CUDA_LIB_DIR)\"
591+
$(cuda-all.cu:%.cu=$(OBJDIR)/%.o) : CPPFLAGS += -I$(CUDA_DIR)/include -DCEED_CUDA_LIB=\"$(CUDA_LIB_DIR)\"
592592
PKG_LIBS += -L$(abspath $(CUDA_LIB_DIR)) -lcudart -lnvrtc -lcuda -lcublas
593593
PKG_STUBS_LIBS += -L$(CUDA_LIB_DIR_STUBS)
594594
LIBCEED_CONTAINS_CXX = 1

backends/cuda/ceed-cuda-compile.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
#include "ceed-cuda-common.h"
3030

31+
const char *CeedCudaLib = CEED_CUDA_LIB;
32+
3133
#define CeedChk_Nvrtc(ceed, x) \
3234
do { \
3335
nvrtcResult result = static_cast<nvrtcResult>(x); \
@@ -389,8 +391,9 @@ static int CeedCompileCore_Cuda(Ceed ceed, const char *source, const char *name,
389391

390392
// Compile wrapper kernel
391393
CeedCallCuda(ceed, cudaGetDeviceProperties(&prop, ceed_data->device_id));
392-
command = std::string(llvm_cxx) + " -flto=thin --cuda-gpu-arch=sm_" + std::to_string(prop.major) + std::to_string(prop.minor) +
393-
" --cuda-device-only -emit-llvm -S " + filename_base + "_0_source.cu -o " + filename_base + "_1_wrapped.ll ";
394+
command = std::string(llvm_cxx) + " -L" + std::string(CeedCudaLib) + " -flto=thin --cuda-gpu-arch=sm_" + std::to_string(prop.major) +
395+
std::to_string(prop.minor) + " --cuda-device-only -emit-llvm -S " + filename_base + "_0_source.cu -o " + filename_base +
396+
"_1_wrapped.ll ";
394397
command += opts[4];
395398
CeedCallSystem(ceed, command.c_str(), "JiT kernel source");
396399
CeedCallSystem(ceed, (std::string("chmod 0777 ") + filename_base + "_1_wrapped.ll").c_str(), "update JiT file permissions");

0 commit comments

Comments
 (0)