[cig-commits] r4112 - cs/pythia/trunk/mpi
leif at geodynamics.org
leif at geodynamics.org
Wed Jul 26 20:20:32 PDT 2006
Author: leif
Date: 2006-07-26 20:20:32 -0700 (Wed, 26 Jul 2006)
New Revision: 4112
Modified:
cs/pythia/trunk/mpi/__init__.py
cs/pythia/trunk/mpi/_mpimodule.h
Log:
Tweaked mpi's __init__.py so that CitcomS works even
in the --disable-embedding case. Also, be careful
to call PyImport_AppendInittab() only once.
Modified: cs/pythia/trunk/mpi/__init__.py
===================================================================
--- cs/pythia/trunk/mpi/__init__.py 2006-07-26 22:56:13 UTC (rev 4111)
+++ cs/pythia/trunk/mpi/__init__.py 2006-07-27 03:20:32 UTC (rev 4112)
@@ -21,23 +21,35 @@
return timingCenter().timer(name)
-# attempt to load the mpi python bindings
-try:
- import _mpi
-except:
-
- def world():
+def world():
+ try:
+ import _mpi
+ except:
from DummyCommunicator import DummyCommunicator
return DummyCommunicator()
- def inParallel(): return 0
- def processors(): return 1
+ else:
+ import Communicator
+ return Communicator.world()
+
+
+def inParallel():
+ try:
+ import _mpi
+ except:
+ return 0
+ else:
+ return 1
+
+
+def processors():
+ try:
+ import _mpi
+ except:
+ return 1
+ else:
+ return world().size
-else:
- from Communicator import world
- def inParallel(): return 1
- def processors(): return world().size
-
def copyright():
return "pythia.mpi: Copyright (c) 1998-2005 Michael A.G. Aivazis"
Modified: cs/pythia/trunk/mpi/_mpimodule.h
===================================================================
--- cs/pythia/trunk/mpi/_mpimodule.h 2006-07-26 22:56:13 UTC (rev 4111)
+++ cs/pythia/trunk/mpi/_mpimodule.h 2006-07-27 03:20:32 UTC (rev 4112)
@@ -35,7 +35,11 @@
public:
_mpimodule() {
- PyImport_AppendInittab("_mpi", &init_mpi);
+ static bool once = true;
+ if (once) {
+ once = false;
+ PyImport_AppendInittab("_mpi", &init_mpi);
+ }
}
~_mpimodule() {}
@@ -94,7 +98,7 @@
namespace mpi {
- static _mpimodule _mpimodule;
+ static _mpimodule _theModule;
}
More information about the cig-commits
mailing list