Changeset 27434e9


Ignore:
Timestamp:
Jun 23, 2021, 5:19:38 PM (7 months ago)
Author:
m3zulfiq <m3zulfiq@…>
Branches:
jacob/cs343-translation, master, new-ast-unique-expr
Children:
b6f39aa
Parents:
2b910f9 (diff), 1d71208 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/locks.hfa

    r2b910f9 r27434e9  
    174174};
    175175
     176static inline void ?{}(fast_lock & this) { this.owner = 0p; }
     177
    176178static inline bool $try_lock(fast_lock & this, $thread * thrd) {
    177179    $thread * exp = 0p;
  • libcfa/src/concurrency/ready_queue.cfa

    r2b910f9 r27434e9  
    2020
    2121
    22 // #define USE_RELAXED_FIFO
     22#define USE_RELAXED_FIFO
    2323// #define USE_WORK_STEALING
    24 #define USE_CPU_WORK_STEALING
     24// #define USE_CPU_WORK_STEALING
    2525
    2626#include "bits/defs.hfa"
     
    760760                for(i; lanes.count) {
    761761                        unsigned long long tsc1 = ts(lanes.data[i]);
    762                         unsigned long long tsc2 = rdtscl()
     762                        unsigned long long tsc2 = rdtscl();
    763763                        lanes.tscs[i].tv = min(tsc1, tsc2);
    764764                }
  • libcfa/src/containers/array.hfa

    r2b910f9 r27434e9  
    137137// Base
    138138forall( [Nq], Sq & | sized(Sq), Tbase & )
    139 static inline tag(arpk(Nq, Sq, Tbase, Tbase)) enq_( tag(Tbase), tag(Nq), tag(Sq), tag(Tbase) ) {}
     139static inline tag(arpk(Nq, Sq, Tbase, Tbase)) enq_( tag(Tbase), tag(Nq), tag(Sq), tag(Tbase) ) {
     140    tag(arpk(Nq, Sq, Tbase, Tbase)) ret;
     141    return ret;
     142}
    140143
    141144// Rec
    142145forall( [Nq], Sq & | sized(Sq), [N], S & | sized(S), recq &, recr &, Tbase & | { tag(recr) enq_( tag(Tbase), tag(Nq), tag(Sq), tag(recq) ); } )
    143 static inline tag(arpk(N, S, recr, Tbase)) enq_( tag(Tbase), tag(Nq), tag(Sq), tag(arpk(N, S, recq, Tbase)) ) {}
     146static inline tag(arpk(N, S, recr, Tbase)) enq_( tag(Tbase), tag(Nq), tag(Sq), tag(arpk(N, S, recq, Tbase)) ) {
     147    tag(arpk(N, S, recr, Tbase)) ret;
     148    return ret;
     149}
    144150
    145151// Wrapper
  • src/Parser/DeclarationNode.cc

    r2b910f9 r27434e9  
    10761076        if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) {
    10771077                // otype is internally converted to dtype + otype parameters
    1078                 static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::DStype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype, TypeDecl::Dimension };
     1078                static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype, TypeDecl::Dimension };
    10791079                static_assert( sizeof(kindMap) / sizeof(kindMap[0]) == TypeDecl::NUMBER_OF_KINDS, "DeclarationNode::build: kindMap is out of sync." );
    10801080                assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." );
    1081                 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype, variable.initializer ? variable.initializer->buildType() : nullptr );
     1081                TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype || variable.tyClass == TypeDecl::DStype, variable.initializer ? variable.initializer->buildType() : nullptr );
    10821082                buildList( variable.assertions, ret->get_assertions() );
    10831083                return ret;
  • src/Parser/parser.yy

    r2b910f9 r27434e9  
    635635postfix_expression:
    636636        primary_expression
    637         | postfix_expression '[' assignment_expression ',' comma_expression ']'
    638                 // { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_binary_val( OperKinds::Index, $3, $5 ) ) ) ); }
    639                 { SemanticError( yylloc, "New array subscript is currently unimplemented." ); $$ = nullptr; }
     637        | postfix_expression '[' assignment_expression ',' tuple_expression_list ']'
     638                        // Historic, transitional: Disallow commas in subscripts.
     639                        // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts.
     640                // { SemanticError( yylloc, "New array subscript is currently unimplemented." ); $$ = nullptr; }
     641                        // Current: Commas in subscripts make tuples.
     642                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }
    640643        | postfix_expression '[' assignment_expression ']'
    641644                // CFA, comma_expression disallowed in this context because it results in a common user error: subscripting a
  • tests/.expect/forall.txt

    r2b910f9 r27434e9  
    1 forall.cfa:216:25: warning: Compiled
     1forall.cfa:242:25: warning: Compiled
  • tests/array-container/array-basic.cfa

    r2b910f9 r27434e9  
    105105    printf("result Ws [][][][] lo = %f\n", result);
    106106
    107     result = total1d_low( wxyz[[all, slice_ix, slice_ix, slice_ix]] );
     107    result = total1d_low( wxyz[all, slice_ix, slice_ix, slice_ix] );
    108108    printf("result Ws [,,,]    lo = %f\n", result);
    109109
     
    111111    printf("result Ws [][][][] hi = %f\n", result);
    112112
    113     result = total1d_hi( wxyz[[all, slice_ix, slice_ix, slice_ix]] );
     113    result = total1d_hi( wxyz[all, slice_ix, slice_ix, slice_ix] );
    114114    printf("result Ws [,,,]    hi = %f\n", result);
    115115
     
    124124    printf("result Xs [][][][] lo = %f\n", result);
    125125
    126     result = total1d_low( wxyz[[slice_ix, all, slice_ix, slice_ix]] );
     126    result = total1d_low( wxyz[slice_ix, all, slice_ix, slice_ix] );
    127127    printf("result Xs [,,,]    lo = %f\n", result);
    128128
     
    130130    printf("result Xs [][][][] hi = %f\n", result);
    131131
    132     result = total1d_hi( wxyz[[slice_ix, all, slice_ix, slice_ix]] );
     132    result = total1d_hi( wxyz[slice_ix, all, slice_ix, slice_ix] );
    133133    printf("result Xs [,,,]    hi = %f\n", result);
    134134
  • tests/array-container/array-md-sbscr-cases.cfa

    r2b910f9 r27434e9  
    5353    // order wxyz, natural split (4-0 or 0-4, no intermediate to declare)
    5454
    55     assert(( wxyz[[iw, ix, iy, iz]] == valExpected ));
     55    assert(( wxyz[iw, ix, iy, iz] == valExpected ));
    5656
    5757    // order wxyz, unnatural split 1-3  (three ways declared)
    5858
    5959    typeof( wxyz[iw] ) xyz1 = wxyz[iw];
    60     assert(( xyz1[[ix, iy, iz]]  == valExpected ));
     60    assert(( xyz1[ix, iy, iz]  == valExpected ));
    6161
    6262    typeof( wxyz[iw] ) xyz2;
    6363    &xyz2 = &wxyz[iw];
    64     assert(( xyz2[[ix, iy, iz]] == valExpected ));
    65 
    66     assert(( wxyz[iw][[ix, iy, iz]] == valExpected ));
     64    assert(( xyz2[ix, iy, iz] == valExpected ));
     65
     66    assert(( wxyz[iw][ix, iy, iz] == valExpected ));
    6767
    6868    // order wxyz, unnatural split 2-2  (three ways declared)
    6969
    70     typeof( wxyz[[iw, ix]] ) yz1 = wxyz[[iw,ix]];
    71     assert(( yz1[[iy, iz]]  == valExpected ));
    72 
    73     typeof( wxyz[[iw, ix]] ) yz2;
    74     &yz2 = &wxyz[[iw, ix]];
    75     assert(( yz2[[iy, iz]]  == valExpected ));
    76 
    77     assert(( wxyz[[iw, ix]][[iy, iz]] == valExpected ));
     70    typeof( wxyz[iw, ix] ) yz1 = wxyz[iw,ix];
     71    assert(( yz1[iy, iz]  == valExpected ));
     72
     73    typeof( wxyz[iw, ix] ) yz2;
     74    &yz2 = &wxyz[iw, ix];
     75    assert(( yz2[iy, iz]  == valExpected ));
     76
     77    assert(( wxyz[iw, ix][iy, iz] == valExpected ));
    7878
    7979    // order wxyz, unnatural split 3-1  (three ways declared)
    8080
    81     typeof( wxyz[[iw, ix, iy]] ) z1 = wxyz[[iw, ix, iy]];
     81    typeof( wxyz[iw, ix, iy] ) z1 = wxyz[iw, ix, iy];
    8282    assert(( z1[iz]  == valExpected ));
    8383
    84     typeof( wxyz[[iw, ix, iy]] ) z2;
    85     &z2 = &wxyz[[iw, ix, iy]];
     84    typeof( wxyz[iw, ix, iy] ) z2;
     85    &z2 = &wxyz[iw, ix, iy];
    8686    assert(( z2[iz] == valExpected ));
    8787
    88     assert(( wxyz[[iw, ix, iy]][iz] == valExpected ));
     88    assert(( wxyz[iw, ix, iy][iz] == valExpected ));
    8989}
    9090
     
    104104    // order wxyz (no intermediates to declare)
    105105
    106     assert(( wxyz[[iw  , ix  , iy  , iz  ]]       == valExpected ));
    107     assert(( wxyz[[iw-1, ix  , iy  , iz  ]]       != valExpected ));
     106    assert(( wxyz[iw  , ix  , iy  , iz  ]       == valExpected ));
     107    assert(( wxyz[iw-1, ix  , iy  , iz  ]       != valExpected ));
    108108
    109109    // order xyzw: *xyz, w
    110110
    111     assert(( wxyz[[all , ix  , iy  , iz  ]][iw  ] == valExpected ));
    112     assert(( wxyz[[all , ix-1, iy  , iz  ]][iw  ] != valExpected ));
    113     assert(( wxyz[[all , ix  , iy  , iz  ]][iw-1] != valExpected ));
     111    assert(( wxyz[all , ix  , iy  , iz  ][iw  ] == valExpected ));
     112    assert(( wxyz[all , ix-1, iy  , iz  ][iw  ] != valExpected ));
     113    assert(( wxyz[all , ix  , iy  , iz  ][iw-1] != valExpected ));
    114114
    115115    // order wyzx: w*yz, x
    116116
    117     assert(( wxyz[[iw  , all , iy  , iz  ]][ix  ] == valExpected ));
    118     assert(( wxyz[[iw  , all , iy-1, iz  ]][ix  ] != valExpected ));
    119     assert(( wxyz[[iw  , all , iy  , iz  ]][ix-1] != valExpected ));
     117    assert(( wxyz[iw  , all , iy  , iz  ][ix  ] == valExpected ));
     118    assert(( wxyz[iw  , all , iy-1, iz  ][ix  ] != valExpected ));
     119    assert(( wxyz[iw  , all , iy  , iz  ][ix-1] != valExpected ));
    120120
    121121    // order wxzy: wx*z, y
    122122  #if 0
    123123    // not working on 32-bit
    124     assert(( wxyz[[iw  , ix  , all , iz  ]][iy  ] == valExpected ));
    125     assert(( wxyz[[iw  , ix  , all , iz-1]][iy  ] != valExpected ));
    126     assert(( wxyz[[iw  , ix  , all , iz  ]][iy-1] != valExpected ));
     124    assert(( wxyz[iw  , ix  , all , iz  ][iy  ] == valExpected ));
     125    assert(( wxyz[iw  , ix  , all , iz-1][iy  ] != valExpected ));
     126    assert(( wxyz[iw  , ix  , all , iz  ][iy-1] != valExpected ));
    127127  #endif
    128128}
     
    131131// The comments specify a covering set of orders, each in its most natural split.
    132132// Covering means that each edge on the lattice of dimesnions-provided is used.
    133 // Natural split means the arity of every -[[-,...]] tuple equals the dimensionality of its "this" operand, then that the fewest "all" subscripts are given.
     133// Natural split means the arity of every -[-,...] tuple equals the dimensionality of its "this" operand, then that the fewest "all" subscripts are given.
    134134// The commented-out test code shows cases that don't work.  We wish all the comment-coverd cases worked.
    135135forall( [Nw], [Nx], [Ny], [Nz] )
     
    147147    // order wxyz (no intermediates to declare)
    148148
    149     assert(( wxyz[[iw, ix, iy, iz]] == valExpected ));
     149    assert(( wxyz[iw, ix, iy, iz] == valExpected ));
    150150
    151151    {
     
    153153        assert( wxyz[iw][all][iy][all] [ix][iz] == valExpected );
    154154
    155         typeof( wxyz[[iw, all, iy, all]] ) xz1 = wxyz[[iw, all, iy, all]];
    156         assert(( xz1[[ix, iz]]  == valExpected ));
    157 
    158         typeof( wxyz[[iw, all, iy, all]] ) xz2;
    159         &xz2 = &wxyz[[iw, all, iy, all]];
    160         assert(( xz2[[ix, iz]]  == valExpected ));
    161 
    162         assert(( wxyz[[iw  , all, iy  , all]][[ix  , iz  ]] == valExpected ));
    163         assert(( wxyz[[iw-1, all, iy  , all]][[ix  , iz  ]] != valExpected ));
    164         assert(( wxyz[[iw  , all, iy-1, all]][[ix  , iz  ]] != valExpected ));
    165         assert(( wxyz[[iw  , all, iy  , all]][[ix-1, iz  ]] != valExpected ));
    166         assert(( wxyz[[iw  , all, iy  , all]][[ix  , iz-1]] != valExpected ));
     155        typeof( wxyz[iw, all, iy, all] ) xz1 = wxyz[iw, all, iy, all];
     156        assert(( xz1[ix, iz]  == valExpected ));
     157
     158        typeof( wxyz[iw, all, iy, all] ) xz2;
     159        &xz2 = &wxyz[iw, all, iy, all];
     160        assert(( xz2[ix, iz]  == valExpected ));
     161
     162        assert(( wxyz[iw  , all, iy  , all][ix  , iz  ] == valExpected ));
     163        assert(( wxyz[iw-1, all, iy  , all][ix  , iz  ] != valExpected ));
     164        assert(( wxyz[iw  , all, iy-1, all][ix  , iz  ] != valExpected ));
     165        assert(( wxyz[iw  , all, iy  , all][ix-1, iz  ] != valExpected ));
     166        assert(( wxyz[iw  , all, iy  , all][ix  , iz-1] != valExpected ));
    167167    }
    168168    {
     
    170170        assert( wxyz[iw][all][all][iz] [ix][iy] == valExpected );
    171171
    172         // typeof( wxyz[[iw, all, all, iz]] ) xy1 = wxyz[[iw, all, all, iz]];
    173         // assert(( xy1[[ix, iy]]  == valExpected ));
    174 
    175         // typeof(  wxyz[[iw, all, all, iz]] ) xy2;
    176         // &xy2 = &wxyz[[iw, all, all, iz]];
    177         // assert(( xy2[[ix, iy]]  == valExpected ));
    178 
    179         // assert(( wxyz[[iw  , all, all, iz  ]][[ix  , iy  ]] == valExpected ));
    180         // assert(( wxyz[[iw-1, all, all, iz  ]][[ix  , iy  ]] != valExpected ));
    181         // assert(( wxyz[[iw  , all, all, iz-1]][[ix  , iy  ]] != valExpected ));
    182         // assert(( wxyz[[iw  , all, all, iz  ]][[ix-1, iy  ]] != valExpected ));
    183         // assert(( wxyz[[iw  , all, all, iz  ]][[ix  , iy-1]] != valExpected ));
     172        // typeof( wxyz[iw, all, all, iz] ) xy1 = wxyz[iw, all, all, iz];
     173        // assert(( xy1[ix, iy]  == valExpected ));
     174
     175        // typeof(  wxyz[iw, all, all, iz] ) xy2;
     176        // &xy2 = &wxyz[iw, all, all, iz];
     177        // assert(( xy2[ix, iy]  == valExpected ));
     178
     179        // assert(( wxyz[iw  , all, all, iz  ][ix  , iy  ] == valExpected ));
     180        // assert(( wxyz[iw-1, all, all, iz  ][ix  , iy  ] != valExpected ));
     181        // assert(( wxyz[iw  , all, all, iz-1][ix  , iy  ] != valExpected ));
     182        // assert(( wxyz[iw  , all, all, iz  ][ix-1, iy  ] != valExpected ));
     183        // assert(( wxyz[iw  , all, all, iz  ][ix  , iy-1] != valExpected ));
    184184    }
    185185    {
     
    187187        assert( wxyz[all][ix][iy][all] [iw][iz] == valExpected );
    188188
    189         typeof( wxyz[[all, ix, iy, all]] ) wz1 = wxyz[[all, ix, iy, all]];
    190         assert(( wz1[[iw, iz]]  == valExpected ));
    191 
    192         assert(( wxyz[[all  , ix, iy  , all]][[iw  , iz  ]] == valExpected ));
     189        typeof( wxyz[all, ix, iy, all] ) wz1 = wxyz[all, ix, iy, all];
     190        assert(( wz1[iw, iz]  == valExpected ));
     191
     192        assert(( wxyz[all  , ix, iy  , all][iw  , iz  ] == valExpected ));
    193193    }
    194194    {
     
    196196        assert( wxyz[all][ix][all][iz] [iw][iy] == valExpected );
    197197
    198         // assert(( wxyz[[all , ix  , all , iz  ]][[iw  , iy  ]] == valExpected ));
     198        // assert(( wxyz[all , ix  , all , iz  ][iw  , iy  ] == valExpected ));
    199199    }
    200200    {
     
    202202        assert( wxyz[all][all][iy][iz] [iw][ix] == valExpected );
    203203
    204         // assert(( wxyz[[all , all , iy  , iz  ]][[iw  , ix  ]] == valExpected ));
     204        // assert(( wxyz[all , all , iy  , iz  ][iw  , ix  ] == valExpected ));
    205205    }
    206206    {
     
    208208        assert( wxyz[all][ix][all][all] [iw][all][iz] [iy] == valExpected );
    209209
    210         typeof( wxyz[all][ix][all][all] ) wyz_workaround = wxyz[[all , ix , all  , all  ]];
    211         typeof( wyz_workaround[iw][all][iz] ) y_workaround = wyz_workaround[[iw , all , iz  ]];
     210        typeof( wxyz[all][ix][all][all] ) wyz_workaround = wxyz[all , ix , all  , all  ];
     211        typeof( wyz_workaround[iw][all][iz] ) y_workaround = wyz_workaround[iw , all , iz  ];
    212212        assert( y_workaround[iy] == valExpected );
    213213
    214         // assert(( wxyz[[all , ix , all  , all  ]][[iw  , all , iz  ]][iy  ] == valExpected ));
     214        // assert(( wxyz[all , ix , all  , all  ][iw  , all , iz  ][iy  ] == valExpected ));
    215215    }
    216216    {
     
    239239    valExpected = getMagicNumber(2, 3, 4, 5);
    240240    assert(( wxyz [2] [3] [4] [5]  == valExpected ));
    241     assert(( wxyz[[2,  3]][4] [5]  == valExpected ));
    242     assert(( wxyz [2][[3,  4]][5]  == valExpected ));
    243     assert(( wxyz [2] [3][[4,  5]] == valExpected ));
    244     assert(( wxyz[[2,  3,  4]][5]  == valExpected ));
    245     assert(( wxyz [2][[3,  4,  5]] == valExpected ));
    246     assert(( wxyz[[2,  3,  4,  5]] == valExpected ));
     241    assert(( wxyz[2,  3][4] [5]  == valExpected ));
     242    assert(( wxyz [2][3,  4][5]  == valExpected ));
     243    assert(( wxyz [2] [3][4,  5] == valExpected ));
     244    assert(( wxyz[2,  3,  4][5]  == valExpected ));
     245    assert(( wxyz [2][3,  4,  5] == valExpected ));
     246    assert(( wxyz[2,  3,  4,  5] == valExpected ));
    247247
    248248    for ( i; Nw ) {
    249         assert(( wxyz[[ i, 3, 4, 5 ]] == getMagicNumber(i, 3, 4, 5) ));
     249        assert(( wxyz[ i, 3, 4, 5 ] == getMagicNumber(i, 3, 4, 5) ));
    250250    }
    251251
    252252    for ( i; Nx ) {
    253         assert(( wxyz[[ 2, i, 4, 5 ]] == getMagicNumber(2, i, 4, 5) ));
     253        assert(( wxyz[ 2, i, 4, 5 ] == getMagicNumber(2, i, 4, 5) ));
    254254    }
    255255
    256256    for ( i; Ny ) {
    257         assert(( wxyz[[ 2, 3, i, 5 ]] == getMagicNumber(2, 3, i, 5) ));
     257        assert(( wxyz[ 2, 3, i, 5 ] == getMagicNumber(2, 3, i, 5) ));
    258258    }
    259259
    260260    for ( i; Nz ) {
    261         assert(( wxyz[[ 2, 3, 4, i ]] == getMagicNumber(2, 3, 4, i) ));
     261        assert(( wxyz[ 2, 3, 4, i ] == getMagicNumber(2, 3, 4, i) ));
    262262    }
    263263
    264264    for ( i; Nw ) {
    265         assert(( wxyz[[ i, all, 4, 5 ]][3] == getMagicNumber(i, 3, 4, 5) ));
     265        assert(( wxyz[ i, all, 4, 5 ][3] == getMagicNumber(i, 3, 4, 5) ));
    266266    }
    267267
    268268    for ( i; Nw ) {
    269         assert(( wxyz[[ all, 3, 4, 5 ]][i] == getMagicNumber(i, 3, 4, 5) ));
     269        assert(( wxyz[ all, 3, 4, 5 ][i] == getMagicNumber(i, 3, 4, 5) ));
    270270    }
    271271}
  • tests/forall.cfa

    r2b910f9 r27434e9  
    199199}
    200200
     201forall( T ) void check_otype() {
     202        T & tr = *0p;
     203        T * tp = 0p;
     204
     205        &tr += 1;
     206        tp += 1;
     207        T & tx = tp[1];
     208
     209        T t;
     210        T t2 = t;
     211}
     212
     213forall( T * ) void check_dstype() {
     214        T & tr = *0p;
     215        T * tp = 0p;
     216
     217        &tr += 1;
     218        tp += 1;
     219        T & tx = tp[1];
     220}
     221
     222forall( T & ) void check_dtype() {
     223        T & tr = *0p;
     224        T * tp = 0p;
     225}
     226
    201227//otype T1 | { void xxx( T1 ); };
    202228
Note: See TracChangeset for help on using the changeset viewer.