[Debian-astro-commits] [gyoto] 47/221: Basic support for MPI functionality in the yorick plug-in: * mpispawn=, mpiclone=; * gyoto.Scenery_rayTrace() support was automatic; * new functions haveMPI(), havePTHREAD().
Thibaut Jean-Claude Paumard
thibaut at moszumanska.debian.org
Fri May 22 20:52:32 UTC 2015
This is an automated email from the git hooks/post-receive script.
thibaut pushed a commit to branch master
in repository gyoto.
commit 3745ef35f95051d4f52089eb7706afd8c37a9eb9
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date: Tue Oct 14 11:01:25 2014 +0200
Basic support for MPI functionality in the yorick plug-in:
* mpispawn=, mpiclone=;
* gyoto.Scenery_rayTrace() support was automatic;
* new functions haveMPI(), havePTHREAD().
---
lib/Scenery.C | 19 +++++++++-------
yorick/gyoto.i | 56 +++++++++++++++++++++++++++++++++++++++++++++++-
yorick/gyoto_Scenery.C | 11 +++++++++-
yorick/gyoto_namespace.i | 2 ++
yorick/gyoto_utils.C | 24 +++++++++++++++++++++
5 files changed, 102 insertions(+), 10 deletions(-)
diff --git a/lib/Scenery.C b/lib/Scenery.C
index 89155c4..1fcb55e 100644
--- a/lib/Scenery.C
+++ b/lib/Scenery.C
@@ -860,16 +860,19 @@ void Gyoto::Scenery::mpiSpawn(int nbchildren) {
if (mpi_team_->size()==nbchildren+1) return;
mpiTerminate(true);
}
- if (!mpi_env_) mpi_env_ = new mpi::environment();
- if (!mpi_world_) mpi_world_ = new mpi::communicator();
- MPI_Comm children_c;
- MPI_Comm_spawn(const_cast<char*>("gyoto-mpi-worker"),
- MPI_ARGV_NULL, nbchildren,
- MPI_INFO_NULL, 0, MPI_COMM_SELF, &children_c,
- MPI_ERRCODES_IGNORE);
+ if (nbchildren) {
+ if (!mpi_env_) mpi_env_ = new mpi::environment();
+ if (!mpi_world_) mpi_world_ = new mpi::communicator();
- mpi_team_ = new mpi::communicator(mpi::intercommunicator (children_c, mpi::comm_take_ownership).merge(false));
+ MPI_Comm children_c;
+ MPI_Comm_spawn(const_cast<char*>("gyoto-mpi-worker"),
+ MPI_ARGV_NULL, nbchildren,
+ MPI_INFO_NULL, 0, MPI_COMM_SELF, &children_c,
+ MPI_ERRCODES_IGNORE);
+
+ mpi_team_ = new mpi::communicator(mpi::intercommunicator (children_c, mpi::comm_take_ownership).merge(false));
+ }
}
void Gyoto::Scenery::mpiTerminate(bool keep_env) {
diff --git a/yorick/gyoto.i b/yorick/gyoto.i
index 3c3a800..5f2f8e8 100644
--- a/yorick/gyoto.i
+++ b/yorick/gyoto.i
@@ -48,6 +48,23 @@ extern gyoto_haveUDUNITS;
HAVE_UDUNITS=1 if compiled with UDUNITS, else 0.
*/
+extern gyoto_havePTHREAD;
+/* DOCUMENT have_pthread = gyoto.havePTHREAD()
+ Tell whether GYOTO was compiled with POSIX thread support
+ (multi-thread parallel computing)
+ OUTPUT:
+ HAVE_PTHREAD=1 if compiled with PTHREAD, else 0.
+*/
+
+extern gyoto_haveMPI;
+/* DOCUMENT have_mpi = gyoto.haveMPI()
+ Tell whether GYOTO was compiled with MPI support (multi-process
+ parallel computing)
+
+ OUTPUT:
+ HAVE_MPI=1 if compiled with MPI, else 0.
+*/
+
extern __gyoto_setErrorHandler;
/* xDOCUMENT __gyoto_setErrorHandler
Must be called once to attach the GYOTO error handler to Yorick's one
@@ -476,6 +493,23 @@ extern gyoto_Scenery;
nthreads=number of parallel threads to use in
gyoto.Scenery_rayTrace. This has no effect when
ray-tracing using the "data = scenery()" syntax below.
+
+ mpispawn=number of parallel MPI jobs (a.k.a. workers) to spawn for
+ ray-tracing using gyoto.Scenery_rayTrace(). Works only if
+ MPI support was built in. Spawned jobs may consume CPU
+ cycles even if they are idle. Use mpispawn=0 to terminate
+ those jobs. Always use mpiclone to send the current
+ Scenery to the workers before calling
+ gyoto.Scenery_rayTrace(). This can be done in the same
+ call as mpispawn:
+ sc, mpispawn=12, mpiclone=;
+
+ mpiclone=[anything]: clone this Scenery into the MPI workers (see
+ mpispawn). The workers do not stay synchonised
+ automatically. mpiclone must always be called right
+ before gyoto.Scenery_rayTrace() (i.e. after any
+ modification to the Scenery or any of the objects it
+ contains, and after having called mpispawn).
RAY-TRACING:
@@ -508,8 +542,28 @@ extern gyoto_Scenery_rayTrace
/* DOCUMENT res = gyoto.Scenery_rayTrace(scenery, imin, imax, jmin, jmax,
impactcoords)
- if IMPACTCOORDS is an unadorned, nil variable it is output. If it
+ If IMPACTCOORDS is an unadorned, nil variable it is output. If it
is an expression or non-nil, it is input.
+
+ This function is a very thin wrapper around the C++ method
+ Gyoto::Scenery::rayTrace(). It behaves exactly the same as the
+ command-line utility gyoto, except:
+
+ - the data are returned as a Yorick array instead of saved to a
+ FITS file (if multiple quantities are requested, they are
+ stored in successive planes in he output data cube);
+ - (i|j)(min|max) default to sane values.
+
+ Gyoto provides an alternative manner for ray-tracing, which is
+ simply calling the Scenery object without any keyword
+ argument. The two methods are not equivalent.
+
+ Example using MPI multi-processing:
+ #include "gyoto.i"
+ restore, gyoto;
+ sc = Scenery("../doc/examples/example-polish-doughnut.xml");
+ data = Scenery_rayTrace(sc(mpispawn=12, mpiclone=));
+ sc, mpispawn=0;
*/
func _gyoto_Scenery_adaptive_raytrace(sco, respmax, &computed) {
diff --git a/yorick/gyoto_Scenery.C b/yorick/gyoto_Scenery.C
index 214632e..4d48b52 100644
--- a/yorick/gyoto_Scenery.C
+++ b/yorick/gyoto_Scenery.C
@@ -166,10 +166,11 @@ extern "C" {
"abstol", "reltol",
"xmlwrite", "clone", "clonephoton",
"impactcoords", "nthreads",
+ "mpispawn", "mpiclone",
0
};
- YGYOTO_WORKER_INIT1(Scenery, Scenery, knames, 21)
+ YGYOTO_WORKER_INIT1(Scenery, Scenery, knames, 23)
// Get pointer
if (yarg_true(kiargs[++k])) {
@@ -248,6 +249,14 @@ extern "C" {
}
YGYOTO_WORKER_GETSET_LONG2(nThreads);
+#ifdef HAVE_MPI
+ YGYOTO_WORKER_RUN( mpiSpawn(ygets_l(iarg)) );
+ YGYOTO_WORKER_RUN( mpiClone() );
+#else
+ if ((iarg=kiargs[++k])>=0) GYOTO_WARNING << "No MPI in this GYOTO" << endl;
+ if ((iarg=kiargs[++k])>=0) GYOTO_WARNING << "No MPI in this GYOTO" << endl;
+#endif
+
// Get ray-traced image if there is a supplementary positional argument
if (
diff --git a/yorick/gyoto_namespace.i b/yorick/gyoto_namespace.i
index da1bdfd..8553209 100644
--- a/yorick/gyoto_namespace.i
+++ b/yorick/gyoto_namespace.i
@@ -3,6 +3,8 @@ gyoto=save(
haveCFITSIO=gyoto_haveCFITSIO,
haveBoost=gyoto_haveBoost,
haveUDUNITS=gyoto_haveUDUNITS,
+ havePTHREAD=gyoto_havePTHREAD,
+ haveMPI=gyoto_haveMPI,
loadPlugin=gyoto_loadPlugin,
Scenery=gyoto_Scenery,
diff --git a/yorick/gyoto_utils.C b/yorick/gyoto_utils.C
index 0d2be69..9916112 100644
--- a/yorick/gyoto_utils.C
+++ b/yorick/gyoto_utils.C
@@ -160,6 +160,30 @@ extern "C" {
}
void
+ Y_gyoto_havePTHREAD(int)
+ {
+ ypush_long(
+#if defined HAVE_PTHREAD
+ 1
+#else
+ 0
+#endif
+ );
+ }
+
+ void
+ Y_gyoto_haveMPI(int)
+ {
+ ypush_long(
+#if defined HAVE_MPI
+ 1
+#else
+ 0
+#endif
+ );
+ }
+
+ void
Y___gyoto_exportSupplier(int)
{
if (!YGyotoGlobalSupplier) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/gyoto.git
More information about the Debian-astro-commits
mailing list