[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] parallellisering



On Wed, 29 Mar 2000, Sune Fischer wrote:

> Klart, men klodset, hvorfor ikke:
> 
> int sum,sum2,sum3;
> 
> sum=sum2=sum3=0;
> 
> //loop 1:
> for (i=0;i<N;i+=2)
> 	sum2++;
> //loop 2:
> for (i=1;i<N;i+=2)
> 	sum3++;
> 
> sum=sum2+sum3;
> 
> 
> (spilder 2x4 bytes, men skulle være 2x hurtigere.)
> startværdien for i passes bare over som argument ved
> pthread_create, og den skal steppe antallet af tråde
> (her 2 tråde). Men som sagt, det kører kun ca 23% hurtigere??

Har du testet et program som ovenstående? Hvis det kun giver 23 % er der
noget ravruskende galt. Jeg ville forvente at det gav mig 95 %.

Her er et lamt script:
--------
#!/bin/bash
yes | head -50000000 > /dev/null &
wait
--------

45.12user 2.28system 0:43.15elapsed 109%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (1589major+491minor)pagefaults 0swaps

Endnu et lamt
script:
--------
#!/bin/bash
yes | head -25000000 > /dev/null &
yes | head -25000000 > /dev/null &
wait
--------
sslug@sslug madsdyd]$ time ./test2
46.15user 1.62system 0:24.05elapsed 198%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (1791major+553minor)pagefaults 0swaps

Tallene er selvfølgelig dybt suspekte, men alligevel - det går da nåsten
en faktor 2 hurtigere. Der er selvfølgelig heller ikke meget kerne
tingeltangel her, men det sagde du jo også at du ikke havde.

Mine lamme script har næsten samme grad af uafhængighed som dit eksempel
med tallene. Så måske har du mange kerne kald i dele der er ikke er
særligt fint granulerede, eller måske smadrer du din cache for vildt?

Mads

-- 
Mads Bondo Dydensborg.                               sslug@sslug
When a single line of script in Linux can do things that'd keep you 
pointing-and-clicking forever in Windows, you have great motivation to learn 
that line of script.
                                        - Chris Worth on The Microsoft Matrix



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *