On Mon, 13 Apr 2015, Brad Chamberlain wrote:

> Chapel distinguished between multidimensional arrays:
>
>       var A: [1..m, 1..n] real;  // a 2D array
>
> and arrays of arrays (arrays whose elements are arrays):
>
>       var B: [1..m] [1..n] real;
>
> The former says "give me a 2D array of reals" while the latter says "give me 
> a 1D array whose elements are 1D arrays of reals".  The former must be 
> indexed as:
>
>       A[i,j] (or A(i,j))
>
> while the latter must be indexed as:
>
>       B[i][j] (or B(i)(j))
>
> If you find that this is not the case, please let us know -- I'm not 
> aware of any bugs along these lines at present.

I agree with everything in the above. The problem is initialization. There 
is only a single example in the Specification. That document also notes on 
page 174 ($20.2.1) that there is an 'Open issue' in this area. I am unsure 
what 'Open' means. Read on.

I have attempted the simplest changes to 'lulesh.chpl' in the benchmarks.

After the 'param' definition of those symbolic constants at about line 
117 of 'lulesh.chpl', I add the following lines which initializes a 1D
array of 1D arrays.

var
     bc_symm_free : [1..6] [1..3] real = // COMPILES PERFECTLY
     [
         [ 0x0f, ZETA_M_SYMM, ZETA_M_FREE ],
         [ 0x33, ETA_M_SYMM, ETA_M_FREE ],
         [ 0x99, XI_M_SYMM, XI_M_FREE ],
         [ 0xf0, ZETA_P_SYMM, ZETA_P_FREE ],
         [ 0xcc, ETA_P_SYMM, ZETA_P_FREE ],
         [ 0x66, XI_P_SYMM, XI_P_FREE ]
     ];


When I compile lulesh all is cool and wonderful.

If I change the declaration to, i.e.

     bc_symm_free : [1..6, 1..3] real = // COMPILATION FAILS
     [
         [ 0x0f, ZETA_M_SYMM, ZETA_M_FREE ],
         [ 0x33, ETA_M_SYMM, ETA_M_FREE ],
         [ 0x99, XI_M_SYMM, XI_M_FREE ],
         [ 0xf0, ZETA_P_SYMM, ZETA_P_FREE ],
         [ 0xcc, ETA_P_SYMM, ZETA_P_FREE ],
         [ 0x66, XI_P_SYMM, XI_P_FREE ]
     ];

because I want a 2D array, an attempt at compilation says

        lulesh.chpl:120: error: rank mismatch in array assignment

If I remove the initialization, there is no problem with the declaration 
of the 2D array.

What have I done wrong?

If I write my own small example code with the same initialization code for 
either the 1D array of 1D arrays, or the 2D array, that same syntax works 
flawlessly for either case, as the example in my original email showed.

I compile manually with

        chpl -o lulesh-bad --fast -suseSpareMaterials lulesh.chpl

Thanks - Damian

Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to