As part of C++17, now the STL can optionally use parallelization. And in fact 
it's so easy that even I can do it.

On Ubuntu 22.04, I just had to install the package 'libtbb-dev'. Then, we need 
to add -ltbb to the link command. Then, we add the following include in 
whichever source file we want to use parallelization:

  #include <execution>

Then, adapting the STL algorithm call to run in parallel is trivial. Here is a 
helpful post in case you are curious. It also gives a simple test program if 
you want to try it out: 
https://stackoverflow.com/questions/51031060/are-c17-parallel-algorithms-implemented-already/55989883#55989883

Of course, the hard part is ensuring the relevant code is thread-safe.

I think it would be nice to set things up so that we could someday optionally 
allow to use such parallelization in LyX. It can be controlled at run-time; for 
example, we could have an LFUN that could toggle it on/off. We would not need 
to expose anything to the user, but it would be nice to set things up so that 
we can test it and then someday in a few years maybe flip a switch to expose 
things to the user.

Does anyone know of any candidates in LyX's code for using such 
parallelization? The best candidates are simple for loops where the iterations 
are independent, and where the for-loop takes long enough time that the user 
notices a lag. I'm going to send an email for a particular use case, but it is 
actually not a good candidate since the iterations are not independent and the 
underlying code is not thread-safe.

Scott

Attachment: signature.asc
Description: PGP signature

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to