Changeset 38e266c for tests/concurrency


Ignore:
Timestamp:
Jun 11, 2023, 6:42:36 PM (11 months ago)
Author:
caparsons <caparson@…>
Branches:
ast-experimental, master
Children:
32a4f3e, 576aadb, 62d62db, 8a930c03
Parents:
1db6d70 (diff), 0658672 (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrency/lockfree_stack.cfa

    r1db6d70 r38e266c  
    1010// Created On       : Thu May 25 15:36:50 2023
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 30 19:02:32 2023
    13 // Update Count     : 18
     12// Last Modified On : Fri Jun  9 14:01:07 2023
     13// Update Count     : 68
    1414//
    1515
     
    2929        int64_t atom;
    3030        #endif // __SIZEOF_INT128__
    31 } __attribute__(( aligned( 16 ) ));
     31};
    3232
    3333struct Node {
     
    4242        n.next = stack;                                                                         // atomic assignment unnecessary
    4343        for () {                                                                                        // busy wait
    44                 if ( CASV( stack.atom, n.next.atom, ((Link){ &n, n.next.count + 1 }.atom) ) ) break; // attempt to update top node
     44                Link temp{ &n, n.next.count + 1 };
     45                if ( CASV( s.stack.atom, n.next.atom, temp.atom ) ) break; // attempt to update top node
    4546        }
    4647}
     
    5051        for () {                                                                                        // busy wait
    5152                if ( t.top == NULL ) return NULL;                               // empty stack ?
    52                 if ( CASV( stack.atom, t.atom, ((Link){ t.top->next.top, t.count }.atom) ) ) return t.top; // attempt to update top node
     53                Link temp{ t.top->next.top, t.count };
     54                if ( CASV( stack.atom, t.atom, temp.atom ) ) return t.top; // attempt to update top node
    5355        }
    5456}
     
    5759Stack stack;                                                                                    // global stack
    5860
    59 enum { Times =
    60         #if defined( __ARM_ARCH )                                                       // ARM CASV is very slow
    61         10_000
    62         #else
    63         1_000_000
    64         #endif // __arm_64__
    65 };
     61enum { Times = 2_000_000 };
    6662
    6763thread Worker {};
     
    8278
    8379        for ( i; N ) {                                                                          // push N values on stack
    84                 // storage must be 16-bytes aligned for cmpxchg16b
    85                 push( stack, *(Node *)memalign( 16, sizeof( Node ) ) );
     80                push( stack, *(Node *)new() );                                  // must be 16-byte aligned
    8681        }
    8782        {
Note: See TracChangeset for help on using the changeset viewer.