Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #20360
| From | mhx@iae.nl (Marcel Hendrix) |
|---|---|
| Subject | Re: pde2 floating point benchmark code |
| Newsgroups | comp.lang.forth |
| Message-ID | <94971297008434@frunobulax.edu> (permalink) |
| Date | 2013-03-06 23:06 +0200 |
| References | <e8a6c8ef-ad07-45c1-b1fb-752fcaf96e0f@googlegroups.com> |
| Organization | Wanadoo |
krishna.myneni@ccreweb.org writes Re: pde2 floating point benchmark code > On Monday, March 4, 2013 8:02:48 PM UTC-6, krishna...@ccreweb.org wrote: >> Here's a useful floating point calculation, solution of the 1-D diffusion >> equation, which may be useful for benchmarking non-native code Forth systems. >> A corresponding version in the higher level language, R, may be found at >> >> ftp://ccreweb.org/software/R/pde/diffusion.R [..] > Also, for reference, there is an R version of this program which uses the R > package, "inline", to permit the "evolve()" function to be written in Fortran > within the R program. 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? Here is a version using Wil Baden's OPG translator. It converts to native code (in iForth), and it can switch (without ANY change) between sfloat, dfloat, xfloat, and arbitrary precision. I suppose XFLOAT (80-bit) is most appropriate in this case. NEEDS -xopg .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 kk < 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 the solution by n time steps, i.e. by an elapsed time of n*dt : EVOLVE ( n -- ) u_i u_ip1 GCOPY 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 GCOPY LOOP ; -- Compute the solution at t=1 TIMER-RESET #25000 evolve .ELAPSED LET. u_i[nx-2]: ( 50% of the time is needed to copy the arrays around ) \ xfloat: 0.192 seconds elapsed. 1.9848403070438166106e+0001 \ arbitrary: 43.132 seconds elapsed. 1.9848403070438166105436153141988337094009e+0001 $01480940 : EVOLVE $0148094A push $01480428 d# $0148094F push $01480468 d# $01480954 lea rbp, [rbp -8 +] qword $01480958 mov [rbp 0 +] qword, $01480965 d# $01480960 jmp GCOPY+10 ( $0147B28A ) offset NEAR $01480965 xor rbx, rbx $01480968 pop rcx $01480969 call (?DO) offset NEAR $01480973 lea rax, [rax 0 +] qword $01480978 push rbx $01480979 mov rcx, #1000 d# $01480980 mov rbx, 1 d# $01480987 call (DO) offset NEAR $01480991 lea rax, [rax 0 +] qword \ LET u_ip1[i]=kk*(u_i[i+1]-2*u_i[i]+u_i[i-1])+u_i[i]: $01480998 fld $0147FAE0 tbyte-offset $0148099E mov rdi, [rbp 0 +] qword $014809A2 lea rdi, [rdi 1 +] qword $014809A6 shl rdi, 4 b# $014809AA fld [rdi $064DBE90 +] tbyte $014809B0 fld $011BAED0 tbyte-offset $014809B6 mov rdi, [rbp 0 +] qword $014809BA shl rdi, 4 b# $014809BE fld [rdi $064DBE90 +] tbyte $014809C4 fmulp ST(1), ST $014809C6 fsubp ST(1), ST $014809C8 mov rdi, [rbp 0 +] qword $014809CC lea rdi, [rdi -1 +] qword $014809D0 shl rdi, 4 b# $014809D4 fld [rdi $064DBE90 +] tbyte $014809DA faddp ST(1), ST $014809DC fmulp ST(1), ST $014809DE mov rdi, [rbp 0 +] qword $014809E2 shl rdi, 4 b# $014809E6 fld [rdi $064DBE90 +] tbyte $014809EC faddp ST(1), ST $014809EE mov rdi, [rbp 0 +] qword $014809F2 shl rdi, 4 b# $014809F6 fstp [rdi $064DFD40 +] tbyte $014809FC add [rbp 0 +] qword, 1 b# $01480A01 add [rbp 8 +] qword, 1 b# $01480A06 jno $01480998 offset NEAR $01480A0C add rbp, #24 b# \ LET u_ip1[0]=u_ip1[1]: \ b.c.: u_x(0, t) = 0 $01480A10 fld $064DFD50 tbyte-offset $01480A16 fstp $064DFD40 tbyte-offset \ LET u_ip1[nx-1]=u_ext: \ b.c.: u(10, t) = u_ext $01480A1C fld $0147FA80 tbyte-offset $01480A22 fstp $064E3BC0 tbyte-offset $01480A28 push rbx $01480A29 push $01480468 d# $01480A2E push $01480428 d# $01480A33 lea rbp, [rbp -8 +] qword $01480A37 mov [rbp 0 +] qword, $01480A44 d# $01480A3F jmp GCOPY+10 ( $0147B28A ) offset NEAR ...
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
pde2 floating point benchmark code krishna.myneni@ccreweb.org - 2013-03-04 18:02 -0800
Re: pde2 floating point benchmark code Mark Wills <markrobertwills@yahoo.co.uk> - 2013-03-04 23:23 -0800
Re: pde2 floating point benchmark code krishna.myneni@ccreweb.org - 2013-03-05 05:22 -0800
Re: pde2 floating point benchmark code Doug Hoffman <glidedog@gmail.com> - 2013-03-05 12:11 -0500
Re: pde2 floating point benchmark code krishna.myneni@ccreweb.org - 2013-03-05 16:11 -0800
Re: pde2 floating point benchmark code Doug Hoffman <glidedog@gmail.com> - 2013-03-06 04:26 -0500
Re: pde2 floating point benchmark code krishna.myneni@ccreweb.org - 2013-03-06 05:22 -0800
Re: pde2 floating point benchmark code Doug Hoffman <glidedog@gmail.com> - 2013-03-06 09:44 -0500
Re: pde2 floating point benchmark code krishna.myneni@ccreweb.org - 2013-03-05 16:17 -0800
Re: pde2 floating point benchmark code mhx@iae.nl (Marcel Hendrix) - 2013-03-06 23:06 +0200
Re: pde2 floating point benchmark code krishna.myneni@ccreweb.org - 2013-03-07 04:57 -0800
Re: pde2 floating point benchmark code m.a.m.hendrix@tue.nl - 2013-03-07 05:49 -0800
Re: pde2 floating point benchmark code mhx@iae.nl (Marcel Hendrix) - 2013-03-07 21:12 +0200
Re: pde2 floating point benchmark code krishna.myneni@ccreweb.org - 2013-03-07 16:07 -0800
Re: pde2 floating point benchmark code Doug Hoffman <glidedog@gmail.com> - 2013-03-10 09:17 -0400
Re: pde2 floating point benchmark code mhx@iae.nl (Marcel Hendrix) - 2013-03-10 18:33 +0200
Re: pde2 floating point benchmark code Doug Hoffman <glidedog@gmail.com> - 2013-03-11 04:54 -0400
Re: pde2 floating point benchmark code humptydumpty <ouatubi@gmail.com> - 2013-03-07 22:32 -0800
Re: pde2 floating point benchmark code Krishna Myneni <krishna.myneni@ccreweb.org> - 2013-03-08 05:19 -0800
Re: pde2 floating point benchmark code mhx@iae.nl (Marcel Hendrix) - 2013-03-08 21:04 +0200
Re: pde2 floating point benchmark code Krishna Myneni <krishna.myneni@ccreweb.org> - 2013-03-08 16:31 -0800
Re: pde2 floating point benchmark code Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2013-03-09 00:56 +0000
Re: pde2 floating point benchmark code Krishna Myneni <krishna.myneni@ccreweb.org> - 2013-03-08 19:52 -0800
Re: pde2 floating point benchmark code Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2013-03-09 09:09 +0000
Re: pde2 floating point benchmark code mhx@iae.nl (Marcel Hendrix) - 2013-03-09 13:37 +0200
Re: pde2 floating point benchmark code Krishna Myneni <krishna.myneni@ccreweb.org> - 2013-03-09 06:28 -0800
Re: pde2 floating point benchmark code mhx@iae.nl (Marcel Hendrix) - 2013-03-09 17:58 +0200
Re: pde2 floating point benchmark code humptydumpty <ouatubi@gmail.com> - 2013-03-08 12:23 -0800
Re: pde2 floating point benchmark code Krishna Myneni <krishna.myneni@ccreweb.org> - 2013-03-08 16:43 -0800
csiph-web