This is an automated email from the ASF dual-hosted git repository. uwe pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push: new bfc0f24 ARROW-1776: [C++] Define arrow::gpu::CudaContext::bytes_allocated() bfc0f24 is described below commit bfc0f24fcc58f3885c2175c64864cc12af95f938 Author: Kouhei Sutou <k...@clear-code.com> AuthorDate: Wed Nov 8 14:44:26 2017 +0100 ARROW-1776: [C++] Define arrow::gpu::CudaContext::bytes_allocated() Author: Kouhei Sutou <k...@clear-code.com> Closes #1293 from kou/cpp-gpu-cuda-context-bytes-allocated and squashes the following commits: 5221887 [Kouhei Sutou] [C++] Define arrow::gpu::CudaContext::bytes_allocated() --- cpp/src/arrow/gpu/cuda-test.cc | 1 + cpp/src/arrow/gpu/cuda_context.cc | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/cpp/src/arrow/gpu/cuda-test.cc b/cpp/src/arrow/gpu/cuda-test.cc index afdc302..7595f8b 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 42315cd..fff8ece 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 -- To stop receiving notification emails like this one, please contact ['"commits@arrow.apache.org" <commits@arrow.apache.org>'].