caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Sundials/ML 2.5.0
@ 2014-11-28 13:39 Timothy Bourke
  2014-11-28 17:44 ` Gabriel Scherer
  0 siblings, 1 reply; 4+ messages in thread
From: Timothy Bourke @ 2014-11-28 13:39 UTC (permalink / raw)
  To: OCaml list; +Cc: Jun Inoue, Marc Pouzet

[-- Attachment #1: Type: text/plain, Size: 592 bytes --]

We are pleased to announce Sundials/ML, an OCaml interface to the
Sundials suite of numerical solvers (CVODE, CVODES, IDA, IDAS, KINSOL).

Information and documentation: http://inria-parkas.github.io/sundialsml/
Source code (BSD):             https://github.com/inria-parkas/sundialsml

opam install sundialsml # (requires Sundials 2.5.0)

We gratefully acknowledge the original authors of Sundials, and the
support of the ITEA 3 project 11004 MODRIO (Model driven physical
systems operation), Inria, and the Departement d'Informatique de l'ENS.

Timothy Bourke, Jun Inoue, and Marc Pouzet.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Sundials/ML 2.5.0
  2014-11-28 13:39 [Caml-list] Sundials/ML 2.5.0 Timothy Bourke
@ 2014-11-28 17:44 ` Gabriel Scherer
  2014-11-28 21:05   ` Jun Inoue
  0 siblings, 1 reply; 4+ messages in thread
From: Gabriel Scherer @ 2014-11-28 17:44 UTC (permalink / raw)
  To: Timothy Bourke, OCaml list, Jun Inoue, Marc Pouzet

Thanks for the significant effort put in documenting the bindings
(and, of course, the cool software and research); your "information
and documentation" page is impressive.

The page has a very interesting performance comparison of numeric code
partly or fully written in OCaml (using bigarrays of floats) -- and
the not-so-surprising results is that the run times of the OCaml
programs are between 100% and 200% of the run time of the reference C
implementation.

( http://inria-parkas.github.io/sundialsml/perf.opt.png )

I'm curious about this specific part of the explanation:

> For instance, some OCaml versions spend a significant fraction of their time
> in printf, and we were able to lower their ratios by instead using print_string and print_int.

The new 4.02 implementation of formats, due to Benoît Vaugon, should
be significantly faster (in my experience they match the performance of the
less-readable print_* sequence in most situations). Did you try those
OCaml versions with 4.02?

On Fri, Nov 28, 2014 at 2:39 PM, Timothy Bourke <Timothy.Bourke@inria.fr> wrote:
> We are pleased to announce Sundials/ML, an OCaml interface to the
> Sundials suite of numerical solvers (CVODE, CVODES, IDA, IDAS, KINSOL).
>
> Information and documentation: http://inria-parkas.github.io/sundialsml/
> Source code (BSD):             https://github.com/inria-parkas/sundialsml
>
> opam install sundialsml # (requires Sundials 2.5.0)
>
> We gratefully acknowledge the original authors of Sundials, and the
> support of the ITEA 3 project 11004 MODRIO (Model driven physical
> systems operation), Inria, and the Departement d'Informatique de l'ENS.
>
> Timothy Bourke, Jun Inoue, and Marc Pouzet.
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Sundials/ML 2.5.0
  2014-11-28 17:44 ` Gabriel Scherer
@ 2014-11-28 21:05   ` Jun Inoue
  2014-11-28 22:20     ` Jun Inoue
  0 siblings, 1 reply; 4+ messages in thread
From: Jun Inoue @ 2014-11-28 21:05 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: Timothy Bourke, OCaml list, Marc Pouzet

[-- Attachment #1: Type: text/plain, Size: 4077 bytes --]

Thank you for sharing this interesting information, Gabriel!  We
benchmarked the code exclusively with 4.01.0 and didn't know about the
performance boost in printf.

I just measured the performance with
examples/kinsol/serial/kinFerTron_dns.ml, which was one of the
examples that had the most pronounced effect.  As you suggest, the
numbers are a lot closer with 4.02.1.  The median wall-clock times of
10 runs were:

printf,  OCaml 4.02.1: 1.76[s]
print_*, OCaml 4.02.1: 1.62[s]
printf,  OCaml 4.01.0: 2.04[s]
print_*, OCaml 4.01.0: 1.70[s]

The overhead of using printf is about 8% in 4.02.1, as opposed to
about 20% in 4.01.0.  So in 4.02 the effect is noticeably smaller,
though not unmeasurable.  We should note this in the doc in a future
release.

FYI, the experiment can be reproduced as follows (in bash syntax),
using the attached patch (referred to as
/tmp/kinFerTron_dns_printf.diff below):

# Start at the root of the source tree.
opam switch 4.02.1; eval `opam config env`
./configure && make clean all
cd examples/kinsol/serial
# Measure without modification.
make PERF_DATA_POINTS=10 kinFerTron_dns.opt.perf
../../utils/crunchperf -m kinFerTron_dns.opt.perf >
no-printf-4.02.1-kinFerTron_dns.opt.perf
# Apply patch and measure again.
patch -p4 < /tmp/kinFerTron_dns_printf.diff
make PERF_DATA_POINTS=10 kinFerTron_dns.opt.perf
../../utils/crunchperf -m kinFerTron_dns.opt.perf >
printf-4.02.1-kinFerTron_dns.opt.perf
# Undo changes.
patch -p4 -R < /tmp/kinFerTron_dns_printf.diff

cd ../../..
# Back at the root of the source tree.
opam switch 4.01.0; eval `opam config env`
# (Basically the same thing as above)
./configure && make clean all
cd examples/kinsol/serial
make PERF_DATA_POINTS=10 kinFerTron_dns.opt.perf
../../utils/crunchperf -m kinFerTron_dns.opt.perf >
no-printf-4.01.0-kinFerTron_dns.opt.perf
patch -p4 < /tmp/kinFerTron_dns_printf.diff
make PERF_DATA_POINTS=10 kinFerTron_dns.opt.perf
../../utils/crunchperf -m kinFerTron_dns.opt.perf >
printf-4.01.0-kinFerTron_dns.opt.perf

# Summarize results
for i in *kinFerTron_dns.opt.perf; do printf "\n[$i]\n";
../../utils/crunchperf -s $i; done

On Fri, Nov 28, 2014 at 6:44 PM, Gabriel Scherer
<gabriel.scherer@gmail.com> wrote:
> Thanks for the significant effort put in documenting the bindings
> (and, of course, the cool software and research); your "information
> and documentation" page is impressive.
>
> The page has a very interesting performance comparison of numeric code
> partly or fully written in OCaml (using bigarrays of floats) -- and
> the not-so-surprising results is that the run times of the OCaml
> programs are between 100% and 200% of the run time of the reference C
> implementation.
>
> ( http://inria-parkas.github.io/sundialsml/perf.opt.png )
>
> I'm curious about this specific part of the explanation:
>
>> For instance, some OCaml versions spend a significant fraction of their time
>> in printf, and we were able to lower their ratios by instead using print_string and print_int.
>
> The new 4.02 implementation of formats, due to Benoît Vaugon, should
> be significantly faster (in my experience they match the performance of the
> less-readable print_* sequence in most situations). Did you try those
> OCaml versions with 4.02?
>
> On Fri, Nov 28, 2014 at 2:39 PM, Timothy Bourke <Timothy.Bourke@inria.fr> wrote:
>> We are pleased to announce Sundials/ML, an OCaml interface to the
>> Sundials suite of numerical solvers (CVODE, CVODES, IDA, IDAS, KINSOL).
>>
>> Information and documentation: http://inria-parkas.github.io/sundialsml/
>> Source code (BSD):             https://github.com/inria-parkas/sundialsml
>>
>> opam install sundialsml # (requires Sundials 2.5.0)
>>
>> We gratefully acknowledge the original authors of Sundials, and the
>> support of the ITEA 3 project 11004 MODRIO (Model driven physical
>> systems operation), Inria, and the Departement d'Informatique de l'ENS.
>>
>> Timothy Bourke, Jun Inoue, and Marc Pouzet.
>>



-- 
Jun Inoue

[-- Attachment #2: kinFerTron_dns_printf.diff --]
[-- Type: text/plain, Size: 3091 bytes --]

diff --git a/examples/kinsol/serial/kinFerTron_dns.ml b/examples/kinsol/serial/kinFerTron_dns.ml
index 525cffc..edf4bb8 100644
--- a/examples/kinsol/serial/kinFerTron_dns.ml
+++ b/examples/kinsol/serial/kinFerTron_dns.ml
@@ -115,21 +115,13 @@ let set_initial_guess2 udata =
 
 (* Print first lines of output (problem description) *)
 let print_header fnormtol scsteptol =
-  print_string "\nFerraris and Tronconi test problem\n";
-  print_string "Tolerance parameters:\n";
+  printf "\nFerraris and Tronconi test problem\n";
+  printf "Tolerance parameters:\n";
   printf "  fnormtol  = %10.6g\n  scsteptol = %10.6g\n" fnormtol scsteptol
 
 (* Print solution *)
 let print_output u = printf " %8.6g  %8.6g\n" u.{0} u.{1}
 
-let print_string_5d s i =
-  print_string s;
-  if i < 10 then print_string "    "
-  else if i < 100 then print_string "   "
-  else if i < 1000 then print_string "  "
-  else if i < 10000 then print_string " ";
-  print_int i
-
 (* Print final statistics contained in iopt *)
 (* For high NUM_REPS, the cost of OCaml printf becomes important! *)
 let print_final_stats kmem =
@@ -137,21 +129,20 @@ let print_final_stats kmem =
   let nfe  = Kinsol.get_num_func_evals kmem in
   let nje  = Kinsol.Dls.get_num_jac_evals kmem in
   let nfeD = Kinsol.Dls.get_num_func_evals kmem in
-  print_string "Final Statistics:\n";
-  print_string_5d "  nni = " nni;
-  print_string_5d "    nfe  = " nfe;
-  print_string_5d " \n  nje = " nje;
-  print_string_5d "    nfeD = " nfeD;
-  print_string " \n"
+  printf "Final Statistics:\n";
+  printf "  nni = %5d    nfe  = %5d \n" nni nfe;
+  printf "  nje = %5d    nfeD = %5d \n" nje nfeD
 
 (* MAIN PROGRAM *)
 let solve_it kmem u s glstr mset =
   print_newline ();
-  print_string (if mset==1 then "Exact Newton" else "Modified Newton");
-  if not glstr then print_newline () else print_string " with line search\n";
+  if mset == 1 then printf "Exact Newton"
+  else printf "Modified Newton";
+  if not glstr then printf "\n"
+  else printf " with line search\n";
   Kinsol.set_max_setup_calls kmem mset;
   ignore (Kinsol.solve kmem u glstr s s);
-  print_string "Solution:\n  [x1,x2] = ";
+  printf "Solution:\n  [x1,x2] = ";
   print_output (Nvector.unwrap u);
   print_final_stats kmem
 
@@ -193,9 +184,9 @@ let main () =
 
   (* --------------------------- *)
 
-  print_string "\n------------------------------------------\n";
-  print_string "\nInitial guess on lower bounds\n";
-  print_string "  [x1,x2] = ";
+  printf "\n------------------------------------------\n";
+  printf "\nInitial guess on lower bounds\n";
+  printf "  [x1,x2] = ";
   print_output u1;
 
   RealArray.blit u1 u;
@@ -218,9 +209,9 @@ let main () =
 
   (* --------------------------- *)
 
-  print_string "\n------------------------------------------\n";
-  print_string "\nInitial guess in middle of feasible region\n";
-  print_string "  [x1,x2] = ";
+  printf "\n------------------------------------------\n";
+  printf "\nInitial guess in middle of feasible region\n";
+  printf "  [x1,x2] = ";
   print_output u2;
 
   RealArray.blit u2 u;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Sundials/ML 2.5.0
  2014-11-28 21:05   ` Jun Inoue
@ 2014-11-28 22:20     ` Jun Inoue
  0 siblings, 0 replies; 4+ messages in thread
From: Jun Inoue @ 2014-11-28 22:20 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: Timothy Bourke, OCaml list, Marc Pouzet

On Fri, Nov 28, 2014 at 10:05 PM, Jun Inoue <jun.lambda@gmail.com> wrote:
> Thank you for sharing this interesting information, Gabriel!  We
> benchmarked the code exclusively with 4.01.0 and didn't know about the
> performance boost in printf.
>
> I just measured the performance with
> examples/kinsol/serial/kinFerTron_dns.ml, which was one of the
> examples that had the most pronounced effect.  As you suggest, the
> numbers are a lot closer with 4.02.1.  The median wall-clock times of
> 10 runs were:
>
> printf,  OCaml 4.02.1: 1.76[s]
> print_*, OCaml 4.02.1: 1.62[s]
> printf,  OCaml 4.01.0: 2.04[s]
> print_*, OCaml 4.01.0: 1.70[s]
>
> The overhead of using printf is about 8% in 4.02.1, as opposed to
> about 20% in 4.01.0.  So in 4.02 the effect is noticeably smaller,
> though not unmeasurable.  We should note this in the doc in a future
> release.

Correction: the numbers are the medians of the ratios between OCaml
and C (wall-clock time).  The C version takes right about 1[s], so the
conclusion is morally the same, though.

>
> FYI, the experiment can be reproduced as follows (in bash syntax),
> using the attached patch (referred to as
> /tmp/kinFerTron_dns_printf.diff below):
>
> # Start at the root of the source tree.
> opam switch 4.02.1; eval `opam config env`
> ./configure && make clean all
> cd examples/kinsol/serial
> # Measure without modification.
> make PERF_DATA_POINTS=10 kinFerTron_dns.opt.perf
> ../../utils/crunchperf -m kinFerTron_dns.opt.perf >
> no-printf-4.02.1-kinFerTron_dns.opt.perf
> # Apply patch and measure again.
> patch -p4 < /tmp/kinFerTron_dns_printf.diff
> make PERF_DATA_POINTS=10 kinFerTron_dns.opt.perf
> ../../utils/crunchperf -m kinFerTron_dns.opt.perf >
> printf-4.02.1-kinFerTron_dns.opt.perf
> # Undo changes.
> patch -p4 -R < /tmp/kinFerTron_dns_printf.diff
>
> cd ../../..
> # Back at the root of the source tree.
> opam switch 4.01.0; eval `opam config env`
> # (Basically the same thing as above)
> ./configure && make clean all
> cd examples/kinsol/serial
> make PERF_DATA_POINTS=10 kinFerTron_dns.opt.perf
> ../../utils/crunchperf -m kinFerTron_dns.opt.perf >
> no-printf-4.01.0-kinFerTron_dns.opt.perf
> patch -p4 < /tmp/kinFerTron_dns_printf.diff
> make PERF_DATA_POINTS=10 kinFerTron_dns.opt.perf
> ../../utils/crunchperf -m kinFerTron_dns.opt.perf >
> printf-4.01.0-kinFerTron_dns.opt.perf
>
> # Summarize results
> for i in *kinFerTron_dns.opt.perf; do printf "\n[$i]\n";
> ../../utils/crunchperf -s $i; done
>
> On Fri, Nov 28, 2014 at 6:44 PM, Gabriel Scherer
> <gabriel.scherer@gmail.com> wrote:
>> Thanks for the significant effort put in documenting the bindings
>> (and, of course, the cool software and research); your "information
>> and documentation" page is impressive.
>>
>> The page has a very interesting performance comparison of numeric code
>> partly or fully written in OCaml (using bigarrays of floats) -- and
>> the not-so-surprising results is that the run times of the OCaml
>> programs are between 100% and 200% of the run time of the reference C
>> implementation.
>>
>> ( http://inria-parkas.github.io/sundialsml/perf.opt.png )
>>
>> I'm curious about this specific part of the explanation:
>>
>>> For instance, some OCaml versions spend a significant fraction of their time
>>> in printf, and we were able to lower their ratios by instead using print_string and print_int.
>>
>> The new 4.02 implementation of formats, due to Benoît Vaugon, should
>> be significantly faster (in my experience they match the performance of the
>> less-readable print_* sequence in most situations). Did you try those
>> OCaml versions with 4.02?
>>
>> On Fri, Nov 28, 2014 at 2:39 PM, Timothy Bourke <Timothy.Bourke@inria.fr> wrote:
>>> We are pleased to announce Sundials/ML, an OCaml interface to the
>>> Sundials suite of numerical solvers (CVODE, CVODES, IDA, IDAS, KINSOL).
>>>
>>> Information and documentation: http://inria-parkas.github.io/sundialsml/
>>> Source code (BSD):             https://github.com/inria-parkas/sundialsml
>>>
>>> opam install sundialsml # (requires Sundials 2.5.0)
>>>
>>> We gratefully acknowledge the original authors of Sundials, and the
>>> support of the ITEA 3 project 11004 MODRIO (Model driven physical
>>> systems operation), Inria, and the Departement d'Informatique de l'ENS.
>>>
>>> Timothy Bourke, Jun Inoue, and Marc Pouzet.
>>>
>
>
>
> --
> Jun Inoue



-- 
Jun Inoue

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-11-28 22:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-28 13:39 [Caml-list] Sundials/ML 2.5.0 Timothy Bourke
2014-11-28 17:44 ` Gabriel Scherer
2014-11-28 21:05   ` Jun Inoue
2014-11-28 22:20     ` Jun Inoue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).