1# ----------------------------------------------------------------------------- 2 3# Datatype 4 5cdef api object PyMPIDatatype_New(MPI_Datatype arg): 6 cdef Datatype obj = <Datatype>Datatype.__new__(Datatype) 7 obj.ob_mpi = arg 8 return obj 9 10cdef api MPI_Datatype* PyMPIDatatype_Get(object arg) except NULL: 11 return &(<Datatype?>arg).ob_mpi 12 13# ----------------------------------------------------------------------------- 14 15# Status 16 17cdef api object PyMPIStatus_New(MPI_Status *arg): 18 cdef Status obj = <Status>Status.__new__(Status) 19 if (arg != NULL and 20 arg != MPI_STATUS_IGNORE and 21 arg != MPI_STATUSES_IGNORE): 22 obj.ob_mpi = arg[0] 23 else: pass # XXX should fail ? 24 return obj 25 26cdef api MPI_Status* PyMPIStatus_Get(object arg) except? NULL: 27 if arg is None: return MPI_STATUS_IGNORE 28 return &(<Status?>arg).ob_mpi 29 30# ----------------------------------------------------------------------------- 31 32# Request 33 34cdef api object PyMPIRequest_New(MPI_Request arg): 35 cdef Request obj = <Request>Request.__new__(Request) 36 obj.ob_mpi = arg 37 return obj 38 39cdef api MPI_Request* PyMPIRequest_Get(object arg) except NULL: 40 return &(<Request?>arg).ob_mpi 41 42# ----------------------------------------------------------------------------- 43 44# Message 45 46cdef api object PyMPIMessage_New(MPI_Message arg): 47 cdef Message obj = <Message>Message.__new__(Message) 48 obj.ob_mpi = arg 49 return obj 50 51cdef api MPI_Message* PyMPIMessage_Get(object arg) except NULL: 52 return &(<Message?>arg).ob_mpi 53 54# ----------------------------------------------------------------------------- 55 56# Op 57 58cdef api object PyMPIOp_New(MPI_Op arg): 59 cdef Op obj = <Op>Op.__new__(Op) 60 obj.ob_mpi = arg 61 return obj 62 63cdef api MPI_Op* PyMPIOp_Get(object arg) except NULL: 64 return &(<Op?>arg).ob_mpi 65 66# ----------------------------------------------------------------------------- 67 68# Info 69 70cdef api object PyMPIInfo_New(MPI_Info arg): 71 cdef Info obj = <Info>Info.__new__(Info) 72 obj.ob_mpi = arg 73 return obj 74 75cdef api MPI_Info* PyMPIInfo_Get(object arg) except NULL: 76 return &(<Info?>arg).ob_mpi 77 78# ----------------------------------------------------------------------------- 79 80# Group 81 82cdef api object PyMPIGroup_New(MPI_Group arg): 83 cdef Group obj = <Group>Group.__new__(Group) 84 obj.ob_mpi = arg 85 return obj 86 87cdef api MPI_Group* PyMPIGroup_Get(object arg) except NULL: 88 return &(<Group?>arg).ob_mpi 89 90# ----------------------------------------------------------------------------- 91 92# Comm 93 94cdef api object PyMPIComm_New(MPI_Comm arg): 95 cdef type cls = Comm 96 cdef int inter = 0 97 cdef int topo = MPI_UNDEFINED 98 if arg != MPI_COMM_NULL: 99 CHKERR( MPI_Comm_test_inter(arg, &inter) ) 100 if inter: 101 cls = Intercomm 102 else: 103 CHKERR( MPI_Topo_test(arg, &topo) ) 104 if topo == MPI_UNDEFINED: 105 cls = Intracomm 106 elif topo == MPI_CART: 107 cls = Cartcomm 108 elif topo == MPI_GRAPH: 109 cls = Graphcomm 110 elif topo == MPI_DIST_GRAPH: 111 cls = Distgraphcomm 112 else: 113 cls = Intracomm 114 cdef Comm obj = <Comm>cls.__new__(cls) 115 obj.ob_mpi = arg 116 return obj 117 118cdef api MPI_Comm* PyMPIComm_Get(object arg) except NULL: 119 return &(<Comm?>arg).ob_mpi 120 121# ----------------------------------------------------------------------------- 122 123# Win 124 125cdef api object PyMPIWin_New(MPI_Win arg): 126 cdef Win obj = <Win>Win.__new__(Win) 127 obj.ob_mpi = arg 128 return obj 129 130cdef api MPI_Win* PyMPIWin_Get(object arg) except NULL: 131 return &(<Win?>arg).ob_mpi 132 133# ----------------------------------------------------------------------------- 134 135# File 136 137cdef api object PyMPIFile_New(MPI_File arg): 138 cdef File obj = <File>File.__new__(File) 139 obj.ob_mpi = arg 140 return obj 141 142cdef api MPI_File* PyMPIFile_Get(object arg) except NULL: 143 return &(<File?>arg).ob_mpi 144 145# ----------------------------------------------------------------------------- 146 147# Errhandler 148 149cdef api object PyMPIErrhandler_New(MPI_Errhandler arg): 150 cdef Errhandler obj = <Errhandler>Errhandler.__new__(Errhandler) 151 obj.ob_mpi = arg 152 return obj 153 154cdef api MPI_Errhandler* PyMPIErrhandler_Get(object arg) except NULL: 155 return &(<Errhandler?>arg).ob_mpi 156 157# ----------------------------------------------------------------------------- 158