#include <Python.h>
#include <math.h>
#include <mpi.h>
Include dependency graph for mpi_eman.c:
Go to the source code of this file.
Functions | |
PyObject * | mpi_init (PyObject *self, PyObject *args) |
PyObject * | mpi_comm_rank (PyObject *self, PyObject *args) |
PyObject * | mpi_comm_size (PyObject *self, PyObject *args) |
PyObject * | mpi_send (PyObject *self, PyObject *args) |
PyObject * | mpi_recv (PyObject *self, PyObject *args) |
PyObject * | mpi_probe (PyObject *self, PyObject *args) |
PyObject * | mpi_iprobe (PyObject *self, PyObject *args) |
PyObject * | mpi_bcast_send (PyObject *self, PyObject *args) |
PyObject * | mpi_bcast_recv (PyObject *self, PyObject *args) |
PyObject * | mpi_barrier (PyObject *self, PyObject *args) |
PyObject * | mpi_finalize (PyObject *self, PyObject *args) |
PyMODINIT_FUNC | initmpi_eman_c (void) |
Variables | |
PyMethodDef | EmanMpiMethods [] |
|
Definition at line 204 of file mpi_eman.c. References EmanMpiMethods, and PyMODINIT_FUNC. 00204 {
00205 (void) Py_InitModule("mpi_eman_c", EmanMpiMethods);
00206 }
|
|
Definition at line 178 of file mpi_eman.c. 00178 { 00179 00180 MPI_Barrier(MPI_COMM_WORLD); 00181 Py_RETURN_NONE; 00182 }
|
|
Definition at line 162 of file mpi_eman.c. References data. 00162 { 00163 const char * data; 00164 int datalen; 00165 int root; 00166 00167 PyArg_ParseTuple(args,"ii",&datalen,&root); 00168 data=(const char *)malloc(datalen); 00169 MPI_Bcast((void *)data,datalen,MPI_CHAR,root,MPI_COMM_WORLD); 00170 00171 PyObject *ret = Py_BuildValue("s#",(void *)data,datalen); 00172 free((void *)data); 00173 00174 return ret; 00175 }
|
|
Definition at line 143 of file mpi_eman.c. References data. 00143 { 00144 const char * data; 00145 int datalen; 00146 int myrank; 00147 MPI_Comm_rank(MPI_COMM_WORLD, &myrank); 00148 00149 PyArg_ParseTuple(args,"s#",&data,&datalen); 00150 // printf("Sent: %d\n",datalen); 00151 MPI_Bcast((void *)data,datalen,MPI_CHAR,myrank,MPI_COMM_WORLD); 00152 Py_RETURN_NONE; 00153 }
|
|
Definition at line 24 of file mpi_eman.c. 00024 { 00025 int myrank; 00026 MPI_Comm_rank(MPI_COMM_WORLD, &myrank); 00027 00028 return Py_BuildValue("i",myrank); 00029 }
|
|
Definition at line 31 of file mpi_eman.c. 00031 { 00032 int size; 00033 MPI_Comm_size(MPI_COMM_WORLD, &size); 00034 00035 return Py_BuildValue("i",size); 00036 }
|
|
Definition at line 184 of file mpi_eman.c. 00184 { 00185 MPI_Finalize(); 00186 Py_RETURN_NONE; 00187 }
|
|
Definition at line 12 of file mpi_eman.c. 00012 { 00013 MPI_Init(NULL,NULL); 00014 00015 int myrank; 00016 MPI_Comm_rank(MPI_COMM_WORLD, &myrank); 00017 00018 int size; 00019 MPI_Comm_size (MPI_COMM_WORLD, &size); 00020 00021 return Py_BuildValue("ii",myrank,size); 00022 }
|
|
Definition at line 115 of file mpi_eman.c. 00115 { 00116 MPI_Status status; 00117 int datalen,src,tag,flag; 00118 00119 // Get a string argument 00120 if (!PyArg_ParseTuple(args,"ii",&src,&tag)) return NULL; 00121 00122 if (src<0) src=MPI_ANY_SOURCE; 00123 if (tag<0) tag=MPI_ANY_TAG; 00124 00125 MPI_Iprobe(src,tag,MPI_COMM_WORLD,&flag,&status); 00126 if (!flag) Py_RETURN_NONE; 00127 00128 MPI_Get_count(&status,MPI_CHAR,&datalen); 00129 00130 PyObject *ret = Py_BuildValue("iii",datalen,status.MPI_SOURCE,status.MPI_TAG); 00131 00132 return ret; 00133 }
|
|
Definition at line 90 of file mpi_eman.c. References status. 00090 { 00091 MPI_Status status; 00092 int datalen,src,tag; 00093 00094 // Get a string argument 00095 if (!PyArg_ParseTuple(args,"ii",&src,&tag)) return NULL; 00096 00097 if (src<0) src=MPI_ANY_SOURCE; 00098 if (tag<0) tag=MPI_ANY_TAG; 00099 00100 MPI_Probe(src,tag,MPI_COMM_WORLD,&status); 00101 MPI_Get_count(&status,MPI_CHAR,&datalen); 00102 00103 PyObject *ret = Py_BuildValue("iii",datalen,status.MPI_SOURCE,status.MPI_TAG); 00104 00105 return ret; 00106 }
|
|
Definition at line 60 of file mpi_eman.c. 00060 { 00061 MPI_Status status; 00062 const char * data; 00063 int datalen,src,tag; 00064 00065 // Get a string argument 00066 if (!PyArg_ParseTuple(args,"ii",&src,&tag)) return NULL; 00067 00068 if (src<0) src=MPI_ANY_SOURCE; 00069 if (tag<0) tag=MPI_ANY_TAG; 00070 00071 MPI_Probe(src,tag,MPI_COMM_WORLD,&status); 00072 00073 MPI_Get_count(&status,MPI_CHAR,&datalen); 00074 data=(const char *)malloc(datalen); 00075 MPI_Recv((void *)data,datalen,MPI_CHAR,src,tag,MPI_COMM_WORLD,&status); 00076 00077 PyObject *ret = Py_BuildValue("s#ii",(void *)data,datalen,status.MPI_SOURCE,status.MPI_TAG); 00078 free((void *)data); 00079 00080 return ret; 00081 }
|
|
Definition at line 42 of file mpi_eman.c. References data. 00042 { 00043 const char * data; 00044 int datalen,dest,tag; 00045 00046 // Get a string argument 00047 if (!PyArg_ParseTuple(args,"s#ii",&data,&datalen,&dest,&tag)) return NULL; 00048 00049 MPI_Send((void *)data,datalen,MPI_CHAR,dest,tag,MPI_COMM_WORLD); 00050 00051 Py_RETURN_NONE; 00052 00053 }
|
|
Initial value: { {"mpi_init",mpi_init,METH_VARARGS,"MPI_Init command. No arguments. Returns the rank id and process count to each node."}, {"mpi_comm_rank",mpi_comm_rank,METH_VARARGS,"This will return the rank id, same as returned by mpi_init."}, {"mpi_comm_size",mpi_comm_size,METH_VARARGS,"This will return the number of processes, same as returned by mpi_init."}, {"mpi_send",mpi_send,METH_VARARGS,"MPI_Send(string,destination rank,tag)"}, {"mpi_recv",mpi_recv,METH_VARARGS,"MPI_Recv(source rank,tag). If either is negative, arbitrary values accepted. Returns (data,src,tag)."}, {"mpi_probe",mpi_probe,METH_VARARGS,"MPI_Probe(source rank,tag). If either is negative, arbitrary values accepted. Returns (len,src,tag)."}, {"mpi_iprobe",mpi_iprobe,METH_VARARGS,"MPI_Iprobe(source rank,tag). If either is negative, arbitrary values accepted. Returns (len,src,tag) or None if no recieves are pending."}, {"mpi_bcast_send",mpi_bcast_send,METH_VARARGS,"MPI_Bcast(string). Provide a string to broadcast to other nodes"}, {"mpi_bcast_recv",mpi_bcast_recv,METH_VARARGS,"MPI_Bcast(data_length,source). Receives a broadcast of length data_length from source and returns a string."}, {"mpi_barrier",mpi_barrier,METH_VARARGS,"MPI_Barrier(). No arguments or return. Blocks until all nodes call it."}, {"mpi_finalize",mpi_finalize,METH_VARARGS,"MPI_Finalize(). No arguments or return. Call before exiting an MPI Python program exactly once."}, {NULL,NULL,0,NULL} } Definition at line 189 of file mpi_eman.c. Referenced by initmpi_eman_c(). |