Re: Syncing cpus on a multi-cpu, dual core system

2006-12-16 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
M. L. Dodson [EMAIL PROTECTED] writes:
: On a computational chemistry list I subscribe to there is a
: current thread about multi-cpu systems needing to have the cpu
: frequencies synced (this is in a Linux context).  This is
: evidently not just having the cpus running at nominally the same
: frequency but something else in addition.  A posting in the thread
: said variations less than 0.1% were not problematic.  However, the
: poster said it was an issue in a dual cpu, dual core system he had
: set up.
: 
: My questions are:
: 1. Is this real or an urban legend?
: 2. If real, is this a Linuxism or is FreeBSD affected as well?
: 3. How do you sync the cpus, if it is needed?
: 4. anything else some one wants to expound on along this line.

Linux keeps the cpu's frequencies 'synchronized' so that it can use
the fast time keeping hardware (TSC).  FreeBSD uses different
mechanisms for its timekeeping, so doesn't need to keep them in sync
at all, and doesn't even try at this point.  Maybe this is what they
are talking about...

Warner
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Syncing cpus on a multi-cpu, dual core system

2006-12-16 Thread Stephen Montgomery-Smith

M. Warner Losh wrote:

In message: [EMAIL PROTECTED]
M. L. Dodson [EMAIL PROTECTED] writes:
: On a computational chemistry list I subscribe to there is a
: current thread about multi-cpu systems needing to have the cpu
: frequencies synced (this is in a Linux context).  This is
: evidently not just having the cpus running at nominally the same
: frequency but something else in addition.  A posting in the thread
: said variations less than 0.1% were not problematic.  However, the
: poster said it was an issue in a dual cpu, dual core system he had
: set up.
: 
: My questions are:

: 1. Is this real or an urban legend?
: 2. If real, is this a Linuxism or is FreeBSD affected as well?
: 3. How do you sync the cpus, if it is needed?
: 4. anything else some one wants to expound on along this line.

Linux keeps the cpu's frequencies 'synchronized' so that it can use
the fast time keeping hardware (TSC).  FreeBSD uses different
mechanisms for its timekeeping, so doesn't need to keep them in sync
at all, and doesn't even try at this point.  Maybe this is what they
are talking about...

Warner


One thing I have noticed with FreeBSD is that if I am running a program 
that multithreads and creates and destroys threads a lot (e.g. the fftw3 
port), then top underreports significantly - that is on a 4 processor 
system it might report 60% (or even 0%) cpu usage, when it is clear from 
the TIME field that it is closer to 250% cpu usage.


The other thing I have noticed is that when I split jobs using threads 
so that I can use several processors, the speed up to the program is far 
less than one might expect - indeed sometimes it even gets slower.


Stephen
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Syncing cpus on a multi-cpu, dual core system

2006-12-16 Thread Simon Roberts

- Original Message 
From: Stephen Montgomery-Smith [EMAIL PROTECTED]

...snip snip...

The other thing I have noticed is that when I split jobs using threads 
so that I can use several processors, the speed up to the program is far 
less than one might expect - indeed sometimes it even gets slower.

Stephen

-

This is probably Amdahl's law.

Simon





__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Syncing cpus on a multi-cpu, dual core system

2006-12-16 Thread M. L. Dodson
On Saturday 16 December 2006 12:30, M. Warner Losh wrote:
 In message: [EMAIL PROTECTED]

 M. L. Dodson [EMAIL PROTECTED] writes:
 : On a computational chemistry list I subscribe to there is a
 : current thread about multi-cpu systems needing to have the cpu
 : frequencies synced (this is in a Linux context).  This is
 : evidently not just having the cpus running at nominally the same
 : frequency but something else in addition.  A posting in the thread
 : said variations less than 0.1% were not problematic.  However, the
 : poster said it was an issue in a dual cpu, dual core system he had
 : set up.
 :
 : My questions are:
 : 1. Is this real or an urban legend?
 : 2. If real, is this a Linuxism or is FreeBSD affected as well?
 : 3. How do you sync the cpus, if it is needed?
 : 4. anything else some one wants to expound on along this line.

 Linux keeps the cpu's frequencies 'synchronized' so that it can use
 the fast time keeping hardware (TSC).  FreeBSD uses different
 mechanisms for its timekeeping, so doesn't need to keep them in sync
 at all, and doesn't even try at this point.  Maybe this is what they
 are talking about...

 Warner

That is very much in line with the context of the postings on the
computational chemistry list I mentioned.  This is the likely
source of the issue for people on that list (very few use *BSD).
They just assume if you are not using Solaris or Irix, then you
must be using Linux of some flavor.

And this means I don't have to bother with that particular piece
of nonsense.

Thanks to everyone who answered.
Bud Dodson
-- 
M. L. Dodson
Email:  mldodson-at-houston-dot-rr-dot-com
Phone:  eight_three_two-56_three-386_one

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Syncing cpus on a multi-cpu, dual core system

2006-12-16 Thread Matthew Dillon
The TSCs for each individual cpu core can drift relative to each other,
even on multi-core chips like AMD X2s.  This only effects code which
uses the TSC, which isn't a whole lot.  They need to be synchronized
with each other (by calculating the drift and correcting for it) when
using the TSC to log events, such as KTR logging might do.  Since the
TSC runs off the PLL, the drift rate will change based on the temperature
of each core.

I'm not sure whether the LAPIC timers can be depended upon to operate
from the same physical clock source or not (i.e. whether they drift 
relative to each other or not).  I haven't tested them for that.

-Matt
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Syncing cpus on a multi-cpu, dual core system

2006-12-15 Thread Simon Roberts

- Original Message 
 On a computational chemistry list I subscribe to there is a
 current thread about multi-cpu systems needing to have the cpu
 frequencies synced (this is in a Linux context).  This is
 evidently not just having the cpus running at nominally the same
 frequency but something else in addition.  A posting in the thread
 said variations less than 0.1% were not problematic.  However, the
 poster said it was an issue in a dual cpu, dual core system he had
 set up.
 
 My questions are:
 1. Is this real or an urban legend?

If CPUs use the same FSB (as is the case with dual-core chip), they are
already in sync. Right? For system that use multiple FSB clocks [like
dual-(dualcore-CPU) systems], it might be possible to vary the clocks
(as much as the manufacturer allows without hw modifications: e.g.,
SpeedStep, or something similar).

Why someone would want to have CPUs running at precisely the same
frequency is beyond my imagination.



My dual core system does speedstep the two CPUs independently, it's clearly 
visible when running the speed monitor applets. I guess if only one thread is 
busy, only one CPU needs to work hard.

As to why it would matter that they be in sync? My imagination runs to these 
two possibilities: 1) someone is writing multi-threaded software but doesn't 
really know how to do this correctly. 2) someone is writing ultra-high 
performance multi-threaded software that requires two threads on the two CPUs 
to be able to run in a way that doesn't risk data corruption, but needs to be 
able to do it without slowing down to check 
monitors/semaphores/other-threadsafety-devices. To address this, they've 
counted CPU cycles and are running a producer and consumer type scenario in 
such a way that the threads are perfectly out of phase with one another, so as 
to ensure that reads by one are not mixed in with writes by the other. I guess 
option 2 would be kinda legitimate, but I suspect actually a special case of 1 
anyway--mainly because I find it hard to believe it has a snowball's chance in 
hell of working on systems that have pipelines, instruction look-ahead, etc. 
Might have worked on a dual 6502 based system when you knew exactly how long an 
instruction would take, and it always took that long :)

Bottom line; I'm inclined to the urban-legend classification.

$0.02
Simon





__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Syncing cpus on a multi-cpu, dual core system

2006-12-15 Thread Joseph Koshy

frequency but something else in addition.  A posting in the
thread said variations less than 0.1% were not problematic.
However, the poster said it was an issue in a dual cpu, dual
core system he had set up.


Why would application code care about CPU frequencies?

Is it trying to measure its 'performance' by subtracting
two TSC readings?  That won't necessarily work on
modern multi-CPU systems where each CPU could be running
at a different CPU speed.

On FreeBSD, with hwpmc(4), you can allocate a process-mode
counting pmc that counts non-sleep cycles (e.g.,
p4-global-power-events,mask=running on an Intel P4) and
then use RDPMC instructions where you would have used RDTSC
instructions.  This is as cheap as the RDTSC technique and
will work on SMP systems.

--
FreeBSD Volunteer, http://people.freebsd.org/~jkoshy/
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Syncing cpus on a multi-cpu, dual core system

2006-12-14 Thread soralx

 On a computational chemistry list I subscribe to there is a
 current thread about multi-cpu systems needing to have the cpu
 frequencies synced (this is in a Linux context).  This is
 evidently not just having the cpus running at nominally the same
 frequency but something else in addition.  A posting in the thread
 said variations less than 0.1% were not problematic.  However, the
 poster said it was an issue in a dual cpu, dual core system he had
 set up.
 
 My questions are:
 1. Is this real or an urban legend?

If CPUs use the same FSB (as is the case with dual-core chip), they are
already in sync. Right? For system that use multiple FSB clocks [like
dual-(dualcore-CPU) systems], it might be possible to vary the clocks
(as much as the manufacturer allows without hw modifications: e.g.,
SpeedStep, or something similar).

Why someone would want to have CPUs running at precisely the same
frequency is beyond my imagination.

 Bud Dodson

[SorAlx]  ridin' VN1500-B2
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]