Hi John --
> That's exactly what I want to do. However, the problem is that both
> block and my distribution (as it is derived from block) override(?) the
> method _remoteAccessData.getDataIndex and I get errors about
> ambiguous calls. I know this is something that should be fixed eventually,
> but I just wanted to get a fast work-around for now. Unfortunately I can't
> figure out if I would be safe just renaming the method in my dist?
I'm not that familiar with the RAD optimization myself, but browsing the
sources, it appears to me that all calls to, say, Block's version of this
function are within BlockDist.chpl itself, so I think you'd be safe renaming
your implementation of the function and all calls to it (if it differs) or
re-using
Block's (if it doesn't).
> I'd definitely like to see something like this, too. I actually just used
> C-style
> preprocessor directives in my code and ran it through C preprocessor before
> handing it to chapel compiler.
Yeah. that's a fine workaround as long as nothing in your Chapel code causes
cpp to break (many implementations are very C-centric and will warn about
legal Chapel code).
> Well, I will be able to work around this somehow for now....Currently I have
> to
> call the constructor like following:
>
> const tbl: [LocaleSpace] real = 1.0;
> const domMap = if useBlockDist then
> new dmap(new Block(...))
> else
> new dmap(new MyBlock(new
> MyPolicy(relCutTable=tbl, ...)));
>
> Now tbl is defined whether I use block dist or MyBlock (I hope compiler
> optimizes that away?). How could I write that so that I could factor tbl out?
What about pushing the entire else clause into a helper function, declaring tbl
as
a local variable in that helper function and passing it into the MyPolicy
constructor
from there? The helper could either return the new MyPolicy object, or it could
create the entire new MyBlock object (or, presumably even the new dmap)?
>
> > I tried something like:
>
> new MyPolicy(relCutTable=1.0)
> new MyPolicy(relCutTable[LocaleSpace]=1.0)
Yeah, there's no way to create a new variable symbol in an actual argument list
itself...
> Also, is there any kind of swap-by-reference routine in Chapel? Ie. I have
> two arrays,
> u and u0. Now I want u0 to get contents of u, and what u gets is of no
> importance.
> Writing u0=u (or u0<=>u ) would copy by value causing unnecessary overhead.
> I'm looking for something similar like how one would swap pointers in C... I
> think I
> could wrap arrays inside classes, but that would make code harder to read and
> maintain...
We don't supply this by default because the user's view of an array in Chapel
is not
memory oriented, it's index->variable oriented (and, in general, the
optimization won't
make sense unless the two arrays share the same domain and domain map and that
domain map stores all arrays identically and there aren't any outstanding
references to
the array. I've postulated that it'd be possible to extend the swap overload
for arrays
in modules/internal/ChapelArray.chpl to handle this case:
//
// Swap operator for arrays
//
inline proc <=>(x: [], y: []) {
forall (a,b) in zip(x, y) do
a <=> b;
}
but haven't ever taken that on myself. As you say, one could do this by
bypassing
the official array interface and making calls into, say, a helper function with
the
[My]BlockArr class that did the swapping, but I don't believe that any of our
current
domain maps export such a routine. I think in practice what people tend to do
is
to pass the two arrays into a helper routine, swapping the order of the
arguments
to get an A, B vs. B, A kind of effect, or to create an array [1..2] of arrays
and use
indices into the outer array to get the same effect.
-Brad
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users