Commit f094acc6 by tianxing wang

Fixed bug where cache would never be allocated at the specified device_id

parent ad3fbd95
...@@ -14,6 +14,10 @@ namespace gpucache { ...@@ -14,6 +14,10 @@ namespace gpucache {
// printf("Cache: keySize: %lu, valueSize: %u, dim: %u, capacity: %lu, " // printf("Cache: keySize: %lu, valueSize: %u, dim: %u, capacity: %lu, "
// "maxQueryNum: %u, deviceId: %u\n", // "maxQueryNum: %u, deviceId: %u\n",
// sizeof(KeyType), value_size, dim, capacity, max_query_num, device_id); // sizeof(KeyType), value_size, dim, capacity, max_query_num, device_id);
int device_count;
CUDA_CHECK(cudaGetDeviceCount(&device_count));
assert(device_id < device_count && "device_id should less than total device num");
CUDA_CHECK(cudaSetDevice(device_id));
CUDA_CHECK(cudaMalloc((void **) &keys, capacity * key_size)); CUDA_CHECK(cudaMalloc((void **) &keys, capacity * key_size));
CUDA_CHECK(cudaMalloc((void **) &values, capacity * value_size)); CUDA_CHECK(cudaMalloc((void **) &values, capacity * value_size));
CUDA_CHECK(cudaMalloc((void **) &timestamps, capacity * sizeof(uint8_t))); CUDA_CHECK(cudaMalloc((void **) &timestamps, capacity * sizeof(uint8_t)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment