[R-pkg-devel] OpenMP on MacOS

Hugh Parsonage hugh@p@r@on@ge @end|ng |rom gm@||@com
Mon Jun 7 16:28:30 CEST 2021

Ensure you surround all your omp pragmas like so:

#ifdef _OPENMP
#pragma omp parallel ...

Essentially, detecting the operating system is not enough -- you need
to condition your use of OpenMP if and only if _OPENMP is available.

You should also do the same for

#include <omp.h>

Note that this will also make your loops sequential when OpenMP is not

On Mon, 7 Jun 2021 at 21:52, Konrad Krämer via R-package-devel
<r-package-devel using r-project.org> wrote:
> Dear all,
> I have a problem regarding OpenMP on Mac OS. Recently I submitted my package to CRAN (https://cran.r-project.org/web/packages/paropt/index.html). However, there seems to be a problem with 'fopenmp' on Mac OS using clang++. I have read many forums regarding the topic. Thus, I know that there is no support for OpenMp on Mac OS (at least using the default clang compiler).
> The error was: clang: error: unsupported option '-fopenmp'
> Is it possible to detect the operating system and set according to this the compile flags and use also a sequentiell version of the code?
> Or is there a better way to cope with this problem?
> Many thanks in advance for your help.
> Regards,
> Konrad
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

More information about the R-package-devel mailing list