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 opencl assign test to reassign zero sized vector after recover_memory() #3219

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

SteveBronder
Copy link
Collaborator

@SteveBronder SteveBronder commented Aug 10, 2023

Submission Checklist

  • Run unit tests: ./runTests.py src/test/unit
  • Run cpplint: make cpplint
  • Declare copyright holder and open-source license: see below

Summary

Fixes a bug in the stan opencl assign tests that reuses a var_value<matrix_cl<double>> after stan::math::recover_memory() is called. This popped up in stan-dev/math#2905 in the math. My guess is that this could be the cause of why sometimes these tests would fail randomly.

@t4c1 if you have any time could you take a look at this? I wasn't sure if this was intended as some part of the test or not and I'm missing something. You can replicate the error this fixes with the following

git clone --recursive [email protected]:stan-dev/stan.git
cd lib/stan_math
git checkout feature/threadsafe-matrixcl
cd ../../
python ./runTests.py ./src/test/unit/model/indexing/assign_cl_test.cpp

It's odd because after recover_memory() is called m_empty_v_cl will have a size of (4, 1). Which is the same size as the m2_cl vector we try to assign to it, but that test successfully throws so I'm not sure why that would happen.

Intended Effect

Fix bug in var_value<matrix_cl<double>> assignment

How to Verify

python ./runTests.py ./src/test/unit/model/indexing/assign_cl_test.cpp

Side Effects

Documentation

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Simons Foundation

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

@t4c1
Copy link
Collaborator

t4c1 commented Aug 15, 2023

Sorry, it has been too long since I worked on this. The code does not ring any bells. But from a cursory glance this change looks good.

@SteveBronder
Copy link
Collaborator Author

@rok-cesnovar could you look at / approve this?

@rok-cesnovar rok-cesnovar self-requested a review October 12, 2023 14:34
@rok-cesnovar
Copy link
Member

Of course, on it.

Copy link
Member

@rok-cesnovar rok-cesnovar left a comment

Choose a reason for hiding this comment

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

LGTM

@SteveBronder SteveBronder merged commit 88cffcf into develop Oct 18, 2023
@WardBrian WardBrian deleted the fix/opencl-assign-test branch November 14, 2024 14:41
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.

4 participants