Hi,
What I meant was that I wanted to have param rank in the policy classes. I
already thought making policy classes non-generic and methods generic, however
I was not satisfied with the outcome. Technically it did work but I want the
option to store something rank related in the policy class (like a domain(rank)
).
What I ended up doing is:
class MyDist {
var policy;
...
proc MyDist(policy, ...) {
// Is the following line necessary?
this.policy = policy;
}
}
That solution seems to work well enough so I think I'll use it for now.
Another question: In block distribution, the local blocks (domain is
LocBlockDist.myChunk) don't cover just the bounding box, but rather the whole
space representable by the used index type and rank. Brad already wrote about
this, but would you mind expanding a bit on this issue? I did use the BlockDist
as a starting point for MyDist, and have rewritten the chunk calculation. I did
a test where I changed myChunks to cover just the bounding box and my test
programs didn't break, so where is this actually needed?
John
30.01.2015, 18:51, "Vassily Litvinov" <[email protected]>:
> John,
>
> To confirm what you observe, if your getRank() method returns a param,
> then it will not dispatch dynamically. Indeed it can't because you need
> the result at compile time.
>
> I did not quite follow your rank troubles. My understanding was that
> MyBlockDist will hold the rank - that's where you avoid subclasses.
>
> Is that the case that you need param rank in the PolicyType hierarchy,
> too? To make that work, make PolicyType classes non-generic. It is the
> methods in those classes that can be generic - e.g. rank and element
> type would be passed into those methods from MyBlockDist methods.
>
> Vassily
>
> On 01/30/15 02:05, John MacFrenz wrote:
>> Hi,
>>> The actual argument(s) must be compile-time "params". In your example,
>>> 'i' would need to be a "param", not "var".
>>>
>>> Note that "rank" is usually a param, so you should be able to write:
>>>
>>> var A: [...] ...; // A is an array
>>> compilerError("Error: rank=" + A.rank);
>> Thanks for reminding me about that, though the actual situation is a bit
>> more complicated than this, see below.
>>> A slight variation on your class declaration:
>>>
>>> class MyBlockDist {
>>> type policyType;
>>> var policy:policyType;
>>> ....
>>> }
>>>
>>> would be avoiding 'policyType' and having 'policy' be a generic field:
>>>
>>> class MyBlockDist {
>>> var policy;
>>> ....
>>> }
>> Hm, I think I tried that but ran into some kind of problems. Well, I'll
>> give it another go and ask further quesitons if I can't make it work...
>>> In some cases you won't be able to mix instances different
>>> instantiations of MyBlockDist. This may or may not be an issue for you.
>>> If it is, make the 'policy' field be non-generic, its type being the
>>> root of your policy-type class hierarchy:
>>>
>>> class MyBlockDist {
>>> var policy:RootPolicy;
>>> ....
>>> }
>>>
>>> class RootPolicy {...}
>>> class MyFirstPolicy: RootPolicy {...}
>>> class MySecondPolicy: RootPolicy {...}
>>>
>>> etc.
>> This is the exact approach I would like to take, however there seems to be
>> several problems associated with this... I guess that it mostly boils down
>> to the fact that I need to have the rank as parameter, but as Brad
>> previously explained, I can't have that in the base class. So I had to push
>> it down to child classes, which brought its own problems. That is, it seems
>> I can't do compile time checks of rank in MyBlockDist, since it's the child
>> class that has the rank parameter. I tried writing a getRank() method which
>> is overridden in child class, but it didn't work. This also seems to make
>> assignment of domains fail at compile time.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users