[Openmp-dev] OpenMP problems with clang 3.7.0

Cownie, James H via Openmp-dev openmp-dev at lists.llvm.org
Wed Sep 23 03:48:53 PDT 2015


> My usecase would be to compile a static executable for easy 
> distribution.
And that is, indeed, very seductive, and, in your case may work.

The problem comes when, sometime in the future, you decide that you also need to link in some other library that happens to use OpenMP internally (such as Intel's Math Kernel Library), and then you have a horrible (and potentially hard to diagnose) problem.
Or, your program grows and becomes a framework that dlopens user written "plug-ins".

-- Jim

James Cownie <james.h.cownie at intel.com>
SSG/DPD/TCAR (Technical Computing, Analyzers and Runtimes)
Tel: +44 117 9071438

-----Original Message-----
From: Christof Söger [mailto:csoeger at uos.de] 
Sent: Wednesday, September 23, 2015 11:23 AM
To: Cownie, James H
Cc: LLVM-OpenMP (openmp-dev at lists.llvm.org)
Subject: Re: [Openmp-dev] OpenMP problems with clang 3.7.0

On 23.09.2015 11:39, Cownie, James H wrote:
>> 1) Is it possible to build a static version of libomp?
> Compiling a static OpenMP library is, in general, a very bad idea.
> It can easily lead to both awful performance (due to over-subscription) and incorrect program execution when you use any libraries which also use OpenMP.
>
> Imagine that your static instance of the OpenMP runtime starts one thread/core. Now you call into some other library which has its own statically linked OpenMP runtime. That runtime knows nothing about the threads you have already created, so it creates a whole new set. Now you have double over-subscription. Ouch.
>
> Or, suppose you execute an omp atomic statement in a case where it is implemented using a static lock inside the runtime. If you have two runtimes, you have two different locks, and its possible for atomicity not to be enforced between code that uses the two different OpenMP runtimes.
>
> For correctness and performance you need to ensure that there's only one OpenMP runtime in a process. As soon as you create a static OpenMP runtime you make it very easy for that not to be the case.
>
> So, I'm sure it's possible (heck, "It's only software"), but it's not made easy because doing it is a really bad idea.
>
> -- Jim
My usecase would be to compile a static executable for easy 
distribution. But if it is not supported directly I will not try to do it.

Christof
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


More information about the Openmp-dev mailing list