Changeset d9265a2
- Timestamp:
- Aug 12, 2020, 4:22:49 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 2b5be17
- Parents:
- 419c434
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/readv.cfa
r419c434 rd9265a2 69 69 70 70 int main(int argc, char * argv[]) { 71 BENCH_DECL72 71 unsigned num_io = 1; 73 io_context_params params;74 72 int file_flags = 0; 75 73 unsigned sublen = 16; 76 74 77 arg_loop: 78 for(;;) { 79 static struct option options[] = { 80 BENCH_OPT_LONG 81 {"bufsize", required_argument, 0, 'b'}, 82 {"submitthread", no_argument , 0, 's'}, 83 {"eagersubmit", no_argument , 0, 'e'}, 84 {"kpollsubmit", no_argument , 0, 'k'}, 85 {"kpollcomplete", no_argument , 0, 'i'}, 86 {"fixed-files", no_argument , 0, 'f'}, 87 {"open-direct", no_argument , 0, 'o'}, 88 {"submitlength", required_argument, 0, 'l'}, 89 {0, 0, 0, 0} 90 }; 75 bool subthrd = false; 76 bool subeagr = false; 77 bool odirect = false; 78 bool kpollsb = false; 79 bool kpollcp = false; 91 80 92 int idx = 0; 93 int opt = getopt_long(argc, argv, BENCH_OPT_SHORT "b:sekil:", options, &idx); 81 cfa_option opt[] = { 82 BENCH_OPT_CFA 83 {'b', "bufsize", "Number of bytes to read per request", buflen}, 84 {'s', "submitthread", "If set, cluster uses polling thread to submit I/O", subthrd, parse_settrue}, 85 {'e', "eagersubmit", "If set, cluster submits I/O eagerly but still aggregates submits", subeagr, parse_settrue}, 86 {'f', "fixed-files", "Pre-register files with the io_contexts", fixed_file, parse_settrue}, 87 {'o', "open-direct", "Open files with O_DIRECT flag, bypassing the file cache", odirect, parse_settrue}, 88 {'k', "kpollsubmit", "If set, cluster uses an in kernel thread to poll submission, implies -f, requires elevated permissions", kpollsb, parse_settrue}, 89 {'i', "kpollcomplete", "If set, cluster polls fds for completions instead of relying on interrupts to get notifications, implies -o", kpollcp, parse_settrue}, 90 {'l', "submitlength", "Size of the buffer that stores ready submissions", sublen}, 91 {'n', "numcontexts", "Number of io_contexts to the cluster", num_io}, 92 }; 93 int opt_cnt = sizeof(opt) / sizeof(cfa_option); 94 94 95 const char * arg = optarg ? optarg : ""; 96 char * end; 97 switch(opt) { 98 // Exit Case 99 case -1: 100 break arg_loop; 101 BENCH_OPT_CASE 102 case 'b': 103 buflen = strtoul(arg, &end, 10); 104 if(*end != '\0' && buflen < 10) { 105 fprintf(stderr, "Buffer size must be at least 10, was %s\n", arg); 106 goto usage; 107 } 108 break; 109 case 's': 110 params.poller_submits = true; 111 break; 112 case 'e': 113 params.eager_submits = true; 114 break; 115 case 'k': 116 params.poll_submit = true; 117 case 'f': 118 fixed_file = true; 119 break; 120 case 'i': 121 params.poll_complete = true; 122 case 'o': 123 file_flags |= O_DIRECT; 124 break; 125 case 'l': 126 sublen = strtoul(arg, &end, 10); 127 if(*end != '\0' && sublen < 16) { 128 fprintf(stderr, "Submit length must be at least 16, was %s\n", arg); 129 goto usage; 130 } 131 // flags |= (sublen << CFA_CLUSTER_IO_BUFFLEN_OFFSET); 132 break; 133 default: /* ? */ 134 fprintf(stderr, "%d\n", opt); 135 usage: 136 bench_usage( argv ); 137 fprintf( stderr, " -b, --buflen=SIZE Number of bytes to read per request\n" ); 138 fprintf( stderr, " -s, --submitthread If set, cluster uses polling thread to submit I/O\n" ); 139 fprintf( stderr, " -e, --eagersubmit If set, cluster submits I/O eagerly but still aggregates submits\n" ); 140 fprintf( stderr, " -k, --kpollsubmit If set, cluster uses IORING_SETUP_SQPOLL\n" ); 141 fprintf( stderr, " -i, --kpollcomplete If set, cluster uses IORING_SETUP_IOPOLL\n" ); 142 fprintf( stderr, " -l, --submitlength=LEN Max number of submitions that can be submitted together\n" ); 143 exit(EXIT_FAILURE); 95 char **left; 96 parse_args( opt, opt_cnt, "[OPTIONS]...\ncforall yield benchmark", left ); 97 98 if(kpollcp || odirect) { 99 if( (buflen % 512) != 0 ) { 100 fprintf(stderr, "Buffer length must be a multiple of 512 when using O_DIRECT, was %lu\n\n", buflen); 101 print_args_usage(opt, opt_cnt, "[OPTIONS]...\ncforall yield benchmark", true); 144 102 } 145 103 } 146 104 105 io_context_params params; 106 107 if( subthrd ) params.poller_submits = true; 108 if( subeagr ) params.eager_submits = true; 109 if( kpollsb ) params.poll_submit = true; 110 if( kpollcp ) params.poll_complete = true; 111 147 112 if(params.poll_submit ) fixed_file = true; 148 if(params.poll_complete) file_flags |= O_DIRECT; 113 if(params.poll_complete) odirect = true; 114 115 if(odirect) file_flags |= O_DIRECT; 149 116 150 117 int lfd = open(__FILE__, file_flags);
Note: See TracChangeset
for help on using the changeset viewer.