Debian Codegraph @

pymusic/pymusic.pxd

raw
1 # The following include is needed to define a missing type MPI_Message
2 # which is lacking for a certain combination of MPI and mpi4py versions
3 cdef extern from "mpi_compat.h":
4 pass
5
6 include "pyconfig.pxi"
7 cimport mpi4py.MPI as MPI
8 IF MPI4V2:
9 from mpi4py.libmpi cimport *
10 ELSE:
11 from mpi4py.mpi_c cimport *
12
13 from libcpp cimport bool as cbool
14 from libcpp.string cimport string
15 from cpython.ref cimport PyObject
16
17 ###########################################################
18
19 cdef extern from "music/predict_rank.hh" namespace "MUSIC":
20 cdef int CPredictRank "MUSIC::predictRank" (int, char**)
21
22 cdef extern from "music/message.hh" namespace "MUSIC":
23 cdef cppclass CMessageHandler "MUSIC::MessageHandler":
24 pass
25
26 cdef extern from "music/music_c.h" namespace "MUSIC":
27 cdef cppclass CEventHandler "MUSIC::EventHandler":
28 pass
29 cdef cppclass CEHLocal "MUSIC::EHLocal"(CEventHandler):
30 CEHLocal(PyObject*)
31 cdef cppclass CEHGlobal "MUSIC::EHGlobal"(CEventHandler):
32 CEHGlobal(PyObject*)
33 cdef cppclass CMHandler "MUSIC::MHandler"(CMessageHandler):
34 CMHandler(PyObject*, cbool)
35
36 cdef extern from "music/event.hh" namespace "MUSIC":
37 cdef cppclass CEventHandlerGlobalIndex "MUSIC::EventHandlerGlobalIndex":
38 pass
39 cdef cppclass CEventHandlerLocalIndex "MUSIC::EventHandlerLocalIndex":
40 pass
41 cdef cppclass CEventHandlerPtr "MUSIC::EventHandlerPtr":
42 pass
43
44 cdef extern from "music/data_map.hh" namespace "MUSIC":
45 cdef cppclass CDataMap "MUSIC::DataMap":
46 pass
47
48 cdef extern from "music/index_map.hh" namespace "MUSIC":
49 cdef cppclass CIndex "MUSIC::Index":
50 int WILDCARD_MAX
51 ctypedef enum IndexType "MUSIC::Index::Type":
52 IndexGLOBAL "MUSIC::Index::GLOBAL",
53 IndexLOCAL "MUSIC::Index::LOCAL"
54
55 cdef cppclass GlobalIndex(CIndex):
56 GlobalIndex(int)
57
58 cdef cppclass LocalIndex(CIndex):
59 LocalIndex(int)
60
61 cdef cppclass CIndexMap "MUSIC::IndexMap":
62 pass
63
64 cdef extern from "music/permutation_index.hh" namespace "MUSIC":
65 cdef cppclass PermutationIndex(CIndexMap):
66 PermutationIndex(GlobalIndex*, int)
67
68 cdef extern from "music/linear_index.hh" namespace "MUSIC":
69 cdef cppclass LinearIndex(CIndexMap):
70 LinearIndex(GlobalIndex, int)
71
72 cdef extern from "music/array_data.hh" namespace "MUSIC":
73 cdef cppclass CArrayData "MUSIC::ArrayData"(CDataMap):
74 CArrayData(void*, MPI_Datatype, int, int)
75 CArrayData(void*, MPI_Datatype, CIndexMap*)
76
77 cdef extern from "music/port.hh" namespace "MUSIC":
78 cdef cppclass CPort "MUSIC::Port":
79 cbool isConnected()
80 cbool hasWidth()
81 int width()
82
83 cdef cppclass CContInputPort "MUSIC::ContInputPort"(CPort):
84 pass
85
86 cdef cppclass CContOutputPort "MUSIC::ContOutputPort"(CPort):
87 pass
88
89 cdef cppclass CEventInputPort "MUSIC::EventInputPort"(CPort):
90 pass
91
92 cdef cppclass CEventOutputPort "MUSIC::EventOutputPort"(CPort):
93 pass
94
95 cdef cppclass CMessageInputPort "MUSIC::MessageInputPort"(CPort):
96 pass
97
98 cdef cppclass CMessageOutputPort "MUSIC::MessageOutputPort"(CPort):
99 void insertMessage(double, void*, size_t)
100
101 # This is necessary for the virtual downcast
102 cdef extern from *:
103 CContInputPort* dc_CContInputPort \
104 "dynamic_cast<MUSIC::ContInputPort*>" (CPort*)
105 CContOutputPort* dc_CContOutputPort \
106 "dynamic_cast<MUSIC::ContOutputPort*>"(CPort*)
107 CEventInputPort* dc_CEventInputPort \
108 "dynamic_cast<MUSIC::EventInputPort*>" (CPort*)
109 CEventOutputPort* dc_CEventOutputPort \
110 "dynamic_cast<MUSIC::EventOutputPort*>"(CPort*)
111 CMessageInputPort* dc_CMessageInputPort \
112 "dynamic_cast<MUSIC::MessageInputPort*>" (CPort*)
113 CMessageOutputPort* dc_CMessageOutputPort \
114 "dynamic_cast<MUSIC::MessageOutputPort*>"(CPort*)
115
116 cdef extern from "music/setup.hh" namespace "MUSIC":
117 cdef cppclass CSetup "MUSIC::Setup":
118 CSetup(int&, char**&) except +
119 CSetup(int&, char**&, int, int*) except +
120
121 cbool config(string, string*)
122
123 CContInputPort* publishContInput(string)
124 CContOutputPort* publishContOutput(string)
125 CEventInputPort* publishEventInput(string)
126 CEventOutputPort* publishEventOutput(string)
127 CMessageInputPort* publishMessageInput(string)
128 CMessageOutputPort* publishMessageOutput(string)
129
130 cdef extern from "music/runtime.hh" namespace "MUSIC":
131 cdef cppclass CRuntime "MUSIC::Runtime":
132 CRuntime(CSetup*, double) except +
133 void finalize()
134 double time()
135 void tick()
136
137 cdef extern void cython_callback(PyObject*, double, IndexType, int)
138
139 cdef extern from "music/music_c.h" namespace "MUSIC":
140 cdef inline MPI_Comm communicator(CSetup*)
141 cdef inline MPI_Comm communicator(CRuntime*)
142 cdef inline int toint(GlobalIndex)
143 cdef inline int toint(LocalIndex)
144 cdef inline cbool tick(CRuntime*) except False
145 cdef inline CEventHandlerPtr getEventHandlerPtr(IndexType, CEventHandler*)
146
147 cdef inline void mapImpl "MUSIC::Implementer::mapImpl" (
148 CContInputPort*, CDataMap*, double, int, cbool)
149 cdef inline void mapImpl "MUSIC::Implementer::mapImpl" (
150 CContOutputPort*, CDataMap*, int)
151 cdef inline void mapImpl "MUSIC::Implementer::mapImpl" (
152 CEventInputPort*, CIndexMap*, IndexType,
153 CEventHandlerPtr, double, int)
154 cdef inline void mapImpl "MUSIC::Implementer::mapImpl" (
155 CEventOutputPort*, CIndexMap*, IndexType, int)
156 cdef inline void insertEventImpl "MUSIC::Implementer::insertEventImpl" (
157 CEventOutputPort*, double, int)
158 cdef inline void mapImpl "MUSIC::Implementer::mapImpl" (
159 CMessageInputPort*, CMessageHandler*, double, int)
160 cdef inline void mapImpl "MUSIC::Implementer::mapImpl" (
161 CMessageOutputPort*, int)
162 cdef inline void insertMessage "MUSIC::Implementer::insertMessage" (
163 CMessageOutputPort*, double t, void*, size)
164
165 cdef cbool pythonError
166 cdef PyObject* etype
167 cdef PyObject* evalue
168 cdef PyObject* etraceback
169
170
171 ###########################################################
172
173 cdef class Setup(object):
174 cdef CSetup* ptr
175 cdef list argv
176 cdef int provided
177 cdef readonly MPI.Intracomm comm
178 cdef set ports
179
180 cdef null(self)
181 cpdef MPI.Intracomm getcomm(self)
182
183 ###########################################################
184
185 cdef class Runtime(object):
186 cdef CRuntime* ptr
187 cdef readonly MPI.Intracomm comm
188 cdef set ports
189 cdef int isFinalized
190
191 ###########################################################
192
193 cdef class Port(object):
194 cdef CPort* ptr
195 cpdef object null(self)
196
197 ## Some day, virtual multiple inheritance will be
198 ## a capital crime ^^^^
199
200 cdef class ContInputPort(Port):
201 pass
202
203 cdef class ContOutputPort(Port):
204 pass
205
206 cdef class EventInputPort(Port):
207 cdef set events
208 cpdef object null(self)
209
210 cdef class EventOutputPort(Port):
211 pass
212
213 cdef class MessageInputPort(Port):
214 cdef set events
215 cpdef object null(self)
216
217 cdef class MessageOutputPort(Port):
218 cdef bint pickled
219
220 ##########################################################
221
222 from music.pybuffer cimport Buffer
223
224 cdef class DataMap(object):
225 cdef CDataMap* ptr
226 cdef Buffer buf
227
228 cdef class IndexMap(object):
229 cdef CIndexMap* ptr
230 cdef Buffer buf
231
232 cdef class EventHandler:
233 cdef CEventHandler* ptr
234 cdef object func
235
236 cdef class MessageHandler:
237 cdef CMessageHandler* ptr
238 cdef object func
239
240 cdef cbool EventCallback "MUSIC::EventCallback" ( \
241 PyObject*, double, IndexType, int) except False
242
243 cdef cbool MessageCallback "MUSIC::MessageCallback" ( \
244 PyObject*, double, void*, size_t, cbool) except False