#include <Python.h>
#include "documentation.h"
#include <Numeric/arrayobject.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mpi.h>
Include dependency graph for mympimodule.c:
Go to the source code of this file.
Defines | |
#define | VERSION "1.13.0" |
#define | COPYWRITE "Copyright (c) 2005 The Regents of the University of California All Rights Reserved. print mpi.copywrite() for details." |
#define | DATA_TYPE long |
#define | COM_TYPE long |
#define | ARG_ARRAY |
#define | LIBRARY "Numeric" |
#define | PyMODINIT_FUNC void |
#define | MPI_VERSION 1 |
#define | MPI_SUBVERSION 0 |
#define | com_ray_size 20 |
#define | CAST long |
#define | VERT_FUNC PyInt_FromLong |
#define | CAST long |
#define | VERT_FUNC PyInt_FromLong |
#define | CAST long |
#define | VERT_FUNC PyInt_FromLong |
#define | CAST long |
#define | VERT_FUNC PyInt_FromLong |
#define | CAST long |
#define | VERT_FUNC PyInt_FromLong |
#define | CAST long |
#define | VERT_FUNC PyInt_FromLong |
#define | CAST long |
#define | VERT_FUNC PyInt_FromLong |
Functions | |
void | char_func (char *ret, int retl, char *str, int slen, char *str2, int slen2, int *offset) |
void | the_date (double *since, char *date_str) |
void | myerror (char *s) |
int | getptype (long mpitype) |
void | eh (MPI_Comm *comm, int *err,...) |
PyObject * | mpi_get_processor_name (PyObject *self, PyObject *args) |
PyObject * | mpi_test (PyObject *self, PyObject *args) |
PyObject * | mpi_wait (PyObject *self, PyObject *args) |
PyObject * | mpi_isend (PyObject *self, PyObject *args) |
PyObject * | mpi_irecv (PyObject *self, PyObject *args) |
PyObject * | mpi_group_rank (PyObject *self, PyObject *args) |
PyObject * | mpi_group_incl (PyObject *self, PyObject *args) |
PyObject * | mpi_comm_group (PyObject *self, PyObject *args) |
PyObject * | mpi_comm_dup (PyObject *self, PyObject *args) |
PyObject * | mpi_comm_set_errhandler (PyObject *self, PyObject *args) |
PyObject * | mpi_comm_create (PyObject *self, PyObject *args) |
PyObject * | mpi_barrier (PyObject *self, PyObject *args) |
PyObject * | mpi_send (PyObject *self, PyObject *args) |
PyObject * | mpi_recv (PyObject *self, PyObject *args) |
PyObject * | mpi_status (PyObject *self, PyObject *args) |
PyObject * | mpi_error (PyObject *self, PyObject *args) |
PyObject * | mpi_wtime (PyObject *self, PyObject *args) |
PyObject * | mpi_wtick (PyObject *self, PyObject *args) |
PyObject * | mpi_attr_get (PyObject *self, PyObject *args) |
PyObject * | mpi_comm_split (PyObject *self, PyObject *args) |
PyObject * | mpi_probe (PyObject *self, PyObject *args) |
PyObject * | mpi_get_count (PyObject *self, PyObject *args) |
PyObject * | mpi_comm_size (PyObject *self, PyObject *args) |
PyObject * | mpi_comm_rank (PyObject *self, PyObject *args) |
PyObject * | mpi_iprobe (PyObject *self, PyObject *args) |
PyObject * | mpi_init (PyObject *self, PyObject *args) |
PyObject * | mpi_start (PyObject *self, PyObject *args) |
PyObject * | mpi_bcast (PyObject *self, PyObject *args) |
PyObject * | mpi_scatterv (PyObject *self, PyObject *args) |
PyObject * | mpi_gatherv (PyObject *self, PyObject *args) |
PyObject * | mpi_gather (PyObject *self, PyObject *args) |
PyObject * | mpi_scatter (PyObject *self, PyObject *args) |
PyObject * | mpi_reduce (PyObject *self, PyObject *args) |
PyObject * | mpi_finalize (PyObject *self, PyObject *args) |
PyObject * | mpi_alltoall (PyObject *self, PyObject *args) |
PyObject * | mpi_alltoallv (PyObject *self, PyObject *args) |
PyObject * | copywrite (PyObject *self, PyObject *args) |
PyMODINIT_FUNC | initmpi (void) |
Variables | |
char | DATE_SRC [] = "$Date: 2009/12/06 01:15:37 $" |
int | calls = 0 |
int | errs = 0 |
MPI_Errhandler | newerr |
MPI_Comm | mycomm |
char | cw [2160] |
MPI_Comm | com_ray [com_ray_size] |
char | errstr [256] |
char | version [8] |
MPI_Status | status |
int | ierr |
int | erroron |
PyObject * | mpiError |
PyMethodDef | mpiMethods [] |
|
Definition at line 62 of file mympimodule.c. |
|
|
|
|
|
|
|
|
|
|
|
|
|
Referenced by initmpi(), mpi_comm_create(), mpi_comm_dup(), mpi_comm_group(), mpi_comm_split(), and mpi_group_incl(). |
|
Definition at line 113 of file mympimodule.c. |
|
Definition at line 61 of file mympimodule.c. Referenced by mpi_alltoall(), mpi_alltoallv(), mpi_attr_get(), mpi_barrier(), mpi_bcast(), mpi_comm_create(), mpi_comm_dup(), mpi_comm_group(), mpi_comm_rank(), mpi_comm_set_errhandler(), mpi_comm_size(), mpi_comm_split(), mpi_gather(), mpi_gatherv(), mpi_iprobe(), mpi_probe(), mpi_recv(), mpi_reduce(), mpi_scatter(), mpi_scatterv(), and mpi_send(). |
|
Definition at line 58 of file mympimodule.c. Referenced by initmpi(). |
|
Definition at line 60 of file mympimodule.c. Referenced by mpi_alltoall(), mpi_alltoallv(), mpi_bcast(), mpi_gather(), mpi_gatherv(), mpi_get_count(), mpi_recv(), mpi_reduce(), mpi_scatter(), mpi_scatterv(), and mpi_send(). |
|
Definition at line 73 of file mympimodule.c. Referenced by initmpi(). |
|
Definition at line 108 of file mympimodule.c. Referenced by initmpi(). |
|
Definition at line 104 of file mympimodule.c. Referenced by initmpi(). |
|
Definition at line 86 of file mympimodule.c. Referenced by initmpi(), and initmpi_eman_c(). |
|
Definition at line 57 of file mympimodule.c. Referenced by initmpi(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
Referenced by initmpi(), mpi_comm_create(), mpi_comm_dup(), mpi_comm_group(), mpi_comm_split(), and mpi_group_incl(). |
|
|
|
Definition at line 1450 of file mympimodule.c. References cw. 01450 { 01451 int i; 01452 for(i=0;i<2160;i++) { 01453 cw[i]=(char)0; 01454 } 01455 strncat(cw,"Copyright (c) 2005 The Regents of the University of California\n",80); 01456 strncat(cw,"All Rights Reserved\n",80); 01457 strncat(cw,"Permission to use, copy, modify and distribute any part of this\n",80); 01458 strncat(cw," software for educational, research and non-profit purposes,\n",80); 01459 strncat(cw," without fee, and without a written agreement is hereby granted,\n",80); 01460 strncat(cw," provided that the above copyright notice, this paragraph and the\n",80); 01461 strncat(cw," following three paragraphs appear in all copies.\n",80); 01462 strncat(cw,"Those desiring to incorporate this software into commercial products or\n",80); 01463 strncat(cw," use for commercial purposes should contact the Technology\n",80); 01464 strncat(cw," Transfer & Intellectual Property Services, University of\n",80); 01465 strncat(cw," California, San Diego, 9500 Gilman Drive, Mail Code 0910, La\n",80); 01466 strncat(cw," Jolla, CA 92093-0910, Ph: (858) 534-5815, FAX: (858) 534-7345,\n",80); 01467 strncat(cw," E-MAIL:invent@ucsd.edu.\n",80); 01468 strncat(cw,"IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY\n",80); 01469 strncat(cw," PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR\n",80); 01470 strncat(cw," CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF\n",80); 01471 strncat(cw," THE USE OF THIS SOFTWARE EVEN IF THE UNIVERSITY OF\n",80); 01472 strncat(cw," CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n",80); 01473 strncat(cw,"THE SOFTWARE PROVIDED HEREIN IS ON AN AS IS BASIS, AND THE\n",80); 01474 strncat(cw," UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE\n",80); 01475 strncat(cw," MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\n",80); 01476 strncat(cw," THE UNIVERSITY OF CALIFORNIA MAKES NO REPRESENTATIONS AND\n",80); 01477 strncat(cw," EXTENDS NO WARRANTIES OF ANY KIND, EITHER IMPLIED OR EXPRESS,\n",80); 01478 strncat(cw," INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n",80); 01479 strncat(cw," MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR THAT THE\n",80); 01480 strncat(cw," USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT, TRADEMARK OR\n",80); 01481 strncat(cw," OTHER RIGHTS.\n",80); 01482 return PyString_FromString(cw); 01483 }
|
|
Definition at line 133 of file mympimodule.c. References ierr. Referenced by mpi_init(), and mpi_start(). 00134 { 00135 char string[256]; 00136 int len; 00137 00138 /* 00139 if (*err != MPI_ERR_OTHER) { 00140 errs++; 00141 printf( "Unexpected error code\n" );fflush(stdout); 00142 } 00143 if (*comm != mycomm) { 00144 errs++; 00145 printf( "Unexpected communicator\n" );fflush(stdout); 00146 } 00147 calls++; 00148 */ 00149 ierr=*err; 00150 /* 00151 MPI_Error_string(ierr, string, &len); 00152 printf( "mpi generated the error %d %s\n",*err,string );fflush(stdout); 00153 */ 00154 printf( "mpi generated the error %d\n",*err );fflush(stdout); 00155 return; 00156 }
|
|
Definition at line 168 of file mympimodule.c. Referenced by mpi_alltoall(), mpi_alltoallv(), mpi_bcast(), mpi_gather(), mpi_gatherv(), mpi_recv(), mpi_reduce(), mpi_scatter(), mpi_scatterv(), and mpi_send(). 00168 { 00169 if(mpitype == (long)MPI_INT) return(PyArray_INT); 00170 if(mpitype == (long)MPI_FLOAT) return(PyArray_FLOAT); 00171 if(mpitype == (long)MPI_DOUBLE) return(PyArray_DOUBLE); 00172 printf("could not find type input: %ld available: MPI_FLOAT %ld MPI_INT %ld MPI_DOUBLE %ld\n",mpitype,(long)MPI_FLOAT,(long)MPI_INT,(long)MPI_DOUBLE); 00173 return(PyArray_INT); 00174 }
|
|
Definition at line 1552 of file mympimodule.c. References CAST, COPYWRITE, DATE_DOC, DATE_SRC, LIBRARY, MPI_SUBVERSION, MPI_VERSION, mpiError, mpiMethods, PyMODINIT_FUNC, VERSION, and VERT_FUNC. 01553 { 01554 #ifdef DO_UNSIGED 01555 #define CAST unsigned long 01556 #define VERT_FUNC PyLong_FromUnsignedLong 01557 #else 01558 #define CAST long 01559 #define VERT_FUNC PyInt_FromLong 01560 #endif 01561 PyObject *m, *d; 01562 PyObject *tmp; 01563 import_array(); 01564 m=Py_InitModule("mpi", mpiMethods); 01565 mpiError = PyErr_NewException("mpi.error", NULL, NULL); 01566 Py_INCREF(mpiError); 01567 PyModule_AddObject(m, "error", mpiError); 01568 d = PyModule_GetDict(m); 01569 tmp = PyString_FromString(VERSION); 01570 PyDict_SetItemString(d, "VERSION", tmp); Py_DECREF(tmp); 01571 tmp = PyInt_FromLong((long)MPI_VERSION); 01572 PyDict_SetItemString(d, "MPI_VERSION", tmp); Py_DECREF(tmp); 01573 tmp = PyInt_FromLong((long)MPI_SUBVERSION); 01574 PyDict_SetItemString(d, "MPI_SUBVERSION", tmp); Py_DECREF(tmp); 01575 tmp = PyString_FromString(COPYWRITE); 01576 PyDict_SetItemString(d, "COPYWRITE", tmp); Py_DECREF(tmp); 01577 tmp = VERT_FUNC((CAST)MPI_CHAR); 01578 PyDict_SetItemString(d, "MPI_CHAR", tmp); Py_DECREF(tmp); 01579 tmp = VERT_FUNC((CAST)MPI_BYTE); 01580 PyDict_SetItemString(d, "MPI_BYTE", tmp); Py_DECREF(tmp); 01581 tmp = VERT_FUNC((CAST)MPI_SHORT); 01582 PyDict_SetItemString(d, "MPI_SHORT", tmp); Py_DECREF(tmp); 01583 tmp = VERT_FUNC((CAST)MPI_INT); 01584 PyDict_SetItemString(d, "MPI_INT", tmp); Py_DECREF(tmp); 01585 tmp = VERT_FUNC((CAST)MPI_LONG); 01586 PyDict_SetItemString(d, "MPI_LONG", tmp); Py_DECREF(tmp); 01587 tmp = VERT_FUNC((CAST)MPI_FLOAT); 01588 PyDict_SetItemString(d, "MPI_FLOAT", tmp); Py_DECREF(tmp); 01589 tmp = VERT_FUNC((CAST)MPI_DOUBLE); 01590 PyDict_SetItemString(d, "MPI_DOUBLE", tmp); Py_DECREF(tmp); 01591 tmp = VERT_FUNC((CAST)MPI_UNSIGNED_CHAR); 01592 PyDict_SetItemString(d, "MPI_UNSIGNED_CHAR", tmp); Py_DECREF(tmp); 01593 tmp = VERT_FUNC((CAST)MPI_UNSIGNED_SHORT); 01594 PyDict_SetItemString(d, "MPI_UNSIGNED_SHORT", tmp); Py_DECREF(tmp); 01595 tmp = VERT_FUNC((CAST)MPI_UNSIGNED); 01596 PyDict_SetItemString(d, "MPI_UNSIGNED", tmp); Py_DECREF(tmp); 01597 tmp = VERT_FUNC((CAST)MPI_UNSIGNED_LONG); 01598 PyDict_SetItemString(d, "MPI_UNSIGNED_LONG", tmp); Py_DECREF(tmp); 01599 tmp = VERT_FUNC((CAST)MPI_LONG_DOUBLE); 01600 PyDict_SetItemString(d, "MPI_LONG_DOUBLE", tmp); Py_DECREF(tmp); 01601 tmp = VERT_FUNC((CAST)MPI_FLOAT_INT); 01602 PyDict_SetItemString(d, "MPI_FLOAT_INT", tmp); Py_DECREF(tmp); 01603 tmp = VERT_FUNC((CAST)MPI_LONG_INT); 01604 PyDict_SetItemString(d, "MPI_LONG_INT", tmp); Py_DECREF(tmp); 01605 tmp = VERT_FUNC((CAST)MPI_DOUBLE_INT); 01606 PyDict_SetItemString(d, "MPI_DOUBLE_INT", tmp); Py_DECREF(tmp); 01607 tmp = VERT_FUNC((CAST)MPI_SHORT_INT); 01608 PyDict_SetItemString(d, "MPI_SHORT_INT", tmp); Py_DECREF(tmp); 01609 tmp = VERT_FUNC((CAST)MPI_2INT); 01610 PyDict_SetItemString(d, "MPI_2INT", tmp); Py_DECREF(tmp); 01611 tmp = VERT_FUNC((CAST)MPI_LONG_DOUBLE_INT); 01612 PyDict_SetItemString(d, "MPI_LONG_DOUBLE_INT", tmp); Py_DECREF(tmp); 01613 tmp = VERT_FUNC((CAST)MPI_LONG_LONG_INT); 01614 PyDict_SetItemString(d, "MPI_LONG_LONG_INT", tmp); Py_DECREF(tmp); 01615 tmp = VERT_FUNC((CAST)MPI_PACKED); 01616 PyDict_SetItemString(d, "MPI_PACKED", tmp); Py_DECREF(tmp); 01617 tmp = VERT_FUNC((CAST)MPI_Pack); 01618 PyDict_SetItemString(d, "MPI_Pack", tmp); Py_DECREF(tmp); 01619 tmp = VERT_FUNC((CAST)MPI_Unpack); 01620 PyDict_SetItemString(d, "MPI_Unpack", tmp); Py_DECREF(tmp); 01621 tmp = VERT_FUNC((CAST)MPI_UB); 01622 PyDict_SetItemString(d, "MPI_UB", tmp); Py_DECREF(tmp); 01623 tmp = VERT_FUNC((CAST)MPI_LB); 01624 PyDict_SetItemString(d, "MPI_LB", tmp); Py_DECREF(tmp); 01625 tmp = VERT_FUNC((CAST)MPI_MAX); 01626 PyDict_SetItemString(d, "MPI_MAX", tmp); Py_DECREF(tmp); 01627 tmp = VERT_FUNC((CAST)MPI_MIN); 01628 PyDict_SetItemString(d, "MPI_MIN", tmp); Py_DECREF(tmp); 01629 tmp = VERT_FUNC((CAST)MPI_SUM); 01630 PyDict_SetItemString(d, "MPI_SUM", tmp); Py_DECREF(tmp); 01631 tmp = VERT_FUNC((CAST)MPI_PROD); 01632 PyDict_SetItemString(d, "MPI_PROD", tmp); Py_DECREF(tmp); 01633 tmp = VERT_FUNC((CAST)MPI_LAND); 01634 PyDict_SetItemString(d, "MPI_LAND", tmp); Py_DECREF(tmp); 01635 tmp = VERT_FUNC((CAST)MPI_BAND); 01636 PyDict_SetItemString(d, "MPI_BAND", tmp); Py_DECREF(tmp); 01637 tmp = VERT_FUNC((CAST)MPI_LOR); 01638 PyDict_SetItemString(d, "MPI_LOR", tmp); Py_DECREF(tmp); 01639 tmp = VERT_FUNC((CAST)MPI_BOR); 01640 PyDict_SetItemString(d, "MPI_BOR", tmp); Py_DECREF(tmp); 01641 tmp = VERT_FUNC((CAST)MPI_LXOR); 01642 PyDict_SetItemString(d, "MPI_LXOR", tmp); Py_DECREF(tmp); 01643 tmp = VERT_FUNC((CAST)MPI_BXOR); 01644 PyDict_SetItemString(d, "MPI_BXOR", tmp); Py_DECREF(tmp); 01645 tmp = VERT_FUNC((CAST)MPI_MINLOC); 01646 PyDict_SetItemString(d, "MPI_MINLOC", tmp); Py_DECREF(tmp); 01647 tmp = VERT_FUNC((CAST)MPI_MAXLOC); 01648 PyDict_SetItemString(d, "MPI_MAXLOC", tmp); Py_DECREF(tmp); 01649 tmp = VERT_FUNC((CAST)MPI_MAXLOC); 01650 PyDict_SetItemString(d, "MPI_MAXLOC", tmp); Py_DECREF(tmp); 01651 tmp = VERT_FUNC((CAST)MPI_COMM_NULL); 01652 PyDict_SetItemString(d, "MPI_COMM_NULL", tmp); Py_DECREF(tmp); 01653 tmp = VERT_FUNC((CAST)MPI_OP_NULL); 01654 PyDict_SetItemString(d, "MPI_OP_NULL", tmp); Py_DECREF(tmp); 01655 tmp = VERT_FUNC((CAST)MPI_GROUP_NULL); 01656 PyDict_SetItemString(d, "MPI_GROUP_NULL", tmp); Py_DECREF(tmp); 01657 tmp = VERT_FUNC((CAST)MPI_DATATYPE_NULL); 01658 PyDict_SetItemString(d, "MPI_DATATYPE_NULL", tmp); Py_DECREF(tmp); 01659 tmp = VERT_FUNC((CAST)MPI_REQUEST_NULL); 01660 PyDict_SetItemString(d, "MPI_REQUEST_NULL", tmp); Py_DECREF(tmp); 01661 tmp = VERT_FUNC((CAST)MPI_ERRHANDLER_NULL); 01662 PyDict_SetItemString(d, "MPI_ERRHANDLER_NULL", tmp); Py_DECREF(tmp); 01663 tmp = VERT_FUNC((CAST)MPI_MAX_PROCESSOR_NAME); 01664 PyDict_SetItemString(d, "MPI_MAX_PROCESSOR_NAME", tmp); Py_DECREF(tmp); 01665 tmp = VERT_FUNC((CAST)MPI_MAX_ERROR_STRING); 01666 PyDict_SetItemString(d, "MPI_MAX_ERROR_STRING", tmp); Py_DECREF(tmp); 01667 tmp = PyInt_FromLong((long)MPI_UNDEFINED); 01668 PyDict_SetItemString(d, "MPI_UNDEFINED", tmp); Py_DECREF(tmp); 01669 tmp = VERT_FUNC((CAST)MPI_KEYVAL_INVALID); 01670 PyDict_SetItemString(d, "MPI_KEYVAL_INVALID", tmp); Py_DECREF(tmp); 01671 tmp = VERT_FUNC((CAST)MPI_BSEND_OVERHEAD); 01672 PyDict_SetItemString(d, "MPI_BSEND_OVERHEAD", tmp); Py_DECREF(tmp); 01673 tmp = VERT_FUNC((CAST)MPI_PROC_NULL); 01674 PyDict_SetItemString(d, "MPI_PROC_NULL", tmp); Py_DECREF(tmp); 01675 tmp = VERT_FUNC((CAST)MPI_ANY_SOURCE); 01676 PyDict_SetItemString(d, "MPI_ANY_SOURCE", tmp); Py_DECREF(tmp); 01677 tmp = VERT_FUNC((CAST)MPI_ANY_TAG); 01678 PyDict_SetItemString(d, "MPI_ANY_TAG", tmp); Py_DECREF(tmp); 01679 tmp = VERT_FUNC((CAST)MPI_BOTTOM); 01680 PyDict_SetItemString(d, "MPI_BOTTOM", tmp); Py_DECREF(tmp); 01681 tmp = VERT_FUNC((CAST)MPI_COMM_WORLD); 01682 PyDict_SetItemString(d, "MPI_COMM_WORLD", tmp); Py_DECREF(tmp); 01683 tmp = VERT_FUNC((CAST)MPI_TAG_UB); 01684 PyDict_SetItemString(d, "MPI_TAG_UB", tmp); Py_DECREF(tmp); 01685 tmp = VERT_FUNC((CAST)MPI_HOST); 01686 PyDict_SetItemString(d, "MPI_HOST", tmp); Py_DECREF(tmp); 01687 tmp = VERT_FUNC((CAST)MPI_IO); 01688 PyDict_SetItemString(d, "MPI_IO", tmp); Py_DECREF(tmp); 01689 tmp = VERT_FUNC((CAST)MPI_WTIME_IS_GLOBAL); 01690 PyDict_SetItemString(d, "MPI_WTIME_IS_GLOBAL", tmp); Py_DECREF(tmp); 01691 01692 tmp = PyString_FromString(LIBRARY); 01693 PyDict_SetItemString(d, "ARRAY_LIBRARY", tmp); Py_DECREF(tmp); 01694 01695 tmp = PyString_FromString(DATE_DOC); 01696 PyDict_SetItemString(d, "DATE_DOC", tmp); Py_DECREF(tmp); 01697 tmp = PyString_FromString(DATE_SRC); 01698 PyDict_SetItemString(d, "DATE_SRC", tmp); Py_DECREF(tmp); 01699 01700 #ifdef MPI2 01701 tmp = VERT_FUNC((CAST)MPI_UNIVERSE_SIZE); 01702 PyDict_SetItemString(d, "MPI_UNIVERSE_SIZE", tmp); Py_DECREF(tmp); 01703 tmp = VERT_FUNC((CAST)MPI_ROOT); 01704 PyDict_SetItemString(d, "MPI_ROOT", tmp); Py_DECREF(tmp); 01705 tmp = VERT_FUNC((CAST)MPI_ARGV_NULL); 01706 PyDict_SetItemString(d, "MPI_ARGV_NULL", tmp); Py_DECREF(tmp); 01707 tmp = VERT_FUNC((CAST)MPI_INFO_NULL); 01708 PyDict_SetItemString(d, "MPI_INFO_NULL", tmp); Py_DECREF(tmp); 01709 #endif 01710 }
|
|
Definition at line 1303 of file mympimodule.c. References COM_TYPE, DATA_TYPE, getptype(), and ierr. 01303 { 01304 /* 01305 int MPI_Alltoall( void *sendbuf, int sendcount, MPI_Datatype sendtype, 01306 void *recvbuf, int recvcnt, MPI_Datatype recvtype, 01307 MPI_Comm comm ) 01308 */ 01309 COM_TYPE comm; 01310 DATA_TYPE sendtype,recvtype; 01311 PyObject *sendbuf_obj; 01312 PyArrayObject *array,*result; 01313 int sendcnts,recvcnt; 01314 int numprocs,myid; 01315 int dimensions[1]; 01316 char *sptr,*rptr; 01317 sendcnts=0; 01318 01319 array=NULL; 01320 sptr=NULL; 01321 01322 if (!PyArg_ParseTuple(args, "Oilill", &sendbuf_obj, &sendcnts,&sendtype,&recvcnt,&recvtype,&comm)) 01323 return NULL; 01324 /* ! get the number of processors in this comm */ 01325 ierr=MPI_Comm_size((MPI_Comm)comm,&numprocs); 01326 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 01327 01328 /* get sendbuf */ 01329 array = (PyArrayObject *) PyArray_ContiguousFromObject(sendbuf_obj, getptype(sendtype), 1, 3); 01330 if (array == NULL) 01331 return NULL; 01332 sptr=(char*)(array->data); 01333 01334 01335 /* allocate the recvbuf */ 01336 dimensions[0]=recvcnt*numprocs; 01337 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, getptype(recvtype)); 01338 rptr=(char*)(result->data); 01339 01340 /* do the call */ 01341 ierr=MPI_Alltoall(sptr, sendcnts, (MPI_Datatype)sendtype,rptr,recvcnt,(MPI_Datatype)recvtype, (MPI_Comm )comm ); 01342 Py_DECREF(array); 01343 return PyArray_Return(result); 01344 }
|
|
Definition at line 1345 of file mympimodule.c. References COM_TYPE, DATA_TYPE, getptype(), and ierr. 01345 { 01346 /* 01347 int MPI_Alltoallv ( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype sendtype, 01348 void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype recvtype, 01349 MPI_Comm comm ) 01350 */ 01351 COM_TYPE comm; 01352 DATA_TYPE sendtype,recvtype; 01353 PyObject *sendbuf_obj, *recvcnts_obj,*rdispls_obj,*sdispls_obj,*sendcnts_obj; 01354 PyArrayObject *array,*result; 01355 int *sendcnts,*sdispls,*rdispls,*recvcnts,rtot,i; 01356 char *sptr,*rptr; 01357 int numprocs; 01358 int dimensions[1]; 01359 01360 rdispls=0; 01361 01362 array=NULL; 01363 sptr=NULL; 01364 01365 if (!PyArg_ParseTuple(args, "OOOlOOll", &sendbuf_obj, &sendcnts_obj,&sdispls_obj,&sendtype,&recvcnts_obj,&rdispls_obj,&recvtype,&comm)) 01366 return NULL; 01367 /* ! get the number of processors in this comm */ 01368 ierr=MPI_Comm_size((MPI_Comm)comm,&numprocs); 01369 rtot=0; 01370 recvcnts=0; 01371 01372 /* printf(" get the recvcnts array \n"); */ 01373 array = (PyArrayObject *) PyArray_ContiguousFromObject(recvcnts_obj, PyArray_INT, 1, 1); 01374 if (array == NULL) 01375 return NULL; 01376 recvcnts=(int*)malloc((size_t) (sizeof(int)*numprocs)); 01377 memcpy((void *)recvcnts, (void*)array->data, (size_t) (sizeof(int)*numprocs)); 01378 rtot=0; 01379 for(i=0;i<numprocs;i++) 01380 rtot=rtot+recvcnts[i]; 01381 Py_DECREF(array); 01382 01383 /* printf(" get the recv offset array \n"); */ 01384 array = (PyArrayObject *) PyArray_ContiguousFromObject(rdispls_obj, PyArray_INT, 1, 1); 01385 if (array == NULL) 01386 return NULL; 01387 rdispls=(int*)malloc((size_t) (sizeof(int)*numprocs)); 01388 memcpy((void *)rdispls, (void*)array->data, (size_t) (sizeof(int)*numprocs)); 01389 Py_DECREF(array); 01390 01391 /* printf(" allocate the recvbuf \n"); */ 01392 dimensions[0]=rtot; 01393 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, getptype(recvtype)); 01394 rptr=(char*)(result->data); 01395 01396 01397 01398 /* printf(" get the sendcnts array \n"); */ 01399 array = (PyArrayObject *) PyArray_ContiguousFromObject(sendcnts_obj, PyArray_INT, 1, 1); 01400 if (array == NULL) 01401 return NULL; 01402 sendcnts=(int*)malloc((size_t) (sizeof(int)*numprocs)); 01403 memcpy((void *)sendcnts, (void*)array->data, (size_t) (sizeof(int)*numprocs)); 01404 Py_DECREF(array); 01405 01406 /* printf(" get the send offset array \n"); */ 01407 array = (PyArrayObject *) PyArray_ContiguousFromObject(sdispls_obj, PyArray_INT, 1, 1); 01408 if (array == NULL) 01409 return NULL; 01410 sdispls=(int*)malloc((size_t) (sizeof(int)*numprocs)); 01411 memcpy((void *)sdispls, (void*)array->data, (size_t) (sizeof(int)*numprocs)); 01412 Py_DECREF(array); 01413 01414 /* printf(" get sendbuf\n"); */ 01415 array = (PyArrayObject *) PyArray_ContiguousFromObject(sendbuf_obj, getptype(sendtype), 1, 3); 01416 if (array == NULL) 01417 return NULL; 01418 sptr=(char*)array->data; 01419 01420 /* printf(" do the call %d \n"); */ 01421 /* 01422 MPI_Comm_rank((MPI_Comm)comm,&myid); 01423 printf("myid =%d ",myid); 01424 for(i=0;i<numprocs;i++) 01425 printf("%d ",sendcnts[i]); 01426 printf(" | "); 01427 for(i=0;i<numprocs;i++) 01428 printf("%d ",sdispls[i]); 01429 printf(" | "); 01430 for(i=0;i<numprocs;i++) 01431 printf("%d ",recvcnts[i]); 01432 printf(" | "); 01433 for(i=0;i<numprocs;i++) 01434 printf("%d ",rdispls[i]); 01435 printf("\n"); 01436 */ 01437 ierr=MPI_Alltoallv(sptr, sendcnts, sdispls, (MPI_Datatype)sendtype, 01438 rptr, recvcnts, rdispls, (MPI_Datatype)recvtype, 01439 (MPI_Comm)comm); 01440 01441 Py_DECREF(array); 01442 free(recvcnts); 01443 free(rdispls); 01444 free(sendcnts); 01445 free(sdispls); 01446 01447 return PyArray_Return(result); 01448 }
|
|
Definition at line 434 of file mympimodule.c. References COM_TYPE, flag, and ierr. 00434 { 00435 /* 00436 int MPI_Attr_get ( MPI_Comm comm,int keyval,void *attr_value,int *flag) 00437 Input Parameters 00438 comm communicator to which attribute is attached (handle) 00439 keyval key value (integer) 00440 00441 Output Parameters 00442 attr_value attribute value, unless flag = false 00443 flag true if an attribute value was extracted; false if no attribute is associated with the key 00444 */ 00445 00446 int keyval, *attr_value; 00447 int flag; 00448 COM_TYPE comm; 00449 if (!PyArg_ParseTuple(args, "li", &comm, &keyval)) 00450 return NULL; 00451 00452 /* printf("mpi_attr_get: keyval:%d\n",keyval); */ 00453 00454 /* get the keyval for the specified attribute */ 00455 ierr = MPI_Attr_get((MPI_Comm)comm, keyval, &attr_value,&flag); 00456 if ( !flag ) { 00457 return NULL; 00458 } 00459 00460 /* printf("mpi_attr_get: attr_val: %d %d\n",*attr_value,flag); */ 00461 return( PyInt_FromLong((long)*attr_value)); 00462 }
|
|
Definition at line 342 of file mympimodule.c. References COM_TYPE, and ierr. 00343 { 00344 /* int MPI_Barrier ( MPI_Comm comm ) */ 00345 COM_TYPE comm; 00346 int ierr; 00347 00348 if (!PyArg_ParseTuple(args, "l", &comm)) 00349 return NULL; 00350 ierr=MPI_Barrier((MPI_Comm)comm ); 00351 return PyInt_FromLong((long)ierr); 00352 }
|
|
Definition at line 964 of file mympimodule.c. References COM_TYPE, DATA_TYPE, getptype(), and ierr. 00964 { 00965 /* int MPI_Bcast ( void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm ) */ 00966 int count,root; 00967 DATA_TYPE datatype; 00968 COM_TYPE comm; 00969 int myid; 00970 int mysize; 00971 PyArrayObject *result; 00972 PyArrayObject *array; 00973 PyObject *input; 00974 int dimensions[1]; 00975 char *aptr; 00976 00977 if (!PyArg_ParseTuple(args, "Oilil", &input, &count,&datatype,&root,&comm)) 00978 return NULL; 00979 dimensions[0]=count; 00980 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, getptype(datatype)); 00981 aptr=(char*)(result->data); 00982 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 00983 #ifdef MPI2 00984 if(myid == root || root == MPI_ROOT) { 00985 #else 00986 if(myid == root) { 00987 #endif 00988 array = (PyArrayObject *) PyArray_ContiguousFromObject(input, getptype(datatype), 0, 3); 00989 if (array == NULL) 00990 return NULL; 00991 ierr=MPI_Type_size((MPI_Datatype)datatype,&mysize); 00992 memcpy((void *)(result->data), (void*)array->data, (size_t) (mysize*count)); 00993 Py_DECREF(array); 00994 } 00995 ierr=MPI_Bcast(aptr,count,(MPI_Datatype)datatype,root,(MPI_Comm)comm); 00996 return PyArray_Return(result); 00997 }
|
|
Definition at line 322 of file mympimodule.c. References CAST, COM_TYPE, ierr, and VERT_FUNC. 00323 { 00324 /* int MPI_Comm_create ( MPI_Comm comm, MPI_Group group, MPI_Comm *comm_out ) */ 00325 #ifdef DO_UNSIGED 00326 #define CAST unsigned long 00327 #define VERT_FUNC PyLong_FromUnsignedLong 00328 #else 00329 #define CAST long 00330 #define VERT_FUNC PyInt_FromLong 00331 #endif 00332 COM_TYPE incomm,outcomm; 00333 long group; 00334 00335 if (!PyArg_ParseTuple(args, "ll", &incomm,&group)) 00336 return NULL; 00337 ierr=MPI_Comm_create ((MPI_Comm)incomm,(MPI_Group)group,(MPI_Comm*)&outcomm ); 00338 return VERT_FUNC((CAST)outcomm); 00339 }
|
|
Definition at line 271 of file mympimodule.c. References CAST, COM_TYPE, ierr, and VERT_FUNC. 00272 { 00273 /* int MPI_Comm_dup ( MPI_Comm comm, MPI_Comm *comm_out ) */ 00274 #ifdef DO_UNSIGED 00275 #define CAST unsigned long 00276 #define VERT_FUNC PyLong_FromUnsignedLong 00277 #else 00278 #define CAST long 00279 #define VERT_FUNC PyInt_FromLong 00280 #endif 00281 long tmpcomm; 00282 COM_TYPE incomm,outcomm; 00283 00284 if (!PyArg_ParseTuple(args, "l", &tmpcomm)) 00285 return NULL; 00286 incomm=(COM_TYPE)tmpcomm; 00287 ierr=MPI_Comm_dup ((MPI_Comm)incomm,(MPI_Comm*)&outcomm ); 00288 return VERT_FUNC((CAST)outcomm); 00289 }
|
|
Definition at line 248 of file mympimodule.c. References CAST, COM_TYPE, ierr, and VERT_FUNC. 00249 { 00250 /* int MPI_Comm_group ( MPI_Comm comm, MPI_Group *group ) */ 00251 #ifdef DO_UNSIGED 00252 #define CAST unsigned long 00253 #define VERT_FUNC PyLong_FromUnsignedLong 00254 #else 00255 #define CAST long 00256 #define VERT_FUNC PyInt_FromLong 00257 #endif 00258 MPI_Group group; 00259 COM_TYPE comm; 00260 int ierr; 00261 00262 if (!PyArg_ParseTuple(args, "l", &comm)) 00263 return NULL; 00264 if((sizeof(MPI_Group) != sizeof(long)) && (sizeof(MPI_Group) != sizeof(int))) 00265 printf("can not return MPI_Group as long or int sizes %ld %ld %ld", 00266 sizeof(MPI_Group),sizeof(long),sizeof(int)); 00267 ierr=MPI_Comm_group ( (MPI_Comm) comm, &group ); 00268 return VERT_FUNC((CAST)group); 00269 }
|
|
Definition at line 777 of file mympimodule.c. References COM_TYPE, and ierr. 00778 { 00779 /* int MPI_Probe( int source, int tag, MPI_Comm comm, MPI_Status *status ) */ 00780 COM_TYPE comm; 00781 int rank; 00782 00783 if (!PyArg_ParseTuple(args, "l",&comm)) 00784 return NULL; 00785 ierr=MPI_Comm_rank((MPI_Comm)comm,&rank); 00786 return PyInt_FromLong((long)rank); 00787 }
|
|
Definition at line 292 of file mympimodule.c. References COM_TYPE, ierr, and newerr. 00293 { 00294 /* int MPI_Comm_dup ( MPI_Comm comm, MPI_Comm *comm_out ) */ 00295 #ifdef DO_UNSIGED 00296 #define CAST unsigned long 00297 #define VERT_FUNC PyLong_FromUnsignedLong 00298 #else 00299 #define CAST long 00300 #define VERT_FUNC PyInt_FromLong 00301 #endif 00302 long tmpcomm; 00303 COM_TYPE incomm; 00304 int choice; 00305 00306 if (!PyArg_ParseTuple(args, "li", &tmpcomm,&choice)) 00307 return NULL; 00308 incomm=(COM_TYPE)tmpcomm; 00309 if(choice == 0) 00310 ierr= MPI_Comm_set_errhandler( (MPI_Comm)incomm, MPI_ERRORS_ARE_FATAL ); 00311 if(choice == 1) 00312 ierr= MPI_Comm_set_errhandler( (MPI_Comm)incomm, MPI_ERRORS_RETURN ); 00313 if(choice == 2) 00314 ierr= MPI_Comm_set_errhandler( (MPI_Comm)incomm, newerr ); 00315 00316 return PyInt_FromLong((long)ierr); 00317 }
|
|
Definition at line 765 of file mympimodule.c. References COM_TYPE, and ierr. 00766 { 00767 /* int MPI_Probe( int source, int tag, MPI_Comm comm, MPI_Status *status ) */ 00768 COM_TYPE comm; 00769 int numprocs; 00770 00771 if (!PyArg_ParseTuple(args, "l",&comm)) 00772 return NULL; 00773 ierr=MPI_Comm_size((MPI_Comm)comm,&numprocs); 00774 return PyInt_FromLong((long)numprocs); 00775 }
|
|
Definition at line 721 of file mympimodule.c. References CAST, COM_TYPE, ierr, key, and VERT_FUNC. 00722 { 00723 /* int MPI_Comm_split ( MPI_Comm comm, int color, int key, MPI_Comm *comm_out ) */ 00724 #ifdef DO_UNSIGED 00725 #define CAST unsigned long 00726 #define VERT_FUNC PyLong_FromUnsignedLong 00727 #else 00728 #define CAST long 00729 #define VERT_FUNC PyInt_FromLong 00730 #endif 00731 int color,key; 00732 COM_TYPE incomm,outcomm; 00733 00734 if (!PyArg_ParseTuple(args, "lii", &incomm,&color,&key)) 00735 return NULL; 00736 ierr=MPI_Comm_split ((MPI_Comm)incomm,color,key,(MPI_Comm*)&outcomm ); 00737 return VERT_FUNC((CAST)outcomm); 00738 }
|
|
Definition at line 418 of file mympimodule.c. References ierr. 00419 { 00420 return PyInt_FromLong((long)ierr); 00421 }
|
|
Definition at line 1298 of file mympimodule.c. References erroron. 01298 { 01299 /* int MPI_Finalize() */ 01300 if(erroron){ erroron=0; return NULL;} 01301 return PyInt_FromLong((long)MPI_Finalize()); 01302 }
|
|
Definition at line 1148 of file mympimodule.c. References COM_TYPE, DATA_TYPE, getptype(), and ierr. 01148 { 01149 /* 01150 int MPI_Gather ( void *sendbuf, int sendcnt, MPI_Datatype sendtype, 01151 void *recvbuf, int recvcnts, 01152 MPI_Datatype recvtype, 01153 int root, MPI_Comm comm ) 01154 */ 01155 int root; 01156 COM_TYPE comm; 01157 DATA_TYPE sendtype,recvtype; 01158 PyObject *sendbuf_obj; 01159 PyArrayObject *array,*result; 01160 int sendcnt,recvcnt,rtot; 01161 char *sptr,*rptr; 01162 int numprocs,myid; 01163 int dimensions[1]; 01164 01165 array=NULL; 01166 sptr=NULL; 01167 01168 if (!PyArg_ParseTuple(args, "Oililil", &sendbuf_obj, &sendcnt,&sendtype,&recvcnt,&recvtype,&root,&comm)) 01169 return NULL; 01170 /* ! get the number of processors in this comm */ 01171 ierr=MPI_Comm_size((MPI_Comm)comm,&numprocs); 01172 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 01173 rtot=0; 01174 /* printf(" get sendbuf\n"); */ 01175 array = (PyArrayObject *) PyArray_ContiguousFromObject(sendbuf_obj, getptype(sendtype), 0, 3); 01176 if (array == NULL) 01177 return NULL; 01178 sptr=array->data; 01179 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 01180 #ifdef MPI2 01181 if(myid == root || root == MPI_ROOT) { 01182 #else 01183 if(myid == root) { 01184 #endif 01185 rtot=recvcnt*numprocs; 01186 } 01187 /* printf(" allocate the recvbuf \n"); */ 01188 dimensions[0]=rtot; 01189 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, getptype(recvtype)); 01190 rptr=(char*)(result->data); 01191 01192 01193 /* printf(" do the call %d \n",recvcnt); */ 01194 ierr=MPI_Gather(sptr, sendcnt, (MPI_Datatype)sendtype,rptr,recvcnt,(MPI_Datatype)recvtype, root, (MPI_Comm )comm ); 01195 Py_DECREF(array); 01196 /* printf(" did the call %d \n",myid); */ 01197 return PyArray_Return(result); 01198 }
|
|
Definition at line 1069 of file mympimodule.c. References COM_TYPE, DATA_TYPE, getptype(), and ierr. 01069 { 01070 /* 01071 int MPI_Gatherv ( void *sendbuf, int sendcnt, MPI_Datatype sendtype, 01072 void *recvbuf, int *recvcnts, int *displs, MPI_Datatype recvtype, 01073 int root, MPI_Comm comm ) 01074 */ 01075 int root; 01076 COM_TYPE comm; 01077 DATA_TYPE sendtype,recvtype; 01078 PyObject *sendbuf_obj, *recvcnts_obj,*displs_obj; 01079 PyArrayObject *array,*result; 01080 int sendcnt,*displs,*recvcnts,rtot,i; 01081 char *sptr,*rptr; 01082 int numprocs,myid; 01083 int dimensions[1]; 01084 01085 displs=0; 01086 01087 array=NULL; 01088 sptr=NULL; 01089 01090 if (!PyArg_ParseTuple(args, "OilOOlil", &sendbuf_obj, &sendcnt,&sendtype,&recvcnts_obj,&displs_obj,&recvtype,&root,&comm)) 01091 return NULL; 01092 /* ! get the number of processors in this comm */ 01093 ierr=MPI_Comm_size((MPI_Comm)comm,&numprocs); 01094 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 01095 rtot=0; 01096 recvcnts=0; 01097 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 01098 #ifdef MPI2 01099 if(myid == root || root == MPI_ROOT) { 01100 #else 01101 if(myid == root) { 01102 #endif 01103 /* printf(" get the recv_counts array \n"); */ 01104 array = (PyArrayObject *) PyArray_ContiguousFromObject(recvcnts_obj, PyArray_INT, 1, 1); 01105 if (array == NULL) 01106 return NULL; 01107 recvcnts=(int*)malloc((size_t) (sizeof(int)*numprocs)); 01108 memcpy((void *)recvcnts, (void*)array->data, (size_t) (sizeof(int)*numprocs)); 01109 rtot=0; 01110 for(i=0;i<numprocs;i++) 01111 rtot=rtot+recvcnts[i]; 01112 Py_DECREF(array); 01113 /* printf(" get the offset array \n"); */ 01114 array = (PyArrayObject *) PyArray_ContiguousFromObject(displs_obj, PyArray_INT, 1, 1); 01115 if (array == NULL) 01116 return NULL; 01117 displs=(int*)malloc((size_t) (sizeof(int)*numprocs)); 01118 memcpy((void *)displs, (void*)array->data, (size_t) (sizeof(int)*numprocs)); 01119 Py_DECREF(array); 01120 } 01121 /* printf(" allocate the recvbuf \n"); */ 01122 dimensions[0]=rtot; 01123 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, getptype(recvtype)); 01124 rptr=(char*)(result->data); 01125 /* printf(" get sendbuf\n"); */ 01126 array = (PyArrayObject *) PyArray_ContiguousFromObject(sendbuf_obj, getptype(sendtype), 1, 3); 01127 if (array == NULL) 01128 return NULL; 01129 sptr=array->data; 01130 01131 01132 /* printf(" do the call %d \n",recvcnt); */ 01133 ierr=MPI_Gatherv(sptr, sendcnt, (MPI_Datatype)sendtype,rptr,recvcnts,displs,(MPI_Datatype)recvtype, root, (MPI_Comm )comm ); 01134 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 01135 #ifdef MPI2 01136 if(myid == root || root == MPI_ROOT) { 01137 #else 01138 if(myid == root) { 01139 #endif 01140 Py_DECREF(array); 01141 free(recvcnts); 01142 free(displs); 01143 } 01144 /* printf(" did the call %d \n",myid); */ 01145 return PyArray_Return(result); 01146 }
|
|
Definition at line 752 of file mympimodule.c. References DATA_TYPE, ierr, and status. 00753 { 00754 /* int MPI_Get_count( MPI_Status *status, MPI_Datatype datatype, int *count ) */ 00755 DATA_TYPE datatype; 00756 int count; 00757 00758 if (!PyArg_ParseTuple(args, "l",&datatype)) 00759 return NULL; 00760 ierr=MPI_Get_count(&status,(MPI_Datatype)datatype,&count); 00761 return PyInt_FromLong((long)count); 00762 }
|
|
Definition at line 159 of file mympimodule.c. References ierr. 00160 { 00161 /* int MPI_Get_processor_name( char *name, int *resultlen) */ 00162 char c_name[MPI_MAX_PROCESSOR_NAME]; 00163 int c_len; 00164 ierr=MPI_Get_processor_name((char *)c_name,&c_len); 00165 return PyString_FromStringAndSize(c_name,c_len); 00166 }
|
|
Definition at line 216 of file mympimodule.c. References CAST, ierr, and VERT_FUNC. 00217 { 00218 /* int MPI_Group_incl ( MPI_Group group, int n, int *ranks, MPI_Group *group_out ) */ 00219 #ifdef DO_UNSIGED 00220 #define CAST unsigned long 00221 #define VERT_FUNC PyLong_FromUnsignedLong 00222 #else 00223 #define CAST long 00224 #define VERT_FUNC PyInt_FromLong 00225 #endif 00226 long in_group; 00227 int *ranks,n; 00228 MPI_Group group,out_group; 00229 PyObject *ranks_obj; 00230 PyArrayObject *array; 00231 00232 if (!PyArg_ParseTuple(args, "liO", &in_group,&n,&ranks_obj)) 00233 return NULL; 00234 group=(MPI_Group)in_group; 00235 array = (PyArrayObject *) PyArray_ContiguousFromObject(ranks_obj, PyArray_INT, 1, 1); 00236 if (array == NULL) 00237 return NULL; 00238 if(array->dimensions[0] < n) 00239 return NULL; 00240 ranks=(int*)malloc((size_t) (n*sizeof(int))); 00241 memcpy((void*)ranks,(void *)(array->data), (size_t) (n*sizeof(int))); 00242 ierr=MPI_Group_incl ( (MPI_Group )group, n, ranks, &out_group); 00243 free(ranks); 00244 Py_DECREF(array); 00245 return VERT_FUNC((CAST)out_group); 00246 }
|
|
Definition at line 202 of file mympimodule.c. References ierr. 00203 { 00204 /* int MPI_Group_rank ( MPI_Group group, int *rank ) */ 00205 long in_group; 00206 int rank; 00207 MPI_Group group; 00208 00209 if (!PyArg_ParseTuple(args, "l", &in_group)) 00210 return NULL; 00211 group=(MPI_Group)in_group; 00212 ierr=MPI_Group_rank (group, &rank ); 00213 return PyInt_FromLong((long)rank); 00214 }
|
|
Definition at line 802 of file mympimodule.c. References data, eh(), erroron, ierr, and newerr. 00802 { 00803 PyObject *input; 00804 int argc,i,n; 00805 int did_it; 00806 char **argv; 00807 #ifdef ARG_STR 00808 char *argstr; 00809 int *strides; 00810 int arglen; 00811 #endif 00812 #ifdef SIZE_RANK 00813 PyArrayObject *result; 00814 int dimensions[1],data[2]; 00815 char *aptr; 00816 #endif 00817 #ifdef ARG_ARRAY 00818 PyObject *result; 00819 #endif 00820 int myid; 00821 int len; 00822 argv=NULL; 00823 erroron=0; 00824 ierr=MPI_Initialized(&did_it); 00825 if(!did_it){ 00826 if (!PyArg_ParseTuple(args, "iO", &argc, &input)) 00827 return NULL; 00828 argv=(char**)malloc((argc+2)*sizeof(char*)); 00829 n=PyList_Size(input); 00830 for(i=0;i<n;i++) { 00831 len=strlen(PyString_AsString(PyList_GetItem(input,i))); 00832 argv[i]=(char*)malloc(len+1); 00833 argv[i][len]=(char)0; 00834 strncpy(argv[i],PyString_AsString(PyList_GetItem(input,i)),(size_t)len); 00835 /* printf("%s ",argv[i]); */ 00836 } 00837 00838 /* printf("\n"); */ 00839 Py_DECREF(input); 00840 #ifdef LAM_MPI 00841 ierr=MPI_Init(NULL,NULL); 00842 #else 00843 ierr=MPI_Init(&argc,&argv); 00844 ierr=MPI_Comm_rank(MPI_COMM_WORLD,&myid); 00845 00846 /* 00847 for(i=0;i<argc;i++) { 00848 printf("from %d init %d %s\n",myid,i,argv[i]); 00849 00850 } 00851 */ 00852 #endif 00853 00854 #ifdef MPI2 00855 MPI_Comm_create_errhandler( eh, &newerr ); 00856 #endif 00857 00858 /* free(argv); */ 00859 } 00860 00861 /* this returns the command line as a string */ 00862 #ifdef ARG_STR 00863 arglen=0; 00864 strides=(int*)malloc(argc*sizeof(int)); 00865 strides[0]=0; 00866 for(i=0;i<argc;i++) { 00867 arglen=arglen+strlen(argv[i])+1; 00868 strides[i+1]=strides[i]+strlen(argv[i])+1; 00869 } 00870 argstr=(char*)malloc(arglen*sizeof(char)); 00871 for(i=0;i<argc;i++) { 00872 for(n=0;n<strlen(argv[i]);n++) { 00873 argstr[strides[i]+n]=argv[i][n]; 00874 } 00875 argstr[strides[i]+strlen(argv[i])]=(char)32; 00876 /* 00877 free(argv[i]); 00878 */ 00879 } 00880 return PyString_FromString(argstr); 00881 #endif 00882 #ifdef ARG_ARRAY 00883 result = PyTuple_New(argc); 00884 for(i=0;i<argc;i++) { 00885 PyTuple_SetItem(result,i,PyString_FromString(argv[i])); 00886 } 00887 /* 00888 for(i=0;i<argc;i++) { 00889 free(argv[i]); 00890 } 00891 */ 00892 return result; 00893 #endif 00894 /* this returns size and rank */ 00895 #ifdef SIZE_RANK 00896 ierr=MPI_Comm_size(MPI_COMM_WORLD,&numprocs); 00897 ierr=MPI_Comm_rank(MPI_COMM_WORLD,&myid); 00898 dimensions[0]=2; 00899 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, PyArray_INT); 00900 if (result == NULL) 00901 return NULL; 00902 data[0]=myid; 00903 data[1]=numprocs; 00904 aptr=(char*)&(data); 00905 for(i=0;i<8;i++) 00906 result->data[i]=aptr[i]; 00907 if(erroron){ erroron=0; return NULL;} 00908 return PyArray_Return(result); 00909 #endif 00910 }
|
|
Definition at line 790 of file mympimodule.c. References COM_TYPE, flag, ierr, and status. 00791 { 00792 /* int MPI_Iprobe( int source, int tag, MPI_Comm comm, int *flag, MPI_Status *status ) */ 00793 int source,tag,flag; 00794 COM_TYPE comm; 00795 00796 if (!PyArg_ParseTuple(args, "iil", &source,&tag,&comm)) 00797 return NULL; 00798 ierr=MPI_Iprobe(source,tag, (MPI_Comm )comm, &flag,&status ); 00799 return PyInt_FromLong((long)flag); 00800 }
|
|
Definition at line 195 of file mympimodule.c. 00196 { 00197 /* int MPI_Irecv( void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request ) */ 00198 printf("this routine does not work yet\n"); 00199 return NULL; 00200 }
|
|
Definition at line 189 of file mympimodule.c. 00190 { 00191 /* int MPI_Isend( void *buf, int count, MPI_Datatype datatype, int dest, int tag,MPI_Comm comm, MPI_Request *request ) */ 00192 printf("this routine does not work yet\n"); 00193 return NULL; 00194 }
|
|
Definition at line 740 of file mympimodule.c. References COM_TYPE, ierr, and status. 00741 { 00742 /* int MPI_Probe( int source, int tag, MPI_Comm comm, MPI_Status *status ) */ 00743 int source,tag; 00744 COM_TYPE comm; 00745 00746 if (!PyArg_ParseTuple(args, "iil", &source,&tag,&comm)) 00747 return NULL; 00748 ierr=MPI_Probe(source,tag, (MPI_Comm )comm, &status ); 00749 return PyInt_FromLong((long)0); 00750 }
|
|
Definition at line 384 of file mympimodule.c. References COM_TYPE, DATA_TYPE, getptype(), ierr, and status. 00385 { 00386 /* int MPI_Recv( void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status ) */ 00387 int count,source,tag; 00388 DATA_TYPE datatype; 00389 COM_TYPE comm; 00390 PyArrayObject *result; 00391 int dimensions[1]; 00392 char *aptr; 00393 00394 if (!PyArg_ParseTuple(args, "iliil", &count,&datatype,&source,&tag,&comm)) 00395 return NULL; 00396 dimensions[0]=count; 00397 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, getptype(datatype)); 00398 aptr=(char*)(result->data); 00399 ierr=MPI_Recv( aptr, count, (MPI_Datatype)datatype,source,tag, (MPI_Comm)comm, &status ); 00400 return PyArray_Return(result); 00401 }
|
|
Definition at line 1258 of file mympimodule.c. References COM_TYPE, DATA_TYPE, getptype(), and ierr. 01258 { 01259 /* int MPI_Reduce ( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm ) */ 01260 int count,root; 01261 DATA_TYPE datatype; 01262 COM_TYPE comm; 01263 long op; 01264 int myid; 01265 PyArrayObject *result; 01266 PyArrayObject *array; 01267 PyObject *input; 01268 int dimensions[1]; 01269 char *sptr,*rptr; 01270 01271 if (!PyArg_ParseTuple(args, "Oillil", &input, &count,&datatype,&op,&root,&comm)) 01272 return NULL; 01273 MPI_Comm_rank((MPI_Comm)comm,&myid); 01274 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 01275 #ifdef MPI2 01276 if(myid == root || root == MPI_ROOT) { 01277 #else 01278 if(myid == root) { 01279 #endif 01280 dimensions[0]=count; 01281 } 01282 else { 01283 dimensions[0]=0; 01284 } 01285 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, getptype(datatype)); 01286 rptr=(char*)(result->data); 01287 01288 array = (PyArrayObject *) PyArray_ContiguousFromObject(input, getptype(datatype), 0, 3); 01289 if (array == NULL) 01290 return NULL; 01291 sptr=(char*)(array->data); 01292 ierr=MPI_Reduce(sptr,rptr,count,(MPI_Datatype)datatype,(MPI_Op)op,root,(MPI_Comm)comm); 01293 Py_DECREF(array); 01294 return PyArray_Return(result); 01295 }
|
|
Definition at line 1200 of file mympimodule.c. References COM_TYPE, DATA_TYPE, getptype(), and ierr. 01200 { 01201 /* 01202 int MPI_Scatter ( void *sendbuf, int sendcnt, MPI_Datatype sendtype, 01203 void *recvbuf, int recvcnt, MPI_Datatype recvtype, 01204 int root, MPI_Comm comm ) 01205 */ 01206 int root; 01207 COM_TYPE comm; 01208 DATA_TYPE sendtype,recvtype; 01209 PyObject *sendbuf_obj; 01210 PyArrayObject *array,*result; 01211 int sendcnts,recvcnt; 01212 int numprocs,myid; 01213 int dimensions[1]; 01214 char *sptr,*rptr; 01215 01216 sendcnts=0; 01217 01218 array=NULL; 01219 sptr=NULL; 01220 01221 if (!PyArg_ParseTuple(args, "Oililil", &sendbuf_obj, &sendcnts,&sendtype,&recvcnt,&recvtype,&root,&comm)) 01222 return NULL; 01223 /* ! get the number of processors in this comm */ 01224 ierr=MPI_Comm_size((MPI_Comm)comm,&numprocs); 01225 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 01226 01227 #ifdef MPI2 01228 if(myid == root || root == MPI_ROOT) { 01229 #else 01230 if(myid == root) { 01231 #endif 01232 /* get sendbuf */ 01233 array = (PyArrayObject *) PyArray_ContiguousFromObject(sendbuf_obj, getptype(sendtype), 1, 3); 01234 if (array == NULL) 01235 return NULL; 01236 sptr=(char*)(array->data); 01237 01238 } 01239 01240 /* allocate the recvbuf */ 01241 dimensions[0]=recvcnt; 01242 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, getptype(recvtype)); 01243 rptr=(char*)(result->data); 01244 01245 /* do the call */ 01246 ierr=MPI_Scatter(sptr, sendcnts, (MPI_Datatype)sendtype,rptr,recvcnt,(MPI_Datatype)recvtype, root, (MPI_Comm )comm ); 01247 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 01248 #ifdef MPI2 01249 if(myid == root || root == MPI_ROOT) { 01250 #else 01251 if(myid == root) { 01252 #endif 01253 Py_DECREF(array); 01254 } 01255 return PyArray_Return(result); 01256 }
|
|
Definition at line 1000 of file mympimodule.c. References COM_TYPE, DATA_TYPE, getptype(), and ierr. 01000 { 01001 /* int MPI_Scatterv(void *sendbuf, int *sendcnts, int *displs, MPI_Datatype sendtype, 01002 void *recvbuf, int recvcnt, MPI_Datatype recvtype, 01003 int root, MPI_Comm comm ) */ 01004 int root; 01005 COM_TYPE comm; 01006 DATA_TYPE sendtype,recvtype; 01007 PyObject *sendbuf_obj, *sendcnts_obj,*displs_obj; 01008 PyArrayObject *array,*result; 01009 int *sendcnts,*displs,recvcnt; 01010 char *sptr,*rptr; 01011 int *sray; 01012 int numprocs,myid; 01013 int dimensions[1]; 01014 01015 sendcnts=0; 01016 displs=0; 01017 01018 array=NULL; 01019 sptr=NULL; 01020 01021 if (!PyArg_ParseTuple(args, "OOOlilil", &sendbuf_obj, &sendcnts_obj,&displs_obj,&sendtype,&recvcnt,&recvtype,&root,&comm)) 01022 return NULL; 01023 /* ! get the number of processors in this comm */ 01024 ierr=MPI_Comm_size((MPI_Comm)comm,&numprocs); 01025 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 01026 01027 01028 #ifdef MPI2 01029 if(myid == root || root == MPI_ROOT) { 01030 #else 01031 if(myid == root) { 01032 #endif 01033 array = (PyArrayObject *) PyArray_ContiguousFromObject(sendcnts_obj, PyArray_INT, 1, 1); 01034 if (array == NULL) 01035 return NULL; 01036 sendcnts=(int*)malloc((size_t) (sizeof(int)*numprocs)); 01037 memcpy((void *)sendcnts, (void*)array->data, (size_t) (sizeof(int)*numprocs)); 01038 Py_DECREF(array); 01039 array = (PyArrayObject *) PyArray_ContiguousFromObject(displs_obj, PyArray_INT, 1, 1); 01040 if (array == NULL) 01041 return NULL; 01042 displs=(int*)malloc((size_t) (sizeof(int)*numprocs)); 01043 memcpy((void *)displs, (void*)array->data, (size_t) (sizeof(int)*numprocs)); 01044 Py_DECREF(array); 01045 array = (PyArrayObject *) PyArray_ContiguousFromObject(sendbuf_obj, getptype(sendtype), 1, 3); 01046 if (array == NULL) 01047 return NULL; 01048 sptr=(char*)(array->data); 01049 } 01050 01051 dimensions[0]=recvcnt; 01052 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, getptype(recvtype)); 01053 rptr=(char*)(result->data); 01054 01055 ierr=MPI_Scatterv(sptr, sendcnts, displs, (MPI_Datatype)sendtype,rptr,recvcnt,(MPI_Datatype)recvtype, root, (MPI_Comm )comm ); 01056 ierr=MPI_Comm_rank((MPI_Comm)comm,&myid); 01057 #ifdef MPI2 01058 if(myid == root || root == MPI_ROOT) { 01059 #else 01060 if(myid == root) { 01061 #endif 01062 Py_DECREF(array); 01063 free(sendcnts); 01064 free(displs); 01065 } 01066 return PyArray_Return(result); 01067 }
|
|
Definition at line 353 of file mympimodule.c. References COM_TYPE, DATA_TYPE, getptype(), and ierr. 00354 { 00355 /* int MPI_Send( void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm ) */ 00356 int count,dest,tag; 00357 DATA_TYPE datatype; 00358 COM_TYPE comm; 00359 int i,n; 00360 PyObject *input; 00361 PyArrayObject *array; 00362 char *aptr; 00363 00364 if (!PyArg_ParseTuple(args, "Oiliil", &input, &count,&datatype,&dest,&tag,&comm)) 00365 return NULL; 00366 array = (PyArrayObject *) PyArray_ContiguousFromObject(input, getptype(datatype), 0, 3); 00367 if (array == NULL) 00368 return NULL; 00369 /* 00370 n=1; 00371 for(i=0;i<array->nd;i++) 00372 n = n* array->dimensions[i]; 00373 if(array->nd == 0)n=1; 00374 if (n < count) 00375 return NULL; 00376 */ 00377 aptr=(char*)(array->data); 00378 ierr=MPI_Send(aptr, count, (MPI_Datatype)datatype, dest, tag, (MPI_Comm)comm ); 00379 Py_DECREF(array); 00380 return PyInt_FromLong((long)ierr); 00381 }
|
|
Definition at line 912 of file mympimodule.c. References data, eh(), erroron, ierr, and newerr. 00912 { 00913 PyArrayObject *result; 00914 int argc,did_it,i; 00915 int dimensions[1],data[2]; 00916 int numprocs,myid; 00917 char *command,*aptr; 00918 char **argv; 00919 erroron=0; 00920 if (!PyArg_ParseTuple(args, "is", &argc, &command)) 00921 return NULL; 00922 ierr=MPI_Initialized(&did_it); 00923 if(!did_it){ 00924 /* MPI_Init(0,0); */ /* lam mpi will start with this line 00925 mpich requires us to build a real 00926 command line */ 00927 /* MPI_Init(0,0); */ 00928 argv=(char**)malloc((argc+2)*sizeof(char*)); 00929 argv[0]=(char*)malloc(128); 00930 sprintf(argv[0],"dummy"); 00931 strtok(command, " "); 00932 for(i=0;i<argc-1;i++) { 00933 argv[i+1]=strtok(NULL, " "); 00934 } 00935 printf("calling mpi init from mpi_start\n"); 00936 for (i=0;i<argc;i++) 00937 printf("%d %d %s\n",i,(int)strlen(argv[i]),argv[i]); 00938 #ifdef LAM_MPI 00939 ierr=MPI_Init(NULL,NULL); 00940 #else 00941 ierr=MPI_Init(&argc,&argv); 00942 #endif 00943 } 00944 ierr=MPI_Comm_size(MPI_COMM_WORLD,&numprocs); 00945 ierr=MPI_Comm_rank(MPI_COMM_WORLD,&myid); 00946 #ifdef MPI2 00947 MPI_Comm_create_errhandler( eh, &newerr ); 00948 #endif 00949 00950 00951 dimensions[0]=2; 00952 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, PyArray_INT); 00953 if (result == NULL) 00954 return NULL; 00955 data[0]=myid; 00956 data[1]=numprocs; 00957 aptr=(char*)&(data); 00958 for(i=0;i<8;i++) 00959 result->data[i]=aptr[i]; 00960 if(erroron){ erroron=0; return NULL;} 00961 return PyArray_Return(result); 00962 }
|
|
Definition at line 403 of file mympimodule.c. References status. 00404 { 00405 /* int MPI_Recv( void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status ) */ 00406 PyArrayObject *result; 00407 int dimensions[1],statray[3]; 00408 00409 dimensions[0]=3; 00410 result = (PyArrayObject *)PyArray_FromDims(1, dimensions, PyArray_INT); 00411 statray[0]=status.MPI_SOURCE; 00412 statray[1]=status.MPI_TAG; 00413 statray[2]=status.MPI_ERROR; 00414 memcpy((void *)(result->data), (void*)statray, (size_t) (12)); 00415 return PyArray_Return(result); 00416 }
|
|
Definition at line 176 of file mympimodule.c. 00177 { 00178 /* int MPI_Test (MPI_Request *request,int *flag, MPI_Status *status) */ 00179 printf("this routine does not work yet\n"); 00180 return NULL; 00181 }
|
|
Definition at line 183 of file mympimodule.c. 00184 { 00185 /* int MPI_Wait (MPI_Request *request, MPI_Status *status) */ 00186 printf("this routine does not work yet\n"); 00187 return NULL; 00188 }
|
|
Definition at line 429 of file mympimodule.c. 00429 {
00430
00431 return( PyFloat_FromDouble(MPI_Wtick()));
00432 }
|
|
Definition at line 424 of file mympimodule.c. 00424 {
00425
00426 return( PyFloat_FromDouble(MPI_Wtime()));
00427 }
|
|
Definition at line 1711 of file mympimodule.c. References erroron, and mpiError. 01711 { 01712 erroron=1; 01713 PyErr_SetString(mpiError,s); 01714 }
|
|
|
|
Definition at line 92 of file mympimodule.c. |
|
Definition at line 114 of file mympimodule.c. |
|
Definition at line 111 of file mympimodule.c. Referenced by copywrite(). |
|
Definition at line 55 of file mympimodule.c. Referenced by initmpi(). |
|
Definition at line 129 of file mympimodule.c. Referenced by mpi_finalize(), mpi_init(), mpi_start(), and myerror(). |
|
Definition at line 93 of file mympimodule.c. |
|
Definition at line 115 of file mympimodule.c. |
|
|
Definition at line 131 of file mympimodule.c. |
|
Definition at line 1493 of file mympimodule.c. Referenced by initmpi(). |
|
Definition at line 95 of file mympimodule.c. |
|
Definition at line 94 of file mympimodule.c. Referenced by mpi_comm_set_errhandler(), mpi_init(), and mpi_start(). |
|
|
Definition at line 116 of file mympimodule.c. |