Skip to content

Commit

Permalink
Remove RAFT memory management (#400)
Browse files Browse the repository at this point in the history
Answers #308.
Requires the appropriate changes in `cuML` and `cuGraph` before merging.

Authors:
  - Victor Lafargue (https://github.com/viclafargue)

Approvers:
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #400
  • Loading branch information
viclafargue authored Mar 18, 2022
1 parent 44a46cf commit 613c722
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 681 deletions.
36 changes: 1 addition & 35 deletions cpp/include/raft/cudart_utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2020, NVIDIA CORPORATION.
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -299,40 +299,6 @@ void print_device_vector(const char* variable_name,
}
/** @} */

static std::mutex mutex_;
static std::unordered_map<void*, size_t> allocations;

template <typename Type>
void allocate(Type*& ptr, size_t len, rmm::cuda_stream_view stream, bool setZero = false)
{
size_t size = len * sizeof(Type);
ptr = (Type*)rmm::mr::get_current_device_resource()->allocate(size, stream);
if (setZero) CUDA_CHECK(cudaMemsetAsync((void*)ptr, 0, size, stream));

std::lock_guard<std::mutex> _(mutex_);
allocations[ptr] = size;
}

template <typename Type>
void deallocate(Type*& ptr, rmm::cuda_stream_view stream)
{
std::lock_guard<std::mutex> _(mutex_);
size_t size = allocations[ptr];
allocations.erase(ptr);
rmm::mr::get_current_device_resource()->deallocate((void*)ptr, size, stream);
}

inline void deallocate_all(rmm::cuda_stream_view stream)
{
std::lock_guard<std::mutex> _(mutex_);
for (auto& alloc : allocations) {
void* ptr = alloc.first;
size_t size = alloc.second;
rmm::mr::get_current_device_resource()->deallocate(ptr, size, stream);
}
allocations.clear();
}

/** helper method to get max usable shared mem per block parameter */
inline int getSharedMemPerBlock()
{
Expand Down
70 changes: 0 additions & 70 deletions cpp/include/raft/mr/allocator.hpp

This file was deleted.

211 changes: 0 additions & 211 deletions cpp/include/raft/mr/buffer_base.hpp

This file was deleted.

57 changes: 0 additions & 57 deletions cpp/include/raft/mr/device/allocator.hpp

This file was deleted.

Loading

0 comments on commit 613c722

Please sign in to comment.