faiss/gpu/utils/DeviceMemory.cpp
Lucas Hosseini afe0fdc161
Facebook sync (Mar 2019) (#756)
Facebook sync (Mar 2019)

- MatrixStats object
- option to round coordinates during k-means optimization
- alternative option for search in HNSW
- moved stats and imbalance_factor of IndexIVF to InvertedLists object
- range search for IVFScalarQuantizer
- direct unit8 codec in ScalarQuantizer
- renamed IndexProxy to IndexReplicas and moved to main Faiss
- better support for PQ code assignment with external index
- support for IMI2x16 (4B virtual centroids!)
- support for k = 2048 search on GPU (instead of 1024)
- most CUDA mem alloc failures throw exceptions instead of terminating on an assertion
- support for renaming an ondisk invertedlists
- interrupt computations with ctrl-C in python
2019-03-29 16:32:28 +01:00

79 lines
1.6 KiB
C++

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD+Patents license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "DeviceMemory.h"
#include "DeviceUtils.h"
#include "../../FaissAssert.h"
namespace faiss { namespace gpu {
DeviceMemoryReservation::DeviceMemoryReservation()
: state_(NULL),
device_(0),
data_(NULL),
size_(0),
stream_(0) {
}
DeviceMemoryReservation::DeviceMemoryReservation(DeviceMemory* state,
int device,
void* p,
size_t size,
cudaStream_t stream)
: state_(state),
device_(device),
data_(p),
size_(size),
stream_(stream) {
}
DeviceMemoryReservation::DeviceMemoryReservation(
DeviceMemoryReservation&& m) noexcept {
state_ = m.state_;
device_ = m.device_;
data_ = m.data_;
size_ = m.size_;
stream_ = m.stream_;
m.data_ = NULL;
}
DeviceMemoryReservation::~DeviceMemoryReservation() {
if (data_) {
FAISS_ASSERT(state_);
state_->returnAllocation(*this);
}
data_ = NULL;
}
DeviceMemoryReservation&
DeviceMemoryReservation::operator=(DeviceMemoryReservation&& m) {
if (data_) {
FAISS_ASSERT(state_);
state_->returnAllocation(*this);
}
state_ = m.state_;
device_ = m.device_;
data_ = m.data_;
size_ = m.size_;
stream_ = m.stream_;
m.data_ = NULL;
return *this;
}
DeviceMemory::~DeviceMemory() {
}
} } // namespace