From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e19b5ae33edaea7c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!217.73.144.45.MISMATCH!feeder2.ecngs.de!ecngs!feeder.ecngs.de!newsfeed.freenet.de!newsfeed00.sul.t-online.de!t-online.de!news.task.gda.pl!not-for-mail From: jtg Newsgroups: comp.lang.ada Subject: Re: puzzled re hyperthreaded performance Date: Thu, 15 Sep 2005 08:08:26 +0200 Organization: CI TASK http://news.task.gda.pl/ Message-ID: References: NNTP-Posting-Host: pwr74.pwradio.pl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.task.gda.pl 1126764243 21356 153.19.176.74 (15 Sep 2005 06:04:03 GMT) X-Complaints-To: abuse@news.task.gda.pl NNTP-Posting-Date: Thu, 15 Sep 2005 06:04:03 +0000 (UTC) X-Organization-Notice: Organization line has been filtered In-Reply-To: X-Accept-Language: pl, en-us, en User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.11) Gecko/20050728 X-Original-Organization: CI TASK http://www.task.gda.pl/ Xref: g2news1.google.com comp.lang.ada:4679 Date: 2005-09-15T08:08:26+02:00 List-Id: tmoran@acm.org wrote: > I have a multitasking program that runs faster if I insert a "delay d;" > statement to prevent some of the multitasking overlap. > This is a version of the Shootout k-nucleotide program, which involves > a series of create/fill/lookup in hash tables, using the Ada 95 version > of Ada.Containers.Indefinite_Hashed_Maps I let the operations run in > two tasks, each with their own hash table. Memory requirement are minor. > Alt_Task.Start; > delay d; > Compute; > Alt_Task.Finish; > Alt_Task performs the same computations as Compute, reading the same > String, but sharing no other data. There are no obvious task interactions, > and I don't see any in Ada.Containers > For every additional 1.0 seconds of "d", the sequence runs about 1.5 > seconds faster. This is Gnat 3.15p on W2k on a hyperthreaded Pentium > (two virtual CPUs). > Any suggestions what's going on? For every second of parallel processing 1.5 second is lost. So parallel processing slows the computations 2.5 times! There may be several reasons, more or less obvious. I guess the most important may be inefficient cache usage. You may try to perform both operations in sequence, or make them share the same hash table (if they perform the same computations on the same data), or split the computations in other way (one task with hash table and one for calculations only). Other factor may be task switching, but I can't believe it can slow the processing so hard! By the way, when you have "proper" multiprocessor environment, where each processor has its own cache, in certain circumstances you may observe the opposite phenomenon: for example problem solving on two processors can run MORE than two times faster. I suggest you run a test in some "proper" multiprocessor environment, i.e. two processors or a true multicore processor (with separate caches), but not virtual MP. One more thing: ensure Alt_Task is not terminated on Finish, but the computations are completed.