Skip to content

Commit

Permalink
update gpu related flags
Browse files Browse the repository at this point in the history
  • Loading branch information
jianxiaoyang committed Oct 29, 2023
1 parent 4b1fc6b commit 5199c52
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 37 deletions.
4 changes: 2 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1759,8 +1759,8 @@ $as_echo "\"no -- using ${CUDA_HOME}/lib for CUDA libs\"" >&6; }
$as_echo "\"yes -- using ${CUDA_HOME}/lib64 for CUDA libs\"" >&6; }
cu_libdir="${CUDA_HOME}/lib64"
fi
CUDA_LIBS="${CUDA_LIBS} -lOpenCL -L${cu_libdir} -lcudart"
CUDA_CPPFLAGS="${CUDA_CPPFLAGS} -DHAVE_OPENCL -DGPU_COX -I${CUDA_HOME}/include -I${cu_libdir} -pthread -rdynamic"
CUDA_LIBS="${CUDA_LIBS} -L${cu_libdir} -lcudart"
CUDA_CPPFLAGS="${CUDA_CPPFLAGS} -DHAVE_CUDA -I${CUDA_HOME}/include -I${cu_libdir} -pthread -rdynamic"
fi


Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ else
AC_MSG_RESULT("yes -- using ${CUDA_HOME}/lib64 for CUDA libs")
cu_libdir="${CUDA_HOME}/lib64"
fi
CUDA_LIBS="${CUDA_LIBS} -lOpenCL -L${cu_libdir} -lcudart"
CUDA_CPPFLAGS="${CUDA_CPPFLAGS} -DHAVE_OPENCL -DGPU_COX -I${CUDA_HOME}/include -I${cu_libdir} -pthread -rdynamic"
CUDA_LIBS="${CUDA_LIBS} -L${cu_libdir} -lcudart"
CUDA_CPPFLAGS="${CUDA_CPPFLAGS} -DHAVE_CUDA -I${CUDA_HOME}/include -I${cu_libdir} -pthread -rdynamic"
fi

AC_SUBST(CUDA_HOME)
Expand Down
23 changes: 22 additions & 1 deletion src/RcppGpuInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#include <boost/compute/algorithm/reduce.hpp> // TODO Change
#endif // HAVE_OPENCL

#ifdef HAVE_CUDA
#include <cuda_runtime_api.h>
#include <cuda.h>
#endif // HAVE_CUDA

//' @export
// [[Rcpp::export("listOpenCLDevices")]]
Rcpp::CharacterVector listOpenCLDevices() {
Expand All @@ -22,6 +27,16 @@ Rcpp::CharacterVector listOpenCLDevices() {
}
#endif // HAVE_OPENCL;

#ifdef HAVE_CUDA
int devicesCount;
cudaGetDeviceCount(&devicesCount);
for(int deviceIndex = 0; deviceIndex < devicesCount; ++deviceIndex) {
cudaDeviceProp deviceProperties;
cudaGetDeviceProperties(&deviceProperties, deviceIndex);
devices.push_back(deviceProperties.name);
}
#endif // HAVE_CUDA;

return devices;
}

Expand All @@ -30,6 +45,12 @@ std::string getDefaultOpenCLDevice() {
#ifdef HAVE_OPENCL
return boost::compute::system::default_device().name();
#else
return "";
#ifdef HAVE_CUDA
cudaDeviceProp deviceProperties;
cudaGetDeviceProperties(&deviceProperties, 0);
return deviceProperties.name;
#else
return "";
#endif // HAVE_CUDA
#endif // HAVE_OPENCL
}
36 changes: 5 additions & 31 deletions src/cyclops/engine/AbstractModelSpecifics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#include "engine/GpuModelSpecifics.hpp"
#endif // HAVE_OPENCL

#ifdef GPU_COX
#ifdef HAVE_CUDA
#include "engine/GpuModelSpecificsCox.hpp"
#endif //GPU_COX
#endif //HAVE_CUDA

namespace bsccs {

Expand All @@ -33,11 +33,11 @@ AbstractModelSpecifics* deviceFactory(
case DeviceType::CPU :
model = new ModelSpecifics<Model,RealType>(modelData);
break;
#ifdef GPU_COX
#ifdef HAVE_CUDA
case DeviceType::GPU :
model = new GpuModelSpecificsCox<Model,RealType>(modelData, deviceName);
break;
#endif //GPU_COX
#endif //HAVE_CUDA
default:
break; // nullptr
}
Expand All @@ -54,7 +54,7 @@ AbstractModelSpecifics* deviceFactory(
switch (deviceType) {
#ifdef HAVE_OPENCL
case DeviceType::GPU :
// model = new GpuModelSpecifics<Model,RealType,ModelG>(modelData, deviceName);
model = new GpuModelSpecifics<Model,RealType,ModelG>(modelData, deviceName);
break;
#endif // HAVE_OPENCL
default:
Expand Down Expand Up @@ -158,19 +158,6 @@ AbstractModelSpecifics* precisionFactory<float>(
}
}
#endif // HAVE_OPENCL
/*
#ifdef GPU_COX
if (deviceType == DeviceType::GPU) {
switch (modelType) {
case ModelType::COX :
model = deviceFactory<BreslowTiedCoxProportionalHazards<float>,float>(modelData, deviceType, deviceName);
break;
default:
break;
}
}
#endif // GPU_COX
*/
return model;
}

Expand Down Expand Up @@ -262,19 +249,6 @@ AbstractModelSpecifics* precisionFactory<double>(
}
}
#endif // HAVE_OPENCL
/*
#ifdef GPU_COX
if (deviceType == DeviceType::GPU) {
switch (modelType) {
case ModelType::COX :
model = deviceFactory<BreslowTiedCoxProportionalHazards<double>,double>(modelData, deviceType, deviceName);
break;
default:
break;
}
}
#endif // GPU_COX
*/
return model;
}

Expand Down
1 change: 0 additions & 1 deletion src/cyclops/engine/BaseGpuModelSpecifics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <thrust/device_vector.h>

#include "ModelSpecifics.hpp"
//#include "CudaDetail.h"

namespace bsccs {

Expand Down
1 change: 1 addition & 0 deletions src/cyclops/engine/GpuModelSpecificsCox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <cuda.h>
#include <cuda_runtime_api.h>

#include "BaseGpuModelSpecifics.hpp"
#include "ModelSpecifics.hpp"
#include "Iterators.h"
#include "CudaKernel.h"
Expand Down

0 comments on commit 5199c52

Please sign in to comment.