From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,558daf67e4949172 X-Google-Attributes: gidf7344,public X-Google-Thread: 114669,2caf1b9cb227c27e X-Google-Attributes: gid114669,public X-Google-Thread: 1164f8,558daf67e4949172 X-Google-Attributes: gid1164f8,public X-Google-Thread: f6134,558daf67e4949172 X-Google-Attributes: gidf6134,public X-Google-Thread: 102b75,558daf67e4949172 X-Google-Attributes: gid102b75,public From: Terje Mathisen Subject: Minimum overhead SMP sync (Was: Re: Linux in OpenVMS Galaxy) Date: 1999/07/20 Message-ID: <3794C2C1.491AF938@hda.hydro.com>#1/1 X-Deja-AN: 503225683 Content-Transfer-Encoding: 7bit References: <378FC06D.58CF@smarts.com> <7mojhs$225q@news1.newsguy.com> <7n24fu$k08$1@murrow.corp.sgi.com> Followup-To: comp.arch Content-Type: text/plain; charset=us-ascii Organization: Hydro Mime-Version: 1.0 Newsgroups: comp.sys.dec,comp.os.vms,comp.arch,comp.org.decus,comp.sys.super (Followups set to comp.arch) John McCalpin wrote: > Maybe.... We certainly have proof that some non-trivial codes > exist that scale to 256p while retaining an SMP programming model. > These do *not* parallelize each loop independently -- the overheads > would kill unless you had enormous/impractical problem sizes. > Instead, the parallelization is on a larger scale. Sometimes this > requires significant code modification and sometimes it does not. This is obviously correct, and it made me wonder about what the minimum possible SMP overhead could be, since this would determine the absolute limit for parallel granularity. It seems most modern cpus have some kind of Load Locked/Store Conditional operation, while x86 is a significant alternative which uses a conditional exchange. Using a queue of work-to-do tasks, an idle cpu can grab the next entry in a linked list by retrieving the head ptr, using this to get the next ptr from the first entry and then update the head ptr to skip the first entry. The critical path here (assuming x86) is the MOV eax, [first_task] MOV ebx, [eax.next_task] LOCK CMPXCHG [head],ebx sequence which entails a minimum of 4 memory operations, where the first will probably be a cache miss (since it will be in the L1/L2 cache of some other cpu), and the actual exchange has to go directly to memory. With 100 ns for an L2 cache miss or a LOCKed memory operation, I get 300 ns as an absolute minimum. With faster RAM this can be reduced a bit, but it seems like most big SMP/ccNUMA systems are slower rather than faster.(?) 300 ns is up to 450 instructions on a 500 MHz PentiumIII, i.e. a fairly significant time slot. This means that on an N-way SMP machine, each job has to take significantly more than N times as long as this, otherwise the assumption about low lock contention will be broken. Anyway, my question is this: What is the fastest possible way to partition out individual tasks in an SMP machine. Can it be done significantly faster than my snippet above if you have specialized hw? Terje -- - Using self-discipline, see http://www.eiffel.com/discipline "almost all programming can be viewed as an exercise in caching"