Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update of Mac installation information for Monterey (v 12) #5271

Open
markdanese opened this issue Nov 23, 2021 · 5 comments
Open

Update of Mac installation information for Monterey (v 12) #5271

markdanese opened this issue Nov 23, 2021 · 5 comments

Comments

@markdanese
Copy link

markdanese commented Nov 23, 2021

I had to do a fresh install on a new M1 Mac running Monterey (v 12.0.1) today. I followed the instructions at https://github.com/Rdatatable/data.table/wiki/Installation (which were really helpful). However, I couldn't get data.table to install from source or recognize OpenMP.

It turns out that in Step 2, Option 1 (LLVM) the Makevars file specifications don't work with the current version of the Mac OS (Monterey 12.0.1) and the latest version of Homebrew (3.3.5) which installs into a new location. Below is the code that worked for me. I installed from source without a problem and OpenMP is recognized. I had to install gettext (brew install gettext). I had also installed gcc via Homebrew also, but I don't know if that was required. After this, I get OpenMP working with 5 threads, which is correct.

Hopefully this will be helpful to someone. Note that, despite the success with data.table, the fst package doesn't recognize OpenMP even after installing from source, so I can't guarantee that the code below will solve all related issues. I will file an issue in the fst repo separately.

HOMEBREW_LOC=/opt/homebrew
LLVM_LOC=$(HOMEBREW_LOC)/opt/llvm
CC=$(LLVM_LOC)/bin/clang -fopenmp
CXX=$(LLVM_LOC)/bin/clang++ -fopenmp
# -O3 should be faster than -O2 (default) level optimisation ..
CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L$(HOMEBREW_LOC)/opt/gettext/lib -L$(LLVM_LOC)/lib -Wl,-rpath,$(LLVM_LOC)/lib
CPPFLAGS=-I$(HOMEBREW_LOC)/opt/gettext/include -I$(LLVM_LOC)/include
@avimallu
Copy link
Contributor

You can make the edit on the data.table wiki yourself to help other people like yourself!

Not sure if this will work on your system - but these flags made even packages like fst that seem to rely on some fortran elements work for me on OpenMP on a Linux system:

CC = /usr/bin/gcc64
CXX = /usr/bin/g++
CXX11 = /usr/bin/g++
CXX14= /usr/bin/g++
CXX17= /usr/bin/g++
CXX1X= /usr/bin/g++
FC = /usr/bin/gfortran48
SHLIB_OPENMP_CFLAGS = -fopenmp
SHLIB_OPENMP_CXXFLAGS= -fopenmp
SHLIB_OPENMP_FCFLAGS= -fopenmp
SHLIB_OPENMP_FFLAGS= -fopenmp

You should be able to modify suitably to get it to work on Mac.

@George9000
Copy link

George9000 commented Nov 29, 2021

I too installed on an M1 mac with Monterey.

see https://mac.r-project.org/openmp/
slightly modified instructions

mkdir ~/Documents/openmp
mkdir ~/Documents/openmp/usr
mkdir ~/Documents/openmp/usr/local

cd ~/Documents/openmp
curl -O https://mac.r-project.org/openmp/openmp-13.0.0-darwin21-Release.tar.gz
tar fvxz openmp-13.0.0-darwin21-Release.tar.gz -C .  # note the period for current directory

cd /usr/local
sudo mkdir lib
sudo mkdir include
cd lib
sudo cp /Users/foo/Documents/openmp/usr/local/lib/libomp.dylib .

cd ../include
sudo cp /Users/foo/Documents/openmp/usr/local/include/* .

Then....
make a ~/.R/Makevars as follows

CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
CPPFLAGS += -Xclang -fopenmp -I/usr/local/include
LDFLAGS += -lomp -L/usr/local/lib

With that data.table built and gave 5 threads when loaded.

For my builds I like to git clone into a directory and then run the R CMD variations

git clone git@github.com:Rdatatable/data.table.git
R CMD build data.table
R CMD remove data.table # in case there is an existing old version
R CMD install data.table_1.14.3.tar.gz

@fox34
Copy link

fox34 commented Dec 12, 2021

@markdanese
Copy link
Author

I also fixed the fst problem with additional lines in Makevars. Please see this fst issue.

@pat-s
Copy link

pat-s commented Feb 28, 2022

The installation instructions for arm Macs might need an update pointing to the location of libomp/lib as described in fstpackage/fst#242 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants