[Networkit] build broken with --openmp=no and clang

Matteo Riondato matteo at cs.brown.edu
Thu Jul 13 17:19:54 CEST 2017


Hi all,

The build is broken when building with “scons —target=Lib —optimize=True —openmp=no” and the compiler is Clang.

The issue is that many files include <omp.h> unconditionally but they should actually check for _OPENMP to be defined (See Sect. 2.2 of the OpenMP specification: http://www.openmp.org/wp-content/uploads/openmp-4.5.pdf).
Additionally, the call to omp_* functions should be redefined or wrapped. Luckily, most of the code (the major exception being TopCloseness) just uses omp_get_thread_num() and omp_get_max_threads(), so one could likely do

#ifdef _OPENMP
#include <omp.h>
#else
#define omp_get_max_threads() 1
#define omp_get_thread_num() 0
#endif

Actually, in many cases, the correct solution is to refactor the code that calls these functions to use user-defined custom openmp reductions. Much of this code is essentially populating data structures in parallel in a for loop, so defining a custom openmp reduction in these cases is usually straightforward.

Matteo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.ira.uni-karlsruhe.de/pipermail/networkit/attachments/20170713/8189374e/attachment.sig>


More information about the NetworKit mailing list