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 unary operations minus and logical negation to kernel generator #1824

Merged
merged 5 commits into from
Apr 8, 2020

Conversation

t4c1
Copy link
Contributor

@t4c1 t4c1 commented Apr 3, 2020

Summary

Adds unary operations (unary minus and logical negation) to kernel generator.

Tests

New operations are tested.

Side Effects

None.

Release notes

Added unary operations (unary minus and logical negation) to kernel generator.

Checklist

  • Math issue Implement OpenCL kernel generator #1342

  • Copyright holder: Tadej Ciglarič

    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

@t4c1
Copy link
Contributor Author

t4c1 commented Apr 3, 2020

@serban-nicusor-toptal This PR has been reformated 3 times in a row. It seems there are still some differences in clang format, even if they are all nominally 6.0.0.

@serban-nicusor-toptal
Copy link
Contributor

Hey, would it help if I spin up a machine and send you credentials maybe you can debug it ?
Or is there something I can do by myself to fix this?

@rok-cesnovar
Copy link
Member

The difference is probably in the exact version:

See
auto-formatting by clang-format version 6.0.0 (tags/google/stable/2017-11-14
and
auto-formatting by clang-format version 6.0.0-1ubuntu2~16.04..1 (tags/RELEASE_600/final)

Can you check which one was the second one and see if we can put it on the same tag?

@serban-nicusor-toptal
Copy link
Contributor

@rok-cesnovar auto-formatting by clang-format version 6.0.0-1ubuntu2~16.04..1 (tags/RELEASE_600/final) is the good one we need ?

@rok-cesnovar
Copy link
Member

I am not an expert on this, but my hunch is that ye, aynthing with (tags/RELEASE_600/final) is good. The other one looks like a release candidate or a nightly build.

@serban-nicusor-toptal
Copy link
Contributor

Okay thanks, on it.

@serban-nicusor-toptal
Copy link
Contributor

serban-nicusor-toptal commented Apr 3, 2020

Hmmh the job passed clang-format now.
It ran on ec2 both times #4 which formatted clang and #5 which ran after #4 formatting changes.

clang-format --version
clang-format version 6.0.0-1ubuntu2~16.04.1 (tags/RELEASE_600/final)

So I think what's causing issues is actually the legacy clang-format on gelman-mac seen in #3

+ clang-format --version
clang-format version 6.0.0 (tags/google/stable/2017-11-14)

Going to make a backup of the legacy clang-format on gelman-mac and try to update it to a newer 6.0.0 version.


This will take a little bit of time, I need to get sudo access on the machine. Sorry!


Edit: Done!

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 4.91 4.87 1.01 0.91% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 0.98 -1.72% slower
eight_schools/eight_schools.stan 0.09 0.09 1.0 -0.17% slower
gp_regr/gp_regr.stan 0.22 0.22 0.98 -1.62% slower
irt_2pl/irt_2pl.stan 6.48 6.43 1.01 0.81% faster
performance.compilation 88.22 87.04 1.01 1.34% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 7.64 7.52 1.02 1.57% faster
pkpd/one_comp_mm_elim_abs.stan 21.38 20.43 1.05 4.42% faster
sir/sir.stan 93.79 94.26 1.0 -0.5% slower
gp_regr/gen_gp_data.stan 0.05 0.05 1.0 0.43% faster
low_dim_gauss_mix/low_dim_gauss_mix.stan 2.95 2.96 1.0 -0.12% slower
pkpd/sim_one_comp_mm_elim_abs.stan 0.31 0.31 1.0 0.01% faster
arK/arK.stan 1.73 1.74 1.0 -0.1% slower
arma/arma.stan 0.65 0.65 0.99 -0.68% slower
garch/garch.stan 0.51 0.51 1.0 0.27% faster
Mean result: 1.00345906499

Jenkins Console Log
Blue Ocean
Commit hash: 2e9a962


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

Copy link
Collaborator

@SteveBronder SteveBronder left a comment

Choose a reason for hiding this comment

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

lgtm! Once quick Q though, should this PR also include the macro for defining other unary ops?

typename std::remove_reference_t<T>::Scalar> {
using base = unary_operation_cl<unary_minus_<T>, T,
typename std::remove_reference_t<T>::Scalar>;
using base::arguments_;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this get used somewhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was planning to do a refactor that would make derived classes use operation_cl::arguments_ directely again instead of get_argument (possibly before this PR was merged). At the end I did not do it in this PR, but it is comming.

@t4c1 t4c1 merged commit 11742e2 into stan-dev:develop Apr 8, 2020
@t4c1
Copy link
Contributor Author

t4c1 commented Apr 8, 2020

About macro: this PR already adds both that make sense (I don't plan to support in place ones like ++). Custom functions can be added with the macros in unary_function_cl.hpp.

@rok-cesnovar rok-cesnovar deleted the cl_kernel_generator_unary_ops branch April 9, 2020 06:42
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.

6 participants