Ignore:
Timestamp:
May 27, 2022, 11:22:23 PM (6 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master, pthread-emulation, qualifiedEnum
Children:
0a004b7
Parents:
c3b9d639
Message:

make expected output for nested functions deterministic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/nested_function.cfa

    rc3b9d639 r5416b44  
    1 //
    2 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    3 //
    4 // The contents of this file are covered under the licence agreement in the
    5 // file "LICENCE" distributed with Cforall.
    6 //
    7 // nested_function.cfa -- Test nested functions run on user-thread stacks.
    8 //
    9 // Author           : Peter A. Buhr
    10 // Created On       : Mon May 23 22:21:30 2022
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 23 23:11:25 2022
    13 // Update Count     : 4
    14 //
    15 
    161#include <thread.hfa>
    172#include <fstream.hfa>
    183#include <stdlib.hfa>
    194
    20 thread T {};
     5enum { VALUES = 10_000 };
     6int values[VALUES], total = 0;
    217
    22 enum { VALUES = 10_000 };
    23 int values[VALUES];
     8thread T { int id; };
    249
    2510void main( T & ) {
     11        int sum = 0;
    2612        void f() {
    2713                int i = 0;
     
    3622                        else h();
    3723                        i += 1;
    38                         sout | "j" | j | bsearchl( j, values, VALUES ); // has internal nested compare routine
     24                        sum += bsearchl( j, values, VALUES );           // has internal nested compare routine
    3925                } // h
    4026                h();
    41                 sout | "i" | i | bsearchl( i, values, VALUES ); // has internal nested compare routine
    4227        } // f
    4328        f();
     29        __atomic_fetch_add( &total, sum, __ATOMIC_SEQ_CST );
    4430}
    4531int main() {
    4632        set_seed( 1003 );
    4733        for ( i; VALUES ) values[i] = i;
    48         T t[5];
     34        {
     35                T t[5];
     36        }
     37        sout | "total" | total;
    4938}
Note: See TracChangeset for help on using the changeset viewer.