[Networkit] parallel Graph iterators for Python
christian.staudt at kit.edu
Thu Nov 19 16:56:40 CET 2015
What about the Cython level then? If I have a simple function (see example below) and put it inside a .pyx file, would it work with the parallel iterator?
""" switch states of nodes"""
if state[u] == S:
elif state[u] == E:
# exposed nodes become infectious after eTime
if (t - timestamp[u]) >= self.eTime:
elif state[u] == I:
# contact neighbors of infectious nodes with a chance to transmit infection
for v in self.G.neighbors(u):
# infectious nodes become removed after iTime
if (t - timestamp[u]) >= self.iTime:
elif state[u] == R:
# apply here
On 19 Nov 2015, at 05:51, Michael Hamann <michael.hamann at kit.edu> wrote:
> On Wednesday 18 November 2015 19:25:29, Christian Staudt wrote:
>> is there a reason why only the sequential Graph iterators are pythonized?
>> Can the parallel iterators be accessed via Python and/or Cython?
> There are several reasons. First of all the parallel iterators use new
> threads. Each of these threads needs to be initialized for Python (see also
> ). The second reason is that all code that is pure Python code needs to
> hold the global interpreter lock (GIL). We would need to acquire that lock for
> every single node or edge which is a huge overhead and means that that the
> only way that the code for several nodes or edges can run in parallel is if it
> releases the GIL again. For example if the Python callback calls other
> NetworKit methods this would be the case for run()-methods, but not for simple
> getter or setter methods. We could add that there of course, but I think that
> in many cases releasing and acquiring the lock is more work than the actual
> method call.
> Therefore I think that it doesn't make sense to find out how to make the
> parallel iterators accessible in Python as there is probably no benefit of
> having them available.
> Best regards,
>  https://gist.github.com/liuyu81/3473376 for a C-API example,
> http://stackoverflow.com/questions/29243881/communication-between-python-cython-c-in-multithreaded-environment describes the setting we would need -
> but does not have a real answer.
> NetworKit mailing list
> NetworKit at ira.uni-karlsruhe.de
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
More information about the NetworKit