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