Skip to content

Fix OpenMP support for cross-platform compatibility #8

@Arshammik

Description

@Arshammik

The package currently uses OpenMP for parallelization with the following configuration in src/Makevars:

CXX_STD = CXX14
PKG_CXXFLAGS += -O3 -march=native -pipe -fopenmp
PKG_LIBS     += -fopenmp $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

This works fine on Linux but fails to compile on macOS with the following error:

clang++: error: unsupported option '-fopenmp'

This happens because Apple's default Clang compiler doesn't support OpenMP. Additionally, R CMD check gives warnings about GNU extensions.

Proposed Solution

Create platform-specific Makevars files and a configure script to automatically handle the differences between operating systems:

  1. Keep current settings for Linux in src/Makevars
  2. Create src/Makevars.win for Windows
  3. Create src/Makevars.mac for macOS without OpenMP flags
  4. Add a configure script that detects macOS and uses the appropriate Makevars file
  5. Add documentation for users who want OpenMP support on macOS
  6. Add a function to check if OpenMP is enabled at runtime

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions