Skip to content

Commit

Permalink
separate OpenCL code and CUDA code in 'BaseGpuModelSpecifics.hpp'; re…
Browse files Browse the repository at this point in the history
…move BH dependency for current codebase (without OpenCL)
  • Loading branch information
jianxiaoyang committed Nov 2, 2023
1 parent f0b272e commit a2b3a95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Imports:
survival,
bit64
LinkingTo: Rcpp,
BH (>= 1.51.0),
RcppEigen (>= 0.3.2),
RcppParallel
Suggests:
Expand Down
12 changes: 11 additions & 1 deletion src/cyclops/engine/BaseGpuModelSpecifics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
#ifndef BASEGPUMODELSPECIFICS_HPP
#define BASEGPUMODELSPECIFICS_HPP

#ifdef HAVE_OPENCL
#include <boost/compute/algorithm/reduce.hpp>
#endif // HAVE_OPENCL

#ifdef HAVE_CUDA
#include <thrust/device_vector.h>
#endif //HAVE_CUDA

#include "ModelSpecifics.hpp"

namespace bsccs {

#ifdef HAVE_OPENCL
namespace compute = boost::compute;
#endif // HAVE_OPENCL

namespace detail {

Expand All @@ -24,6 +31,7 @@ namespace bsccs {
static const int maxBlockSize = 256;
}; // namespace constant

#ifdef HAVE_OPENCL
template <typename DeviceVec, typename HostVec>
DeviceVec allocateAndCopyToDevice(const HostVec& hostVec, const compute::context& context, compute::command_queue& queue) {
DeviceVec deviceVec(hostVec.size(), context);
Expand All @@ -36,6 +44,7 @@ namespace bsccs {
deviceVec.resize(hostVec.size());
compute::copy(std::begin(hostVec), std::end(hostVec), std::begin(deviceVec), queue);
}
#endif // HAVE_OPENCL

template <typename HostVec, typename DeviceVec>
void compare(const HostVec& host, const DeviceVec& device, const std::string& error, double tolerance = 1E-10) {
Expand Down Expand Up @@ -69,6 +78,7 @@ namespace bsccs {
SourceCode(std::string body, std::string name) : body(body), name(name) { }
};

#ifdef HAVE_OPENCL
template <typename RealType>
class AllGpuColumns {
public:
Expand Down Expand Up @@ -466,6 +476,6 @@ namespace bsccs {
int multiprocessors = device.get_info<cl_uint>(CL_DEVICE_MAX_COMPUTE_UNITS)*4/5;

};

#endif // HAVE_OPENCL
}
#endif //BASEGPUMODELSPECIFICS_HPP

0 comments on commit a2b3a95

Please sign in to comment.