Skip to content

Commit

Permalink
minor adjustment on configure.R and Makevars.in
Browse files Browse the repository at this point in the history
  • Loading branch information
jianxiaoyang committed Nov 1, 2023
1 parent 9ccc037 commit 1c0ed8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"`
## done by a number of packages, but recommended only for more advanced users
## comfortable with autoconf and its related tools.

CPICFLAGS = -fpic
PKG_CPPFLAGS = -I. -Icyclops -DR_BUILD -DDOUBLE_PRECISION

PKG_CXXFLAGS = -g1

PKG_CPPFLAGS = -I. -Icyclops -DR_BUILD -DDOUBLE_PRECISION

OBJECTS.cyclops = \
cyclops/CcdInterface.o \
cyclops/CompressedDataMatrix.o \
Expand Down
12 changes: 4 additions & 8 deletions tools/configure.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (getRversion() < "4.2") { # Windoz

cuda_home <- system2(command = "find", args = c("/usr/local/", "-maxdepth", "1" ,"-name", "cuda"), stdout = TRUE)
if (length(cuda_home)==0) {
message("no CUDA installation found")
message("no CUDA installation found; only compile host code")
} else {
message(paste0("using CUDA_HOME=", cuda_home))
nvcc <- c(paste0(cuda_home, "/bin/nvcc -arch=sm_70")) # TODO remove hardcoding of ARCH
Expand All @@ -41,21 +41,17 @@ if (length(cuda_home)==0) {
cuda_libs <- paste0("-L", cu_libdir, " -lcudart")
cuda_cppflags <-paste0("-DHAVE_CUDA -I", cuda_home, "/include -I", cu_libdir, " -pthread -rdynamic")

txt <- c(paste0("CUDA_HOME =", cuda_home),
paste0("CUB_PATH =", cub_path),
paste0("NVCC =", nvcc),
paste0("CPICFLAGS = -fpic"), # TODO
txt)
# modify Makevars.in if CUDA is available
txt[grep("^PKG_LIBS", txt)] <- paste(txt[grep("^PKG_LIBS", txt)], cuda_libs)
txt[grep("^PKG_CPPFLAGS", txt)] <- paste(txt[grep("^PKG_CPPFLAGS", txt)], cuda_cppflags)
engine_idx <- grep("^OBJECTS.engine =", txt)
engine_idx <- grep("^OBJECTS.engine", txt)
txt[engine_idx+1] <- paste(txt[engine_idx+1],
"cyclops/engine/CudaKernel.o",
"cyclops/engine/CudaDetail.o")
txt <- c(txt,
'all: $(OBJECTS)',
'%.o: %.cu',
paste0('\t', nvcc,' --default-stream per-thread -c -Xcompiler "$(CPICFLAGS) $(CPPFLAGS) -c" -I$(CUB_PATH) $(R_PATH_LINKER) $^ -o $@'),
paste0('\t', nvcc,' --default-stream per-thread -c -Xcompiler "-fPIC $(CPPFLAGS) -c" -I', cub_path,' $(R_PATH_LINKER) $^ -o $@'),
'clean:',
'\trm -rf *o',
'.PHONY: all clean')
Expand Down

0 comments on commit 1c0ed8f

Please sign in to comment.