andishgar commented on issue #46578:
URL: https://github.com/apache/arrow/issues/46578#issuecomment-2915664149
@kou, the example below demonstrates a practical case where one buffer is
viewed and the other is copied (when cpu_memory_manager_ is passed). I will
send a pull request soon to clarify this further
```c++
TEST_F(TestArrayDataStatisticsViewOrCopyTO,
CudaBufferAndCudaBufferPointToCpuMemory) {
ASSERT_OK_AND_ASSIGN(auto bitmap_buffer,
GenerateGPUBitmapBufferPointToCpuMemory(10));
ASSERT_OK_AND_ASSIGN(auto data_buffer, GenerateGPUtDataBuffer(
{1, 2, 3, 4, 5, 6, 7, 8, 9,
10}));
auto array_data = ArrayData::Make(int32(), 10, {bitmap_buffer,
data_buffer});
auto statistics = std::make_shared<ArrayStatistics>();
statistics->max = 10;
array_data->statistics = statistics;
array_data->null_count = 4;
// Why does the assertion below fail?
// ASSERT_TRUE(is_valid_as_array(array_data));
{
// Since it's not possible to get a host pointer from data_buffer,
//data_buffer is copied. (bitmap_buffer is viewed)
ASSERT_OK_AND_ASSIGN(auto copied_array_data,
array_data->ViewOrCopyTo(cpu_memory_manager_));
ASSERT_FALSE(is_statistics_viewed(array_data, copied_array_data));
}
{
// Despite using the same memory manager, data_buffer is still being
copied.
// Should we consider this a bug?
ASSERT_OK_AND_ASSIGN(auto copied_array_data,
array_data->ViewOrCopyTo(cuda_memory_manager_));
ASSERT_FALSE(is_statistics_viewed(array_data, copied_array_data));
}
{
// Since neither the buffer nor the 'to' memory manager belong to the
CPU,
// the buffers are copied.
ASSERT_OK_AND_ASSIGN(auto copied_array_data,
array_data->ViewOrCopyTo(my_cuda_memory_manager));
ASSERT_FALSE(is_statistics_viewed(array_data, copied_array_data));
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]