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

Method CopyBufferSliceToCPU

cpp/src/arrow/device.cc:118–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118Status MemoryManager::CopyBufferSliceToCPU(const std::shared_ptr<Buffer>& buf,
119 int64_t offset, int64_t length,
120 uint8_t* out_data) {
121 if (ARROW_PREDICT_TRUE(buf->is_cpu())) {
122 memcpy(out_data, buf->data() + offset, static_cast<size_t>(length));
123 return Status::OK();
124 }
125
126 auto& from = buf->memory_manager();
127 auto cpu_mm = default_cpu_memory_manager();
128 // Try a view first
129 auto maybe_buffer_result = from->ViewBufferTo(buf, cpu_mm);
130 if (!COPY_BUFFER_SUCCESS(maybe_buffer_result)) {
131 // View failed, try a copy instead
132 maybe_buffer_result = from->CopyBufferTo(buf, cpu_mm);
133 }
134 ARROW_ASSIGN_OR_RAISE(auto maybe_buffer, std::move(maybe_buffer_result));
135 if (maybe_buffer != nullptr) {
136 memcpy(out_data, maybe_buffer->data() + offset, static_cast<size_t>(length));
137 return Status::OK();
138 }
139
140 return Status::NotImplemented("Copying buffer slice from ", from->device()->ToString(),
141 " to CPU not supported");
142}
143
144#undef COPY_BUFFER_RETURN
145#undef COPY_BUFFER_SUCCESS

Callers

nothing calls this directly

Calls 9

OKFunction · 0.70
NotImplementedFunction · 0.70
dataMethod · 0.45
memory_managerMethod · 0.45
ViewBufferToMethod · 0.45
CopyBufferToMethod · 0.45
ToStringMethod · 0.45
deviceMethod · 0.45

Tested by

no test coverage detected