|Re: [eigen] enabling OpenMP in only a subset of a library|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] enabling OpenMP in only a subset of a library
- From: Jim Bosch <talljimbo@xxxxxxxxx>
- Date: Mon, 13 May 2013 11:43:47 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=FgpFct9VAzmM+ncFAd7Jx4hLUcdQN/W4LS5ws7JMTGI=; b=WJtk4udQwnugaiqKsluDCiueaWu+jrdHuCZdhq9wNEUrvr1CJHsGM6rW8y48ARu6VF ax+ZRZ8ty/z6WDj9Rz6DDbtQ9ABAOQV1ZlokH+E11MW37LXHiQpifXuQGJ7goyYh96Vu JydhPyikfQTOg5g/g+Zm0u/Bd49DnQJm1miJEvuF9lUT6M2dYvtGaVy2oVHjnZ2QBbVJ Ut7vRCj1PmieDo83tZ7Jxm8X3m0ZS1Y0yluMEe0324+QV+gDPQD50gS4GnMmgPyDiUso W/NxOUiMZQqITP4Dthwx4ceunyB93J4/mCxK4SV+7Nujp+0ZJhWBTPH8ySBsJoJcJmS8 HR0g==
On 05/12/2013 07:15 AM, Gael Guennebaud wrote:
sorry for late reply but I guess the only solution is to recompile everything.
Thanks; good to know I wasn't missing anything.
In the future, if we want to support hybrid OpenMP/non-OpenMP code, we
could make each function whose implementation depends on the
activation of OpenMP has a related template parameter, e.g.:
template<....., bool omp_enabled = EIGEN_OMP_ENABLED>
This way the parallel and sequential versions will have different
Seems like a good idea to me!
In the meantime, I have been tinkering with another possibility: including the Eigen headers within a namespace when compiling OpenMP-enabled code. This seems to work, though it's a bit fragile as you have to manually include all the standard library headers used by Eigen first.
On Fri, May 10, 2013 at 4:24 AM, Jim Bosch <talljimbo@xxxxxxxxx> wrote:
We have a large software framework that uses Eigen in a lot of places (many
libraries linked together; often these are linked into Python modules).
We're almost always using Eigen in single-threaded processes that can only
use a single core (because any other cores will be busy with other similar
processes), and we're quite happy just using Eigen without any threading or
However, we also have a larger problem for which we'd like to turn on OpenMP
support in Eigen, and utilize multiple cores in a single process - but we
want to be able to link the OpenMP-enabled code against the rest of the
framework that uses Eigen without any kind of threading.
As I understand it, that's not possible to do naively, as it means we end up
defining some inline functions (e.g. nbThreads) in different ways in
different compilation units, and that's Undefined Behavior.
Is there any way to make this work without having to recompile all the
non-OpenMP code with OpenMP support while calling setNbThreads(1) to disable
it until we want it? Or other recommendations on how to accomplish what we
want to do here?
Thanks in advance!