Hi, > but for module uses, I don't think this is an option. > Note that if the goal of your question is to switch between two > distributions, this could be done by use-ing both modules and then using a > conditional like the above to specify which dmap to use. We do this sort > of thing in [test/release/]examples/benchmarks/lulesh and .../miniMD for > example.
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? > If I'm understanding properly, I don't think there is at present using > config params. The challenge is that conditionals on config params > introduce new lexical scopes, so I find myself often wanting to do things > like: > > if myParamTest then > var x: int; > else > var x: real; > > ...x... > --------- > but this doesn't work because the scope of 'x' is the branch of the > conditional, so it's out of scope by the time the conditional ends. In > many cases, you can switch to a conditional expression: > Note that I/we have had a long-standing desire to have a simplified > version of param conditionals that could be evaluated early (near parse > time) and not introduce lexical scopes in order to get a cpp-style > #if/#ifdef-like capability in the language for cases like this, but > nobody's pushed on it hard enough to propose a design that has stuck. > We're definitely open to inspiration here. 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. I think a lot of cases would be covered by having a compile time conditional statements which didn't create new lexical scopes, called maybe preif or something. >> Also, I have a constructor defined as >> >> proc MyPolicy(boundingBox: domain, param rank=boundingBox.rank, type >> idxType=boundingBox.idxType, targetLocs: [] locale = Locales, >> relCutTable: [] real) >> >> How could I have relCutTable's default value to be an array filled with >> 1.0s, with same domain as targetLocs? > Do either of these work? > > relCutTable: [targetLocs.domain] real = 1.0 > > or: > > targetLocs: [?tld] locale = Locales, > relCutTable: [tld] real = 1.0 > > If not, let me know. (in which case, a lame workaround would be to create > two constructors, one of which takes relCutTable, the other of which > doesn't. If you could forward constructors (something we're currently > planning for), this wouldn't be so bad, but without that, it'd result in > lame code duplication (though maybe that could be moved into a helper > routine). Neither of those worked, unfortunately. Both result in unresolved call to MyPolicy -error. 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? I tried something like: new MyPolicy(relCutTable=1.0) new MyPolicy(relCutTable[LocaleSpace]=1.0) 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... ------------------------------------------------------------------------------ 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
