1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
cdef class Status:
"""
Status
"""
def __cinit__(self):
self.ob_mpi.MPI_SOURCE = MPI_ANY_SOURCE
self.ob_mpi.MPI_TAG = MPI_ANY_TAG
self.ob_mpi.MPI_ERROR = MPI_SUCCESS
def __richcmp__(self, other, int op):
if not isinstance(self, Status): return NotImplemented
if not isinstance(other, Status): return NotImplemented
cdef Status s = self, o = other
cdef int r = _eq_Status(&s.ob_mpi, &o.ob_mpi)
if op == 2: return r == 0
elif op == 3: return r != 0
else: raise TypeError(mpistr("only '==' and '!='"))
def Get_source(self):
"""
Get message source
"""
return self.ob_mpi.MPI_SOURCE
def Set_source(self, source):
"""
Set message source
"""
self.ob_mpi.MPI_SOURCE = source
property source:
"""source"""
def __get__(self):
return self.Get_source()
def __set__(self, value):
self.Set_source(value)
def Get_tag(self):
"""
Get message tag
"""
return self.ob_mpi.MPI_TAG
def Set_tag(self, tag):
"""
Set message tag
"""
self.ob_mpi.MPI_TAG = tag
property tag:
"""tag"""
def __get__(self):
return self.Get_tag()
def __set__(self, value):
self.Set_tag(value)
def Get_error(self):
"""
Get message error
"""
return self.ob_mpi.MPI_ERROR
def Set_error(self, error):
"""
Set message error
"""
self.ob_mpi.MPI_ERROR = error
property error:
"""error"""
def __get__(self):
return self.Get_error()
def __set__(self, value):
self.Set_error(value)
def Get_count(self, Datatype datatype not None=BYTE):
"""
Get the number of *top level* elements
"""
cdef int count = MPI_UNDEFINED
CHKERR( MPI_Get_count(&self.ob_mpi, datatype.ob_mpi, &count) )
return count
def Get_elements(self, Datatype datatype not None):
"""
Get the number of basic elements in a datatype
"""
cdef int elements = MPI_UNDEFINED
CHKERR( MPI_Get_elements(&self.ob_mpi, datatype.ob_mpi, &elements) )
return elements
def Set_elements(self, Datatype datatype not None, int count):
"""
Set the number of elements in a status
.. note:: This should be only used when implementing
query callback functions for generalized requests
"""
CHKERR( MPI_Status_set_elements(&self.ob_mpi, datatype.ob_mpi, count) )
def Is_cancelled(self):
"""
Test to see if a request was cancelled
"""
cdef bint flag = 0
CHKERR( MPI_Test_cancelled(&self.ob_mpi, &flag) )
return flag
def Set_cancelled(self, bint flag):
"""
Set the cancelled state associated with a status
.. note:: This should be only used when implementing
query callback functions for generalized requests
"""
CHKERR( MPI_Status_set_cancelled(&self.ob_mpi, flag) )
property cancelled:
"""
cancelled state
"""
def __get__(self):
return self.Is_cancelled()
def __set__(self, value):
self.Set_cancelled(value)
|