From: Sven Zenker <Sven.Zenker@gmx.net>
To: a_mulyadi@softhome.net
Cc: qemu-devel@nongnu.org
Subject: Re: Re: [Qemu-devel] Timing problems
Date: Tue, 30 Aug 2005 17:08:19 -0400 [thread overview]
Message-ID: <1125436100.9706.19.camel@linux> (raw)
In-Reply-To: <200508291001.39221.a_mulyadi@softhome.net>
Hi,
> Hm..... hard choice.....correctness traded for perfomance.... But
> anyway....IMHO this hack is needed for every speed-step enabled
> machine. Perhaps...the other workaround is via cpufreqd? I don't have
> any Pentium M based PC/laptop around, so this is just a pure guess
Yeah, you can also expect problems with the original versions on
multi-processor machines, I would think. Would be nice to compare
performance of the patched and original version. Unfortunately can't do
that right now because timing of the non-patched version is of course
messed up on my machine.
>
> BTW, your patch seems reversed....if you really mean you want to fetch
> realtime clock, you should use "rdtsc", right? But the patch seems
> replaced "rdtsc" with get_clock()....
rdtsc gives you the cpu's clock count, which, if CPU frequency changes,
or your code is run on different processors (multiprocessor machine),
cannot be assumed to be related to real time anymore. Resolutionwise,
the real time clock may be inferior, of course, as Jim mentioned.
Jim: could you point me to this other patch? Thanks!
>
> Another thing, IMHO it is better to use unified format (diff -u). More
> readable and i think it is a standart
Here you go:
+++++++++++++++++++++++++++++++++++
qemu-0.7.1 # diff -u vl.c.org vl.c
--- vl.c.org 2005-08-26 19:03:52.000000000 -0400
+++ vl.c 2005-08-28 14:43:00.000000000 -0400
@@ -500,16 +500,11 @@
} while (h != h1);
return ((int64_t)h << 32) | l;
}
-
#elif defined(__i386__)
-
int64_t cpu_get_real_ticks(void)
{
- int64_t val;
- asm volatile ("rdtsc" : "=A" (val));
- return val;
+ return get_clock();
}
-
#elif defined(__x86_64__)
int64_t cpu_get_real_ticks(void)
@@ -591,18 +586,7 @@
void cpu_calibrate_ticks(void)
{
- int64_t usec, ticks;
-
- usec = get_clock();
- ticks = cpu_get_real_ticks();
-#ifdef _WIN32
- Sleep(50);
-#else
- usleep(50 * 1000);
-#endif
- usec = get_clock() - usec;
- ticks = cpu_get_real_ticks() - ticks;
- ticks_per_sec = (ticks * 1000000LL + (usec >> 1)) / usec;
+ ticks_per_sec = 1000000LL; /* our real time clock resolution */
}
/* compute with 96 bit intermediate result: (a*b)/c */
+++++++++++++++++++++++++++++++++++
qemu-0.7.1/linux-user # diff -u main.c.org main.c
--- main.c.org 2005-08-28 14:40:16.000000000 -0400
+++ main.c 2005-08-28 15:06:31.000000000 -0400
@@ -110,9 +110,7 @@
int64_t cpu_get_real_ticks(void)
{
- int64_t val;
- asm volatile ("rdtsc" : "=A" (val));
- return val;
+ return get_clock();
}
#elif defined(__x86_64__)
+++++++++++++++++++++++++++++++++++
Best regards,
Sven
next prev parent reply other threads:[~2005-08-30 21:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-28 19:23 [Qemu-devel] Timing problems Sven Zenker
2005-08-29 3:01 ` Mulyadi Santosa
2005-08-29 3:21 ` Jim C. Brown
2005-08-30 21:08 ` Sven Zenker [this message]
2005-08-31 12:19 ` Mulyadi Santosa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1125436100.9706.19.camel@linux \
--to=sven.zenker@gmx.net \
--cc=a_mulyadi@softhome.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.