Revision 56ba07c329465d57aad4bff8e774bd67787c064d authored by Roberto Di Cosmo on 07 November 2011, 21:06:40 UTC, committed by Roberto Di Cosmo on 07 November 2011, 21:06:40 UTC
1 parent 92d670d
utils.ml
(**************************************************************************)
(* Generic testing framework for evaluating speedup on Parmap *)
(* a multi-core *)
(* *)
(* Author(s): Roberto Di Cosmo *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU General Public License as *)
(* published by the Free Software Foundation, either version 2 of the *)
(* License, or (at your option) any later version. *)
(**************************************************************************)
open Parmap
let scale_test ?(inorder=true) ?(step=1) compute sequence iter nprocmin nprocmax =
Printf.eprintf "Testing scalability with %d iterations on %d to %d cores, step %d\n" iter nprocmin nprocmax step;
let rseq,tseq =
let d=Unix.gettimeofday() in
match sequence with
L l -> let l'=List.map compute l in l',(Unix.gettimeofday() -. d)
| A a -> let l'=Array.to_list(Array.map compute a) in l',(Unix.gettimeofday() -. d)
in
Printf.eprintf "Sequential execution takes %f seconds\n" tseq;
for incr = 0 to (nprocmax-nprocmin)/step do
let i = nprocmin + incr in
let tot=ref 0.0 in
for j=1 to iter do
let d=Unix.gettimeofday() in
let rpar=parmap ~ncores:i compute sequence in
tot:=!tot+.(Unix.gettimeofday()-.d);
if rseq<>rpar then
begin
if (List.sort compare rseq) <> (List.sort compare rpar) then
Printf.eprintf "Parmap failure: result mismatch!\n"
else
if inorder then Printf.eprintf "Parmap failure: result order was expected to be preserved, and is not.\n"
else Printf.eprintf "Parmap warning: result order is not preserved.\n"
end
done;
let speedup=tseq /. (!tot /. (float iter)) in
Printf.eprintf "Speedup with %d cores (average on %d iterations): %f (tseq=%f, tpar=%f)\n" i iter speedup tseq (!tot /. (float iter))
done;
rseq
;;
Computing file changes ...