Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
ocamlmpi reduce_int_array, showstopper?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-09-04 (18:26)
From: Mike Lin <mikelin@M...>
Subject: ocamlmpi reduce_int_array, showstopper?
Hi Sylvain, Xavier,
I have encountered what seems to be a serious problem with
reduce_int_array in ocamlmpi, namely, in a trivial test case it
successfully returns incorrect results. This is my test code

(* ocamlopt -o test -I +ocamlmpi mpi.cmxa *)
let me = Mpi.comm_rank Mpi.comm_world;;
let n = Mpi.comm_size Mpi.comm_world;;
let k = 1

let src = Array.make 1 k;;
let dest = Array.make 1 0;;
Mpi.reduce_int_array src dest Mpi.Int_sum 0 Mpi.comm_world;;
if me = 0 then Printf.printf "using reduce_int_array, expected: %d
got: %d\n" (n*k) dest.(0);;

let srcf = Array.make 1 (float k);;
let destf = Array.make 1 0.;;
Mpi.reduce_float_array srcf destf Mpi.Float_sum 0 Mpi.comm_world;;
if me = 0 then Printf.printf "using reduce_float_array, expected: %.1f
got: %.1f\n" (float (n*k)) destf.(0);;

I ran this on n=8 processors on NCSA Abe and the output is

using reduce_int_array, expected: 8 got: 0
using reduce_float_array, expected: 8.0 got: 8.0

If I change k to 1,000,000 I get:

using reduce_int_array, expected: 8000000 got: 4000000
using reduce_float_array, expected: 8000000.0 got: 8000000.0

[mikelin@honest3 ~/]$ uname -a
Linux 2.6.18-92.1.10.el5_lustre.1.6.6smp-perfctr
#7 SMP Tue Nov 10 10:41:00 CST 2009 x86_64 x86_64 x86_64 GNU/Linux
[mikelin@honest3 ~/]$ which mpiexec

see also:

I know the ocamlmpi code has been stable for some time, but I wonder
if it's been tested on x86_64? Let me know if you're able to reproduce