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

Overloaded C99 math functions for integer arguments #454

Open
tnowotny opened this issue Sep 8, 2021 · 1 comment
Open

Overloaded C99 math functions for integer arguments #454

tnowotny opened this issue Sep 8, 2021 · 1 comment

Comments

@tnowotny
Copy link
Member

tnowotny commented Sep 8, 2021

In NVCC there is no overloaded function for, e.g., exp(a) if a is an integer variable or constant. This could lead to problems if users use integers in their models. A case in point is brian-team/brian2genn#133
Suggested solution is to define overloaded functions for all math functions like so:

__host__ __device__ scalar exp(int x) {
    return exp((scalar) x);
}

for the CUDA backend.
However, this would mean that there is a potential discrepancy for the CPU version, in which exp(a) for integer a resolves to double. We could therefore also add

scalar exp(int x) {
    return exp((scalar) x);
}

for the CPU backend.

@neworderofjamie
Copy link
Contributor

It will be a little more tricky for the CPU backend as these overloads will clash with the existing integer overloads but maybe they can be 'hidden' somehow..

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