Ignore:
Timestamp:
Nov 16, 2017, 12:26:09 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
0cf5b79, 0fe4e62, 5f91d650
Parents:
11094d9 (diff), c3d048c (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:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/csv-data.c

    r11094d9 rb7f8cb4  
    2828// coroutine context switch
    2929long long int measure_coroutine() {
    30         const unsigned int NoOfTimes = N;
     30        const unsigned int NoOfTimes = 50000000;
    3131        long long int StartTime, EndTime;
    3232
     
    4343// thread context switch
    4444long long int measure_thread() {
    45         const unsigned int NoOfTimes = N;
     45        const unsigned int NoOfTimes = 50000000;
    4646        long long int StartTime, EndTime;
    4747
     
    6161
    6262long long int measure_1_monitor_entry() {
    63         const unsigned int NoOfTimes = N;
     63        const unsigned int NoOfTimes = 5000000;
    6464        long long int StartTime, EndTime;
    6565        mon_t mon;
     
    7979
    8080long long int measure_2_monitor_entry() {
    81         const unsigned int NoOfTimes = N;
     81        const unsigned int NoOfTimes = 5000000;
    8282        long long int StartTime, EndTime;
    8383        mon_t mon1, mon2;
     
    9494//-----------------------------------------------------------------------------
    9595// single internal sched entry
     96const unsigned int NoOfTimes = 500000;
     97
    9698mon_t mon1;
    9799
     
    107109
    108110void side1A( mon_t & mutex a, long long int * out ) {
     111        const unsigned int NoOfTimes = 500000;
    109112        long long int StartTime, EndTime;
    110113
     
    112115        for( int i = 0;; i++ ) {
    113116                signal(cond1a);
    114                 if( i > N ) break;
     117                if( i > NoOfTimes ) break;
    115118                wait(cond1b);
    116119        }
    117120        EndTime = Time();
    118121
    119         *out = ( EndTime - StartTime ) / N;
     122        *out = ( EndTime - StartTime ) / NoOfTimes;
    120123}
    121124
     
    141144
    142145//-----------------------------------------------------------------------------
    143 // multi internal sched entry
     146// multi internal sched
    144147mon_t mon2;
    145148
     
    155158
    156159void side2A( mon_t & mutex a, mon_t & mutex b, long long int * out ) {
     160        const unsigned int NoOfTimes = 500000;
    157161        long long int StartTime, EndTime;
    158162
     
    160164        for( int i = 0;; i++ ) {
    161165                signal(cond2a);
    162                 if( i > N ) break;
     166                if( i > NoOfTimes ) break;
    163167                wait(cond2b);
    164168        }
    165169        EndTime = Time();
    166170
    167         *out = ( EndTime - StartTime ) / N;
     171        *out = ( EndTime - StartTime ) / NoOfTimes;
    168172}
    169173
     
    189193
    190194//-----------------------------------------------------------------------------
     195// single external sched
     196
     197volatile int go = 0;
     198
     199void __attribute__((noinline)) call( mon_t & mutex m1 ) {}
     200
     201long long int  __attribute__((noinline)) wait( mon_t & mutex m1 ) {
     202        go = 1;
     203        const unsigned int NoOfTimes = 5000000;
     204        long long int StartTime, EndTime;
     205
     206        StartTime = Time();
     207        for (size_t i = 0; i < NoOfTimes; i++) {
     208                waitfor(call, m1);
     209        }
     210
     211        EndTime = Time();
     212        go = 0;
     213        return ( EndTime - StartTime ) / NoOfTimes;
     214}
     215
     216thread thrd3 {};
     217void ^?{}( thrd3 & mutex this ) {}
     218void main( thrd3 & this ) {
     219        while(go == 0) { yield(); }
     220        while(go == 1) { call(mon1); }
     221
     222}
     223
     224long long int measure_1_sched_ext() {
     225        go = 0;
     226        thrd3 t;
     227        return wait(mon1);
     228}
     229
     230//-----------------------------------------------------------------------------
     231// multi external sched
     232
     233void __attribute__((noinline)) call( mon_t & mutex m1, mon_t & mutex m2 ) {}
     234
     235long long int  __attribute__((noinline)) wait( mon_t & mutex m1, mon_t & mutex m2 ) {
     236        go = 1;
     237        const unsigned int NoOfTimes = 5000000;
     238        long long int StartTime, EndTime;
     239
     240        StartTime = Time();
     241        for (size_t i = 0; i < NoOfTimes; i++) {
     242                waitfor(call, m1, m2);
     243        }
     244
     245        EndTime = Time();
     246        go = 0;
     247        return ( EndTime - StartTime ) / NoOfTimes;
     248}
     249
     250thread thrd4 {};
     251void ^?{}( thrd4 & mutex this ) {}
     252void main( thrd4 & this ) {
     253        while(go == 0) { yield(); }
     254        while(go == 1) { call(mon1, mon2); }
     255
     256}
     257
     258long long int measure_2_sched_ext() {
     259        go = 0;
     260        thrd3 t;
     261        return wait(mon1, mon2);
     262}
     263
     264//-----------------------------------------------------------------------------
    191265// main loop
    192266int main()
    193267{
    194         sout | time(NULL) | ',';
    195         sout | measure_coroutine() | ',';
    196         sout | measure_thread() | ',';
    197         sout | measure_1_monitor_entry() | ',';
    198         sout | measure_2_monitor_entry() | ',';
    199         sout | measure_1_sched_int() | ',';
    200         sout | measure_2_sched_int() | endl;
    201 }
     268        sout | "\tepoch:" | time(NULL) | ',' | endl;
     269        sout | "\tctxswitch: {" | endl;
     270        sout | "\t\tcoroutine: "| measure_coroutine() | ',' | endl;
     271        sout | "\t\tthread:" | measure_thread() | ',' | endl;
     272        sout | "\t}," | endl;
     273        sout | "\tmutex: ["     | measure_1_monitor_entry()     | ',' | measure_2_monitor_entry()       | "]," | endl;
     274        sout | "\tscheduling: ["| measure_1_sched_int()         | ',' | measure_2_sched_int()   | ','  |
     275                                          measure_1_sched_ext()         | ',' | measure_2_sched_ext()   | "]," | endl;
     276}
Note: See TracChangeset for help on using the changeset viewer.