-
Is it possible to use multiple different selections for a single variable in one read? I have data that is stored 3D in space, plus 2 extra dimensions However, I am not sure, if it is possible to have multiple selections, or if the last selection call overwrites all selections for previous Another way would be to copy the variable, set different selections. Is that a possibility? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
Yes, you can do
However, the reader is not smart enough to combine work on multiple selections and it will read the necessary contiguous (probably the entire) dataset to carry out one selection again and again. If performance is a concern, and if this is a big 5D array written by many processes, I would read the entire data block by block and make the transformation in memory manually. |
Beta Was this translation helpful? Give feedback.
-
Hi,
Two points here. The first is that the Get() interface into which you pass a raw pointer does not allocate data for you. Instead, it assumes that you have allocated enough space to hold whatever you are reading. In this case, you're passing in the address of data, which is a stack-allocated variable, so when this Get() does happen, you're going to overwrite the stack and bad things will happen. If you want ADIOS to allocate memory for what you're reading, you should declare data as a "std:vector<real_t> data" so that ADIOS can resize that appropriately. Second, you've commended out the call to PerformGets(). By default the ADIOS Get() function operates in Deferred mode, so it doesn't do anything immediately but waits until PerformGets() (or EndStep() in streaming mode). So, you'll need the call to PerfromGets(). (It looks like the documentation you point too says that "the value is immediately available", but that should only be true if the value that is subject to the Get() is a single value, not an array. I don't know you're data, but it sure looks like you're trying to read an array there. That doc is also plastered with notes about "Preliminary, experimental API, may change soon. " that probably shouldn't be there. Once we get this sorted out, we can sort the documentation issues.) |
Beta Was this translation helpful? Give feedback.
-
Unfortunately memory management between Put() and Get() are necessarily pretty dissimilar. There's nothing like a Span on the Get() side, mostly because you may request a selection that has to be built from multiple write blocks and never existed as a contiguous unit anywhere. So there's nothing on the read side where we give you pointers to ADIOS-internal memory. You must either provide us with pre-allocated memory, or give us an appropriately-typed std::vector (that you own) and ADIOS will set its size appropriately. I'll be honest, without digging deeper, i'm a little puzzled as to how this is compiling. You're passing in a void** to Get(), and we have created methods where the second parameter to Get() is T* where T is a set of atomic types. Somehow C++ must be promoting void* to something, maybe a string? Maybe uintptr_t which can be converted to uint64_t, which would be valid, but not what you want. But somehow it's compiling, and then somehow the Get() is doing something, which it shouldn't be doing without PerformGets() unless variable maps to a single-value datum and not an array. I don't have the whole code, so I don't know if or how that might be happening, but I have to suspect something like that. While I'm not entirely sure of how it's doing what it's doing, I am sure that it is not going to do what you intend because that's not the way ADIOS manages memory on the reader side. For an array, you must either pass in a std::vector (easier because ADIOS can resize it to whatever is needed), or determine the size of the buffer you need (perhaps using the variable.SelectionSize() method), allocate the memory and pass in a pointer to that memory. |
Beta Was this translation helpful? Give feedback.
-
Oh, and glad you got it working pre-allocated... If there are no more questions around this, you can close when you're ready. |
Beta Was this translation helpful? Give feedback.
Yes, you can do
However, the reader is not smart enough to combine work on multiple selections and it will read the necessary contiguous (probably the entire) dataset to carry out one selection again and again.
If performance is a concern, and if this is a big 5D array written by many processes, I would read the entire data block by block and make the transformation in memory manually.