From c60514f89ba1cc91cd30e20ecb70ebd637b07df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Thu, 2 Feb 2012 10:00:17 +0000 Subject: [PATCH] add some MPI tests. --- library/lammpi/examples/hello.yap | 13 +++++++++++++ library/lammpi/examples/talk.yap | 30 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 library/lammpi/examples/hello.yap create mode 100644 library/lammpi/examples/talk.yap diff --git a/library/lammpi/examples/hello.yap b/library/lammpi/examples/hello.yap new file mode 100644 index 000000000..fdfd7eb2f --- /dev/null +++ b/library/lammpi/examples/hello.yap @@ -0,0 +1,13 @@ + +:- use_module(library(lam_mpi)). + +:- initialization(main). + +main :- + mpi_init, + mpi_comm_size(Sz), + mpi_comm_rank(Rank), + mpi_version(V0,V1), + format('MPI ~d.~d workers=~d id=~d~n', [V0,V1,Sz, Rank]), + mpi_finalize. + diff --git a/library/lammpi/examples/talk.yap b/library/lammpi/examples/talk.yap new file mode 100644 index 000000000..d366146a4 --- /dev/null +++ b/library/lammpi/examples/talk.yap @@ -0,0 +1,30 @@ + +:- use_module(library(lam_mpi)). + +:- initialization(main). + +main :- + mpi_init, + mpi_comm_size(2), + mpi_comm_rank(Rank), + do_comm(Rank), + mpi_finalize. + +do_comm(0) :- + between(1,10,I), + gen_list(I,List), + mpi_send(List, 1, I), + fail. +do_comm(0). +do_comm(1) :- + between(1,10,I), + mpi_recv(0, I, List), + writeln(I:List), + fail. +do_comm(1). + +gen_list(0,[]) :- !. +gen_list(I,I.List) :- + I1 is I-1, + gen_list(I1,List). +