Skip to content

Commit

Permalink
Fix formatting in nbody benchmark.
Browse files Browse the repository at this point in the history
benchmarks/progs/nbody/*.m:
    As above.
  • Loading branch information
opturion-jfischer committed Dec 4, 2015
1 parent 6f45b93 commit edd6081
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions benchmarks/progs/nbody/nbody.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
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)
).

%-----------------------------------------------------------------------------%

:- 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.
Expand All @@ -71,12 +71,12 @@
!: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.
Expand All @@ -89,7 +89,7 @@

:- 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,
Expand Down Expand Up @@ -142,7 +142,7 @@

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,
Expand Down
12 changes: 6 additions & 6 deletions benchmarks/progs/nbody/nbody_foreign.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
% http://shootout.alioth.debian.org/
%
% Author: Julien Fischer <[email protected]>
%
%
% 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.
%
%-----------------------------------------------------------------------------%
Expand Down Expand Up @@ -50,7 +50,7 @@
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)
).

Expand Down Expand Up @@ -105,7 +105,7 @@

:- 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),
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/progs/nbody/nbody_mutvar.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
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)
).

Expand Down Expand Up @@ -75,7 +75,7 @@
!: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.
Expand All @@ -95,7 +95,7 @@

:- 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),
Expand Down Expand Up @@ -190,7 +190,7 @@
vx :: F,
vy :: F,
vz :: F,
mass :: float % Mass is a constant.
mass :: float % Mass is a constant.
).

:- pragma inline(get_position/6).
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/progs/nbody/nbody_ref.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
%
% Author: Julien Fischer <[email protected]>
%
% 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
%
Expand Down

0 comments on commit edd6081

Please sign in to comment.