<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div>Good to know, thanks!</div><div>Paul</div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><b>From: </b>"Mathieu Westphal" <mathieu.westphal@kitware.com><br><b>To: </b>"Paul Melis" <paul.melis@surfsara.nl><br><b>Cc: </b>"vtk" <vtkusers@vtk.org><br><b>Sent: </b>Thursday, 8 September, 2016 14:30:23<br><b>Subject: </b>Re: [vtkusers] VTK 7.0.0 + Python: GIL released?<br></div><br><div data-marker="__QUOTED_TEXT__"><div dir="ltr"><div><div><div><div>Hi<br><br></div>Sorry, I did not see you were only on VTK.<br></div>The option is exposed in ParaView cmake option, the same way VTK_NO_PYTHON_THREAD is.<br></div>But you should be able to define the option manually when configuring VTK.<br><br>-DVTK_PYTHON_FULL_THREADSAFE:BOOL="ON"<br><br></div>Regards,<br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr">Mathieu Westphal<br></div></div></div>
<br><div class="gmail_quote">On Thu, Sep 8, 2016 at 2:11 PM, Paul Melis <span dir="ltr"><<a href="mailto:paul.melis@surfsara.nl" target="_blank">paul.melis@surfsara.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:#000000"><div>Great! But the <span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">VTK_PYTHON_FULL_THREADSAFE option doesn't seem to exist at the CMake level. With a git update of a minute ago:</span></div><div><span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff"><br></span></div><div><span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">/data/c/vtk-git$ find . -name CMakeLists.txt | xargs -iX grep -Hs VTK_PYTHON_FULL_THREADSAFE X<br><empty></span></div><div><span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff"><br></span></div><div><span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">/data/c/vtk-git$ find . | xargs -iX grep -Hs VTK_PYTHON_FULL_THREADSAFE X<br>./Utilities/PythonInterpreter/vtkPythonInterpreter.cxx:#ifdef VTK_PYTHON_FULL_THREADSAFE<br>./Utilities/Python/vtkPythonConfigure.h.in:#cmakedefine VTK_PYTHON_FULL_THREADSAFE<br>./Utilities/Python/vtkPython.h:// Note: behaviour of this class depends on VTK_PYTHON_FULL_THREADSAFE.<br>./Utilities/Python/vtkPython.h: // If force is TRUE, lock/unlock even if VTK_PYTHON_FULL_THREADSAFE is not defined.<br>./Utilities/Python/vtkPython.h: // If force is FALSE, lock/unlock is only performed if VTK_PYTHON_FULL_THREADSAFE is<br>./Utilities/Python/vtkPython.h:#ifdef VTK_PYTHON_FULL_THREADSAFE<br>./Utilities/Python/vtkPython.h: // Force is always true with VTK_PYTHON_FULL_THREADSAFE<br></span></div><div><span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff"><br></span></div><div>/data/c/vtk-git-release$ cmake -D<span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">VTK_WRAP_PYTHON=ON</span> ../vtk-git<br></div><div><span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">...<br>/data/c/vtk-git-release$ grep VTK_PYTHON_FULL_THREADSAFE CMakeCache.txt </span></div><div><span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff"><empty></span></div><div><span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff"><br></span></div><div><span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">/data/c/vtk-git-release$ grep THREAD CMakeCache.txt <br>CMAKE_THREAD_LIBS:STRING=-lpthread<br>LIBPROJ_USE_THREAD:BOOL=ON<br>VTK_MAX_THREADS:STRING=64<br>CMAKE_HAVE_PTHREADS_CREATE:INTERNAL=<br>CMAKE_HAVE_PTHREAD_CREATE:INTERNAL=1<br>CMAKE_HAVE_PTHREAD_H:INTERNAL=1<br>//ADVANCED property for variable: CMAKE_THREAD_LIBS<br>CMAKE_THREAD_LIBS-ADVANCED:INTERNAL=1<br>H5_HAVE_PTHREAD_H:INTERNAL=1<br>H5_SYSTEM_SCOPE_THREADS:INTERNAL=1<br>HAVE_PTHREAD_H:INTERNAL=1<br>//Have symbol PTHREAD_MUTEX_RECURSIVE<br>HAVE_PTHREAD_MUTEX_RECURSIVE_DEFN:INTERNAL=<br>HDF5_ENABLE_THREADSAFE:INTERNAL=OFF<br>//ADVANCED property for variable: LIBPROJ_USE_THREAD<br>LIBPROJ_USE_THREAD-ADVANCED:INTERNAL=1<br>SYSTEM_SCOPE_THREADS:INTERNAL=TRUE<br>//ADVANCED property for variable: VTK_MAX_THREADS<br>VTK_MAX_THREADS-ADVANCED:INTERNAL=1<br></span></div><div><span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff"><br></span></div><div><span style="color:#000000;font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:#ffffff">Paul</span></div><br><hr><div><b>From: </b>"Mathieu Westphal" <<a href="mailto:mathieu.westphal@kitware.com" target="_blank">mathieu.westphal@kitware.com</a>><br><b>To: </b>"Paul Melis" <<a href="mailto:paul.melis@surfsara.nl" target="_blank">paul.melis@surfsara.nl</a>><br><b>Cc: </b>"vtk" <<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>><br><b>Sent: </b>Thursday, 8 September, 2016 13:51:18<br><b>Subject: </b>Re: [vtkusers] VTK 7.0.0 + Python: GIL released?<br></div><div><div class="h5"><br><div><div dir="ltr"><div><div><div><div>Hi<br><br></div>All python calls are protected by gil if the VTK_PYTHON_FULL_THREADSAFE option is on.<br></div>The mechanism take place in vtkPython.h, where the vtkPythonScopeGilEnsurer is configured by the cmake option.<br></div>the vtkPythonScopeGilEnsurer is then ( suposed to be ) used before every pthon call.<br><br></div>Regards,<br></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr">Mathieu Westphal<br></div></div></div>
<br><div class="gmail_quote">On Thu, Sep 8, 2016 at 1:23 PM, Paul Melis <span dir="ltr"><<a href="mailto:paul.melis@surfsara.nl" target="_blank">paul.melis@surfsara.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
What's the status of threading in VTK 7.0.0 under Python w.r.t the GIL,<br>
specifically for classes derived from vtkAlgorithm?<br>
I'm attempting to offload a computation (basically vtkStreamTracer.Update())<br>
to a Python threading.Thread, but strongly get the impression that<br>
the GIL is not released by Update().<br>
<br>
The release notes (<a href="https://blog.kitware.com/vtk-7-0-0/" rel="noreferrer" target="_blank">https://blog.kitware.com/vtk-7-0-0/</a>) seem to suggest<br>
there was some recent development in this area:<br>
<br>
* multi-threaded Python codes facilitated by VTK's new and optional<br>
protocol for using the Global Interpreter Lock<br>
<br>
But clicking the link appears to indicate this is for VTK used inside<br>
Paraview only. I see the mentioned cmake variable VTK_PYTHON_FULL_THREADSAFE<br>
referenced by files under Utilities/Python, but the cmake files themselves<br>
don't contain a reference, nor something like an option. Would hacking<br>
the define in somewhere cause Update() to be protected by the GIL?<br>
Commit <a href="https://github.com/Kitware/VTK/commit/8eb50dd23fd762d42fe1a6785bbaa704f2ed76c3" rel="noreferrer" target="_blank">https://github.com/Kitware/VTK/commit/8eb50dd23fd762d42fe1a6785bbaa704f2ed76c3</a><br>
lists some classes and their possible protection by vtkPythonScopeGilEnsurer,<br>
but what specifically is covered isn't entirely clear to me.<br>
<br>
Thanks,<br>
Paul<br>
<br>
--<br>
<br>
Paul Melis<br>
| Visualization group leader & developer | SURFsara |<br>
| Science Park 140 | 1098 XG Amsterdam |<br>
| T 020 800 1312 | <a href="mailto:paul.melis@surfsara.nl" target="_blank">paul.melis@surfsara.nl</a> | <a href="http://www.surfsara.nl" rel="noreferrer" target="_blank">www.surfsara.nl</a> |<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div></div><br></div></div></div></div></div></blockquote></div></div><br></div></div></body></html>