[cig-commits] r5074 - cs/merlin/trunk

leif at geodynamics.org leif at geodynamics.org
Sat Oct 21 04:03:30 PDT 2006


Author: leif
Date: 2006-10-21 04:03:29 -0700 (Sat, 21 Oct 2006)
New Revision: 5074

Added:
   cs/merlin/trunk/Makefile.am
   cs/merlin/trunk/configure.ac
   cs/merlin/trunk/ld.pyx
   cs/merlin/trunk/mpi-defs.h
   cs/merlin/trunk/mpi-imports.c
   cs/merlin/trunk/mpi.h
   cs/merlin/trunk/mpipython.cpp
   cs/merlin/trunk/python.cpp
Log:
Rough draft of Merlin's realization as a "configuration kernel".
This includes a sketch of pyld, which had hitherto been a secret
project.


Added: cs/merlin/trunk/Makefile.am
===================================================================
--- cs/merlin/trunk/Makefile.am	2006-10-20 20:20:36 UTC (rev 5073)
+++ cs/merlin/trunk/Makefile.am	2006-10-21 11:03:29 UTC (rev 5074)
@@ -0,0 +1,38 @@
+## Process this file with automake to produce Makefile.in
+
+ACLOCAL_AMFLAGS = -I ./m4
+
+
+bin_PROGRAMS = python mpipython
+
+
+INCLUDES = -I$(top_srcdir)/lib/mpi -I$(PYTHON_INCDIR)
+
+
+python_SOURCES = python.cpp
+
+python$(EXEEXT): $(python_OBJECTS) $(python_DEPENDENCIES) 
+	@rm -f python$(EXEEXT)
+	$(CXXLINK) $(PYTHON_LDFLAGS) $(PYTHON_LINKFORSHARED) -o $@ \
+		$(python_LDFLAGS) $(python_OBJECTS) $(python_LDADD) \
+		$(PYTHON_BLDLIBRARY) \
+		$(FCLIBS) \
+		$(PYTHON_LIBS) $(PYTHON_MODLIBS) $(PYTHON_SYSLIBS) \
+		$(LIBS) \
+		$(PYTHON_LDLAST)
+
+
+mpipython_SOURCES = mpipython.cpp libmpi.c
+
+mpipython$(EXEEXT): $(mpipython_OBJECTS) $(mpipython_DEPENDENCIES) 
+	@rm -f mpipython$(EXEEXT)
+	$(CXXLINK) $(PYTHON_LDFLAGS) $(PYTHON_LINKFORSHARED) -o $@ \
+		$(mpipython_LDFLAGS) $(mpipython_OBJECTS) $(mpipython_LDADD) \
+		$(PYTHON_BLDLIBRARY) \
+		$(FCLIBS) \
+		$(PYTHON_LIBS) $(PYTHON_MODLIBS) $(PYTHON_SYSLIBS) \
+		$(LIBS) \
+		$(PYTHON_LDLAST)
+
+
+## end of Makefile.am

Added: cs/merlin/trunk/configure.ac
===================================================================
--- cs/merlin/trunk/configure.ac	2006-10-20 20:20:36 UTC (rev 5073)
+++ cs/merlin/trunk/configure.ac	2006-10-21 11:03:29 UTC (rev 5074)
@@ -0,0 +1,44 @@
+dnl                                               -*- Autoconf -*-
+dnl Process this file with autoconf to produce a configure script.
+dnl
+
+AC_PREREQ(2.59)
+AC_INIT([merlin], [1.0], [leif at geodynamics.org])
+AC_CONFIG_SRCDIR([bin/python.c])
+AC_CONFIG_HEADER([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE([foreign])
+
+# Checks for programs.
+AM_PATH_PYTHON([2.3])
+CIT_PYTHON_SYSCONFIG
+AC_PROG_CC([mpicc hcc mpcc mpcc_r mpxlc cmpicc gcc cc cl icc ecc pgcc xlc xlc_r])
+AC_PROG_CXX([mpicxx mpic++ mpiCC hcp mpCC mpxlC mpxlC_r cmpic++ g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlc++_r xlC_r xlC icpc ecpc pgCC])
+AC_PROG_F77
+AC_PROG_FC
+AC_PROG_RANLIB
+
+# Checks for libraries.
+AC_SEARCH_LIBS([MPI_Init], [mpi mpich], [], [AC_MSG_ERROR([MPI library not found])])
+
+# Checks for header files.
+AC_CHECK_HEADER([mpi.h], [], [AC_MSG_ERROR([header 'mpi.h' not found])])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_F77_WRAPPERS
+AC_FC_WRAPPERS
+AC_FC_SRCEXT(f90)
+AC_FC_FREEFORM()
+CIT_FC_MAIN
+
+# Checks for library functions.
+
+# Influential environment variables.
+AC_ARG_VAR(PYTHON, [Python interpreter])
+
+AC_CONFIG_FILES([Makefile
+                 bin/Makefile])
+
+AC_OUTPUT
+
+dnl end of configure.ac

Added: cs/merlin/trunk/ld.pyx
===================================================================
--- cs/merlin/trunk/ld.pyx	2006-10-20 20:20:36 UTC (rev 5073)
+++ cs/merlin/trunk/ld.pyx	2006-10-21 11:03:29 UTC (rev 5074)
@@ -0,0 +1,128 @@
+#!/usr/bin/env python
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                               merlin
+#
+# Copyright (c) 2006, California Institute of Technology
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#
+#    * Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+#
+#    * Redistributions in binary form must reproduce the above
+#    copyright notice, this list of conditions and the following
+#    disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#
+#    * Neither the name of the California Institute of Technology nor
+#    the names of its contributors may be used to endorse or promote
+#    products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+
+# imports
+
+
+cdef public class ImportEntry [object PyImportEntryObject, type PyImportEntry_Type]:
+    cdef int nameLength
+    cdef public char *name
+    cdef public int flags
+
+
+cdef extern from "":
+    struct PyImportEntryObject
+
+
+cdef public class ImportTable [object PyImportTableObject, type PyImportTable_Type]:
+    
+    cdef int count
+    cdef PyImportEntryObject *entries
+
+    def entryList(self):
+        cdef PyImportEntryObject *e
+        cdef int i
+        l = []
+        for i from 0 <= i < self.count:
+            entry = <object>&e[i]
+            l.append(entry)
+        return l
+
+
+cdef public class ModuleImportEntry [object PyModuleImportEntryObject, type PyModuleImportEntry_Type]:
+    cdef int nameLength
+    cdef public char *name
+    cdef public int flags
+
+
+cdef extern from "":
+    struct PyModuleImportEntryObject
+
+
+cdef public class ModuleImportTable [object PyModuleImportTableObject, type PyModuleImportTable_Type]:
+    
+    cdef public char *version
+    cdef int count
+    cdef PyModuleImportEntryObject *entries
+
+    def entryList(self):
+        cdef PyModuleImportEntryObject *e
+        cdef int i
+        l = []
+        for i from 0 <= i < self.count:
+            entry = <object>&e[i]
+            l.append(entry)
+        return l
+
+
+# exports
+
+
+cdef public class ExportEntry [object PyExportEntryObject, type PyExportEntry_Type]:
+    cdef int nameLength
+    cdef public char *name
+
+
+cdef extern from "":
+    struct PyExportEntryObject
+
+
+cdef public class ExportTable [object PyExportTableObject, type PyExportTable_Type]:
+    
+    cdef public char *version
+    cdef int count
+    cdef PyExportEntryObject *entries
+    cdef PyExportEntryObject *(*hash)(char *name, int nameLength)
+
+    def entryList(self):
+        cdef PyExportEntryObject *e
+        cdef int i
+        l = []
+        for i from 0 <= i < self.count:
+            entry = <object>&e[i]
+            l.append(entry)
+        return l
+
+
+# end of file

Added: cs/merlin/trunk/mpi-defs.h
===================================================================
--- cs/merlin/trunk/mpi-defs.h	2006-10-20 20:20:36 UTC (rev 5073)
+++ cs/merlin/trunk/mpi-defs.h	2006-10-21 11:03:29 UTC (rev 5074)
@@ -0,0 +1,135 @@
+/*
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *                               merlin
+ *
+ * Copyright (c) 2006, California Institute of Technology
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    * Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ *    * Neither the name of the California Institute of Technology nor
+ *    the names of its contributors may be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+*/
+
+#ifdef PyLD_MACRO
+
+
+#define MPI_SUCCESS PyLD_MACRO(MPI_SUCCESS)
+
+#define MPI_Allreduce PyLD_MACRO(MPI_Allreduce)
+#define MPI_Barrier PyLD_MACRO(MPI_Barrier)
+#define MPI_Cart_coords PyLD_MACRO(MPI_Cart_coords)
+#define MPI_Cart_create PyLD_MACRO(MPI_Cart_create)
+#define MPI_Comm_create PyLD_MACRO(MPI_Comm_create)
+#define MPI_Comm_group PyLD_MACRO(MPI_Comm_group)
+#define MPI_Comm_rank PyLD_MACRO(MPI_Comm_rank)
+#define MPI_Comm_size PyLD_MACRO(MPI_Comm_size)
+#define MPI_Finalize PyLD_MACRO(MPI_Finalize)
+#define MPI_Gather PyLD_MACRO(MPI_Gather)
+#define MPI_Get_count PyLD_MACRO(MPI_Get_count)
+#define MPI_Group_excl PyLD_MACRO(MPI_Group_excl)
+#define MPI_Group_free PyLD_MACRO(MPI_Group_free)
+#define MPI_Group_incl PyLD_MACRO(MPI_Group_incl)
+#define MPI_Group_rank PyLD_MACRO(MPI_Group_rank)
+#define MPI_Group_size PyLD_MACRO(MPI_Group_size)
+#define MPI_Init PyLD_MACRO(MPI_Init)
+#define MPI_Initialized PyLD_MACRO(MPI_Initialized)
+#define MPI_Irecv PyLD_MACRO(MPI_Irecv)
+#define MPI_Isend PyLD_MACRO(MPI_Isend)
+#define MPI_Send PyLD_MACRO(MPI_Send)
+#define MPI_Sendrecv PyLD_MACRO(MPI_Sendrecv)
+#define MPI_Waitall PyLD_MACRO(MPI_Waitall)
+#define MPI_Wtime PyLD_MACRO(MPI_Wtime)
+
+
+#else /* !PyLD_MACRO */
+
+
+PyLD_VAR(int, MPI_SUCCESS)
+
+PyLD_FUNC(int, MPI_Allreduce, (void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm),
+         (sendbuf, recvbuf, count, datatype, op, comm))
+PyLD_FUNC(int, MPI_Barrier, (MPI_Comm comm),
+          (comm))
+PyLD_FUNC(int, MPI_Cart_coords, (MPI_Comm comm, int rank, int dim, int *coordinates),
+          (comm, rank, dim, coordinates))
+PyLD_FUNC(int, MPI_Cart_create, (MPI_Comm comm, int size, int *procs, int *periods, int reorder, MPI_Comm *comm),
+          (comm, size, procs, periods, reorder, comm))
+PyLD_FUNC(int, MPI_Comm_create, (MPI_Comm comm, MPI_Group group, MPI_Comm *comm),
+          (comm, group, comm))
+PyLD_FUNC(int, MPI_Comm_group, (MPI_Comm comm, MPI_Group *group),
+          (comm, group))
+PyLD_FUNC(int, MPI_Comm_rank, (MPI_Comm comm, int *rank),
+          (comm, rank))
+PyLD_FUNC(int, MPI_Comm_size, (MPI_Comm comm, int *size),
+          (comm, size))
+PyLD_FUNC(int, MPI_Finalize, (void),
+          ())
+PyLD_FUNC(int, MPI_Gather, (void *sendbuf, int sendcount, MPI_Datatype sendtype,
+                            void *recvbuf, int recvcount, MPI_Datatype recvtype,
+                            int root, MPI_Comm comm),
+          (sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm))
+PyLD_FUNC(int, MPI_Get_count, (MPI_Status *status, MPI_Datatype datatype, int *count),
+          (status, datatype, count))
+PyLD_FUNC(int, MPI_Group_excl, (MPI_Group group, int size, int *ranks, MPI_Group *group),
+          (group, size, ranks, group))
+PyLD_FUNC(int, MPI_Group_free, (MPI_Group *group),
+          (group))
+PyLD_FUNC(int, MPI_Group_incl, (MPI_Group group, int size, int *ranks, MPI_Group *group),
+          (group, size, ranks, group))
+PyLD_FUNC(int, MPI_Group_rank, (MPI_Group group, int *rank),
+          (group, rank))
+PyLD_FUNC(int, MPI_Group_size, (MPI_Group group, int *size),
+          (group, size))
+PyLD_FUNC(int, MPI_Init, (int *argc, char ***argv),
+          (argc, argv))
+PyLD_FUNC(int, MPI_Initialized, (int *flag),
+          (flag))
+PyLD_FUNC(int, MPI_Irecv, (void *buf, int count, MPI_Datatype datatype, int source, int tag,  MPI_Comm comm, MPI_Request *request),
+          (buf, count, datatype, source, tag, comm, request))
+PyLD_FUNC(int, MPI_Isend, (void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request),
+          (buf, count, datatype, dest, tag, comm, request))
+PyLD_FUNC(int, MPI_Send, (void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm),
+          (buf, count, datatype, dest, tag, comm))
+PyLD_FUNC(int, MPI_Sendrecv, (void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag,
+                              void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag,
+                              MPI_Comm comm, MPI_Status * status),
+          (sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, recvcount, recvtype, source, recvtag, comm, status))
+PyLD_FUNC(int, MPI_Waitall, (int count, MPI_Request *array_of_requests, MPI_Status *array_of_statuses),
+          (count, array_of_requests, array_of_statuses))
+PyLD_FUNC(double, MPI_Wtime, (void),
+          ())
+    
+#endif /* !PyLD_MACRO */
+
+
+/* end of file */

Added: cs/merlin/trunk/mpi-imports.c
===================================================================
--- cs/merlin/trunk/mpi-imports.c	2006-10-20 20:20:36 UTC (rev 5073)
+++ cs/merlin/trunk/mpi-imports.c	2006-10-21 11:03:29 UTC (rev 5074)
@@ -0,0 +1,65 @@
+/*
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *                               merlin
+ *
+ * Copyright (c) 2006, California Institute of Technology
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    * Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ *    * Neither the name of the California Institute of Technology nor
+ *    the names of its contributors may be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#define PyImportEntry_INIT(name) PyObject_HEAD_INIT(&PyImportEntry_Type), sizeof(#name)-1, #name, (void *)&__py_imp_ ## name
+
+#define PyLD_FUNC(ret, name, proto, args) \
+ret (*__py_imp_ ## name)proto;
+#include "mpi-defs.h"
+#undef PyLD_FUNC
+
+static PyImportEntryObject __py_importTable[] = {
+#define PyLD_FUNC(ret, name, proto, args) { PyImportEntry_INIT(name) },
+#include "mpi-defs.h"
+}
+#undef PyLD_FUNC
+
+#define PyLD_FUNC(ret, name, proto, args) \
+ret name proto \
+{ \
+    return (*__py_imp_ ## name)args; \
+}
+#include "mpi-defs.h"
+#undef PyLD_FUNC
+
+    
+/* end of file */

Added: cs/merlin/trunk/mpi.h
===================================================================
--- cs/merlin/trunk/mpi.h	2006-10-20 20:20:36 UTC (rev 5073)
+++ cs/merlin/trunk/mpi.h	2006-10-21 11:03:29 UTC (rev 5074)
@@ -0,0 +1,70 @@
+/*
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *                               merlin
+ *
+ * Copyright (c) 2006, California Institute of Technology
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    * Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ *    * Neither the name of the California Institute of Technology nor
+ *    the names of its contributors may be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+*/
+
+
+#ifndef __merlin_mpi_h__
+#define __merlin_mpi_h__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define PyLD_FUNC(ret, name, proto, args) ret (*__py_imp_ ## name)proto;
+#include "mpi-defs.h"
+#undef PyLD_FUNC
+
+#define PyLD_MACRO(name) (__py_imp_ ## name)
+#include "mpi-defs.h"
+#undef PyLD_MACRO
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __merlin_mpi_h__ */
+
+
+/* end of file */

Added: cs/merlin/trunk/mpipython.cpp
===================================================================
--- cs/merlin/trunk/mpipython.cpp	2006-10-20 20:20:36 UTC (rev 5073)
+++ cs/merlin/trunk/mpipython.cpp	2006-10-21 11:03:29 UTC (rev 5074)
@@ -0,0 +1,89 @@
+//
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+//                               merlin
+//
+// Copyright (c) 2006, California Institute of Technology
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+//
+//    * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    * Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    * Neither the name of the California Institute of Technology nor
+//    the names of its contributors may be used to endorse or promote
+//    products derived from this software without specific prior
+//    written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+//
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+
+
+// Avoid MPI/C++ interaction issues.
+#define MERLIN_MPI_IMP mpi_wrapper
+#include "merlin/mpi-wrappers.h"
+#include "mpi.h"
+
+#include <Python.h>
+#include <stdio.h>
+
+
+// include the implementations of our built-in extension modules
+#include "ld.c"
+#include "_mpi.c"
+
+
+struct _inittab inittab[] = {
+    { "ld", initld },
+    { "_mpi", init_mpi },
+    { 0, 0 }
+};
+
+
+int main(int argc, char **argv)
+{
+    int errorcode = MPI_Init(&argc, &argv);
+    if (errorcode != MPI_SUCCESS) {
+        fprintf(stderr,
+                "%s: MPI_Init: error %d\n",
+                argv[0], errorcode);
+    }
+    
+    // add our extension modules
+    if (PyImport_ExtendInittab(inittab) == -1) {
+        fprintf(stderr,
+                "%s: PyImport_ExtendInittab failed! Exiting...\n",
+                argv[0]);
+        return 1;
+    }
+    int status = Py_Main(argc, argv);
+    
+    MPI_Finalize();
+    
+    return status;
+}
+
+
+// end of file

Added: cs/merlin/trunk/python.cpp
===================================================================
--- cs/merlin/trunk/python.cpp	2006-10-20 20:20:36 UTC (rev 5073)
+++ cs/merlin/trunk/python.cpp	2006-10-21 11:03:29 UTC (rev 5074)
@@ -0,0 +1,71 @@
+//
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+//                               merlin
+//
+// Copyright (c) 2006, California Institute of Technology
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+//
+//    * Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    * Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    * Neither the name of the California Institute of Technology nor
+//    the names of its contributors may be used to endorse or promote
+//    products derived from this software without specific prior
+//    written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+//
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+
+
+#include <Python.h>
+#include <stdio.h>
+
+
+// include the implementations of our built-in extension modules
+#include "ld.c"
+
+
+struct _inittab inittab[] = {
+    { "ld", initld },
+    { 0, 0 }
+};
+
+
+int main(int argc, char **argv)
+{
+    // add our extension modules
+    if (PyImport_ExtendInittab(inittab) == -1) {
+        fprintf(stderr,
+                "%s: PyImport_ExtendInittab failed! Exiting...\n",
+                argv[0]);
+        return 1;
+    }
+    return Py_Main(argc, argv);
+}
+
+
+// end of file



More information about the cig-commits mailing list