Fix formatting in nbody benchmark.

benchmarks/progs/nbody/*.m:
    As above.
This commit is contained in:
Julien Fischer
2015-12-04 14:25:09 +11:00
parent 6f45b93ddc
commit edd60810d4
4 changed files with 17 additions and 17 deletions

View File

@@ -41,7 +41,7 @@ main(!IO) :-
io.format("%.9f\n", [f(energy(NBodySystem0))], !IO),
int.fold_up(advance(0.01), 1, N, NBodySystem0, NBodySystem),
io.format("%.9f\n", [f(energy(NBodySystem))], !IO)
else
else
io.set_exit_status(1, !IO)
).
@@ -49,7 +49,7 @@ main(!IO) :-
:- func new_n_body_system = (bodies::array_uo) is det.
new_n_body_system =
new_n_body_system =
offset_momentum(array([sun, jupiter, saturn, uranus, neptune])).
:- func offset_momentum(bodies::array_di) = (bodies::array_uo) is det.
@@ -71,12 +71,12 @@ offset_momentum_2(Body, !Px, !Py, !Pz) :-
!:Px = !.Px + Body ^ vx * Body ^ mass,
!:Py = !.Py + Body ^ vy * Body ^ mass,
!:Pz = !.Pz + Body ^ vz * Body ^ mass.
%-----------------------------------------------------------------------------%
:- func energy(bodies::array_ui) = (float::out) is det.
energy(Bodies) = Energy :-
energy(Bodies) = Energy :-
int.fold_up(energy_2(Bodies), 0, Bodies ^ max, 0.0, Energy).
:- pred energy_2(bodies::array_ui, int::in, float::in, float::out) is det.
@@ -89,7 +89,7 @@ energy_2(Bodies, I, !E) :-
:- pred energy_3(bodies::array_ui, body::in, int::in,
float::in, float::out) is det.
energy_3(Bodies, B, J, !E) :-
B2 = Bodies ^ unsafe_elem(J),
Dx = B ^ x - B2 ^ x,
@@ -142,7 +142,7 @@ advance_3(Dt, J, !B, !Bodies) :-
update_pos(Dt, I, !Bodies) :-
some [!Body] (
!:Body = !.Bodies ^ unsafe_elem(I),
!:Body = !.Bodies ^ unsafe_elem(I),
!Body ^ x := !.Body ^ x + Dt * !.Body ^ vx,
!Body ^ y := !.Body ^ y + Dt * !.Body ^ vy,
!Body ^ z := !.Body ^ z + Dt * !.Body ^ vz,

View File

@@ -6,14 +6,14 @@
% http://shootout.alioth.debian.org/
%
% Author: Julien Fischer <juliensf@csse.unimelb.edu.au>
%
%
% A variant of the nbody benchmark in nbody.m that uses mutable data
% structures defined in whatever the target language is.
%
% Compile with: -O5 --intermodule-optimization
%
% Compile with: -O5 --intermodule-optimization
%
% For C (gcc) add: --cflags="-O3 -mfpmath=sse -msse3"
%
%
% TODO: support Erlang.
%
%-----------------------------------------------------------------------------%
@@ -50,7 +50,7 @@ main(!IO) :-
int.fold_up(advance(0.01, NBodySystem), 1, N, !IO),
energy(NBodySystem, FinalEnergy, !IO),
io.format("%.9f\n", [f(FinalEnergy)], !IO)
else
else
io.set_exit_status(1, !IO)
).
@@ -105,7 +105,7 @@ energy_2(Bodies, I, !E, !IO) :-
:- pred energy_3(bodies::array_ui, body_ref::in, int::in,
float::in, float::out, io::di, io::uo) is det.
energy_3(Bodies, B, J, !E, !IO) :-
B2 = Bodies ^ unsafe_elem(J),
get_position(B, Bx, By, Bz, !IO),

View File

@@ -46,7 +46,7 @@ main(!IO) :-
int.fold_up(advance(0.01, NBodySystem), 1, N, !IO),
energy(NBodySystem, FinalEnergy, !IO),
io.format("%.9f\n", [f(FinalEnergy)], !IO)
else
else
io.set_exit_status(1, !IO)
).
@@ -75,7 +75,7 @@ offset_momentum_2(Body, !Px, !Py, !Pz, !IO) :-
!:Px = !.Px + Vx * Body ^ mass,
!:Py = !.Py + Vy * Body ^ mass,
!:Pz = !.Pz + Vz * Body ^ mass.
%-----------------------------------------------------------------------------%
:- pred energy(bodies::array_ui, float::out, io::di, io::uo) is det.
@@ -95,7 +95,7 @@ energy_2(Bodies, I, !E, !IO) :-
:- pred energy_3(bodies::array_ui, body::in, int::in,
float::in, float::out, io::di, io::uo) is det.
energy_3(Bodies, B, J, !E, !IO) :-
B2 = Bodies ^ unsafe_elem(J),
get_position(B, Bx, By, Bz, !IO),
@@ -190,7 +190,7 @@ make_body(Body, MutBody, !IO) :-
vx :: F,
vy :: F,
vz :: F,
mass :: float % Mass is a constant.
mass :: float % Mass is a constant.
).
:- pragma inline(get_position/6).

View File

@@ -7,7 +7,7 @@
%
% Author: Julien Fischer <juliensf@csse.unimelb.edu.au>
%
% A variant of the nbody benchmark in nbody.m that uses stores and refernces.
% A variant of the nbody benchmark in nbody.m that uses stores and references.
%
% Compile with: -O5 --intermodule-optimization --ctgc
%