Weird behavior of jagged_vector_buffer with zero capacity #129
Replies: 1 comment 2 replies
-
This is very interesting! Though not exactly for the reason that I first thought... You are right, technically your code should work. Even if it is not recommended to write code like this. Since (jagged) vector buffers should not be interacted with directly. You should always create a host or device vector "on top of" vector buffers. This is what I did in #130. And as long as I do that, things do work correctly. What happens in your code is that after updating the memory atomically on the device in "managed" memory, the host code tries to access that managed memory through a "system of pointers". And it seems that the just-in-time-copy that would be necessary to get the most recent version of the managed memory back from the device to the host, is not triggering correctly. Very strangely I observed the same weird When using For now I would suggest that you stick to only using the contents of buffers though host/device vectors. In such a setup the code should work correctly... As I wrote in #130, I'll do some further tests with this. As I'll want to see if my theory is indeed correct, and with HIP and SYCL your code would actually work. 🤔 |
Beta Was this translation helpful? Give feedback.
-
I have encountered weird behavior of jagged_vector_buffer when the input argument include the zero capacity.
Everything is fine when we use the device resource and host(managed) resource together:
vecmem::data::jagged_vector_buffer<int> input_data_device({0, 0, 0, 0, 0, 0 }, {0, 1, 200, 1, 100, 2}, device_resource, &managed_resource);
But when I hook the buffer only with managed memory resource, the zero capacity of {0, 1, 200, 1, 100, 2} caused weird output.
vecmem::data::jagged_vector_buffer<int> input_data_device({0, 0, 0, 0, 0, 0 }, {0, 1, 200, 1, 100, 2}, manged_resource);
Actually I am not even sure if it is legal to use only the managed resource for initiating the
jagged_vector_buffer
, So anybody please confirm that if it is the unwanted usage ofjagged_vector_buffer
Following is the codes that I tested in vecmem test directory
test_cuda_jagged_vector_view.cpp
test_cuda_jagged_vector_view_kernels.cu
Expected print output
0
1
200
1
100
2
Actual print output
7
1
200
1
100
2
Beta Was this translation helpful? Give feedback.
All reactions