<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
On the question of whether it would work with Boost.Python - yes. The binding code itself doesn't know anything about the threading underneath, so it's all pretty agnostic to which specific binding approach you take.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
On PyBind11, I have only good things to say about it. It's modelled off Boost.Python so the &quot;feel&quot; of it is very much the same, but being header-only it comes with no dependency baggage. For an example of a fairly big project wrapped with it, see
<a href="https://github.com/tristanic/chimerax-clipper/tree/master/src/bindings" id="LPlnk355410">
https://github.com/tristanic/chimerax-clipper/tree/master/src/bindings</a>. Whether it's desirable to go to the effort of converting the entire CCTBX? That's not for me to say.<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> cctbxbb-bounces@phenix-online.org &lt;cctbxbb-bounces@phenix-online.org&gt; on behalf of David Waterman &lt;dgwaterman@gmail.com&gt;<br>
<b>Sent:</b> 02 October 2020 09:47<br>
<b>To:</b> cctbx mailing list &lt;cctbxbb@phenix-online.org&gt;<br>
<b>Subject:</b> Re: [cctbxbb] Simple C++11 async example</font>
<div>&nbsp;</div>
</div>
<div>
<div dir="ltr">Thanks Tristan,
<div><br>
</div>
<div>This does look useful indeed. I note you use pybind11 in your example. Should this work just as easily&nbsp;with Boost.Python?</div>
<div><br>
</div>
<div>On that topic, I've heard many&nbsp;good things about pybind11. Does anyone have a feeling for how much work it would be to convert cctbx to pybind11 bindings rather than Boost.Python. Is this feasible? Is it desirable?</div>
<div><br>
</div>
<div>Cheers<br clear="all">
<div>
<div dir="ltr" class="x_gmail_signature">-- David<br>
</div>
</div>
<br>
</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Thu, 1 Oct 2020 at 16:45, Tristan Croll &lt;<a href="mailto:tic20@cam.ac.uk">tic20@cam.ac.uk</a>&gt; wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hi all,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
For anyone who's interested: following on from my quick demo of the use of std::async to simplify threading of long-running tasks called from Python, I've put some example code at&nbsp;<a href="https://github.com/tristanic/async-hello-world/tree/master/src" id="x_gmail-m_-2756436829369195614LPlnk" target="_blank">https://github.com/tristanic/async-hello-world/tree/master/src</a>&nbsp;(implemented
 as a ChimeraX plugin for demo purposes, but the C++ code and bindings are entirely generic).&nbsp;</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
To re-iterate what this is about, and why I think it's important: in brief, for most real-world problems Python-level threading is not particularly useful since (except in specific cases) the Global Interpreter Lock limits the overall performance to no better
 than - and often much worse than - single-threaded code. While multiprocessing can be an option for some tasks, it's (a) slow to get started, (b) memory-hungry due to the need for each process to have a complete copy of all the data, (c) rather difficult to
 organise with respect to intercommunication, and (d) not very cross-platform friendly (I'm looking at you, Windows!). The point of this example is to show that with C++11 organising the threading at the C++ level can often end up being both the simplest
<i>and</i>&nbsp;fastest approach - it's only a dozen or so extra lines of fairly boilerplate code required to allow the Python programmer to choose between running the exact same function either in the main thread or asynchronously in a new one.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Why I think it's important: I've said in the past, and continue to believe, that we should be aiming for (interactive) model building, validation and refinement to merge together into a single integrated process - as much as anything, ISOLDE is meant to be
 the proof of principle that this is a possibility. But for that to work, high-performance and cross-platform parallelism is a real necessity. The approach described here is how I'm currently getting ChimeraX to maintain 30+ fps graphics performance while simultaneously
 running interactive molecular dynamics and structure factor calculations. I suspect there are many functions in CCTBX that could potentially benefit from this approach even when not considering GUI applications.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Best regards,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Tristan&nbsp;</div>
<div></div>
<br>
</div>
_______________________________________________<br>
cctbxbb mailing list<br>
<a href="mailto:cctbxbb@phenix-online.org" target="_blank">cctbxbb@phenix-online.org</a><br>
<a href="http://phenix-online.org/mailman/listinfo/cctbxbb" rel="noreferrer" target="_blank">http://phenix-online.org/mailman/listinfo/cctbxbb</a><br>
</blockquote>
</div>
</div>
</body>
</html>