[ https://issues.apache.org/jira/browse/ARROW-1776?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16243953#comment-16243953 ]
ASF GitHub Bot commented on ARROW-1776: --------------------------------------- xhochy closed pull request #1293: ARROW-1776: [C++] Define arrow::gpu::CudaContext::bytes_allocated() URL: https://github.com/apache/arrow/pull/1293 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/cpp/src/arrow/gpu/cuda-test.cc b/cpp/src/arrow/gpu/cuda-test.cc index afdc3020e..7595f8bec 100644 --- a/cpp/src/arrow/gpu/cuda-test.cc +++ b/cpp/src/arrow/gpu/cuda-test.cc @@ -55,6 +55,7 @@ TEST_F(TestCudaBuffer, Allocate) { std::shared_ptr<CudaBuffer> buffer; ASSERT_OK(context_->Allocate(kSize, &buffer)); ASSERT_EQ(kSize, buffer->size()); + ASSERT_EQ(kSize, context_->bytes_allocated()); } void AssertCudaBufferEquals(const CudaBuffer& buffer, const uint8_t* host_data, diff --git a/cpp/src/arrow/gpu/cuda_context.cc b/cpp/src/arrow/gpu/cuda_context.cc index 42315cd50..fff8ece6c 100644 --- a/cpp/src/arrow/gpu/cuda_context.cc +++ b/cpp/src/arrow/gpu/cuda_context.cc @@ -64,6 +64,7 @@ class CudaContext::CudaContextImpl { CUdeviceptr data; CU_RETURN_NOT_OK(cuMemAlloc(&data, static_cast<size_t>(nbytes))); + bytes_allocated_ += nbytes; *out = reinterpret_cast<uint8_t*>(data); return Status::OK(); } @@ -85,6 +86,7 @@ class CudaContext::CudaContextImpl { Status Free(uint8_t* device_ptr, int64_t nbytes) { CU_RETURN_NOT_OK(cuMemFree(reinterpret_cast<CUdeviceptr>(device_ptr))); + bytes_allocated_ -= nbytes; return Status::OK(); } @@ -273,5 +275,7 @@ Status CudaContext::OpenIpcBuffer(const CudaIpcMemHandle& ipc_handle, return Status::OK(); } +int64_t CudaContext::bytes_allocated() const { return impl_->bytes_allocated(); } + } // namespace gpu } // namespace arrow ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > [C++[ arrow::gpu::CudaContext::bytes_allocated() isn't defined > -------------------------------------------------------------- > > Key: ARROW-1776 > URL: https://issues.apache.org/jira/browse/ARROW-1776 > Project: Apache Arrow > Issue Type: Bug > Components: C++ > Affects Versions: 0.7.1 > Reporter: Kouhei Sutou > Priority: Minor > Labels: pull-request-available > Fix For: 0.8.0 > > > arrow/gpu/cuda_context.h declares arrow::gpu::CudaContext::bytes_allocated() > but it's not defined. > Should it be removed or defined? > CudaContext::CudaContextImple::bytes_allocated() exists. So it's easy to > define it. -- This message was sent by Atlassian JIRA (v6.4.14#64029)