Skip to content

MAINT: align random double_fill to float_fill, simplify distributions.c #14611

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

Closed
wants to merge 1 commit into from

Conversation

mattip
Copy link
Member

@mattip mattip commented Sep 29, 2019

Part of the C-API overhaul in gh-14608 and gh-14604, and should be merged first to simplify the distribution function renaming.

double_fill had an interface that required a fill variant of the sampling function, while float_fill and float_fill_from_double were different. Align the interfaces and remove the fill variants in distributions.canddistributions.h`.

@mattip
Copy link
Member Author

mattip commented Sep 29, 2019

ping @bashtage

@rkern
Copy link
Member

rkern commented Sep 30, 2019

Seems right to me, but @bashtage might know if there was something motivating that implementation.

@bashtage
Copy link
Contributor

It is an optimization. The 0 parameter functions are unique in the sense that it is possible to fill blocks without function call overhead since these can be inlined.

Once upon a time, I did some tests and it seemed worth it for large samples. I don't have any saved results to back this up now.

@@ -920,7 +920,7 @@ cdef class Generator:
"""
key = np.dtype(dtype).name
if key == 'float64':
return double_fill(&random_gauss_zig_fill, &self._bitgen, size, self.lock, out)
return double_fill(&random_gauss_zig, &self._bitgen, size, self.lock, out)
Copy link
Contributor

@bashtage bashtage Sep 30, 2019

Choose a reason for hiding this comment

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

I think you can go further if the fill-methods are being removed and you can remove double_fill and just use

cont(&random_gauss_zig, &self._bitgen, size, self.lock, 0,
     0.0, '', CONS_NONE, None,0.0, '', CONS_NONE, None, 0.0, '', CONS_NONE, None
     out)

@mattip
Copy link
Member Author

mattip commented Oct 1, 2019

worth it for large samples

OK, makes sense, since the function calls cannot be inlined. Let's put this off until after gh-14608 and we can see if eliminating distributions.pxd allows the functions to be inlined.

@mattip mattip closed this Oct 3, 2019
@mattip mattip deleted the random-fill branch June 8, 2020 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants