Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #22226

Re: Parallel FIB

From mhx@iae.nl (Marcel Hendrix)
Subject Re: Parallel FIB
Newsgroups comp.lang.forth
Message-ID <66821200988434@frunobulax.edu> (permalink)
Date 2013-05-03 23:53 +0200
References <17061400988434@frunobulax.edu>
Organization Wanadoo

Show all headers | View raw


mhx@iae.nl (Marcel Hendrix) wrote Re: Parallel FIB
[..]
> I think the problem of efficiently using more than 2 cores 
> for a recursive fib is still open.

A webpage on Erlang suggested to start a PAR from a PAR.
The result is quite incredible, I really didn't expect 
to get a factor of 12 speedup. But it appears it is possible
to use all cores after all.

-marcel

-- ------------

[..]

VARIABLE fibsa  0 VALUE na
VARIABLE fibsb  0 VALUE nb

: pfib1a ( n1 -- n2 )
	TO na  na 6 < IF  na fib EXIT  ENDIF
	fibsa OFF
	PAR
	  STARTP  na 5 - fib 8 * fibsa LOCKED+! DROP  ENDP
	  STARTP  na 6 - fib 5 * fibsa LOCKED+! DROP  ENDP
	ENDPAR
	fibsa @ ;

: pfib1b ( n1 -- n2 )
	TO nb  nb 6 < IF  nb fib EXIT  ENDIF
	fibsb OFF
	PAR
	  STARTP  nb 5 - fib 8 * fibsb LOCKED+! DROP  ENDP
	  STARTP  nb 6 - fib 5 * fibsb LOCKED+! DROP  ENDP
	ENDPAR
	fibsb @ ;

: pfib1ab ( n1 -- n2 )
	TO n  n 6 < IF  n fib EXIT  ENDIF
	fibs OFF
	PAR
	  STARTP  n 5 - pfib1a 8 * fibs LOCKED+! DROP  ENDP
	  STARTP  n 6 - pfib1b 5 * fibs LOCKED+! DROP  ENDP
	ENDPAR
	fibs @ ;

[..]

: bench	CR ." \ serial FIB(47)         : " TIMER-RESET #47  fib    U. .ELAPSED 
	CR ." \ new FIB(47)            : " TIMER-RESET #47 sfib    U. .ELAPSED 
	CR ." \ parallel FIB(47) (0)   : " TIMER-RESET #47 pfib0   U. .ELAPSED  
	CR ." \ parallel FIB(47) (1)   : " TIMER-RESET #47 pfib1   U. .ELAPSED  
	CR ." \ parallel FIB(47) (1ab) : " TIMER-RESET #47 pfib1ab U. .ELAPSED  
	CR ." \ parallel FIB(47) (2)   : " TIMER-RESET #47 pfib2   U. .ELAPSED ; 


\ FORTH> bench
\ serial FIB(47)         : 4807526976 45.308 seconds elapsed.
\ new FIB(47)            : 4807526976 6.688 seconds elapsed.
\ parallel FIB(47) (0)   : 4807526976 6.747 seconds elapsed.
\ parallel FIB(47) (1)   : 4807526976 4.169 seconds elapsed.
\ parallel FIB(47) (1ab) : 4807526976 0.355 seconds elapsed. <<<<<<<
\ parallel FIB(47) (2)   : 4807526976 6.830 seconds elapsed. ok

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Parallel FIB mhx@iae.nl (Marcel Hendrix) - 2013-05-02 01:20 +0200
  Re: Parallel FIB anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-02 14:13 +0000
    Re: Parallel FIB Paul Rubin <no.email@nospam.invalid> - 2013-05-02 08:25 -0700
    Re: Parallel FIB mhx@iae.nl (Marcel Hendrix) - 2013-05-03 07:04 +0200
      Re: Parallel FIB anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-03 12:26 +0000
        Re: Parallel FIB Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-03 15:23 +0200
          Re: Parallel FIB fred <email@address.com> - 2013-05-03 16:56 +0100
          Re: Parallel FIB Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-03 18:13 +0200
        Re: Parallel FIB mhx@iae.nl (Marcel Hendrix) - 2013-05-03 21:14 +0200
          Re: Parallel FIB anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-04 13:45 +0000
        Re: Parallel FIB mhx@iae.nl (Marcel Hendrix) - 2013-05-03 21:29 +0200
          Re: Parallel FIB mhx@iae.nl (Marcel Hendrix) - 2013-05-03 23:53 +0200
            Re: Parallel FIB Paul Rubin <no.email@nospam.invalid> - 2013-05-03 18:10 -0700
              Re: Parallel FIB mhx@iae.nl (Marcel Hendrix) - 2013-05-04 07:07 +0200
                Re: Parallel FIB mhx@iae.nl (Marcel Hendrix) - 2013-05-06 21:09 +0200
        Re: Parallel FIB albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-05-04 00:26 +0000

csiph-web