]> git.donarmstrong.com Git - libparallel-mpi-simple-perl.git/commitdiff
add ANY_SOURCE
authorAlex Gough <alex@earth.li>
Fri, 19 Aug 2011 07:48:24 +0000 (19:48 +1200)
committerAlex Gough <alex@earth.li>
Fri, 19 Aug 2011 07:48:24 +0000 (19:48 +1200)
Simple.pm
Simple.xs
ic.pl
test.pl

index 614921ac2e2d530341a671c9149cc0a8456a6abb..9e9b132592015c0b9abc16a2bbe69174ca50e5a9 100644 (file)
--- a/Simple.pm
+++ b/Simple.pm
@@ -15,7 +15,7 @@ sub import {
     my $call = (caller())[0];
     no strict 'refs';
     # subs (MPI_ function calls)
-    foreach (qw(Init Finalize COMM_WORLD Comm_rank Comm_size
+    foreach (qw(Init Finalize COMM_WORLD ANY_SOURCE Comm_rank Comm_size
                Recv Send Barrier Bcast Gather
                Scatter Allgather Alltoall Reduce
                Comm_compare Comm_dup Comm_free Comm_split
index 02911444356773ed6865e02f0e7ac897cb2e782c..288ad5930eae4ddeac2d4fe6f7a3eea054ef921c 100644 (file)
--- a/Simple.xs
+++ b/Simple.xs
@@ -100,6 +100,11 @@ SV* COMM_WORLD () {
   return newSViv((IV)MPI_COMM_WORLD);
 }
 
+/* returns SV whose IV slot is a cast pointer to the MPI_ANY_SOURCE value */
+SV* ANY_SOURCE () {
+  return newSViv((IV)MPI_ANY_SOURCE);
+}
+
 /* calls MPI_Barrier for comm */
 int Barrier (SV*comm) {
   MPI_Barrier((MPI_Comm)SvIVX(comm));
@@ -249,6 +254,9 @@ _Comm_size (comm)
 SV *
 COMM_WORLD ()
 
+SV *
+ANY_SOURCE ()
+
 int
 Barrier (comm)
        SV *    comm
diff --git a/ic.pl b/ic.pl
index 1ec102918ea7be494fcf4971cd8198e5ec7daf10..baef203031bb26a7cb661c692d61bf2670c8477b 100755 (executable)
--- a/ic.pl
+++ b/ic.pl
@@ -157,6 +157,22 @@ MPI_Barrier(MPI_COMM_WORLD);
     }
 }
 
+MPI_Barrier(MPI_COMM_WORLD);
+if ($rank == 0) {
+    my $msg = "Sending from ANY";
+    MPI_Send($msg,1,0,MPI_COMM_WORLD);
+    print "ok 25 # sent from ANY\n";
+}
+else {
+    my $msg = MPI_Recv(MPI_ANY_SOURCE,0,MPI_COMM_WORLD);
+    if ($msg =~ /Sending from ANY/) {
+       print "ok 26 # receive from ANY_SOURCE";
+    }
+    else {
+       print "not ok 26 # receive from ANY_SOURCE";
+    }
+}
+
 MPI_Finalize();
 exit(0);
 
diff --git a/test.pl b/test.pl
index a55463e95acc115e42a4f32ed2f1d14acdb6dd0e..4eb8eb820e8669983c6e0f80f182d0c9c6772061 100644 (file)
--- a/test.pl
+++ b/test.pl
@@ -10,8 +10,8 @@ $incs .= " -I$_" foreach @INC;
 my @newout = sort {
     (($a =~ /(\d+)/g)[0] <=> ($b =~ /(\d+)/g)[0])
 } `$mpirun -np 2 $^X $incs ic.pl`;
-print "1..24\n";
-if (@newout < 24) {
+print "1..26\n";
+if (@newout < 25) {
     print "not ok 1 # mpirun failed.  Do you need to start mpd?\n";
 }
 print @newout;