Changes in / [dab09ad:cd02108]


Ignore:
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • benchmark/benchcltr.hfa

    rdab09ad rcd02108  
    11#pragma once
     2#include <assert.h>
     3#include <stdint.h>
    24
    3 #include <assert.h>
    4 #include <kernel.hfa>
    5 #include <thread.hfa>
    6 #include <stats.hfa>
     5#ifdef __cforall
     6        #include <kernel.hfa>
     7        #include <thread.hfa>
     8        #include <stats.hfa>
     9#else
     10#include <time.h>                                                                               // timespec
     11#include <sys/time.h>                                                                   // timeval
     12
     13enum { TIMEGRAN = 1000000000LL };                                       // nanosecond granularity, except for timeval
     14#endif
    715
    816#define BENCH_OPT_SHORT "d:p:t:SPV"
     
    1422        {"procstat",     no_argument      , 0, 'P'}, \
    1523        {"viewhalts",    no_argument      , 0, 'V'},
    16 
    17 #define BENCH_DECL \
    18         double duration = 5; \
    19         int nprocs = 1; \
    20         int nthreads = 1;
    2124
    2225#define BENCH_OPT_CASE \
     
    5255                break;
    5356
     57double duration = 5;
     58int nprocs = 1;
     59int nthreads = 1;
    5460bool silent = false;
     61bool continuous = false;
    5562bool procstats = false;
    5663bool viewhalts = false;
     64
     65#define BENCH_OPT_CFA \
     66        {'d', "duration",  "Duration of the experiments in seconds", duration }, \
     67        {'t', "nthreads",  "Number of threads to use", nthreads }, \
     68        {'p', "nprocs",    "Number of processors to use", nprocs }, \
     69        {'S', "nostats",   "Don't print statistics", silent, parse_settrue }, \
     70        {'C', "constats",  "Regularly print statistics", continuous, parse_settrue }, \
     71        {'P', "procstat",  "Print statistics for each processors", procstats, parse_settrue }, \
     72        {'V', "viewhalts", "Visualize halts, prints timestamp and Processor id for each halt.", viewhalts, parse_settrue },
     73
     74#ifdef __cforall
     75#include <parseargs.hfa>
     76
    5777struct cluster * the_benchmark_cluster = 0p;
    5878struct BenchCluster {
     
    6080};
    6181
    62 void ?{}( BenchCluster & this, int flags, int stats ) {
    63         (this.self){ "Benchmark Cluster", flags };
     82void ?{}( BenchCluster & this, int num_io, const io_context_params & io_params, int stats ) {
     83        (this.self){ "Benchmark Cluster", num_io, io_params };
    6484
    6585        assert( the_benchmark_cluster == 0p );
     
    105125        }
    106126}
     127#else
     128uint64_t getTimeNsec() {
     129        timespec curr;
     130        clock_gettime( CLOCK_REALTIME, &curr );
     131        return (int64_t)curr.tv_sec * TIMEGRAN + curr.tv_nsec;
     132}
     133
     134uint64_t to_miliseconds( uint64_t durtn ) { return durtn / (TIMEGRAN / 1000LL); }
     135double to_fseconds(uint64_t durtn ) { return durtn / (double)TIMEGRAN; }
     136uint64_t from_fseconds(double sec) { return sec * TIMEGRAN; }
     137
     138
     139void wait_duration(double duration, uint64_t & start, uint64_t & end, bool is_tty) {
     140        for(;;) {
     141                usleep(100000);
     142                end = getTimeNsec();
     143                uint64_t delta = end - start;
     144                /*if(is_tty)*/ {
     145                        printf(" %.1f\r", to_fseconds(delta));
     146                        fflush(stdout);
     147                }
     148                if( delta >= from_fseconds(duration) ) {
     149                        break;
     150                }
     151        }
     152}
     153#endif
     154
    107155
    108156void bench_usage( char * argv [] ) {
  • benchmark/io/readv.cfa

    rdab09ad rcd02108  
    4040int do_read(int fd, struct iovec * iov) {
    4141        // extern ssize_t cfa_preadv2(int, const struct iovec *, int, off_t, int, int = 0, Duration = -1`s, io_cancellation * = 0p, io_context * = 0p);
    42         int sflags = 0;
     42        int sflags = 0
     43        #if defined(CFA_HAVE_IOSQE_ASYNC)
     44                | CFA_IO_ASYNC
     45        #else
     46        #warning no CFA_IO_ASYNC support
     47        #endif
     48        ;
    4349        if(fixed_file) {
    4450                sflags |= CFA_IO_FIXED_FD1;
     
    130136                                bench_usage( argv );
    131137                                fprintf( stderr, "  -b, --buflen=SIZE        Number of bytes to read per request\n" );
    132                                 fprintf( stderr, "  -u, --userthread         If set, cluster uses user-thread to poll I/O\n" );
    133138                                fprintf( stderr, "  -s, --submitthread       If set, cluster uses polling thread to submit I/O\n" );
    134139                                fprintf( stderr, "  -e, --eagersubmit        If set, cluster submits I/O eagerly but still aggregates submits\n" );
     
    139144                }
    140145        }
     146
     147        if(params.poll_submit  ) fixed_file = true;
     148        if(params.poll_complete) file_flags |= O_DIRECT;
    141149
    142150        int lfd = open(__FILE__, file_flags);
  • benchmark/readyQ/yield.cfa

    rdab09ad rcd02108  
    4343
    4444int main(int argc, char * argv[]) {
    45         BENCH_DECL
     45        unsigned num_io = 1;
     46        io_context_params params;
    4647
    47         for(;;) {
    48                 static struct option options[] = {
    49                         BENCH_OPT_LONG
    50                         {0, 0, 0, 0}
    51                 };
     48        cfa_option opt[] = {
     49                BENCH_OPT_CFA
     50        };
     51        int opt_cnt = sizeof(opt) / sizeof(cfa_option);
    5252
    53                 int idx = 0;
    54                 int opt = getopt_long(argc, argv, BENCH_OPT_SHORT, options, &idx);
    55 
    56                 const char * arg = optarg ? optarg : "";
    57                 char * end;
    58                 switch(opt) {
    59                         case -1:
    60                                 goto run;
    61                         BENCH_OPT_CASE
    62                         default: /* ? */
    63                                 fprintf( stderr, "Unkown option '%c'\n", opt);
    64                         usage:
    65                                 bench_usage( argv );
    66                                 exit(1);
    67                 }
    68         }
    69         run:
     53        char **left;
     54        parse_args( argc, argv, opt, opt_cnt, "[OPTIONS]...\ncforall yield benchmark", left );
    7055
    7156        {
     
    7358
    7459                Time start, end;
    75                 BenchCluster cl = { 0, CFA_STATS_READY_Q };
     60                BenchCluster cl = { num_io, params, CFA_STATS_READY_Q };
    7661                {
    7762                        BenchProc procs[nprocs];
  • libcfa/src/concurrency/io.cfa

    rdab09ad rcd02108  
    359359
    360360                        // We got the lock
     361                        // Collect the submissions
    361362                        unsigned to_submit = __collect_submitions( ring );
     363
     364                        // Release the lock now so syscalls can overlap
     365                        unlock(ring.submit_q.lock);
     366
     367                        // Actually submit
    362368                        int ret = __io_uring_enter( ring, to_submit, false );
    363                         if( ret < 0 ) {
    364                                 unlock(ring.submit_q.lock);
    365                                 return;
    366                         }
    367 
    368                         /* paranoid */ verify( ret > 0 || to_submit == 0 || (ring.ring_flags & IORING_SETUP_SQPOLL) );
     369                        if( ret < 0 ) return;
    369370
    370371                        // Release the consumed SQEs
     
    372373
    373374                        // update statistics
    374                         __STATS__( true,
     375                        __STATS__( false,
    375376                                io.submit_q.submit_avg.rdy += to_submit;
    376377                                io.submit_q.submit_avg.csm += ret;
    377378                                io.submit_q.submit_avg.cnt += 1;
    378379                        )
    379 
    380                         unlock(ring.submit_q.lock);
    381380                }
    382381                else {
  • libcfa/src/parseargs.cfa

    rdab09ad rcd02108  
    1919        extern          long long int strtoll (const char* str, char** endptr, int base);
    2020        extern unsigned long long int strtoull(const char* str, char** endptr, int base);
     21        extern                 double strtod  (const char* str, char** endptr);
    2122}
    2223
     
    170171}
    171172
     173bool parse(const char * arg, int & value) {
     174        char * end;
     175        int r = strtoll(arg, &end, 10);
     176        if(*end != '\0') return false;
     177
     178        value = r;
     179        return true;
     180}
     181
    172182bool parse(const char * arg, unsigned & value) {
    173183        char * end;
     
    200210}
    201211
    202 bool parse(const char * arg, int & value) {
    203         char * end;
    204         int r = strtoll(arg, &end, 10);
    205         if(*end != '\0') return false;
    206 
    207         value = r;
    208         return true;
    209 }
     212bool parse(const char * arg, double & value) {
     213        char * end;
     214        double r = strtod(arg, &end);
     215        if(*end != '\0') return false;
     216
     217        value = r;
     218        return true;
     219}
  • libcfa/src/parseargs.hfa

    rdab09ad rcd02108  
    3939
    4040bool parse(const char *, const char * & );
     41bool parse(const char *, int & );
    4142bool parse(const char *, unsigned & );
    4243bool parse(const char *, unsigned long & );
    4344bool parse(const char *, unsigned long long & );
    44 bool parse(const char *, int & );
     45bool parse(const char *, double & );
Note: See TracChangeset for help on using the changeset viewer.