Revision 61df4193

b/xseg/peers/user/bench-lfsr.c
245 245
		lfsr->state = seed;
246 246
	}
247 247

  
248
	lfsr->cached_bit = 1UL << (i-1);
248 249
	lfsr->length = i;
249 250
	lfsr->xnormask = lfsr_create_xnormask(taps[i]);
250 251

  
......
253 254

  
254 255
#ifdef STAND_ALONE
255 256
/*
256
 * Sanity-check every LFSR for wrong tap positions.
257
 * Sanity-check every LFSR for mistakes.
257 258
 */
258 259
static int lfsr_check()
259 260
{
......
266 267
	for (length = 3; length < 64; length++) {
267 268
		if (lfsr_init(&lfsr, pow(2, length) - 1, 1))
268 269
			return -1;
269

  
270
	//	printf("XNOR-mask: %lu, state: %lu, limit: %lu\n",
271
	//			lfsr.xnormask, lfsr.state, lfsr.limit);
270 272
		period = 1; //Already initialized at 1
271 273
		upper_limit = pow(2, length);
272 274

  
......
274 276
			lfsr_next(&lfsr);
275 277

  
276 278
		if (lfsr.state == 1) {
277
			printf("%u-bit LFSR has correct tap positions\n", length);
279
			printf("%u-bit LFSR is correct\n", length);
278 280
		}
279 281
		else {
280
			printf("%u-bit LFSR has incorrect tap positions\n", length);
282
			printf("%u-bit LFSR did not iterate successfully\n", length);
281 283
			printf("Current tap positions: ");
282 284
			for (i = 0; i < MAX_TAPS && taps[length][i] != 0; i++)
283 285
				printf("%u ", taps[length][i]);
284 286
			printf("\n");
285 287
			return -1;
286 288
		}
289
	//	return 0;
287 290
	}
288 291

  
289 292
	return 0;
b/xseg/peers/user/bench-utils.c
151 151
	//chunks in an object.
152 152
	//FIXME: Make it more elegant
153 153
	if (prefs->op == X_READ || prefs->op == X_WRITE)
154
		new = new / (prefs->os / prefs->ts);
154
		new = new / (prefs->os / prefs->bs);
155 155
	snprintf(req_target, TARGETLEN, "%s-%016lu", global_id, new);
156 156
	XSEGLOG2(&lc, D, "Target name of request is %s\n", req_target);
157 157
}
b/xseg/peers/user/bench-xseg.c
350 350

  
351 351
	//srcport and dstport must already be provided by the user.
352 352
	//returns struct xseg_request with basic initializations
353
	XSEGLOG2(&lc, D, "Get new request\n");
353
	//XSEGLOG2(&lc, D, "Get new request\n");
354 354
	timer_start(prefs, prefs->get_tm);
355 355
	req = xseg_get_request(xseg, srcport, dstport, X_ALLOC);
356 356
	if (!req) {
......
360 360
	timer_stop(prefs, prefs->get_tm, NULL);
361 361

  
362 362
	//Allocate enough space for the data and the target's name
363
	XSEGLOG2(&lc, D, "Prepare new request\n");
363
	//XSEGLOG2(&lc, D, "Prepare new request\n");
364 364
	r = xseg_prep_request(xseg, req, TARGETLEN, size);
365 365
	if (r < 0) {
366 366
		XSEGLOG2(&lc, W, "Cannot prepare request! (%lu, %llu)\n",
......
370 370

  
371 371
	//Determine what the next target/chunk will be, based on I/O pattern
372 372
	new = determine_next(prefs);
373
	XSEGLOG2(&lc, D, "Our new request is %lu\n", new);
373 374
	//Create a target of this format: "bench-<obj_no>"
374 375
	create_target(prefs, req, new);
375 376

  
......
386 387
	req->op = prefs->op;
387 388

  
388 389
	//Measure this?
389
	XSEGLOG2(&lc, D, "Allocate peer request\n");
390
	//XSEGLOG2(&lc, D, "Allocate peer request\n");
390 391
	pr = alloc_peer_req(peer);
391 392
	if (!pr) {
392 393
		XSEGLOG2(&lc, W, "Cannot allocate peer request (%ld remaining)\n",
......
402 403
		goto put_peer_request;
403 404
	}
404 405

  
405
	XSEGLOG2(&lc, D, "Set request data\n");
406
	//XSEGLOG2(&lc, D, "Set request data\n");
406 407
	r = xseg_set_req_data(xseg, req, pr);
407 408
	if (r < 0) {
408 409
		XSEGLOG2(&lc, W, "Cannot set request data\n");
......
419 420
	memcpy(pr->priv, &prefs->rec_tm->start_time, sizeof(struct timespec));
420 421

  
421 422
	//Submit the request from the source port to the target port
422
	XSEGLOG2(&lc, D, "Submit request %lu\n", new);
423
	//XSEGLOG2(&lc, D, "Submit request %lu\n", new);
423 424
	//QUESTION: Can't we just use the submision time calculated previously?
424 425
	timer_start(prefs, prefs->sub_tm);
425 426
	p = xseg_submit(xseg, req, srcport, X_ALLOC);
b/xseg/peers/user/bench-xseg.h
145 145
\**************/
146 146

  
147 147
struct lfsr {
148
	uint8_t length;
149
	uint64_t limit;
150 148
	uint64_t state;
151 149
	uint64_t xnormask;
150
	uint64_t cached_bit; //It's faster if it's on the same cacheline
151
	uint64_t limit;
152
	uint8_t length;
152 153
};
153 154

  
154 155
int lfsr_init(struct lfsr *lfsr, uint64_t size, uint64_t seed);
......
160 161
static inline uint64_t lfsr_next(struct lfsr *lfsr)
161 162
{
162 163
	do {
163
		lfsr->state = (lfsr->state >> 1) ^
164
		lfsr->state = ((lfsr->state >> 1) | lfsr->cached_bit) ^
164 165
			(((lfsr->state & 1UL) - 1UL) & lfsr->xnormask);
165
	} while (lfsr->state > lfsr->limit);
166

  
166
		//lfsr->state = (lfsr->state >> 1) ^ (-(lfsr->state & 1UL) & lfsr->xnormask);
167
		//printf("State: %lu\n", lfsr->state);
168
	} while (lfsr->state >= lfsr->limit);
169
	//} while (lfsr->state > lfsr->limit);
170
	//printf("------------\n");
167 171
	return lfsr->state;
168 172
}
169 173

  

Also available in: Unified diff