Boost logo

Boost-Build :

Subject: [Boost-build] Building OpenMP targets
From: Pascal Germroth (pascal_at_[hidden])
Date: 2013-08-02 20:41:50


Hi,

I'm the GSOC student for odeint, where I'm using OpenMP. To compile an
example program, GCC and ICC need a flag, Clang++ doesn't support OpenMP
and I haven't tried VC++ yet.
So I need to add the flags for the compilers that need them and disable
building the target for compilers that don't support OpenMP, which I'm
currently doing with a Jamfile like this:

   project
     : requirements
       <toolset>gcc:<cxxflags>-fopenmp
       <toolset>gcc:<linkflags>-fopenmp
       <toolset>intel:<cxxflags>-openmp
       <toolset>intel:<linkflags>-openmp
     ;

   exe example : example.cpp ;

To prevent building the example on clang I could use

   exe example : example.cpp : <toolset>gcc ;
   exe example : example.cpp : <toolset>intel ;

But enumerating the supported compilers in multiple places doesn't seem
like a good idea.

Instead I'm feature-testing in the source like this, which builds an
empty example when OpenMP is not available (_OPENMP is defined in the
API as set by a supporting compiler)

   #ifdef _OPENMP
     int main() { the example }
   #else
     int main() { return 0; }
   #endif

An earlier thread linked to
<https://github.com/thomassuckow/SystemBoost/blob/master/Jamfile.v2>
where `check-target-builds` is used for feature-testing, can I use this
here to prevent building the empty example?

Is there a way to define/use OpenMP as a feature, so that my Jamfile
wouldn't need to name every toolset but could just require OpenMP for a
target, which would magically set the flag on a supporting compiler or
ignore the target on an unsupported compiler? So that I could write:

   using openmp ;
   project : requirements … ;
   exe example : example.cpp : <openmp>yes ;

Supporting OpenMP in the global toolset definitions could benefit other
projects, too, would this be hard to implement? Where could I look for a
starting point?

Cheers,

-- 
Pascal Germroth

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk