forked from xavierleroy/ocamlmpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestnb.ml
70 lines (52 loc) · 1.59 KB
/
testnb.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(* $Id: test.ml 18 2003-03-31 14:22:57Z xleroy $ *)
(* Regression test *)
open Printf
open Mpi
let print_list printelt l =
printf "[ ";
List.iter (fun x-> printelt x; printf "; ") l;
printf " ]"
let print_int x = printf "%d" x
let print_float x = printf "%f" x
let print_intlist l = print_list print_int l
(* comm_size, comm_rank *)
let size = comm_size comm_world
let myrank = comm_rank comm_world
(* Non-blocking comms *)
(* test between 0 and 1 *)
let _ =
if myrank = 0 then (
printf "rank 0: testing variable length non-blocking comms, sending a list [16;32] to proc 1\n";
let req_pair = Mpi.isend_varlength [16;32] 1 8 comm_world in
wait_pair req_pair
)
else
if myrank = 1 then (
let req = Mpi.ireceive_varlength 0 8 comm_world in
let x = wait_receive req in
printf "rank 1: received "; print_intlist x; printf "\n"
)
let _ =
if myrank = 0 then (
printf "rank 0: testing plain non-blocking comms, sending integer 5 to proc 1\n";
let req = Mpi.isend 5 1 8 comm_world in
wait req
)
else
if myrank = 1 then (
let req = Mpi.ireceive 100 0 8 comm_world in
let x = wait_receive req in
printf "rank 1: received %d\n" x
)
let _ =
if myrank = 0 then (
printf "rank 0: testing non-blocking comms, sending a string to proc 1\n";
let reqpair = Mpi.isend_varlength "ocaml rules" 1 8 comm_world in
wait_pair reqpair
)
else
if myrank = 1 then (
let req = Mpi.ireceive_varlength 0 8 comm_world in
let x = wait_receive req in
printf "rank 1: received string: %s\n" x
)