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

add openmp support for predictions #10

Closed
gravesee opened this issue Apr 20, 2017 · 2 comments
Closed

add openmp support for predictions #10

gravesee opened this issue Apr 20, 2017 · 2 comments

Comments

@gravesee
Copy link
Owner

No description provided.

@gravesee
Copy link
Owner Author

gravesee commented Apr 22, 2017

@idroz I added openmp support and verified that it works on mac. Here are the new timings on a dataset of 7,000 obs and 11 columns and 100 trees of depth 32. Roughly 4x speedup.

It's all under this branch: add-openmp

Unit: milliseconds
 expr      min        lq      mean   median        uq       max neval
  new 229.6577  244.6078  269.6257  253.532  269.4523  471.8144   100
  old 981.9939 1013.5965 1067.6469 1031.105 1099.3970 1640.0559   100

To get it to work on mac you have to first:

brew install llvm

And then edit your ~/.R/Makevars file to look like so:

CXX = /usr/local/opt/llvm/bin/clang
CXXFLAGS = -I/usr/local/opt/llvm/include -fopenmp
LDFLAGS = -L/usr/local/opt/llvm/lib -fopenmp=libiomp5

That last bit with -fopenmp=libiomp5 was a real pain to figure out. I have to add some safety checks. The code will crash if your data.frame has types other than numeric, integer, or factor.

To call the omp parallel predict function do the following:

 p <- predict(mod, newdata, iterative=TRUE)

@gravesee
Copy link
Owner Author

Todos:

  1. Clean up code -- remove printfs
  2. switch callocs to mallocs
  3. change for loop zero-initialization to memcpy?

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

No branches or pull requests

1 participant