Hi Damian --

I'm heading out the door, and taking a stab at your question without 
having had a chance to read your code very carefully.  Hopefully, I've got 
the thrust of the question right and keep you moving without letting 
another day slip by:

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 think the only reason that this isn't called out specifically in the 
language spec is that it feels like a natural composition of concepts 
rather than something specific.  But perhaps a note of clarification could 
help.  I do think that the arrays.chpl primer in the release touches on 
this at least briefly:

        
https://github.com/chapel-lang/chapel/blob/master/test/release/examples/primers/arrays.chpl

One thing that can sometimes muddy the waters is that arrays can also be 
indexed by tuple indices, so one can do things like:

        const ij = (i,j);

        ...A[ij]...

Moreover, when iterating over multidimensional domains, the indices 
generated are tuples.  Thus, given:

        const D = {1..m, 1..n};

One can iterate like this:

        forall ij in D ...  // ij is a 2-tuple

or this:

        forall (i,j) in D ...  // de-tuple into scalars i and j


Running out the door now,
-Brad




On Mon, 13 Apr 2015, Damian McGuckin wrote:

>
> Hi all,
>
> Looking at the following code to play with boundcode condition (masks)
> taken, and hacked, from the LULESU benchmark.
>
> Apologies if my use of tabs causes poor readability.
>
>       /* Compile-time constants */
>
>       param
>               XI_M        = 0x003,
>               XI_M_SYMM   = 0x001,
>               XI_M_FREE   = 0x002,
>
>               XI_P        = 0x00c,
>               XI_P_SYMM   = 0x004,
>               XI_P_FREE   = 0x008,
>
>               ETA_M       = 0x030,
>               ETA_M_SYMM  = 0x010,
>               ETA_M_FREE  = 0x020,
>
>               ETA_P       = 0x0c0,
>               ETA_P_SYMM  = 0x040,
>               ETA_P_FREE  = 0x080,
>
>               ZETA_M      = 0x300,
>               ZETA_M_SYMM = 0x100,
>               ZETA_M_FREE = 0x200,
>
>               ZETA_P      = 0xc00,
>               ZETA_P_SYMM = 0x400,
>               ZETA_P_FREE = 0x800;
>
>       // example of single dimension array of tuples - all Good
>
>       proc eBC1(mask : int) : int
>       {
>               var amask : [1..6] (int, int, int) =
>               [
>                       ( 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 )
>               ];
>               var eBCe : int;
>
>               for (tmask, tsymm, tfree) in amask
>               {
>                       if ((mask & tmask) == tmask) then eBCe |= tsymm;
>               }
>               return eBCe;
>       }
>
>       // array of arrays - x[i, j] indexing - does NOT compile inside LULESH
>       // compiles successfully outside LULESH, i.e. if you just use this code
>       // in a file by itself.
>
>       proc eBC2(mask : int) : int
>       {
>               var amask : [1..6, 1..3] int =
>               [
>                       [ 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 ]
>               ];
>               var eBCe : int;
>
>               for i in 1..6
>               {
>                       var tmask : int = amask[i, 1];
>                       var tsymm : int = amask[i, 2];
>
>                       if ((mask & tmask) == tmask) then eBCe |= tsymm;
>               }
>               return eBCe;
>       }
>
>       // array of arrays - C-style array indexing - does compile inside LULESH
>
>       proc eBC3(mask : int) : int
>       {
>               var amask : [1..6] [1..3] int =
>               [
>                       [ 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 ]
>               ];
>               var eBCe : int;
>
>               for i in 1..6
>               {
>                       var tmask : int = amask[i][1];
>                       var tsymm : int = amask[i][2];
>
>                       if ((mask & tmask) == tmask) then eBCe |= tsymm;
>               }
>               Return eBCe;
>       }
>
> II notice that if I try use an array indexing scheme like
>
>       amask[i, j]
>
> and use it with the compilation configuration options in the LULESH
> benchmark, the compiler tells me there are problems.
>
> I have to resort to something like
>
>       amask[i][j]
>
> While I can live with either, such issues are not discussed, or even
> hinted at, in the language specification. I also cannot find notes or a
> discussion elsewhere to provide guidance. That said, my search keywords
> might be poor choices.
>
> Regards - 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
>

------------------------------------------------------------------------------
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