Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!postnews2.euro.net!news.wanadoo.nl!not-for-mail From: mhx@iae.nl (Marcel Hendrix) Subject: Re: pde2 floating point benchmark code Newsgroups: comp.lang.forth Message-ID: <79911496008434@frunobulax.edu> Date: Thu, 7 Mar 2013 21:12:56 +0200 References: X-Newsreader: iForth 2.0 console (October 21, 2006) Lines: 78 Organization: Wanadoo NNTP-Posting-Date: 07 Mar 2013 20:12:45 GMT NNTP-Posting-Host: s529d937f.adsl.online.nl X-Trace: 1362687165 dr7.euro.net 217 82.157.147.127:51040 X-Complaints-To: abuse@wanadoo.nl Xref: csiph.com comp.lang.forth:20412 krishna.myneni@ccreweb.org writes Re: pde2 floating point benchmark code [..] >>> The Fortran code is compiled and used transparently, and >>> the speedup is enormous. Native code Forth compilers could use this >>> hybrid R program for comparison. The link is >>> ftp://ccreweb.org/software/R/pde/diffusion-fast.R > >> Compare what to what? > I meant, compare the execution time of the R program's calculation > (for diffusion-fast.R) with the execution time of the compiled Forth program ... Can you quote numbers? I don't have R installed. [..] > The method of lines calculation program may be found at > ftp://ccreweb.org/software/R/pde/pde-example.R > It outputs a rather nice color image of the spatial-temporal solution, and > worth looking at if you have installed or can install R on your system. Could you post a picture? I can't read the R syntax to do it with my native plotters :-) >> ( 50% of the time is needed to copy the arrays around ) More like 25% for the fast floating-point < 80 bits. > Not sure how to get around this problem. Even though the calculation might > be done in-place with some extra variables, I don't know if the memory > shuffling can be minimized significantly. Swapping pointers works. -marcel -- -------------------- NEEDS -xopg .dfloat.p \ .xfloat.p \ .arbitrary.p LET 0.5e: GVAL D -- Diffusion coefficient LET 20.0: GVAL u_ext LET 0.01: GVAL dx LET 4e-5: GVAL dt LET D*dt/dx^2: GVAL kk -- choose dt so that fk < 0.5 LET INTEGER(1+10/dx): =: nx nx GARRAY x nx GARRAY u_x_0 nx GARRAY u_i nx GARRAY u_ip1 : INIT ( -- ) nx 0 DO LET x[i]=double[i]*dx: LET u_x_0[i]=1: LET u_i[i]=1: LOOP ; INIT : EVOLVE ( n -- ) u_ip1 u_i LOCALS| u_ip1 u_i | 0 ?DO nx 1- 1 DO LET u_ip1[i]=kk*(u_i[i+1]-2*u_i[i]+u_i[i-1])+u_i[i]: LOOP LET u_ip1[0]=u_ip1[1]: \ b.c.: u_x(0, t) = 0 LET u_ip1[nx-1]=u_ext: \ b.c.: u(10, t) = u_ext u_ip1 u_i TO u_ip1 TO u_i LOOP ; -- Compute the solution at t=1 TIMER-RESET #25000 evolve CR .ELAPSED LET. u_i[nx-2]: \ xfloat: 0.192 seconds elapsed. 1.9848403070438166106e+0001 \ (new) 0.156 seconds elapsed. 1.9848403070438166106e+0001 \ arbitrary: 43.132 seconds elapsed. 1.9848403070438166105436153141988337094009e+0001 \ (new) 41.382 seconds elapsed. 1.9848403070438166105436153141988337094009e+0001