|
From: <den...@us...> - 2009-12-26 01:46:09
|
Revision: 22
http://dsim.svn.sourceforge.net/dsim/?rev=22&view=rev
Author: denis_arnaud
Date: 2009-12-26 01:46:01 +0000 (Sat, 26 Dec 2009)
Log Message:
-----------
[Test] Added a simple test to check the MPI installation.
Modified Paths:
--------------
trunk/dsim/test/boost/mpi/Makefile.am
Added Paths:
-----------
trunk/dsim/test/boost/mpi/mpi_c.cpp
Modified: trunk/dsim/test/boost/mpi/Makefile.am
===================================================================
--- trunk/dsim/test/boost/mpi/Makefile.am 2009-12-26 01:40:41 UTC (rev 21)
+++ trunk/dsim/test/boost/mpi/Makefile.am 2009-12-26 01:46:01 UTC (rev 22)
@@ -3,12 +3,14 @@
MAINTAINERCLEANFILES = Makefile.in
-check_PROGRAMS = mpi
+check_PROGRAMS = mpi_c mpi
-#mpi_c_SOURCES = mpi_c.cpp
-#mpi_c_CXXFLAGS = $(MPICH2_CFLAGS)
-#mpi_c_LDFLAGS = $(MPICH2_LIB)
-#mpi_c_LDADD =
+# mpi_c must be compiled with mpic++
+# Note: mpic++/mpiCC is a wrapper around the MPI C++ compiler, and knows
+# where MPI is installed. So, there is no need to specify any other
+# CFLAGS or LDFLAGS at that stage.
+mpi_c: mpi_c.cpp
+ mpic++ -o $@ $<
mpi_SOURCES = mpi.cpp
mpi_CXXFLAGS = $(BOOST_CFLAGS) $(MPICH2_CFLAGS)
Added: trunk/dsim/test/boost/mpi/mpi_c.cpp
===================================================================
--- trunk/dsim/test/boost/mpi/mpi_c.cpp (rev 0)
+++ trunk/dsim/test/boost/mpi/mpi_c.cpp 2009-12-26 01:46:01 UTC (rev 22)
@@ -0,0 +1,35 @@
+//
+// Simple test of MPI, just to check that a MPI library is installed correctly
+//Source: http://www.boost.org/doc/libs/1_41_0/doc/html/mpi/getting_started.html
+#include <mpi.h>
+#include <iostream>
+
+// ///////////////////// M A I N //////////////////////
+int main(int argc, char* argv[]) {
+ MPI_Init (&argc, &argv);
+
+ int rank = -1;
+
+ MPI_Comm_rank (MPI_COMM_WORLD, &rank);
+
+ if (rank == 0) {
+ int value = 17;
+ int result = MPI_Send(&value, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
+
+ if (result == MPI_SUCCESS) {
+ std::cout << "Rank 0 OK!" << std::endl;
+ }
+
+ } else if (rank == 1) {
+ int value;
+ int result = MPI_Recv(&value, 1, MPI_INT, 0, 0, MPI_COMM_WORLD,
+ MPI_STATUS_IGNORE);
+
+ if (result == MPI_SUCCESS && value == 17)
+ std::cout << "Rank 1 OK!" << std::endl;
+ }
+
+ MPI_Finalize();
+
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|