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

Fixed an error regarding the pow() function of the DaCe runtime. #1582

Closed

Conversation

philip-paul-mueller
Copy link
Collaborator

@philip-paul-mueller philip-paul-mueller commented Jun 2, 2024

Currently there was an inplementation for T pow(T, T), where T is a template and two for the case where T is a signed or unsigned integer. This is a problem if we consider the call pow(double, long long) because the call is ambigious and results in a compiler error. As a solution I added the function T pow(T, E), where both T and E are templates.

Currently there was an inplementation for `T pow(T, T)`, where `T` is a template and two for the case where `T` is a signed or unsigned integer.
This is a problem if we consider the call `pow(double, long long)` because the call is ambigious and results in a compiler error.
As a solution I added the function `T pow(T, E)`, where both `T` and `E` are templates.

I also think that the implementation of the int case could be improved because currently it is a simple for loop.
@philip-paul-mueller philip-paul-mueller marked this pull request as draft June 2, 2024 13:29
@philip-paul-mueller philip-paul-mueller marked this pull request as ready for review June 3, 2024 04:58
template<typename T, typename E>
DACE_CONSTEXPR DACE_HDFI T pow(const T& a, const E& b)
{
return (T)std::pow(a, (T)b);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the cast really necessary? Since C++11, there is an overload for when the two arguments have different types (overload A): https://en.cppreference.com/w/cpp/numeric/math/pow

Shouldn't we just forward directly to that overload and let the standard library pick the implementation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea.

@BenWeber42
Copy link
Contributor

I'm closing this one, since it's superseded by #1583

@BenWeber42 BenWeber42 closed this Jun 19, 2024
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.

2 participants