- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Question (mainly for developers): however, I'm uncertain about exact semantics and usage of the offset field, quote:
- The third longword (bytes 8 to 11) contains the offset. The offset is added to the base address to define the start of the array.
But, the entire field seems totally redundant: everything about array element addressing and indexing can be concluded from the base address and DIMS_INFOs of appropriate dimensions. My code, (where exact calculation of that offset is neglected) seems to work just fine in Fortran (using descriptor structure passed from C++ code). Is this just a leftover from older VF versions? Is it used at all for array indexing? If it is, what is the exact semantics (I'm talking about complex cases such as array sections starting at non-1 indices, arrays witl lbound different than zero, etc.)?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Total guess on mypart :-)
Could it be used for handling array slices? or arrays with lower bounds other than 1?
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry Jugoslav somehow I totally missed the last paragraph of your original post.
Perhaps I need a bigger screen :-)
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The data component points to the first element in the array.
The offset field is the position of the origin of the array
(ie element (0, 0 ...)). This may be outsite the bounds of the array.
...
An element is accessed by
data[offset + index0*stride0 + index1*stride1 + index2*stride2]
data[offset + index0*stride0 + index1*stride1 + index2*stride2]
This gives good performance as the computation does not involve the
bounds of the array. For packed arrays, this is optimized further by
substituting the known strides.
Apparently, this could be used to speed up array element index calculation, as it is not necessary to subtract 1 from each index (in order to achieve "C-style" zero-based memory indexing, which is more machine-friendly in terms of efficiency). I assume IVF uses the same semantics... if it uses it at all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From my understanding of how this works is the Offset is the number you add to the index calculations to produce the final address. Fortran has range values for each index and is not (necessarily) zero based as in C/C++.
As an optimization the index supplied is not un-biased back to zero prior to producing the product of the index by the range of the prior index. For example, on a 3 indexed array this technique would eliminate threesubtraction operations. On a one indexed array it eliminates one subtraction operation.
e.g. X(I, J, K)
Effective address =
OffsetX
+ K*SizeSecondIndex*SizeFirstIndex
+ J*SizeFirstIndex
+ I
As opposed to
Effective address =
OffsetX
+ (K-LowValueThirdIndex)*SizeSecondIndex*SizeFirstIndex
+ (J-LowValueSecondIndex)*SizeFirstIndex
+ I-LowValueFirstIndex
(OffsetX would be different for each method)

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page