[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Freepooma-devel] mixing domain and stride information
From: |
ron hylton |
Subject: |
Re: [Freepooma-devel] mixing domain and stride information |
Date: |
Tue, 12 Apr 2005 11:32:10 -0400 |
From: Richard Guenther <address@hidden>
Maybe you can help me see the actual problems.
Richard,
I often solve problems with coefficients that are homogeneous in one or more
dimensions. In Array terms, this means that one or more subscripts really
does nothing and can be ignored. So I have an engine type I call a
FlattenedBrick, descended from BrickBase, which is really a
lower-dimensional brick embedded in the apparent brick. This saves memory
and the unused subscripts are visible to the compiler so there is potential
for optimization, and I have some functions for manipulating FlattenedBricks
that I can use where I think manual optimization is worthwhile.
The previous BrickView worked fine because it just asked BrickBase what the
strides & offset were and got the correct values from FlattenedBrick. Now
BrickView assumes one very specific memory layout rather than asking
BrickBase so FlattenedBrick doesn't work, nor would any other BrickBase
descendant that wanted to use its own memory layout.
Here's a snippet from the original BrickViewBase sliceInit:
{
if (!dom.ignorable(dt))
{
PAssert(d < Dim);
domain_m[d] = Interval<1>(domain[dt].length());
strides_m[d] = baseStrides[dt] * domain[dt].stride();
++d;
}
baseOffset_m += domain[dt].first() * baseStrides[dt];
The new stride & offset is computed from the baseStrides supplied by
BrickBase.
Here's the current version:
int baseStride = 1;
int d = 0;
for (int dt = 0; dt < BaseDim; ++dt)
{
if (!dom.ignorable(dt))
{
PBoundAssert(d < Dim);
domain_m[d] = Interval<1>(domain[dt].length());
strides_m[d] = baseStride * domain[dt].stride();
++d;
}
baseOffset_m += domain[dt].first() * baseStride;
baseStride *= baseDom[dt].length();
BrickView is now using the domain length from BrickBase to compute the
strides and offset and assuming that memory is laid out densely with a
particular ordering of subscripts; control over actual memory layout has
been taken away from BrickBase.
I doubt that there can be any measurable effect on optimization, the changes
are all in BrickView initialization code.
Ron