Changeset 920dca3 for benchmark/io
- Timestamp:
- Jul 30, 2020, 3:01:04 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:
- 3ac8b9f
- Parents:
- f00b26d4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/readv.cfa
rf00b26d4 r920dca3 12 12 } 13 13 14 #include <errno.h> 14 15 #include <unistd.h> 15 16 16 17 #include <clock.hfa> 18 #include <iofwd.hfa> 17 19 #include <kernel.hfa> 18 20 #include <thread.hfa> … … 23 25 24 26 extern bool traceHeapOn(); 25 extern ssize_t cfa_preadv2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags);26 extern ssize_t cfa_preadv2_fixed(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags);27 extern void register_fixed_files( cluster &, int *, unsigned count );28 27 29 28 int fd; … … 31 30 volatile size_t count = 0; 32 31 33 unsigned long int buflen = 5 0;32 unsigned long int buflen = 512; 34 33 bool fixed_file = false; 35 34 … … 40 39 41 40 int do_read(int fd, struct iovec * iov) { 41 // 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 43 if(fixed_file) { 43 return cfa_preadv2_fixed(fd, iov, 1, 0, 0);44 sflags |= CFA_IO_FIXED_FD1; 44 45 } 45 else { 46 return cfa_preadv2(fd, iov, 1, 0, 0); 47 } 46 return cfa_preadv2(fd, iov, 1, 0, 0, sflags, -1`s, 0p, 0p); 48 47 } 49 48 … … 52 51 /* paranoid */ assert( true == __atomic_load_n(&run, __ATOMIC_RELAXED) ); 53 52 54 char data[buflen];53 __attribute__((aligned(512))) char data[buflen]; 55 54 struct iovec iov = { data, buflen }; 56 55 57 56 while(__atomic_load_n(&run, __ATOMIC_RELAXED)) { 58 57 int r = do_read(fd, &iov); 59 if(r < 0) abort("%s\n", strerror( -r));58 if(r < 0) abort("%s\n", strerror(errno)); 60 59 61 60 __atomic_fetch_add( &count, 1, __ATOMIC_SEQ_CST ); … … 65 64 int main(int argc, char * argv[]) { 66 65 BENCH_DECL 67 unsigned flags = 0; 66 unsigned num_io = 1; 67 io_context_params params; 68 68 int file_flags = 0; 69 69 unsigned sublen = 16; … … 74 74 BENCH_OPT_LONG 75 75 {"bufsize", required_argument, 0, 'b'}, 76 {"userthread", no_argument , 0, 'u'},77 76 {"submitthread", no_argument , 0, 's'}, 78 77 {"eagersubmit", no_argument , 0, 'e'}, 79 78 {"kpollsubmit", no_argument , 0, 'k'}, 80 79 {"kpollcomplete", no_argument , 0, 'i'}, 80 {"fixed-files", no_argument , 0, 'f'}, 81 {"open-direct", no_argument , 0, 'o'}, 81 82 {"submitlength", required_argument, 0, 'l'}, 82 83 {0, 0, 0, 0} … … 84 85 85 86 int idx = 0; 86 int opt = getopt_long(argc, argv, BENCH_OPT_SHORT "b: usekil:", options, &idx);87 int opt = getopt_long(argc, argv, BENCH_OPT_SHORT "b:sekil:", options, &idx); 87 88 88 89 const char * arg = optarg ? optarg : ""; … … 100 101 } 101 102 break; 102 case 'u':103 flags |= CFA_CLUSTER_IO_POLLER_USER_THREAD;104 break;105 103 case 's': 106 flags |= CFA_CLUSTER_IO_POLLER_THREAD_SUBMITS;104 params.poller_submits = true; 107 105 break; 108 106 case 'e': 109 flags |= CFA_CLUSTER_IO_EAGER_SUBMITS;107 params.eager_submits = true; 110 108 break; 111 109 case 'k': 112 flags |= CFA_CLUSTER_IO_KERNEL_POLL_SUBMITS; 110 params.poll_submit = true; 111 case 'f': 113 112 fixed_file = true; 114 113 break; 115 114 case 'i': 116 flags |= CFA_CLUSTER_IO_KERNEL_POLL_COMPLETES; 115 params.poll_complete = true; 116 case 'o': 117 117 file_flags |= O_DIRECT; 118 118 break; … … 123 123 goto usage; 124 124 } 125 flags |= (sublen << CFA_CLUSTER_IO_BUFFLEN_OFFSET);125 // flags |= (sublen << CFA_CLUSTER_IO_BUFFLEN_OFFSET); 126 126 break; 127 127 default: /* ? */ … … 150 150 { 151 151 Time start, end; 152 BenchCluster cl = { flags, CFA_STATS_READY_Q | CFA_STATS_IO };152 BenchCluster cl = { num_io, params, CFA_STATS_READY_Q | CFA_STATS_IO }; 153 153 154 154 if(fixed_file) { … … 179 179 printf("\nDone\n"); 180 180 } 181 printf("Readers closed\n"); 181 182 } 182 183 printf("Took %'ld ms\n", (end - start)`ms);
Note: See TracChangeset
for help on using the changeset viewer.