Changeset b6f2b213
- Timestamp:
- May 5, 2020, 11:35:45 AM (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:
- 4e74466
- Parents:
- f90d10f
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/readv.cfa
rf90d10f rb6f2b213 59 59 unsigned long int nthreads = 2; 60 60 unsigned long int nprocs = 1; 61 int flags = 0; 61 62 62 63 printf("Setting local\n"); … … 66 67 for(;;) { 67 68 static struct option options[] = { 68 {"duration", required_argument, 0, 'd'}, 69 {"nthreads", required_argument, 0, 't'}, 70 {"nprocs", required_argument, 0, 'p'}, 71 {"bufsize", required_argument, 0, 'b'}, 69 {"duration", required_argument, 0, 'd'}, 70 {"nthreads", required_argument, 0, 't'}, 71 {"nprocs", required_argument, 0, 'p'}, 72 {"bufsize", required_argument, 0, 'b'}, 73 {"userthread", no_argument , 0, 'u'}, 72 74 {0, 0, 0, 0} 73 75 }; 74 76 75 77 int idx = 0; 76 int opt = getopt_long(argc, argv, "d:t:p:b: ", options, &idx);78 int opt = getopt_long(argc, argv, "d:t:p:b:u", options, &idx); 77 79 78 80 const char * arg = optarg ? optarg : ""; … … 111 113 } 112 114 break; 115 case 'u': 116 flags |= CFA_CLUSTER_IO_POLLER_USER_THREAD; 117 break; 113 118 // Other cases 114 119 default: /* ? */ … … 135 140 { 136 141 Time start, end; 137 cluster cl = { "IO Cluster" };142 cluster cl = { "IO Cluster", flags }; 138 143 the_cluster = &cl; 139 144 #if !defined(__CFA_NO_STATISTICS__) -
libcfa/src/concurrency/io.cfa
rf90d10f rb6f2b213 20 20 21 21 #if !defined(HAVE_LINUX_IO_URING_H) 22 void __kernel_io_startup( cluster &, bool ) {22 void __kernel_io_startup( cluster &, int, bool ) { 23 23 // Nothing to do without io_uring 24 24 } … … 182 182 struct __submition_data submit_q; 183 183 struct __completion_data completion_q; 184 uint32_t flags; 184 uint32_t ring_flags; 185 int cltr_flags; 185 186 int fd; 186 187 semaphore submit; … … 199 200 // I/O Startup / Shutdown logic 200 201 //============================================================================================= 201 void __kernel_io_startup( cluster & this, bool main_cluster ) {202 void __kernel_io_startup( cluster & this, int io_flags, bool main_cluster ) { 202 203 this.io = malloc(); 203 204 … … 294 295 295 296 // Update the global ring info 296 this.io->flags = params.flags; 297 this.io->fd = fd; 298 this.io->done = false; 297 this.io->ring_flags = params.flags; 298 this.io->cltr_flags = io_flags; 299 this.io->fd = fd; 300 this.io->done = false; 299 301 (this.io->submit){ min(*sq.num, *cq.num) }; 300 302 … … 314 316 315 317 void __kernel_io_finish_start( cluster & this ) { 316 __cfadbg_print_safe(io_core, "Kernel I/O : Creating fast poller for cluter %p\n", &this); 317 (this.io->poller.fast){ this }; 318 __thrd_start( this.io->poller.fast, main ); 318 if( this.io->cltr_flags & CFA_CLUSTER_IO_POLLER_USER_THREAD ) { 319 __cfadbg_print_safe(io_core, "Kernel I/O : Creating fast poller for cluter %p\n", &this); 320 (this.io->poller.fast){ this }; 321 __thrd_start( this.io->poller.fast, main ); 322 } 319 323 320 324 // Create the poller thread … … 339 343 __cfadbg_print_safe(io_core, "Kernel I/O : Slow poller stopped for cluster\n", &this); 340 344 341 #if defined(__CFA_IO_POLLING_USER__)345 if( this.io->cltr_flags & CFA_CLUSTER_IO_POLLER_USER_THREAD ) { 342 346 verify( this.io->poller.fast.waiting ); 343 347 verify( this.io->poller.fast.thrd.state == Blocked ); … … 351 355 352 356 __cfadbg_print_safe(io_core, "Kernel I/O : Fast poller stopped for cluster\n", &this); 353 #endif357 } 354 358 } 355 359 … … 473 477 __cfadbg_print_safe(io_core, "Kernel I/O : Slow poller for ring %p ready\n", &ring); 474 478 475 while(!__atomic_load_n(&ring.done, __ATOMIC_SEQ_CST)) { 476 #if defined(__CFA_IO_POLLING_USER__) 477 479 if( ring.cltr_flags & CFA_CLUSTER_IO_POLLER_USER_THREAD ) { 480 while(!__atomic_load_n(&ring.done, __ATOMIC_SEQ_CST)) { 478 481 // In the user-thread approach drain and if anything was drained, 479 482 // batton pass to the user-thread … … 491 494 wait( ring.poller.sem ); 492 495 } 493 494 #else 495 496 } 497 } 498 else { 499 while(!__atomic_load_n(&ring.done, __ATOMIC_SEQ_CST)) { 496 500 //In the naive approach, just poll the io completion queue directly 497 501 int count = __drain_io( ring, &mask, 1, true ); … … 502 506 ring.completion_q.stats.completed_avg.slow_cnt += 1; 503 507 #endif 504 505 #endif 508 } 506 509 } 507 510 … … 512 515 513 516 void main( __io_poller_fast & this ) { 517 verify( this.ring->cltr_flags & CFA_CLUSTER_IO_POLLER_USER_THREAD ); 518 514 519 // Start parked 515 520 park( __cfaabi_dbg_ctx ); -
libcfa/src/concurrency/kernel.cfa
rf90d10f rb6f2b213 254 254 } 255 255 256 void ?{}(cluster & this, const char name[], Duration preemption_rate ) with( this ) {256 void ?{}(cluster & this, const char name[], Duration preemption_rate, int io_flags) with( this ) { 257 257 this.name = name; 258 258 this.preemption_rate = preemption_rate; … … 268 268 threads{ __get }; 269 269 270 __kernel_io_startup( this, &this == mainCluster );270 __kernel_io_startup( this, io_flags, &this == mainCluster ); 271 271 272 272 doregister(this); -
libcfa/src/concurrency/kernel.hfa
rf90d10f rb6f2b213 116 116 struct __io_data; 117 117 118 #define CFA_CLUSTER_IO_POLLER_USER_THREAD 1 << 0 119 // #define CFA_CLUSTER_IO_POLLER_KERNEL_SIDE 1 << 1 120 118 121 //----------------------------------------------------------------------------- 119 122 // Cluster … … 156 159 extern Duration default_preemption(); 157 160 158 void ?{} (cluster & this, const char name[], Duration preemption_rate );161 void ?{} (cluster & this, const char name[], Duration preemption_rate, int flags); 159 162 void ^?{}(cluster & this); 160 163 161 static inline void ?{} (cluster & this) { this{"Anonymous Cluster", default_preemption()}; } 162 static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; } 163 static inline void ?{} (cluster & this, const char name[]) { this{name, default_preemption()}; } 164 static inline void ?{} (cluster & this) { this{"Anonymous Cluster", default_preemption(), 0}; } 165 static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate, 0}; } 166 static inline void ?{} (cluster & this, const char name[]) { this{name, default_preemption(), 0}; } 167 static inline void ?{} (cluster & this, int flags) { this{"Anonymous Cluster", default_preemption(), flags}; } 168 static inline void ?{} (cluster & this, Duration preemption_rate, int flags) { this{"Anonymous Cluster", preemption_rate, flags}; } 169 static inline void ?{} (cluster & this, const char name[], int flags) { this{name, default_preemption(), flags}; } 164 170 165 171 static inline [cluster *&, cluster *& ] __get( cluster & this ) __attribute__((const)) { return this.node.[next, prev]; } -
libcfa/src/concurrency/kernel_private.hfa
rf90d10f rb6f2b213 77 77 //----------------------------------------------------------------------------- 78 78 // I/O 79 void __kernel_io_startup ( cluster &, bool );79 void __kernel_io_startup ( cluster &, int, bool ); 80 80 void __kernel_io_finish_start( cluster & ); 81 81 void __kernel_io_prepare_stop( cluster & );
Note: See TracChangeset
for help on using the changeset viewer.