Skip to content

Feature/1854 OpenCL /prim signatures part 1 - #1859

Merged
rok-cesnovar merged 48 commits into
developfrom
feature/1854-opencl-prim-pt1
May 7, 2020
Merged

rok-cesnovar merged 48 commits into
developfrom
feature/1854-opencl-prim-pt1

Conversation

@rok-cesnovar

@rok-cesnovar rok-cesnovar commented Apr 30, 2020 •

Copy link
Copy Markdown
Member

Summary

Add /prim OpenCL support for the following functions (only matrix ones listed, but this also adds the same signatures for row_vector and vector):

 matrix add(real, matrix)
 matrix add(matrix, real)
 matrix add(matrix, matrix)
 vector col(matrix, int)
 matrix inv(matrix)
 matrix inv_cloglog(matrix)
 matrix inv_logit(matrix)
 matrix inv_sqrt(matrix)
 matrix inv_square(matrix)
 row_vector row(matrix, int)
 int[] dims(matrix)
 int cols(matrix)
 int rows(matrix)

This adds no new OpenCL code, just using the generator.

It also adds argument checks to block(), renames is_valid_expression to is_valid_kernel_expression, require_all_valid_expressions* to require_all_valid_kernel_expressions*

Tests

Added tests for all added functions.

Side Effects

/

Release notes

Added OpenCL support for prim versions of add, col, inv, inv_cloglog, inv_logit, inv_sqrt, inv_square, row, dims, cols.
Added argument checks to OpenCL version of block() and renamed is_valid_expression to is_valid_kernel_expression and require_all_valid_expressions* to require_all_valid_kernel_expressions*.

Checklist

  • Math issue Implement matrix_cl overloads for prim & rev functions #1854

  • Copyright holder: Rok Češnovar

    The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
    - Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
    - Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

  • the basic tests are passing

    • unit tests pass (to run, use: ./runTests.py test/unit)
    • header checks pass, (make test-headers)
    • dependencies checks pass, (make test-math-dependencies)
    • docs build, (make doxygen)
    • code passes the built in C++ standards checks (make cpplint)
  • the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

@rok-cesnovar rok-cesnovar changed the title Feature/1854 opencl prim pt1 Feature/1854 OpenCL /prim signatures part 1 Apr 30, 2020

@SteveBronder SteveBronder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a first pass with some Qs. Think @t4c1 is better reviewing this

Comment thread stan/math/opencl/prim/add.hpp Resolved
namespace stan {
namespace math {

/** \ingroup opencl

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be in a sub group like methods?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could go with a prim subgroup. These are all just trying to add every missing prim signature in the Stan language. I dont think this will be used inside Math directly, much like the regular prim/col is not.

Comment thread stan/math/opencl/prim/col.hpp Outdated
* assigning the resulting expression to a matrix_cl representing
* a column vector.
*
* @tparam T type of the matrix

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T_a, double check the docs for all these

Comment thread stan/math/opencl/prim/cols.hpp Resolved
Comment thread test/unit/math/opencl/prim/col_test.cpp Resolved
@rok-cesnovar

Copy link
Copy Markdown
Member Author

Thanks @SteveBronder for the initial feedback. Addressed all your points. So I guess @t4c1 can take a look when he has time.

@rok-cesnovar

Copy link
Copy Markdown
Member Author

@serban-nicusor-toptal it seems that all Linux workers are offline: All nodes of label ‘linux’ are offline. Can we do anything about this?

@serban-nicusor-toptal

Copy link
Copy Markdown
Contributor

Good morning @rok-cesnovar

Jenkins should take care of this by itself and scale through aws instances.
Sadly I saw lately that some machines went down or are flipping, with the covid situation there isn't much we can do to them so we rely on AWS Instances. ( windows now scales through AWS too so expect less time in the queue )

Comment thread stan/math/opencl/prim/col.hpp Resolved
Comment thread stan/math/opencl/prim/cols.hpp Resolved
Comment thread stan/math/opencl/prim/dims.hpp Resolved
Comment thread stan/math/opencl/prim/rows.hpp Resolved
rok-cesnovar and others added 4 commits May 6, 2020 10:20
Co-authored-by: Tadej Ciglarič <tadej.c@gmail.com>
Co-authored-by: Tadej Ciglarič <tadej.c@gmail.com>
Co-authored-by: Tadej Ciglarič <tadej.c@gmail.com>
t4c1
t4c1 previously approved these changes May 6, 2020
@stan-buildbot

Copy link
Copy Markdown
Contributor

Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 5.1 5.03 1.01 1.24% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 0.99 -1.06% slower
eight_schools/eight_schools.stan 0.09 0.09 1.0 -0.3% slower
gp_regr/gp_regr.stan 0.23 0.23 1.0 -0.28% slower
irt_2pl/irt_2pl.stan 6.43 6.43 1.0 -0.03% slower
performance.compilation 85.8 84.5 1.02 1.52% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 7.55 7.53 1.0 0.18% faster
pkpd/one_comp_mm_elim_abs.stan 20.81 19.84 1.05 4.63% faster
sir/sir.stan 91.33 92.97 0.98 -1.79% slower
gp_regr/gen_gp_data.stan 0.05 0.05 1.01 0.81% faster
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.98 2.99 1.0 -0.15% slower
pkpd/sim_one_comp_mm_elim_abs.stan 0.31 0.34 0.93 -7.93% slower
arK/arK.stan 1.74 1.75 0.99 -0.55% slower
arma/arma.stan 0.77 0.77 1.0 0.42% faster
garch/garch.stan 0.56 0.57 0.99 -0.54% slower
Mean result: 0.998055521247

Jenkins Console Log
Blue Ocean
Commit hash: 8fc0e1a


Machine information ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010

CPU:
Intel(R) Xeon(R) CPU E5-1680 v2 @ 3.00GHz

G++:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Clang:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

@stan-buildbot

Copy link
Copy Markdown
Contributor

Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 5.09 5.08 1.0 0.16% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 1.01 1.26% faster
eight_schools/eight_schools.stan 0.09 0.09 1.01 0.94% faster
gp_regr/gp_regr.stan 0.23 0.23 0.96 -3.91% slower
irt_2pl/irt_2pl.stan 6.44 6.44 1.0 0.04% faster
performance.compilation 85.65 84.38 1.02 1.48% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 7.55 7.56 1.0 -0.09% slower
pkpd/one_comp_mm_elim_abs.stan 20.23 20.2 1.0 0.12% faster
sir/sir.stan 91.07 91.13 1.0 -0.07% slower
gp_regr/gen_gp_data.stan 0.05 0.05 0.99 -0.93% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.99 3.03 0.98 -1.65% slower
pkpd/sim_one_comp_mm_elim_abs.stan 0.31 0.31 0.99 -0.91% slower
arK/arK.stan 1.74 1.75 1.0 -0.45% slower
arma/arma.stan 0.76 0.76 1.0 -0.1% slower
garch/garch.stan 0.57 0.57 1.0 -0.1% slower
Mean result: 0.997359363964

Jenkins Console Log
Blue Ocean
Commit hash: 8fc0e1a


Machine information ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010

CPU:
Intel(R) Xeon(R) CPU E5-1680 v2 @ 3.00GHz

G++:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Clang:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

@rok-cesnovar

Copy link
Copy Markdown
Member Author

@SteveBronder you good with this? Cant merge as your change request is still there. If you dont have any more comments, please go ahead and merge. Thanks!

@rok-cesnovar
rok-cesnovar requested a review from SteveBronder May 7, 2020 10:30

@SteveBronder SteveBronder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@rok-cesnovar
rok-cesnovar merged commit 3f3fa3d into develop May 7, 2020
@rok-cesnovar
rok-cesnovar deleted the feature/1854-opencl-prim-pt1 branch May 7, 2020 19:07
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

Successfully merging this pull request may close these issues.

5 participants