bublina Posted October 30, 2015 Report Share Posted October 30, 2015 (edited) I have noticed, that some array operations come for free in some cases, e.g. do not cost any resources, such as: reverse, transpose, reshape. Since the array representation in memory is like: dimension1 dimension2 ... dimensionx data I can see how things like reshape are for free, but how does for example reverse happen? Does LabVIEW keep these as flags in places with data or does the compiler just know that the next loop should start from back? Edited October 30, 2015 by bublina Quote Link to comment
ned Posted October 30, 2015 Report Share Posted October 30, 2015 Reshape and Transpose aren't free. Reverse and Decimate are; see https://lavag.org/topic/7307-another-reason-why-copy-dots-is-a-bad-name-for-buffer-allocations/ Quote Link to comment
bublina Posted October 31, 2015 Author Report Share Posted October 31, 2015 I meant cpu, though after some testing, it is clear it is optimized by the compiler. Are those buffer dots reworked now? In my 2012 they are showing oddly. Quote Link to comment
ned Posted November 1, 2015 Report Share Posted November 1, 2015 I don't think they've changed. What do you mean by "showing oddly"? Quote Link to comment
hooovahh Posted November 2, 2015 Report Share Posted November 2, 2015 I always heard transpose was "like a no-op" because it didn't move the data around, it just swapped pointer to the memory. If that were the case I could see why a reshape would also be free because the memory it self doesn't need to change just the way the data is interpreted. That being said I have no source stating a transpose is a free operation. Quote Link to comment
Popular Post Rolf Kalbermatter Posted November 2, 2015 Popular Post Report Share Posted November 2, 2015 I always heard transpose was "like a no-op" because it didn't move the data around, it just swapped pointer to the memory. If that were the case I could see why a reshape would also be free because the memory it self doesn't need to change just the way the data is interpreted. That being said I have no source stating a transpose is a free operation. The Transpose can be a free operation but it doesn't have to stay free throughout the diagram. LabVIEW maintains flags for arrays that indicate for instance the order (forward or backward) as well as if it is (transposed or not) The Transpose function then sets that according flag (as does the Revert 1D array does the according flag). Any function consuming the array either has to support that flag and process the array accordingly or first call a function that will normalize the array anyways. So while Transpose may be free in itself it doesn't mean that processing a transposed array is never going to incur the additional processing that goes along with physically transposing the array. I believe it is safe to assume that all native LabVIEW nodes will know how to handle such "subarrays" as will probably autoindexing and similar. However when such an array is passed to a Call Library Node for instance LabVIEW will ALWAYS normalize the array prior to calling the external code function. Similar things account for other array operations such as Array Subset which doesn't always physically create a new array and copies data into it but also can create a subarray that only maintains things like the offset and length into the original array. Of course many of these optimizations will be void and invalidated as soon as your diagram starts to have wire branches that many times require seperate copies of the array data in order to stay consistent. 5 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.