Revision 99ad121f xseg/peers/user/bench-xseg.c

b/xseg/peers/user/bench-xseg.c
54 54
 * a) If in-flight requests are less than given iodepth
55 55
 * b) If we have submitted all of the requests
56 56
 */
57
#define CAN_SEND_REQUEST(prefs)												  \
58
	((prefs->status->submitted - prefs->status->received < prefs->iodepth) && \
59
	(prefs->status->submitted < prefs->status->max))
57
#define CAN_SEND_REQUEST(__p)											\
58
	((__p->status->submitted - __p->status->received < __p->iodepth) && \
59
	(__p->status->submitted < __p->status->max) &&						\
60
	!isTerminate())
60 61

  
61
#define CAN_VERIFY(prefs)													  \
62
	((GET_FLAG(VERIFY, prefs->flags) != VERIFY_NO) && prefs->op == X_READ)
62
#define CAN_VERIFY(__p)													\
63
	((GET_FLAG(VERIFY, __p->flags) != VERIFY_NO) && __p->op == X_READ)
64

  
65
#define CAN_PRINT_PROGRESS(__p, __q)									\
66
	((GET_FLAG(PROGRESS, __p->flags) == PROGRESS_YES) &&				\
67
	(__p->status->received == __q))
63 68

  
64 69
void custom_peer_usage()
65 70
{
......
78 83
			"    --seed    | None    | Initialize LFSR and target names\n"
79 84
			"    --insanity| sane    | Adjust insanity level of benchmark:\n"
80 85
			"              |         |     [sane|eccentric|manic|paranoid]\n"
86
			"    --progress| yes     | Show progress of requests\n"
81 87
			"\n"
82 88
			"Additional information:\n"
83 89
			"  --------------------------------------------\n"
......
97 103
	char pattern[MAX_ARG_LEN + 1];
98 104
	char insanity[MAX_ARG_LEN + 1];
99 105
	char verify[MAX_ARG_LEN + 1];
106
	char progress[MAX_ARG_LEN + 1];
100 107
	struct xseg *xseg = peer->xseg;
101 108
	unsigned int xseg_page_size = 1 << xseg->config.page_shift;
102 109
	long iodepth = -1;
......
116 123
	insanity[0] = 0;
117 124
	verify[0] = 0;
118 125
	request_cap[0] = 0;
126
	progress[0] = 0;
119 127

  
120 128
#ifdef MT
121 129
	for (i = 0; i < nr_threads; i++) {
......
155 163
	READ_ARG_ULONG("--seed", seed);
156 164
	READ_ARG_STRING("--insanity", insanity, MAX_ARG_LEN);
157 165
	READ_ARG_STRING("--verify", verify, MAX_ARG_LEN);
166
	READ_ARG_STRING("--progress", progress, MAX_ARG_LEN);
158 167
	END_READ_ARGS();
159 168

  
160 169
	/*****************************\
......
348 357
		}
349 358
	}
350 359

  
351
	/****************************\
352
	 * Finalize initializations *
353
	\****************************/
360
	/*********************************\
361
	 * Miscellaneous initializations *
362
	\*********************************/
354 363

  
355 364
	/* The request cap must be enforced only after the LFSR is initialized */
356 365
	if (request_cap[0]) {
......
365 374
		prefs->status->max = rc;
366 375
	}
367 376

  
377
	/* Benchmarking progress printing is on by default */
378
	if (!progress[0])
379
		strcpy(progress, "yes");
380
	r = read_progress(progress);
381
	if (r < 0) {
382
		XSEGLOG2(&lc, E, "Invalid syntax: --progress %s\n", progress);
383
		goto arg_fail;
384
	}
385
	SET_FLAG(PROGRESS, prefs->flags, r);
386

  
368 387
	prefs->peer = peer;
369 388
	peer->peerd_loop = bench_peerd_loop;
370 389
	peer->priv = (void *) prefs;
......
516 535
	struct bench *prefs = peer->priv;
517 536
	xport portno_start = peer->portno_start;
518 537
	xport portno_end = peer->portno_end;
519
	uint64_t threshold=1000/(1 + portno_end - portno_start);
520 538
	pid_t pid = syscall(SYS_gettid);
539
	uint64_t threshold=1000/(1 + portno_end - portno_start);
540
	uint64_t cached_prog_quantum = 0;
541
	uint64_t prog_quantum = 0;
521 542
	int r;
522 543
	uint64_t loops;
523 544

  
545
	if (GET_FLAG(PROGRESS, prefs->flags) == PROGRESS_YES) {
546
		prog_quantum = calculate_prog_quantum(prefs);
547
		cached_prog_quantum = prog_quantum;
548
		print_stats(prefs);
549
	}
550

  
524 551
	XSEGLOG2(&lc, I, "%s has tid %u.\n",id, pid);
525 552
	xseg_init_local_signal(xseg, peer->portno_start);
526 553

  
527 554
	timer_start(prefs, prefs->total_tm);
528 555
send_request:
529
	while (!isTerminate()) {
530
#ifdef MT
531
		if (t->func) {
532
			XSEGLOG2(&lc, D, "%s executes function\n", id);
533
			xseg_cancel_wait(xseg, peer->portno_start);
534
			t->func(t->arg);
535
			t->func = NULL;
536
			t->arg = NULL;
537
			continue;
538
		}
539
#endif
556
	while (!(isTerminate() && all_peer_reqs_free(peer))) {
540 557
		while (CAN_SEND_REQUEST(prefs)) {
541 558
			xseg_cancel_wait(xseg, peer->portno_start);
542 559
			XSEGLOG2(&lc, D, "...because %lu < %lu && %lu < %lu\n",
......
553 570
			if (loops == 1)
554 571
				xseg_prepare_wait(xseg, peer->portno_start);
555 572

  
573
			if (UNLIKELY(CAN_PRINT_PROGRESS(prefs, prog_quantum))) {
574
				prog_quantum += cached_prog_quantum;
575
				print_progress(prefs);
576
			}
577

  
556 578
			if (check_ports(peer)) {
557 579
				//If an old request has just been acked, the most sensible
558 580
				//thing to do is to immediately send a new one
......
568 590
		//XSEGLOG2(&lc, I, "%s goes to sleep with %u requests pending\n",
569 591
		//		id, xq_count(q));
570 592
		XSEGLOG2(&lc, I, "%s goes to sleep\n", id);
571
#ifdef ST_THREADS
572
		if (ta){
573
			st_sleep(0);
574
			continue;
575
		}
576
#endif
577 593
		xseg_wait_signal(xseg, 10000000UL);
578 594
		xseg_cancel_wait(xseg, peer->portno_start);
579 595
		XSEGLOG2(&lc, I, "%s woke up\n", id);
......
592 608
	if (!prefs->total_tm->completed)
593 609
		timer_stop(prefs, prefs->total_tm, NULL);
594 610

  
595
	print_stats(prefs);
611
	if (GET_FLAG(PROGRESS, prefs->flags) == PROGRESS_YES)
612
		print_progress(prefs);
613
	else
614
		print_stats(prefs);
615

  
616
	print_remaining(prefs);
596 617
	print_res(prefs, prefs->total_tm, "Total Requests");
597 618
	return;
598 619
}

Also available in: Unified diff