Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jialei gh219 improve consistency check between gpu vs cpu computation for general qp ei #267

Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6f2a3d0
class declarations needed by other files have been moved into gpp_mat…
jialeiwang Jun 11, 2014
f5e5791
implemented EI & grad_EI computation on gpu, with unit tests
jialeiwang Jun 12, 2014
65e3636
modified CMakeLists.txt so that Cmake options are directly read from …
jialeiwang Jun 12, 2014
cc35507
add gpu tests to test cases, and run make test-no-tox seems ok
jialeiwang Jun 12, 2014
d90a1c7
small change to CMakeLists so that extra arguments are read from MOE_…
jialeiwang Jun 12, 2014
3c67826
add ability that user can specify no_mc_iter for EI & grad_EI on GPU
jialeiwang Jun 13, 2014
346b3b1
small bug fix in .cu
jialeiwang Jun 13, 2014
df9c1bc
Merge branch 'master' of github.com:sc932/MOE into jialei_gh123_conne…
jialeiwang Jun 13, 2014
2b4e0d0
exception handling in gpu code is online
jialeiwang Jun 17, 2014
1cc720c
Merge branch 'master' of github.com:sc932/MOE into jialei_gh123_conne…
jialeiwang Jun 17, 2014
2854aaf
changes regarding with first round of review, code cleaning up & code…
jialeiwang Jun 18, 2014
cd66a21
gpu functions modified so that they can set configure_for_test, compi…
jialeiwang Jun 20, 2014
0980fd8
cmake find_package issue solved
jialeiwang Jun 21, 2014
ea8c417
fixes for second round of eliu's comments, mainly address for style i…
jialeiwang Jun 23, 2014
77edcb3
merge
jialeiwang Jun 23, 2014
a4880ff
Renamed RuntimeException according to eliu's change in gpp_exception.hpp
jialeiwang Jun 24, 2014
895b371
Merge branch 'master' of github.com:sc932/MOE into jialei_gh123_conne…
jialeiwang Jun 24, 2014
2aa1a09
unmodified gpp_math_test.hpp/cpp
jialeiwang Jun 25, 2014
b53ba32
Merge branch 'master' of github.com:sc932/MOE into jialei_gh123_conne…
jialeiwang Jun 25, 2014
3009f2d
merge from master
jialeiwang Jun 27, 2014
c5a06fc
Merge branch 'master' of github.com:sc932/MOE into jialei_gh123_conne…
jialeiwang Jun 27, 2014
42362f5
restore gpp_math_test.hpp/cpp
jialeiwang Jun 27, 2014
406929e
Merge branch 'master' of github.com:sc932/MOE into jialei_gh219_impro…
jialeiwang Jun 27, 2014
ef82b1e
some variable names changed to make them easier to read
jialeiwang Jun 27, 2014
0251b0d
Merge branch 'master' of github.com:sc932/MOE into jialei_gh123_conne…
jialeiwang Jun 27, 2014
4f15598
CudaExpectedImprovementState take in UniformRandomGenerator* argument…
jialeiwang Jun 27, 2014
63fb267
Merge branch 'jialei_gh123_connect_GPU_implementation_to_the_new_qp_E…
jialeiwang Jun 27, 2014
2786617
encorporate changes from jialei_gh123...
jialeiwang Jun 27, 2014
c44a7f8
cpu vs gpu consistency check added
jialeiwang Jun 30, 2014
c68ed9f
Merge branch 'master' of github.com:sc932/MOE into jialei_gh219_impro…
jialeiwang Jun 30, 2014
ba82f53
cmake can handle gpu folder now, default gcc for gpu is the version c…
jialeiwang Jun 30, 2014
510d208
changes regarding with eliu's comments
Jul 14, 2014
68d86be
Merge branch 'master' of github.com:sc932/MOE into jialei_gh219_impro…
Jul 14, 2014
30496ee
Merge branch 'master' of github.com:sc932/MOE into jialei_gh219_impro…
Jul 15, 2014
e418390
regarding with eliu's comments
Jul 15, 2014
9c3d8fb
Merge branch 'master' of github.com:sc932/MOE into jialei_gh219_impro…
jialeiwang Jul 17, 2014
7d5134b
changes w.r.t eric's review
jialeiwang Jul 21, 2014
b504363
code fix w.r.t eric's review
jialeiwang Jul 23, 2014
4590675
Merge branch 'master' of github.com:yelp/MOE into jialei_gh219_improv…
jialeiwang Jul 23, 2014
8561e8b
more changes regarding with review
jialeiwang Jul 28, 2014
3cfcae5
Merge branch 'master' of github.com:yelp/MOE into jialei_gh219_improv…
jialeiwang Jul 28, 2014
c92a45d
part of code fix
jialeiwang Jul 29, 2014
eb8db1d
addressed eliu's latest comments
jialeiwang Jul 29, 2014
e24bd22
Merge branch 'master' of github.com:yelp/MOE into jialei_gh219_improv…
jialeiwang Jul 29, 2014
02e9034
doc style improvement
jialeiwang Jul 31, 2014
7ede2dd
Merge branch 'master' of github.com:yelp/MOE into jialei_gh219_improv…
jialeiwang Jul 31, 2014
918f7c2
fixed final reviews
jialeiwang Aug 1, 2014
8ab2d8a
Merge branch 'master' of github.com:yelp/MOE into jialei_gh219_improv…
jialeiwang Aug 1, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 58 additions & 1 deletion moe/optimal_learning/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ set(OPTIMAL_LEARNING_CORE_SOURCES
gpp_math.cpp
gpp_model_selection.cpp
gpp_random.cpp
gpp_expected_improvement_gpu.cpp
)

# readonly
Expand All @@ -88,6 +89,7 @@ set(OPTIMAL_LEARNING_TEST_SOURCES
gpp_random_test.cpp
gpp_test_utils.cpp
gpp_test_utils_test.cpp
gpp_expected_improvement_gpu_test.cpp
)

# readonly
Expand Down Expand Up @@ -228,6 +230,11 @@ function(configure_exec_targets exec_names exec_sources dependencies compile_fla
COMPILE_DEFINITIONS "${compile_definitions}"
LINK_FLAGS "${EXTRA_LINK_FLAGS}"
)
if (${MOE_USE_GPU} MATCHES "1")
add_dependencies(${name} GPU_LIB)
target_link_libraries(${name} ${CUDA_LIBRARIES}
${CMAKE_BINARY_DIR}/gpu/libOL_GPU.so)
endif()
endforeach()
endfunction(configure_exec_targets)

Expand Down Expand Up @@ -258,6 +265,50 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fopenmp -Wall -Wextra ${EXTR
# O3 takes longer to compile and the code produced is at best no faster than O2 (gcc, icc).
string(REGEX REPLACE "O3" "O2" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})

#### GPU Component
# readonly
set(EXTRA_COMPILE_DEFINITIONS_GPU OL_GPU_ENABLED)

# CUDA C compiler may be different from the c/c++ compiler used for compiling cpp
# code, because current available CUDA version does not support gcc 4.7+
set(GPU_CC ${CMAKE_C_COMPILER})
set(GPU_CXX ${CMAKE_CXX_COMPILER})

if (EXISTS ${MOE_GPU_CC})
set(GPU_CC ${MOE_GPU_CC})
endif()
if (EXISTS ${MOE_GPU_CXX})
set(GPU_CXX ${MOE_GPU_CXX})
endif()

# If MOE_USE_GPU is turned on via MOE_CMAKE_OPTS, cmake will try to find CUDA
# package and call gpu cmake to build CUDA code
if (${MOE_USE_GPU} MATCHES "1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a few comments here about:

  1. why we need different GPU compilers (b/c CUDA needs gcc 4.??)
  2. what the if-block is doing (creates "gpu" directory in the build-dir, runs special gpu-cmakelists, recursively calls make)

but the cmake stuff is looking really clean/easy to use now, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if (NOT (EXISTS ${MOE_CUDA_SDK_INCLUDE_DIRS}))
message( FATAL_ERROR "MOE_CUDA_SDK_INCLUDE_DIRS not set!" )
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this required to build w/cuda? i.e., cmake will never figure this out on its own? (e.g., we don't require that users specify the other MOE_FOO env vars, but they're there in case users want to override default behavior)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because CUDA SDK is an optional package for CUDA installation (it's a separate file from the main CUDA package for download in CUDA website), I read .cmake file and it only looks for include_dir for CUDA main package. However, all the error handling utilities are provided by CUDA SDK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have to add header files in CUDA SDK to include_dir as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, we should document these dependencies on the installation page. Like have a CUDA section where we list what cuda version, cuda compute capability is required, driver/software version, SDK versions, and whatever information is relevant/minimal.

find_package(CUDA 5.0 REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
set(EXTRA_COMPILE_DEFINITIONS ${EXTRA_COMPILE_DEFINITIONS}
${EXTRA_COMPILE_DEFINITIONS_GPU})
set(MOE_GPU_CMAKE_OPTS
"-D MOE_CUDA_SDK_INCLUDE_DIRS=${MOE_CUDA_SDK_INCLUDE_DIRS}")
add_custom_target(
GPU_FOLDER
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/gpu/
)
add_custom_target(
GPU_LIB
DEPENDS GPU_FOLDER
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gpu/
COMMAND CC=${GPU_CC} CXX=${GPU_CXX} cmake `echo
${MOE_GPU_CMAKE_OPTS}` ${CMAKE_SOURCE_DIR}/gpu/
COMMAND make
)
endif()


#### Object libraries
# See configure_object_library() function comments for more details.
# WARNING: You MUST have compatible flags set between OBJECT libraries and targets that depend on them!
Expand Down Expand Up @@ -299,9 +350,15 @@ add_library(
$<TARGET_OBJECTS:OPTIMAL_LEARNING_TEST_BUNDLE>
${CMAKE_BINARY_DIR}/__init__.py
)
if (${MOE_USE_GPU} MATCHES "1")
add_dependencies(GPP GPU_LIB)
endif()

target_link_libraries(GPP ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})

if (${MOE_USE_GPU} MATCHES "1")
target_link_libraries(GPP ${CUDA_LIBRARIES} ${CMAKE_BINARY_DIR}/gpu/libOL_GPU.so)
endif()

# Make sure lib ends in ".so"
set_target_properties(
GPP PROPERTIES
Expand Down
206 changes: 206 additions & 0 deletions moe/optimal_learning/cpp/gpp_expected_improvement_gpu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
/*!
\file gpp_expected_improvement_gpu.cpp
\rst
This file contains implementations of GPU related functions. They are actually C++ wrappers for
CUDA C functions defined in gpu/gpp_cuda_math.cu.
\endrst*/

#include "gpp_expected_improvement_gpu.hpp"

#include <algorithm>
#include <vector>

#include "gpp_common.hpp"
#include "gpp_exception.hpp"
#include "gpp_logging.hpp"
#include "gpp_math.hpp"
#include "gpp_random.hpp"

#ifdef OL_GPU_ENABLED

#include "gpu/gpp_cuda_math.hpp"
#include "driver_types.h"
#include "cuda_runtime.h"

#endif

namespace optimal_learning {

#ifdef OL_GPU_ENABLED

inline int get_vector_size(int num_mc_itr, int num_threads, int num_blocks, int num_points) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FunctionNamesAreCamelCase

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, you don't need to mark functions that are defined in only one translation unit with 'inline'.
I'd follow the model of CudaExpectedImprovementState::BuildUnionOfPoints and make this function a static function of the State class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

return ((static_cast<int>(num_mc_itr / (num_threads * num_blocks)) + 1) * (num_threads * num_blocks) * num_points);
}

CudaDevicePointer::CudaDevicePointer(int num_doubles_in) : num_doubles(num_doubles_in) {
if (num_doubles_in > 0) {
CudaError _err = CudaAllocateMemForDoubleVector(num_doubles, &ptr);
if (_err.err != cudaSuccess) {
ptr = nullptr;
ThrowException(OptimalLearningCudaException(_err));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on the CPU, if malloc fails, the ptr is set to null. that might happen on the GPU as well (and then you won't need to do it explicitly and can use your standard error macro). I'd double check that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping

} else {
ptr = nullptr;
}
}

CudaDevicePointer::~CudaDevicePointer() {
CudaFreeMem(ptr);
}

OptimalLearningCudaException::OptimalLearningCudaException(const CudaError& _err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'regular' variables shouldn't be named with a leading underscore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

: OptimalLearningException(_err.file_and_line_info, _err.func_info, cudaGetErrorString(_err.err)) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closing brace goes on its own line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


double CudaExpectedImprovementEvaluator::ComputeExpectedImprovement(StateType * ei_state) const {
double EI_val;
int num_union = ei_state->num_union;
gaussian_process_->ComputeMeanOfPoints(ei_state->points_to_sample_state, ei_state->to_sample_mean.data());
gaussian_process_->ComputeVarianceOfPoints(&(ei_state->points_to_sample_state), ei_state->cholesky_to_sample_var.data());
int leading_minor_index = ComputeCholeskyFactorL(num_union, ei_state->cholesky_to_sample_var.data());
if (unlikely(leading_minor_index != 0)) {
OL_THROW_EXCEPTION(SingularMatrixException, "GP-Variance matrix singular. Check for duplicate points_to_sample/being_sampled or points_to_sample/being_sampled duplicating points_sampled with 0 noise.", ei_state->cholesky_to_sample_var.data(),
num_union, leading_minor_index);
}
unsigned int seed_in = (ei_state->uniform_rng->GetEngine())();
OL_CUDA_ERROR_THROW(CudaGetEI(ei_state->to_sample_mean.data(), ei_state->cholesky_to_sample_var.data(),
best_so_far_, num_union, ei_state->gpu_mu.ptr, ei_state->gpu_chol_var.ptr,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please adjust these indent levels so that the arguments all line up (here & elsewhere)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

ei_state->gpu_ei_storage.ptr, seed_in, num_mc_, &EI_val,
ei_state->gpu_random_number_ei.ptr, ei_state->random_number_ei.data(),
ei_state->configure_for_test));
return EI_val;
}

void CudaExpectedImprovementEvaluator::ComputeGradExpectedImprovement(StateType * ei_state,
double * restrict grad_ei) const {
if (ei_state->num_derivatives == 0) {
OL_THROW_EXCEPTION(OptimalLearningException, "configure_for_gradients set to false, gradient computation is disabled!");
}
const int num_union = ei_state->num_union;
const int num_to_sample = ei_state->num_to_sample;
gaussian_process_->ComputeMeanOfPoints(ei_state->points_to_sample_state, ei_state->to_sample_mean.data());
gaussian_process_->ComputeGradMeanOfPoints(ei_state->points_to_sample_state, ei_state->grad_mu.data());
gaussian_process_->ComputeVarianceOfPoints(&(ei_state->points_to_sample_state), ei_state->cholesky_to_sample_var.data());
int leading_minor_index = ComputeCholeskyFactorL(num_union, ei_state->cholesky_to_sample_var.data());
if (unlikely(leading_minor_index != 0)) {
OL_THROW_EXCEPTION(SingularMatrixException, "GP-Variance matrix singular. Check for duplicate points_to_sample/being_sampled or points_to_sample/being_sampled duplicating points_sampled with 0 noise.", ei_state->cholesky_to_sample_var.data(),
num_union, leading_minor_index);
}

gaussian_process_->ComputeGradCholeskyVarianceOfPoints(&(ei_state->points_to_sample_state),
ei_state->cholesky_to_sample_var.data(),
ei_state->grad_chol_decomp.data());
unsigned int seed_in = (ei_state->uniform_rng->GetEngine())();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change "unsigned int" to "auto" (here and elsewhere). if we use a 64-bit RNG, auto will work seamlessly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used uint64_t instead


OL_CUDA_ERROR_THROW(CudaGetGradEI(ei_state->to_sample_mean.data(), ei_state->grad_mu.data(),
ei_state->cholesky_to_sample_var.data(), ei_state->grad_chol_decomp.data(),
best_so_far_, num_union, num_to_sample, dim_,
(ei_state->gpu_mu).ptr, (ei_state->gpu_grad_mu).ptr, (ei_state->gpu_chol_var).ptr,
(ei_state->gpu_grad_chol_var).ptr, (ei_state->gpu_grad_ei_storage).ptr,
seed_in, num_mc_, grad_ei, ei_state->gpu_random_number_grad_ei.ptr,
ei_state->random_number_grad_ei.data(), ei_state->configure_for_test));
}

void CudaExpectedImprovementEvaluator::SetupGPU(int devID) {
OL_CUDA_ERROR_THROW(CudaSetDevice(devID));
}

CudaExpectedImprovementEvaluator::CudaExpectedImprovementEvaluator(const GaussianProcess& gaussian_process_in,
int num_mc_in, double best_so_far, int devID_in)
: dim_(gaussian_process_in.dim()),
num_mc_(num_mc_in),
best_so_far_(best_so_far),
gaussian_process_(&gaussian_process_in) {
SetupGPU(devID_in);
}

CudaExpectedImprovementEvaluator::~CudaExpectedImprovementEvaluator() {
cudaDeviceReset();
}

CudaExpectedImprovementState::CudaExpectedImprovementState(const EvaluatorType& ei_evaluator,
double const * restrict points_to_sample,
double const * restrict points_being_sampled,
int num_to_sample_in, int num_being_sampled_in,
bool configure_for_gradients,
UniformRandomGenerator * uniform_rng_in)
: dim(ei_evaluator.dim()),
num_to_sample(num_to_sample_in),
num_being_sampled(num_being_sampled_in),
num_derivatives(configure_for_gradients ? num_to_sample : 0),
num_union(num_to_sample + num_being_sampled),
union_of_points(BuildUnionOfPoints(points_to_sample, points_being_sampled, num_to_sample, num_being_sampled, dim)),
points_to_sample_state(*ei_evaluator.gaussian_process(), union_of_points.data(), num_union, num_derivatives),
uniform_rng(uniform_rng_in),
to_sample_mean(num_union),
grad_mu(dim*num_derivatives),
cholesky_to_sample_var(Square(num_union)),
grad_chol_decomp(dim*Square(num_union)*num_derivatives),
configure_for_test(false),
gpu_mu(num_union),
gpu_chol_var(Square(num_union)),
gpu_grad_mu(dim * num_derivatives),
gpu_grad_chol_var(dim * Square(num_union) * num_derivatives),
gpu_ei_storage(kEINumThreads * kEINumBlocks),
gpu_grad_ei_storage(kGradEINumThreads * kGradEINumBlocks * dim * num_derivatives),
gpu_random_number_ei(0),
gpu_random_number_grad_ei(0),
random_number_ei(0),
random_number_grad_ei(0) {
}

CudaExpectedImprovementState::CudaExpectedImprovementState(const EvaluatorType& ei_evaluator,
double const * restrict points_to_sample,
double const * restrict points_being_sampled,
int num_to_sample_in, int num_being_sampled_in,
bool configure_for_gradients,
UniformRandomGenerator * uniform_rng_in,
bool configure_for_test_in)
: dim(ei_evaluator.dim()),
num_to_sample(num_to_sample_in),
num_being_sampled(num_being_sampled_in),
num_derivatives(configure_for_gradients ? num_to_sample : 0),
num_union(num_to_sample + num_being_sampled),
union_of_points(BuildUnionOfPoints(points_to_sample, points_being_sampled, num_to_sample, num_being_sampled, dim)),
points_to_sample_state(*ei_evaluator.gaussian_process(), union_of_points.data(), num_union, num_derivatives),
uniform_rng(uniform_rng_in),
to_sample_mean(num_union),
grad_mu(dim*num_derivatives),
cholesky_to_sample_var(Square(num_union)),
grad_chol_decomp(dim*Square(num_union)*num_derivatives),
configure_for_test(configure_for_test_in),
gpu_mu(num_union),
gpu_chol_var(Square(num_union)),
gpu_grad_mu(dim * num_derivatives),
gpu_grad_chol_var(dim * Square(num_union) * num_derivatives),
gpu_ei_storage(kEINumThreads * kEINumBlocks),
gpu_grad_ei_storage(kGradEINumThreads * kGradEINumBlocks * dim * num_derivatives),
gpu_random_number_ei(configure_for_test ? get_vector_size(ei_evaluator.num_mc(), kEINumThreads, kEINumBlocks, num_union) : 0),
gpu_random_number_grad_ei(configure_for_test ? get_vector_size(ei_evaluator.num_mc(), kGradEINumThreads, kGradEINumBlocks, num_union) : 0),
random_number_ei(configure_for_test ? get_vector_size(ei_evaluator.num_mc(), kEINumThreads, kEINumBlocks, num_union) : 0),
random_number_grad_ei(configure_for_test ? get_vector_size(ei_evaluator.num_mc(), kGradEINumThreads, kGradEINumBlocks, num_union) : 0) {
}

std::vector<double> CudaExpectedImprovementState::BuildUnionOfPoints(double const * restrict points_to_sample, double const * restrict points_being_sampled,
int num_to_sample, int num_being_sampled, int dim) noexcept {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent level

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

std::vector<double> union_of_points(dim*(num_to_sample + num_being_sampled));
std::copy(points_to_sample, points_to_sample + dim*num_to_sample, union_of_points.data());
std::copy(points_being_sampled, points_being_sampled + dim*num_being_sampled, union_of_points.data() + dim*num_to_sample);
return union_of_points;
}

void CudaExpectedImprovementState::UpdateCurrentPoint(const EvaluatorType& ei_evaluator, double const * restrict points_to_sample) {
// update points_to_sample in union_of_points
std::copy(points_to_sample, points_to_sample + num_to_sample*dim, union_of_points.data());

// evaluate derived quantities for the GP
points_to_sample_state.SetupState(*ei_evaluator.gaussian_process(), union_of_points.data(), num_union, num_derivatives);
}

void CudaExpectedImprovementState::SetupState(const EvaluatorType& ei_evaluator, double const * restrict points_to_sample) {
// update quantities derived from points_to_sample
UpdateCurrentPoint(ei_evaluator, points_to_sample);
}
#endif // OL_GPU_ENABLED

} // end namespace optimal_learning

Loading