-fopenmp
flag for openMP support. c
#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
}
gcc -fopenmp test.c -o test.x
➜ ~ ./test.x
Hello from thread 3, nthreads 8
Hello from thread 1, nthreads 8
Hello from thread 2, nthreads 8
Hello from thread 4, nthreads 8
Hello from thread 5, nthreads 8
Hello from thread 6, nthreads 8
Hello from thread 0, nthreads 8
Hello from thread 7, nthreads 8
brew install gcc
.gcc-x.y
available on your command line. I have gcc-9.2
for example. We need to tell R
to use that particular compiler when we build mnlogit
(or any other package). ~/.R/Makevars
. You probably have to create ~/.R
.You could just copy my version. there is a bunch of comments to build different packages. you could just comment out different things for different builds. ``` # floswald 2019 # based on http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-May/003845.html
CFLAGS=-g -O3 -w -fopenmp -mtune=native
CXXFLAGS= -O3 -Wall -pedantic -mtune=native -pipe -fopenmp
FFLAGS=-O3 -g0 -Wall -pipe
FCFLAGS=-O3 -g0 -Wall -pipe FLIBS=-L/usr/local/lib/gcc/9 -lgfortran -lquadmath -lm
VER=9 CC=gcc-$(VER) CXX=g++-$(VER)
FC=gfortran F77=gfortran ```
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.