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

Reply via email to