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 print vector changes because of std::vector<bool> #681

Merged
merged 1 commit into from
May 26, 2022
Merged
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
9 changes: 4 additions & 5 deletions cpp/include/raft/core/cudart_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <iomanip>
#include <iostream>
#include <mutex>
#include <vector>

///@todo: enable once logging has been enabled in raft
//#include "logger.hpp"
Expand Down Expand Up @@ -303,10 +302,10 @@ void print_device_vector(const char* variable_name,
size_t componentsCount,
OutStream& out)
{
std::vector<T> host_mem(componentsCount);
CUDA_CHECK(
cudaMemcpy(host_mem.data(), devMem, componentsCount * sizeof(T), cudaMemcpyDeviceToHost));
print_host_vector(variable_name, host_mem.data(), componentsCount, out);
T* host_mem = new T[componentsCount];
Copy link
Contributor

@achirkin achirkin May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to use unique_ptr to avoid a memory leak on exception, e.g.

auto host_mem = std::make_unique<T[]>(componentsCount);

CUDA_CHECK(cudaMemcpy(host_mem, devMem, componentsCount * sizeof(T), cudaMemcpyDeviceToHost));
print_host_vector(variable_name, host_mem, componentsCount, out);
delete[] host_mem;
}

/**
Expand Down