[cig-commits] r4034 - in cs/pythia/trunk: journal mpi
leif at geodynamics.org
leif at geodynamics.org
Wed Jul 19 03:00:34 PDT 2006
Author: leif
Date: 2006-07-19 03:00:34 -0700 (Wed, 19 Jul 2006)
New Revision: 4034
Added:
cs/pythia/trunk/mpi/_mpimodule.h
Modified:
cs/pythia/trunk/journal/Diagnostic.h
cs/pythia/trunk/journal/NullDiagnostic.h
cs/pythia/trunk/journal/manip-explicit.h
cs/pythia/trunk/journal/manip-templated.h
cs/pythia/trunk/journal/manipulators.h
cs/pythia/trunk/mpi/Communicator.h
cs/pythia/trunk/mpi/Group.h
Log:
Created an inline _mpimodule implementation which works
for CitcomS. Also inlined more functions in journal to
avoid duplicate symbols.
Modified: cs/pythia/trunk/journal/Diagnostic.h
===================================================================
--- cs/pythia/trunk/journal/Diagnostic.h 2006-07-19 06:59:26 UTC (rev 4033)
+++ cs/pythia/trunk/journal/Diagnostic.h 2006-07-19 10:00:34 UTC (rev 4034)
@@ -98,7 +98,7 @@
// the injection operator
template <typename item_t>
-journal::Diagnostic & operator<< (journal::Diagnostic & diagnostic, item_t item) {
+inline journal::Diagnostic & operator<< (journal::Diagnostic & diagnostic, item_t item) {
return diagnostic.inject(item);
}
Modified: cs/pythia/trunk/journal/NullDiagnostic.h
===================================================================
--- cs/pythia/trunk/journal/NullDiagnostic.h 2006-07-19 06:59:26 UTC (rev 4033)
+++ cs/pythia/trunk/journal/NullDiagnostic.h 2006-07-19 10:00:34 UTC (rev 4034)
@@ -61,7 +61,7 @@
// the injection operator
template <typename item_t>
-journal::NullDiagnostic & operator<< (journal::NullDiagnostic & diagnostic, item_t) {
+inline journal::NullDiagnostic & operator<< (journal::NullDiagnostic & diagnostic, item_t) {
return diagnostic;
}
Modified: cs/pythia/trunk/journal/manip-explicit.h
===================================================================
--- cs/pythia/trunk/journal/manip-explicit.h 2006-07-19 06:59:26 UTC (rev 4033)
+++ cs/pythia/trunk/journal/manip-explicit.h 2006-07-19 10:00:34 UTC (rev 4034)
@@ -81,17 +81,17 @@
// the injection operators: leave these in the global namespace
-journal::Diagnostic & operator<< (journal::Diagnostic & s, journal::set_t m)
+inline journal::Diagnostic & operator<< (journal::Diagnostic & s, journal::set_t m)
{
return (*m._f)(s, m._key, m._value);
}
-journal::Diagnostic & operator<< (journal::Diagnostic & s, journal::loc2_t m)
+inline journal::Diagnostic & operator<< (journal::Diagnostic & s, journal::loc2_t m)
{
return (*m._f)(s, m._file, m._line);
}
-journal::Diagnostic & operator<< (journal::Diagnostic & s, journal::loc3_t m)
+inline journal::Diagnostic & operator<< (journal::Diagnostic & s, journal::loc3_t m)
{
return (*m._f)(s, m._file, m._line, m._function);
}
Modified: cs/pythia/trunk/journal/manip-templated.h
===================================================================
--- cs/pythia/trunk/journal/manip-templated.h 2006-07-19 06:59:26 UTC (rev 4033)
+++ cs/pythia/trunk/journal/manip-templated.h 2006-07-19 10:00:34 UTC (rev 4034)
@@ -34,15 +34,15 @@
// the injection operators: leave these in the global namespace
template <typename arg1_t>
-journal::Diagnostic & operator << (
+inline journal::Diagnostic & operator << (
journal::Diagnostic &, journal::manip_1<arg1_t>);
template <typename arg1_t, typename arg2_t>
-journal::Diagnostic & operator << (
+inline journal::Diagnostic & operator << (
journal::Diagnostic &, journal::manip_2<arg1_t, arg2_t>);
template <typename arg1_t, typename arg2_t, typename arg3_t>
-journal::Diagnostic & operator << (
+inline journal::Diagnostic & operator << (
journal::Diagnostic &, journal::manip_3<arg1_t, arg2_t, arg3_t>);
@@ -71,7 +71,7 @@
template <typename arg1_t>
-journal::Diagnostic & operator<< (
+inline journal::Diagnostic & operator<< (
journal::Diagnostic & s, journal::manip_1<arg1_t> m)
{
return (*m._f)(s, m._arg1);
@@ -104,7 +104,7 @@
template <typename arg1_t, typename arg2_t>
-journal::Diagnostic &
+inline journal::Diagnostic &
operator<< (
journal::Diagnostic & s, journal::manip_2<arg1_t, arg2_t> m)
{
@@ -139,7 +139,7 @@
template <typename arg1_t, typename arg2_t, typename arg3_t>
-journal::Diagnostic & operator<<
+inline journal::Diagnostic & operator<<
(journal::Diagnostic & s, journal::manip_3<arg1_t, arg2_t, arg3_t> m) {
return (*m._f)(s, m._arg1, m._arg2, m._arg3);
}
Modified: cs/pythia/trunk/journal/manipulators.h
===================================================================
--- cs/pythia/trunk/journal/manipulators.h 2006-07-19 06:59:26 UTC (rev 4033)
+++ cs/pythia/trunk/journal/manipulators.h 2006-07-19 10:00:34 UTC (rev 4034)
@@ -26,29 +26,29 @@
class Diagnostic;
// end of entry
- Diagnostic & endl(Diagnostic & diag) {
+ inline Diagnostic & endl(Diagnostic & diag) {
diag.record();
return diag;
}
// add a newline
- Diagnostic & newline(Diagnostic & diag) {
+ inline Diagnostic & newline(Diagnostic & diag) {
diag.newline();
return diag;
}
// set metadata key to value
- Diagnostic & __diagmanip_set(Diagnostic & s, const char * key, const char * value) {
+ inline Diagnostic & __diagmanip_set(Diagnostic & s, const char * key, const char * value) {
s.attribute(key, value);
return s;
}
- set_t set(const char * key, const char * value) {
+ inline set_t set(const char * key, const char * value) {
return set_t(__diagmanip_set, key, value);
}
// location information
- Diagnostic & __diagmanip_loc(Diagnostic & s, const char * filename, long line) {
+ inline Diagnostic & __diagmanip_loc(Diagnostic & s, const char * filename, long line) {
s.attribute("filename", filename);
std::stringstream tmp;
@@ -59,11 +59,11 @@
return s;
}
- loc2_t at(const char * file, long line) {
+ inline loc2_t at(const char * file, long line) {
return loc2_t(__diagmanip_loc, file, line);
}
- Diagnostic & __diagmanip_loc(
+ inline Diagnostic & __diagmanip_loc(
Diagnostic & s, const char * filename, long line, const char * function)
{
s.attribute("filename", filename);
@@ -77,13 +77,13 @@
return s;
}
- loc3_t at(const char * file, long line, const char * function) {
+ inline loc3_t at(const char * file, long line, const char * function) {
return loc3_t(__diagmanip_loc, file, line, function);
}
}
-journal::Diagnostic &
+inline journal::Diagnostic &
operator<< (journal::Diagnostic & s, journal::Diagnostic & (m)(journal::Diagnostic &))
{
return (*m)(s);
Modified: cs/pythia/trunk/mpi/Communicator.h
===================================================================
--- cs/pythia/trunk/mpi/Communicator.h 2006-07-19 06:59:26 UTC (rev 4033)
+++ cs/pythia/trunk/mpi/Communicator.h 2006-07-19 10:00:34 UTC (rev 4034)
@@ -93,6 +93,9 @@
}
+#include "_mpimodule.h"
+
+
#endif
// version
Modified: cs/pythia/trunk/mpi/Group.h
===================================================================
--- cs/pythia/trunk/mpi/Group.h 2006-07-19 06:59:26 UTC (rev 4033)
+++ cs/pythia/trunk/mpi/Group.h 2006-07-19 10:00:34 UTC (rev 4034)
@@ -95,6 +95,9 @@
}
+#include "_mpimodule.h"
+
+
// version
// $Id: Group.h,v 1.1.1.1 2005/03/08 16:13:30 aivazis Exp $
Copied: cs/pythia/trunk/mpi/_mpimodule.h (from rev 4033, vendor/pythia/v0.8/packages/mpi/mpimodule/_mpimodule.cc)
===================================================================
--- vendor/pythia/v0.8/packages/mpi/mpimodule/_mpimodule.cc 2006-07-19 06:59:26 UTC (rev 4033)
+++ cs/pythia/trunk/mpi/_mpimodule.h 2006-07-19 10:00:34 UTC (rev 4034)
@@ -0,0 +1,106 @@
+// -*- C++ -*-
+//
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Michael A.G. Aivazis
+// California Institute of Technology
+// (C) 1998-2005 All Rights Reserved
+//
+// <LicenseText>
+//
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+
+#if !defined(pympi__mpimodule_h__)
+#define pympi__mpimodule_h__
+
+#include <mpi.h>
+#include <Python.h>
+
+#if !defined(pympi_Communicator_h__)
+#include "Communicator.h"
+#endif
+
+
+namespace mpi {
+
+ class _mpimodule;
+
+}
+
+
+class mpi::_mpimodule {
+
+// meta-methods
+public:
+
+ _mpimodule() {
+ PyImport_AppendInittab("_mpi", &init_mpi);
+ }
+
+ ~_mpimodule() {}
+
+private:
+ static inline void init_mpi();
+
+ static PyObject * communicatorRank(PyObject *, PyObject * args) {
+ PyObject * py_comm;
+ if (!PyArg_ParseTuple(args, "O:communicatorRank", &py_comm)) return 0;
+ Communicator * comm = (Communicator *) PyCObject_AsVoidPtr(py_comm);
+ return PyInt_FromLong(comm->rank());
+ }
+
+ static PyObject * communicatorSize(PyObject *, PyObject * args) {
+ PyObject * py_comm;
+ if (!PyArg_ParseTuple(args, "O:communicatorSize", &py_comm)) return 0;
+ Communicator * comm = (Communicator *) PyCObject_AsVoidPtr(py_comm);
+ return PyInt_FromLong(comm->size());
+ }
+
+};
+
+
+inline void mpi::_mpimodule::init_mpi()
+{
+ static struct PyMethodDef _methods[] = {
+ {"communicatorRank", communicatorRank, METH_VARARGS, ""},
+ {"communicatorSize", communicatorSize, METH_VARARGS, ""},
+ {0, 0}
+ };
+
+ // create the module and add the functions
+ PyObject * m = Py_InitModule4(
+ "_mpi", _methods, "", 0, PYTHON_API_VERSION);
+
+ // get its dictionary
+ PyObject * d = PyModule_GetDict(m);
+
+ // check for errors
+ if (PyErr_Occurred()) {
+ Py_FatalError("can't initialize module _mpi");
+ }
+
+ // install the module exceptions
+ PyObject *pympi_runtimeError = PyErr_NewException("mpi.runtime", 0, 0);
+ PyDict_SetItemString(d, "RuntimeException", pympi_runtimeError);
+
+ // add some constants
+ PyDict_SetItemString(d, "initialized", PyLong_FromLong(1));
+ PyDict_SetItemString(
+ d, "world", PyCObject_FromVoidPtr(new mpi::Communicator(MPI_COMM_WORLD), 0));
+
+ return;
+}
+
+
+namespace mpi {
+ static _mpimodule _mpimodule;
+}
+
+
+// version
+// $Id: _mpimodule.cc,v 1.1.1.1 2005/03/08 16:13:30 aivazis Exp $
+
+#endif
+
+// End of file
More information about the cig-commits
mailing list