77 lines
1.8 KiB
C++
77 lines
1.8 KiB
C++
#include "cuda_search.h"
|
|
|
|
#include <utility>
|
|
|
|
// Build this translation unit only in the CPU-only target. CUDA-enabled
|
|
// targets compile cuda_search.cu instead; both files intentionally implement
|
|
// the same public ABI.
|
|
|
|
namespace cuda_search {
|
|
|
|
namespace {
|
|
|
|
constexpr const char* kUnavailableMessage =
|
|
"CUDA search backend is not compiled into this executable.";
|
|
|
|
} // namespace
|
|
|
|
struct BatchSession::Impl {
|
|
bool is_initialized = false;
|
|
};
|
|
|
|
BackendInfo query_backend(int device_index) {
|
|
BackendInfo result;
|
|
result.selected_device = device_index;
|
|
result.error = kUnavailableMessage;
|
|
return result;
|
|
}
|
|
|
|
BatchSession::BatchSession() : impl_(std::make_unique<Impl>()) {}
|
|
|
|
BatchSession::~BatchSession() = default;
|
|
|
|
BatchSession::BatchSession(BatchSession&& other) noexcept = default;
|
|
|
|
BatchSession& BatchSession::operator=(BatchSession&& other) noexcept = default;
|
|
|
|
bool BatchSession::initialize(
|
|
const Topology&,
|
|
const SearchConfig&,
|
|
const std::vector<PlaneState>&,
|
|
std::string& error) {
|
|
if (!impl_) {
|
|
impl_ = std::make_unique<Impl>();
|
|
}
|
|
impl_->is_initialized = false;
|
|
error = kUnavailableMessage;
|
|
return false;
|
|
}
|
|
|
|
BatchResult BatchSession::run(const BatchRunConfig&) {
|
|
BatchResult result;
|
|
result.error = kUnavailableMessage;
|
|
return result;
|
|
}
|
|
|
|
void BatchSession::reset() {
|
|
if (impl_) {
|
|
impl_->is_initialized = false;
|
|
}
|
|
}
|
|
|
|
bool BatchSession::initialized() const noexcept {
|
|
return impl_ != nullptr && impl_->is_initialized;
|
|
}
|
|
|
|
BatchResult run_batch(
|
|
const Topology&,
|
|
const SearchConfig& config,
|
|
const std::vector<PlaneState>&) {
|
|
BatchResult result;
|
|
result.device_index = config.device_index;
|
|
result.error = kUnavailableMessage;
|
|
return result;
|
|
}
|
|
|
|
} // namespace cuda_search
|