#1946 fix load index file CPU2GPU fail during searching (#2182)

Signed-off-by: feisiyicl <7764126@qq.com>
This commit is contained in:
feisiyicl 2020-04-29 20:01:52 +08:00 committed by GitHub
parent a76e705a92
commit 9b2368016c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 18 deletions

View File

@ -7,6 +7,7 @@ Please mark all change in change log and use the issue from GitHub
## Bug
- \#1705 Limit the insert data batch size
- \#1929 Skip MySQL meta schema field width check
- \#1946 Fix load index file CPU2GPU fail during searching
- \#1997 Index file missed after compact
- \#2073 Fix CheckDBConfigBackendUrl error message
- \#2076 CheckMetricConfigAddress error message

View File

@ -51,29 +51,31 @@ FaissGpuResourceMgr::InitDevice(int64_t device_id, int64_t pin_mem_size, int64_t
void
FaissGpuResourceMgr::InitResource() {
if (is_init)
return;
if (!initialized_) {
std::lock_guard<std::mutex> lock(init_mutex_);
is_init = true;
if (!initialized_) {
for (auto& device : devices_params_) {
auto& device_id = device.first;
for (auto& device : devices_params_) {
auto& device_id = device.first;
mutex_cache_.emplace(device_id, std::make_unique<std::mutex>());
mutex_cache_.emplace(device_id, std::make_unique<std::mutex>());
auto& device_param = device.second;
auto& bq = idle_map_[device_id];
auto& device_param = device.second;
auto& bq = idle_map_[device_id];
for (int64_t i = 0; i < device_param.resource_num; ++i) {
auto raw_resource = std::make_shared<faiss::gpu::StandardGpuResources>();
for (int64_t i = 0; i < device_param.resource_num; ++i) {
auto raw_resource = std::make_shared<faiss::gpu::StandardGpuResources>();
// TODO(linxj): enable set pinned memory
auto res_wrapper = std::make_shared<Resource>(raw_resource);
AllocateTempMem(res_wrapper, device_id, 0);
// TODO(linxj): enable set pinned memory
auto res_wrapper = std::make_shared<Resource>(raw_resource);
AllocateTempMem(res_wrapper, device_id, 0);
bq.Put(res_wrapper);
bq.Put(res_wrapper);
}
LOG_KNOWHERE_DEBUG_ << "DEVICEID " << device_id << ", resource count " << bq.Size();
}
initialized_ = true;
}
LOG_KNOWHERE_DEBUG_ << "DEVICEID " << device_id << ", resource count " << bq.Size();
}
}
@ -115,7 +117,7 @@ FaissGpuResourceMgr::Free() {
bq.Take();
}
}
is_init = false;
initialized_ = false;
}
void

View File

@ -77,7 +77,8 @@ class FaissGpuResourceMgr {
Dump();
protected:
bool is_init = false;
bool initialized_ = false;
std::mutex init_mutex_;
std::map<int64_t, std::unique_ptr<std::mutex>> mutex_cache_;
std::map<int64_t, DeviceParams> devices_params_;