Changeset 50f6afb for benchmark


Ignore:
Timestamp:
Apr 24, 2021, 11:32:49 AM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
Children:
424dfc4, 986cb99
Parents:
fec63b2 (diff), 8edbe40 (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

Location:
benchmark
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/http/protocol.cfa

    rfec63b2 r50f6afb  
    55        #include <fcntl.h>
    66}
     7
     8#define xstr(s) str(s)
     9#define str(s) #s
    710
    811#include <fstream.hfa>
     
    2124
    2225#define PLAINTEXT_1WRITE
     26#define PLAINTEXT_MEMCPY
    2327#define PLAINTEXT_NOCOPY
    2428
     
    8589#if defined(PLAINTEXT_NOCOPY)
    8690int answer_plaintext( int fd ) {
    87         return answer(fd, http_msgs[OK200_PlainText]->msg, http_msgs[OK200_PlainText]->len + 1); // +1 cause snprintf doesn't count nullterminator
     91        return answer(fd, http_msgs[OK200_PlainText]->msg, http_msgs[OK200_PlainText]->len); // +1 cause snprintf doesn't count nullterminator
     92}
     93#elif defined(PLAINTEXT_MEMCPY)
     94#define TEXTSIZE 15
     95int answer_plaintext( int fd ) {
     96        char text[] = "Hello, World!\n\n";
     97        char ts[] = xstr(TEXTSIZE) " \n\n";
     98        _Static_assert(sizeof(text) - 1 == TEXTSIZE);
     99        char buffer[512 + TEXTSIZE];
     100        char * it = buffer;
     101        memcpy(it, http_msgs[OK200]->msg, http_msgs[OK200]->len);
     102        it += http_msgs[OK200]->len;
     103        int len = http_msgs[OK200]->len;
     104        memcpy(it, ts, sizeof(ts) - 1);
     105        it += sizeof(ts) - 1;
     106        len += sizeof(ts) - 1;
     107        memcpy(it, text, TEXTSIZE);
     108        return answer(fd, buffer, len + TEXTSIZE);
    88109}
    89110#elif defined(PLAINTEXT_1WRITE)
    90111int answer_plaintext( int fd ) {
    91         char text[] = "Hello, World!\n";
     112        char text[] = "Hello, World!\n\n";
    92113        char buffer[512 + sizeof(text)];
    93114        char * it = buffer;
     
    103124#else
    104125int answer_plaintext( int fd ) {
    105         char text[] = "Hello, World!\n";
     126        char text[] = "Hello, World!\n\n";
    106127        int ret = answer_header(fd, sizeof(text));
    107128        if( ret < 0 ) return ret;
     
    194215const char * original_http_msgs[] = {
    195216        "HTTP/1.1 200 OK\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: ",
    196         "HTTP/1.1 200 OK\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 15\n\nHello, World!\n",
     217        "HTTP/1.1 200 OK\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 15\n\nHello, World!\n\n",
    197218        "HTTP/1.1 400 Bad Request\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n",
    198219        "HTTP/1.1 404 Not Found\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n",
  • benchmark/io/http/worker.cfa

    rfec63b2 r50f6afb  
    1818void ?{}( Worker & this ) {
    1919        size_t cli = rand() % options.clopts.cltr_cnt;
    20         ((thread&)this){ "Server Worker Thread", *options.clopts.instance[cli] };
     20        ((thread&)this){ "Server Worker Thread", *options.clopts.instance[cli], 512000 };
    2121        options.clopts.thrd_cnt[cli]++;
    2222        this.pipe[0] = -1;
  • benchmark/readyQ/cycle.cpp

    rfec63b2 r50f6afb  
    33#include <libfibre/fibre.h>
    44
    5 class __attribute__((aligned(128))) bench_sem {
    6         Fibre * volatile ptr = nullptr;
    7 public:
    8         inline bool wait() {
    9                 static Fibre * const ready  = reinterpret_cast<Fibre * const>(1ull);
    10                 for(;;) {
    11                         Fibre * expected = this->ptr;
    12                         if(expected == ready) {
    13                                 if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    14                                         return false;
    15                                 }
    16                         }
    17                         else {
    18                                 /* paranoid */ assert( expected == nullptr );
    19                                 if(__atomic_compare_exchange_n(&this->ptr, &expected, fibre_self(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    20                                         fibre_park();
    21                                         return true;
    22                                 }
    23                         }
    24 
    25                 }
    26         }
    27 
    28         inline bool post() {
    29                 static Fibre * const ready  = reinterpret_cast<Fibre * const>(1ull);
    30                 for(;;) {
    31                         Fibre * expected = this->ptr;
    32                         if(expected == ready) return false;
    33                         if(expected == nullptr) {
    34                                 if(__atomic_compare_exchange_n(&this->ptr, &expected, ready, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    35                                         return false;
    36                                 }
    37                         }
    38                         else {
    39                                 if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    40                                         fibre_unpark( expected );
    41                                         return true;
    42                                 }
    43                         }
    44                 }
    45         }
    46 };
    475struct Partner {
    486        unsigned long long count  = 0;
  • benchmark/readyQ/locality.cpp

    rfec63b2 r50f6afb  
    99        uint64_t dmigs = 0;
    1010        uint64_t gmigs = 0;
    11 };
    12 
    13 class __attribute__((aligned(128))) bench_sem {
    14         Fibre * volatile ptr = nullptr;
    15 public:
    16         inline bool wait() {
    17                 static Fibre * const ready  = reinterpret_cast<Fibre * const>(1ull);
    18                 for(;;) {
    19                         Fibre * expected = this->ptr;
    20                         if(expected == ready) {
    21                                 if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    22                                         return false;
    23                                 }
    24                         }
    25                         else {
    26                                 /* paranoid */ assert( expected == nullptr );
    27                                 if(__atomic_compare_exchange_n(&this->ptr, &expected, fibre_self(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    28                                         fibre_park();
    29                                         return true;
    30                                 }
    31                         }
    32 
    33                 }
    34         }
    35 
    36         inline bool post() {
    37                 static Fibre * const ready  = reinterpret_cast<Fibre * const>(1ull);
    38                 for(;;) {
    39                         Fibre * expected = this->ptr;
    40                         if(expected == ready) return false;
    41                         if(expected == nullptr) {
    42                                 if(__atomic_compare_exchange_n(&this->ptr, &expected, ready, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    43                                         return false;
    44                                 }
    45                         }
    46                         else {
    47                                 if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
    48                                         fibre_unpark( expected );
    49                                         return true;
    50                                 }
    51                         }
    52                 }
    53         }
    5411};
    5512
  • benchmark/readyQ/rq_bench.hfa

    rfec63b2 r50f6afb  
    44#include <stdio.h>
    55#include <stdlib.hfa>
     6#include <stats.hfa>
    67#include <thread.hfa>
    78#include <time.hfa>
     
    6364                (*p){ "Benchmark Processor", this.cl };
    6465        }
     66        #if !defined(__CFA_NO_STATISTICS__)
     67                print_stats_at_exit( this.cl, CFA_STATS_READY_Q );
     68        #endif
    6569}
    6670
  • benchmark/readyQ/rq_bench.hpp

    rfec63b2 r50f6afb  
    66#include <time.h>                                                                               // timespec
    77#include <sys/time.h>                                                                   // timeval
     8
     9typedef __uint128_t __lehmer64_state_t;
     10static inline uint64_t __lehmer64( __lehmer64_state_t & state ) {
     11        state *= 0xda942042e4dd58b5;
     12        return state >> 64;
     13}
    814
    915enum { TIMEGRAN = 1000000000LL };                                       // nanosecond granularity, except for timeval
     
    7581}
    7682
     83class Fibre;
     84int fibre_park();
     85int fibre_unpark( Fibre * );
     86Fibre * fibre_self();
     87
     88class __attribute__((aligned(128))) bench_sem {
     89        Fibre * volatile ptr = nullptr;
     90public:
     91        inline bool wait() {
     92                static Fibre * const ready  = reinterpret_cast<Fibre *>(1ull);
     93                for(;;) {
     94                        Fibre * expected = this->ptr;
     95                        if(expected == ready) {
     96                                if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
     97                                        return false;
     98                                }
     99                        }
     100                        else {
     101                                /* paranoid */ assert( expected == nullptr );
     102                                if(__atomic_compare_exchange_n(&this->ptr, &expected, fibre_self(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
     103                                        fibre_park();
     104                                        return true;
     105                                }
     106                        }
     107
     108                }
     109        }
     110
     111        inline bool post() {
     112                static Fibre * const ready  = reinterpret_cast<Fibre *>(1ull);
     113                for(;;) {
     114                        Fibre * expected = this->ptr;
     115                        if(expected == ready) return false;
     116                        if(expected == nullptr) {
     117                                if(__atomic_compare_exchange_n(&this->ptr, &expected, ready, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
     118                                        return false;
     119                                }
     120                        }
     121                        else {
     122                                if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
     123                                        fibre_unpark( expected );
     124                                        return true;
     125                                }
     126                        }
     127                }
     128        }
     129};
     130
    77131// ==========================================================================================
    78132#include <cstdlib>
     
    188242                this->help       = help;
    189243                this->variable   = reinterpret_cast<void*>(&variable);
    190                 this->parse_fun  = reinterpret_cast<bool (*)(const char *, void * )>(static_cast<bool (*)(const char *, T & )>(parse));
     244                #pragma GCC diagnostic push
     245                #pragma GCC diagnostic ignored "-Wcast-function-type"
     246                                this->parse_fun  = reinterpret_cast<bool (*)(const char *, void * )>(static_cast<bool (*)(const char *, T & )>(parse));
     247                #pragma GCC diagnostic pop
    191248        }
    192249
     
    197254                this->help       = help;
    198255                this->variable   = reinterpret_cast<void*>(&variable);
    199                 this->parse_fun  = reinterpret_cast<bool (*)(const char *, void * )>(parse);
     256                #pragma GCC diagnostic push
     257                #pragma GCC diagnostic ignored "-Wcast-function-type"
     258                        this->parse_fun  = reinterpret_cast<bool (*)(const char *, void * )>(parse);
     259                #pragma GCC diagnostic pop
    200260        }
    201261};
Note: See TracChangeset for help on using the changeset viewer.