Changeset 762fbc1 for benchmark/io


Ignore:
Timestamp:
Aug 15, 2020, 12:20:44 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
Children:
36de20d
Parents:
7f51b9d (diff), 5715d43 (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 into master

Location:
benchmark/io
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/readv.cfa

    r7f51b9d r762fbc1  
    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;
     
    6369
    6470int main(int argc, char * argv[]) {
    65         BENCH_DECL
     71        int file_flags = 0;
    6672        unsigned num_io = 1;
    67         io_context_params params;
    68         int file_flags = 0;
    6973        unsigned sublen = 16;
     74        unsigned nentries = 0;
    7075
    71         arg_loop:
    72         for(;;) {
    73                 static struct option options[] = {
    74                         BENCH_OPT_LONG
    75                         {"bufsize",       required_argument, 0, 'b'},
    76                         {"submitthread",  no_argument      , 0, 's'},
    77                         {"eagersubmit",   no_argument      , 0, 'e'},
    78                         {"kpollsubmit",   no_argument      , 0, 'k'},
    79                         {"kpollcomplete", no_argument      , 0, 'i'},
    80                         {"fixed-files",   no_argument      , 0, 'f'},
    81                         {"open-direct",   no_argument      , 0, 'o'},
    82                         {"submitlength",  required_argument, 0, 'l'},
    83                         {0, 0, 0, 0}
    84                 };
     76        bool subthrd = false;
     77        bool subeagr = false;
     78        bool odirect = false;
     79        bool kpollsb = false;
     80        bool kpollcp = false;
    8581
    86                 int idx = 0;
    87                 int opt = getopt_long(argc, argv, BENCH_OPT_SHORT "b:sekil:", options, &idx);
     82        cfa_option opt[] = {
     83                BENCH_OPT_CFA
     84                {'b', "bufsize",       "Number of bytes to read per request", buflen},
     85                {'s', "submitthread",  "If set, cluster uses polling thread to submit I/O", subthrd, parse_settrue},
     86                {'e', "eagersubmit",   "If set, cluster submits I/O eagerly but still aggregates submits", subeagr, parse_settrue},
     87                {'f', "fixed-files",   "Pre-register files with the io_contexts", fixed_file, parse_settrue},
     88                {'o', "open-direct",   "Open files with O_DIRECT flag, bypassing the file cache", odirect, parse_settrue},
     89                {'k', "kpollsubmit",   "If set, cluster uses an in kernel thread to poll submission, implies -f, requires elevated permissions", kpollsb, parse_settrue},
     90                {'i', "kpollcomplete", "If set, cluster polls fds for completions instead of relying on interrupts to get notifications, implies -o", kpollcp, parse_settrue},
     91                {'l', "submitlength",  "Size of the buffer that stores ready submissions", sublen},
     92                {'r', "numentries",    "Number of entries each of the io_context have", nentries},
     93                {'n', "numcontexts",   "Number of io_contexts to the cluster", num_io},
     94        };
     95        int opt_cnt = sizeof(opt) / sizeof(cfa_option);
    8896
    89                 const char * arg = optarg ? optarg : "";
    90                 char * end;
    91                 switch(opt) {
    92                         // Exit Case
    93                         case -1:
    94                                 break arg_loop;
    95                         BENCH_OPT_CASE
    96                         case 'b':
    97                                 buflen = strtoul(arg, &end, 10);
    98                                 if(*end != '\0' && buflen < 10) {
    99                                         fprintf(stderr, "Buffer size must be at least 10, was %s\n", arg);
    100                                         goto usage;
    101                                 }
    102                                 break;
    103                         case 's':
    104                                 params.poller_submits = true;
    105                                 break;
    106                         case 'e':
    107                                 params.eager_submits = true;
    108                                 break;
    109                         case 'k':
    110                                 params.poll_submit = true;
    111                         case 'f':
    112                                 fixed_file = true;
    113                                 break;
    114                         case 'i':
    115                                 params.poll_complete = true;
    116                         case 'o':
    117                                 file_flags |= O_DIRECT;
    118                                 break;
    119                         case 'l':
    120                                 sublen = strtoul(arg, &end, 10);
    121                                 if(*end != '\0' && sublen < 16) {
    122                                         fprintf(stderr, "Submit length must be at least 16, was %s\n", arg);
    123                                         goto usage;
    124                                 }
    125                                 // flags |= (sublen << CFA_CLUSTER_IO_BUFFLEN_OFFSET);
    126                                 break;
    127                         default: /* ? */
    128                                 fprintf(stderr, "%d\n", opt);
    129                         usage:
    130                                 bench_usage( argv );
    131                                 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" );
    133                                 fprintf( stderr, "  -s, --submitthread       If set, cluster uses polling thread to submit I/O\n" );
    134                                 fprintf( stderr, "  -e, --eagersubmit        If set, cluster submits I/O eagerly but still aggregates submits\n" );
    135                                 fprintf( stderr, "  -k, --kpollsubmit        If set, cluster uses IORING_SETUP_SQPOLL\n" );
    136                                 fprintf( stderr, "  -i, --kpollcomplete      If set, cluster uses IORING_SETUP_IOPOLL\n" );
    137                                 fprintf( stderr, "  -l, --submitlength=LEN   Max number of submitions that can be submitted together\n" );
    138                                 exit(EXIT_FAILURE);
     97        char **left;
     98        parse_args( opt, opt_cnt, "[OPTIONS]...\ncforall yield benchmark", left );
     99
     100        if(kpollcp || odirect) {
     101                if( (buflen % 512) != 0 ) {
     102                        fprintf(stderr, "Buffer length must be a multiple of 512 when using O_DIRECT, was %lu\n\n", buflen);
     103                        print_args_usage(opt, opt_cnt, "[OPTIONS]...\ncforall yield benchmark", true);
    139104                }
    140105        }
     106
     107        io_context_params params;
     108
     109        if( subthrd ) params.poller_submits = true;
     110        if( subeagr ) params.eager_submits  = true;
     111        if( kpollsb ) params.poll_submit    = true;
     112        if( kpollcp ) params.poll_complete  = true;
     113
     114        if(params.poll_submit  ) fixed_file = true;
     115        if(params.poll_complete) odirect    = true;
     116
     117        params.num_ready = sublen;
     118        params.num_entries = nentries;
     119
     120        if(odirect) file_flags |= O_DIRECT;
    141121
    142122        int lfd = open(__FILE__, file_flags);
Note: See TracChangeset for help on using the changeset viewer.