当前位置: 首页>>代码示例>>C++>>正文


C++ rdtscll函数代码示例

本文整理汇总了C++中rdtscll函数的典型用法代码示例。如果您正苦于以下问题:C++ rdtscll函数的具体用法?C++ rdtscll怎么用?C++ rdtscll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rdtscll函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StartAdcAcquireTest

/* test the "responsiveness" of ics-110bl acquire enable/disable bit:
 * 
 * i.e. will the ADC acquire frames "instantaneously" once the enable bit is set ?
 * 		will the ADC stop acquiring "instantaneously" once the enable bit is cleared ???
 * 
 * ANSWER: yes... to both... 
 * 
 */
void StartAdcAcquireTest(void) {
	double trueSampleRate = 0.0;
	extern double tscTicksPerSecond;
	uint64_t now, then, start;
	int i;
	
	syslog(LOG_INFO, "StartAdcAcquireTest() beginning...\n");
	now=then=start=0;
	InitializeVmeCrate();
	trueSampleRate = InitializeAdcModules(10.0/*kHz*/, 32/*channelsPerFrame*/);
	syslog(LOG_INFO, "trueSampleRate=%.9g\n", trueSampleRate);

	/* need to start test on the edge of an RTEMS tick... */
	rtems_task_wake_after(1);
	/*we're only going to play with one ADC...*/
	ICS110BStartAcquisition(AdcModules[0]);
	rdtscll(start);
	/* after 1 tick (==1 ms), we "should" have 10 frames in the adc's FIFO */
	rtems_task_wake_after(1);
	ICS110BStopAcquisition(AdcModules[0]);
	rdtscll(now);
	syslog(LOG_INFO, "adcAcquireTest: slept for %.9f [s]\n", ((double)(now-start))/tscTicksPerSecond);
	
	for(i=0; !ICS110BIsEmpty(AdcModules[0]); i++) {
		uint32_t data = readD32(AdcModules[0], ICS110B_FIFO_OFFSET);
	}
	syslog(LOG_INFO, "adcAcquireTest: read %d frames, %d channels\n", i/32, i);
	
	ShutdownVmeCrates();
}
开发者ID:dchabot,项目名称:cls-orbitcontrol,代码行数:38,代码来源:adcAcquireTest.c

示例2: test_perf

void
test_perf(void)
{
	lwt_t chld1, chld2;
	int i;
	unsigned long long start, end;


	/* Performance tests */
	rdtscll(start);
	for (i = 0 ; i < ITER ; i++) {
		lwt_chan_t c = lwt_chan(0);
		chld1 = lwt_create(fn_null, NULL, 0, c);
		lwt_join(chld1);
	}
	rdtscll(end);
	printf("[PERF] %lld <- fork/join\n", (end-start)/ITER);
	IS_RESET();

	lwt_chan_t c1 = lwt_chan(0);
	chld1 = lwt_create(fn_bounce, (void*)1, 0, c1);
	lwt_chan_t c2 = lwt_chan(0);
	chld2 = lwt_create(fn_bounce, NULL, 0, c2);
	lwt_join(chld1);
	lwt_join(chld2);
	IS_RESET();
}
开发者ID:patriot7,项目名称:lwt,代码行数:27,代码来源:main.c

示例3: while

void *meas_thd(void *d)
{
	unsigned long long s, e;
	unsigned long iter = 0;
	
	while (mcsync.r != -1) {
		mcsync.r = 0;
		while (mcsync.r == 0) ;
		if (mcsync.r == -1) break;

		rdtscll(s);
		/* let the other thread go first to avoid races */
		while (bounce == MEAS_ITER) ;
		while (bounce > 0) {
			unsigned long t;
			
			t = bounce-1;
			bounce = t; /* write to cache line */
			if (bounce == 0) break;
			while (bounce == t) ;
		}
		bounce = 0;
		rdtscll(e);
		//		assert(s < e);
		mcsync.cost = (e-s)/MEAS_ITER;
	}
	printf("running consumer\n"); fflush(stdout);
	//	rb_test_c();
	system("PCM/Intel/./main");

	return NULL;
}
开发者ID:gparmer,项目名称:PipeMeas,代码行数:32,代码来源:mctest.c

示例4: v3_handle_svm_halt

int v3_handle_svm_halt(struct guest_info * info)
{
  if (info->cpl!=0) { 
    v3_raise_exception(info, GPF_EXCEPTION);
  } else {
    
    // What we should do is starting waiting on an OS event that will
    // result in an injection of an interrupt.
    
    // What we will hackishly do instead is resume on any event
    // Plus is this totally GeekOS specific
    
    ullong_t yield_start = 0;
    ullong_t yield_stop = 0;
    uint32_t gap = 0;
    
    PrintDebug("GeekOS Yield\n");
    
    rdtscll(yield_start);
    V3_Yield();
    rdtscll(yield_stop);
    
    
    //v3_update_time(info, yield_stop - yield_start);
    gap = yield_stop - yield_start;
    v3_raise_irq(info, 0);
    
    PrintDebug("GeekOS Yield Done (%d cycles)\n", gap);
    
    info->rip+=1;
  }
    
  return 0;

}
开发者ID:epowers,项目名称:palacios,代码行数:35,代码来源:svm_halt.c

示例5: test_speed_create_join

int test_speed_create_join()
{
	int i=0;
	unsigned long long start, end;
	lwt_t tid1, tid2, tid3;

	tid1 = lwt_create(fn, NULL, 0, 0);
	lwt_join(tid1);
	IS_RESET();

	rdtscll(start);
	for(i=0 ; i < ITER; i++)
	{
		tid1 = lwt_create(fn, NULL, 0, 0);
		lwt_join(tid1);
	}
	rdtscll(end);
	IS_RESET();
	printf("performance of fork/join: --> %lld\n", (end-start)/ITER);

	for(i=0 ; i < ITER; i++)
	{
		tid1 = lwt_create(fn, NULL, 0, 0);
		tid2 = lwt_create(fn, NULL, 0, 0);
		tid3 = lwt_create(fn, NULL, 0, 0);
		lwt_join(tid3);
		lwt_join(tid1);
		lwt_join(tid2);
	}

	IS_RESET();


	return 0;
}
开发者ID:hz-chen,项目名称:lwt,代码行数:35,代码来源:main.c

示例6: producer

void producer(void)
{
	int i;
	unsigned long long start, end, sum = 0, avg, dev = 0;


	for (i = 0 ; i < RB_ITER ; i++) {
		rdtscll(start);
		__p();
		rdtscll(end);
		meas[i] = end - start;
		sum += meas[i];
	}
	avg = sum/RB_ITER;
	for (i = 0 ; i < RB_ITER ; i++) {
		unsigned long long diff = (meas[i] > avg) ? 
			meas[i] - avg : 
			avg - meas[i];
		dev += (diff*diff);
	}
	dev /= RB_ITER;
	printf("round trip deviation^2 = %llu\n", dev);

	printf("RPC pipe: Producer: %llu\n", avg);
}
开发者ID:gparmer,项目名称:PipeMeas,代码行数:25,代码来源:mctest.c

示例7: fh_cpu_rdspeed

/*
 * fh_cpu_rdspeed
 *
 * Compute the CPU speed (in MHz) by looking at the elapsed time in microseconds
 * that it takes to get through 500M CPU cycles.
 */
uint32_t fh_cpu_rdspeed()
{
    uint64_t tsc_start = 0;
    uint64_t tsc_stop  = 0;
    uint64_t tsc_total = 0;
    uint64_t ts2, ts1;
    uint32_t cpu_speed;

    fh_time_get(&ts1);
    rdtscll(tsc_start);
    while (1) {
        barrier();

        rdtscll(tsc_stop);

        if (likely(tsc_stop > tsc_start)) {
            tsc_total += tsc_stop - tsc_start;
        }
        else {
            tsc_total += (uint64_t)~0 - tsc_start + tsc_stop;
        }

        if (tsc_total > (uint64_t)500000000) {
            break;
        }
        tsc_start = tsc_stop;
    }
    fh_time_get(&ts2);

    cpu_speed = (uint32_t) (tsc_total / (ts2-ts1));

    return cpu_speed;
}
开发者ID:SibghatullahSheikh,项目名称:fhce,代码行数:39,代码来源:fh_cpu.c

示例8: timer_monotonic_get

void timer_monotonic_get(struct mono_time *mt)
{
	uint64_t current_tick;
	uint64_t ticks_elapsed;

	if (!mono_counter.initialized) {
		init_timer();
		mono_counter.last_value = rdtscll();
		mono_counter.initialized = 1;
	}

	current_tick = rdtscll();
	ticks_elapsed = current_tick - mono_counter.last_value;

	/* Update current time and tick values only if a full tick occurred. */
	if (ticks_elapsed >= clocks_per_usec) {
		uint64_t usecs_elapsed;

		usecs_elapsed = ticks_elapsed / clocks_per_usec;
		mono_time_add_usecs(&mono_counter.time, (long)usecs_elapsed);
		mono_counter.last_value = current_tick;
	}

	/* Save result. */
	*mt = mono_counter.time;
}
开发者ID:0ida,项目名称:coreboot,代码行数:26,代码来源:delay_tsc.c

示例9: call_cs

void call_cs(void)
{
	static int first = 0;
	static int high, low;
	u64_t start = 0, end = 0;

	if(first == 1){
		low = cos_get_thd_id();
		sched_wakeup(cos_spd_id(), high);
	}

	if(first == 0){
		first = 1;
		high = cos_get_thd_id();
		sched_block(cos_spd_id(), 0);
		rdtscll(start);
		sched_block(cos_spd_id(), low);
	}

	if (cos_get_thd_id() == low) {
		sched_wakeup(cos_spd_id(), high);
	}

	if (cos_get_thd_id() == high) {
		rdtscll(end);
		printc("context switch cost: %llu cycs\n", (end-start) >> 1);
		first = 0;
	}
开发者ID:ryuxin,项目名称:cbuf-composite,代码行数:28,代码来源:micro_pong.c

示例10: test_aes_perf

static void test_aes_perf(void)
{
#if 0 /* this did not seem to work with new compiler?! */
#ifdef __i386__
#define rdtscll(val) \
     __asm__ __volatile__("rdtsc" : "=A" (val))
	const int num_iters = 10;
	int i;
	unsigned int start, end;
	u8 key[16], pt[16], ct[16];
	void *ctx;

	printf("keySetupEnc:");
	for (i = 0; i < num_iters; i++) {
		rdtscll(start);
		ctx = aes_encrypt_init(key, 16);
		rdtscll(end);
		aes_encrypt_deinit(ctx);
		printf(" %d", end - start);
	}
	printf("\n");

	printf("Encrypt:");
	ctx = aes_encrypt_init(key, 16);
	for (i = 0; i < num_iters; i++) {
		rdtscll(start);
		aes_encrypt(ctx, pt, ct);
		rdtscll(end);
		printf(" %d", end - start);
	}
	aes_encrypt_deinit(ctx);
	printf("\n");
#endif /* __i386__ */
#endif
}
开发者ID:AlejandroAbad,项目名称:hostap,代码行数:35,代码来源:test-aes.c

示例11: test_perf_channels

void
test_perf_channels(int chsz)
{
	lwt_chan_t from, to;
	lwt_t t;
	int i;
	unsigned long long start, end;

	//assert(LWT_RUNNING == lwt_current()->state);
	from = lwt_chan(chsz);
	assert(from);
	t    = lwt_create_chan(fn_chan, from, 0);
	to   = lwt_rcv_chan(from);
	assert(to->snd_cnt);
	rdtscll(start);
	for (i = 0 ; i < ITER ; i++) {
		assert(1 == (int)lwt_rcv(from));
		lwt_snd(to, (void*)2);
	}
	lwt_chan_deref(to);
	rdtscll(end);
	printf("[PERF] %5lld <- snd+rcv (buffer size %d)\n", 
	       (end-start)/(ITER*2), chsz);
	lwt_join(t);
}
开发者ID:kalmuthu,项目名称:threads,代码行数:25,代码来源:main3.c

示例12: measure_loop_costs

static unsigned long measure_loop_costs(unsigned long spin) 
{
	u64_t start, end, min, max;
	unsigned long temp = 0;

	temp = spin * 15 / 2;
	loop_cost = temp;
	return temp;

	rdtscll(start);
	do {
		int i;
		min = MAXULONG;
		max= 0;
		for (i = 0 ; i < 10 ; i++) {
			temp = get_loop_cost(spin);
			if (temp < min) min = temp;
			if (temp > max) max = temp;
		}
	} while ((max-min) > (min/128));

	loop_cost = temp;
	rdtscll(end);
	assert(end>start);
	printc("spin:%lu, loopcost measurement :%lu\n",spin, temp );
	return temp;
}
开发者ID:asweeney86,项目名称:Composite,代码行数:27,代码来源:exe_cbuf_synth_hier.c

示例13: timer_monotonic_get

void timer_monotonic_get(struct mono_time *mt)
{
	uint64_t current_tick;
	uint64_t ticks_elapsed;
	unsigned long ticks_per_usec;
	struct monotonic_counter *mono_counter;

	mono_counter = get_monotonic_context();
	if (!mono_counter->initialized) {
		init_timer();
		mono_counter->last_value = rdtscll();
		mono_counter->initialized = 1;
	}

	current_tick = rdtscll();
	ticks_elapsed = current_tick - mono_counter->last_value;
	ticks_per_usec = get_clocks_per_usec();

	/* Update current time and tick values only if a full tick occurred. */
	if (ticks_elapsed >= ticks_per_usec) {
		uint64_t usecs_elapsed;

		usecs_elapsed = ticks_elapsed / ticks_per_usec;
		mono_time_add_usecs(&mono_counter->time, (long)usecs_elapsed);
		mono_counter->last_value = current_tick;
	}

	/* Save result. */
	*mt = mono_counter->time;
}
开发者ID:siro20,项目名称:coreboot,代码行数:30,代码来源:delay_tsc.c

示例14: consumer

void consumer(void)
{
	int i;
	unsigned long long start, end, c_sum = 0, avg, dev = 0;

	rdtscll(start);
	for (i = 0 ; i < RB_ITER ; i++) {
		c_meas[i] = __c();
		c_sum += c_meas[i];
	}
	rdtscll(end);
	avg = sum/RB_ITER;
	for (i = 0 ; i < RB_ITER ; i++) {
		unsigned long long diff = (c_meas[i] > avg) ? 
			c_meas[i] - avg : 
			avg - c_meas[i];
		dev += (diff*diff);
//		printf("%llu, diff %llu\n", c_meas[i], diff);
	}
	dev /= RB_ITER;

	printf("one way trip deviation^2 = %llu\n", dev);

	printf("one way: %d\n", sum / RB_ITER);
//	printf("RPC pipe: Consumer: %lld\n", avg);
}
开发者ID:gparmer,项目名称:PipeMeas,代码行数:26,代码来源:mctest.c

示例15: call

void call(void)
{
    static int first = 0;
    static int low = 0, high = 0;

    if (first == 0 ) {
        high = cos_get_thd_id();
        low = high + 1;
        first = 1;
    }

    u64_t start = 0, end = 0;

    int j = 0;
    while(j++ < 10) {
        if (cos_get_thd_id() == high) {
            /* printc("p3\n"); */
            sched_block(cos_spd_id(), 0);
            /* printc("p4\n"); */
            rdtscll(start);
        }
        /* printc(" thd %d is calling lower \n", cos_get_thd_id()); */

        call_lower(low, high);

        if (cos_get_thd_id() == high) {
            rdtscll(end);
            printc("cost of cached stkPIP %llu cycs\n", end-start);
        }
    }
    return;
}
开发者ID:HelloCompositeKevin,项目名称:test_merge_conflict,代码行数:32,代码来源:micro_pong.c


注:本文中的rdtscll函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。