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

Common math function support? #9

Closed
lordofhyphens opened this issue Jul 18, 2014 · 4 comments
Closed

Common math function support? #9

lordofhyphens opened this issue Jul 18, 2014 · 4 comments

Comments

@lordofhyphens
Copy link

Is it desirable in general to have a short math header that contains common functions from and are supported on the device? Maybe templated to allow for selection of the fast functions on CUDA? I've noticed that the compiler can get confused and go for a template of something from cmath where instead you'd want to promote an int to a double and use the device function instead.

I use std::pow() and std::abs() in my own device code, so it's useful for me. Something like being able to call hemi::pow(x,y) and get reasonable results on both the host and device?

@harrism
Copy link
Owner

harrism commented Jul 21, 2014

This could indeed be useful. Please see the discussion on #6 though. Portability is very important here, so a good design is important. I welcome pull requests. Thanks!

@lordofhyphens
Copy link
Author

I'm a bit torn on whether to look at this from the CUDA side or the host. I suspect it would be easier to use the math function names. This way, the functionality is clear (especially w/r/t rounding). Going the other way (from functions in to API is more natural to program in, but there's a pile of very specific functions with different rounding behaviors.

Right now, I've got everything as templated inline functions. Interesting side effect is that when the compiler is evaluating what template to use when the result of ?: is being passed to a function, the output is a bit weird when the types differ slightly (like a signed/unsigned int). It's fixable via typecasting, though.

On a related note, is there a preference as to a framework to use for writing testcases for some of these additions to Hemi?

@lordofhyphens
Copy link
Author

See #10 for a pull request for this.

@harrism
Copy link
Owner

harrism commented Jul 23, 2014

I would probably use google test, BTW (haven't looked at pull request yet).

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

No branches or pull requests

2 participants