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

[Revert] "[opt] Allocate hbm uniformly for buckets to avoid fragmentation." #192

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 16 additions & 10 deletions include/merlin/core_kernels.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,12 @@ void initialize_buckets(Table<K, V, S>** table, BaseAllocator* allocator,
uint32_t reserve_size =
bucket_max_size < CACHE_LINE_SIZE ? CACHE_LINE_SIZE : bucket_max_size;
bucket_memory_size += reserve_size * sizeof(uint8_t);
uint8_t* address = nullptr;
allocator->alloc(MemoryType::Device, (void**)&(address),
bucket_memory_size * (end - start));
(*table)->buckets_address.push_back(address);
for (int i = start; i < end; i++) {
allocate_bucket_others<K, V, S><<<1, 1>>>(
(*table)->buckets, i, address + (bucket_memory_size * (i - start)),
reserve_size, bucket_max_size);
uint8_t* address = nullptr;
allocator->alloc(MemoryType::Device, (void**)&(address),
bucket_memory_size);
allocate_bucket_others<K, V, S><<<1, 1>>>((*table)->buckets, i, address,
reserve_size, bucket_max_size);
}
CUDA_CHECK(cudaDeviceSynchronize());

Expand Down Expand Up @@ -367,9 +365,17 @@ void double_capacity(Table<K, V, S>** table, BaseAllocator* allocator) {
/* free all of the resource of a Table. */
template <class K, class V, class S>
void destroy_table(Table<K, V, S>** table, BaseAllocator* allocator) {
for (auto addr : (*table)->buckets_address) {
allocator->free(MemoryType::Device, addr);
}
uint8_t** d_address = nullptr;
CUDA_CHECK(cudaMalloc((void**)&d_address, sizeof(uint8_t*)));
for (int i = 0; i < (*table)->buckets_num; i++) {
uint8_t* h_address;
get_bucket_others_address<K, V, S>
<<<1, 1>>>((*table)->buckets, i, d_address);
CUDA_CHECK(cudaMemcpy(&h_address, d_address, sizeof(uint8_t*),
cudaMemcpyDeviceToHost));
allocator->free(MemoryType::Device, h_address);
}
CUDA_CHECK(cudaFree(d_address));

for (int i = 0; i < (*table)->num_of_memory_slices; i++) {
if (is_on_device((*table)->slices[i])) {
Expand Down
2 changes: 0 additions & 2 deletions include/merlin/types.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <stddef.h>
#include <cstdint>
#include <cuda/std/semaphore>
#include <vector>
#include "debug.hpp"

namespace nv {
Expand Down Expand Up @@ -215,7 +214,6 @@ struct Table {
int slots_number = 0; // unused
int device_id = 0; // Device id
int tile_size;
std::vector<uint8_t*> buckets_address;
};

template <class K, class S>
Expand Down
Loading