Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly x86 > Code performanc...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 4627 of 4646
Post > Topic >>

Code performance, rdtsc and code alignment

by James Harris <spamtrap@[EMAIL PROTECTED] > Apr 21, 2008 at 06:28 PM

If I run the code below (which is based on an Intel performance
measuring note) the times for each of the three inter-rdtsc sequences
is almost always 122 cycles. However, if the align directive is
removed, sometimes the cycle counts vary markedly.

Anyone else seen this effect?


An example of running the code without the align directive:

Calibration times 122, 122, 122
Calibration times 122, 213, 122
Calibration times 122, 193, 122
Calibration times 122, 213, 122
Calibration times 122, 234, 122
Calibration times 122, 193, 122
Calibration times 122, 193, 122
Calibration times 122, 248, 122
Calibration times 122, 193, 122
Calibration times 122, 213, 122

With the align directive:

Calibration times 122, 122, 122
Calibration times 122, 122, 122
Calibration times 122, 122, 122
Calibration times 122, 122, 122
Calibration times 122, 122, 122
Calibration times 122, 122, 122
Calibration times 122, 122, 122
Calibration times 122, 122, 122
Calibration times 122, 122, 122
Calibration times 122, 122, 122


;;;;;;;;
;Calibrate the time stamp counter measurement

	align 32
tsc_calibrate:
	mov	eax, [subtime_1]	;Preload cache
	xor	eax, eax
	cpuid
	rdtsc
	mov	[subtime_1], eax
	xor	eax, eax
	cpuid
	rdtsc
	sub	eax, [subtime_1]
	mov	[subtime_1], eax

	mov	eax, [subtime_2]	;Preload cache
	xor	eax, eax
	cpuid
	rdtsc
	mov	[subtime_2], eax
	xor	eax, eax
	cpuid
	rdtsc
	sub	eax, [subtime_2]
	mov	[subtime_2], eax

	mov	eax, [subtime_3]	;Preload cache
	xor	eax, eax
	cpuid
	rdtsc
	mov	[subtime_3], eax
	xor	eax, eax
	cpuid
	rdtsc
	sub	eax, [subtime_3]
	mov	[subtime_3], eax

	ret




 1 Posts in Topic:
Code performance, rdtsc and code alignment
James Harris <spamtra  2008-04-21 18:28:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 11:01:04 CDT 2008.