MCPcopy Create free account
hub / github.com/apache/arrow / CudaBufferWriterBenchmark

Function CudaBufferWriterBenchmark

cpp/src/arrow/gpu/cuda_benchmark.cc:36–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34constexpr int64_t kGpuNumber = 0;
35
36static void CudaBufferWriterBenchmark(benchmark::State& state, const int64_t total_bytes,
37 const int64_t chunksize,
38 const int64_t buffer_size) {
39 CudaDeviceManager* manager = nullptr;
40 ABORT_NOT_OK(CudaDeviceManager::Instance().Value(&manager));
41 std::shared_ptr<CudaContext> context;
42 ABORT_NOT_OK(manager->GetContext(kGpuNumber).Value(&context));
43
44 std::shared_ptr<CudaBuffer> device_buffer;
45 ABORT_NOT_OK(context->Allocate(total_bytes).Value(&device_buffer));
46 CudaBufferWriter writer(device_buffer);
47
48 if (buffer_size > 0) {
49 ABORT_NOT_OK(writer.SetBufferSize(buffer_size));
50 }
51
52 std::shared_ptr<ResizableBuffer> buffer;
53 ASSERT_OK(MakeRandomByteBuffer(total_bytes, default_memory_pool(), &buffer));
54
55 const uint8_t* host_data = buffer->data();
56 while (state.KeepRunning()) {
57 int64_t bytes_written = 0;
58 ABORT_NOT_OK(writer.Seek(0));
59 while (bytes_written < total_bytes) {
60 int64_t bytes_to_write = std::min(chunksize, total_bytes - bytes_written);
61 ABORT_NOT_OK(writer.Write(host_data + bytes_written, bytes_to_write));
62 bytes_written += bytes_to_write;
63 }
64 }
65 state.SetBytesProcessed(int64_t(state.iterations()) * total_bytes);
66}
67
68static void Writer_Buffered(benchmark::State& state) {
69 // 128MB

Callers 2

Writer_BufferedFunction · 0.85
Writer_UnbufferedFunction · 0.85

Calls 9

MakeRandomByteBufferFunction · 0.85
default_memory_poolFunction · 0.85
ValueMethod · 0.45
GetContextMethod · 0.45
AllocateMethod · 0.45
SetBufferSizeMethod · 0.45
dataMethod · 0.45
SeekMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected