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

Validate edm::isFinite() / edm::isNotFinite() on GPU and compare with std::isfinite() #617

Open
ericcano opened this issue Apr 15, 2021 · 1 comment

Comments

@ericcano
Copy link

edm::isNotFinite has not yet been validate on GPU. It should be and compared with its std:: counterpart in both CPU and GPU cases.

It seems benign at first sight. It implies a few integer operations (while the std:: version calls a more open ended intrinsic (I did not dig out what the std intrinsic actually contains, in any of CPU of GPU):

  template <typename T>
  constexpr bool isNotFinite(T x) {
    return !isFinite(x);
  }

  template <>
  constexpr bool isFinite(float x) {
    const unsigned int mask = 0x7f800000;
    union {
      unsigned int l;
      float d;
    } v = {.d = x};
    return (v.l & mask) != mask;
  }

While std:: version is:

  template<typename _Tp>
    inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
					   int>::__type
    isfinite(_Tp __f)
    {
      typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
      return __builtin_isfinite(__type(__f));
    }
@fwyzard
Copy link

fwyzard commented Apr 15, 2021

What about using CUDA's isfinite() math function ?
__device__ ​ __RETURN_TYPE isfinite ( float a )
__device__ ​ __RETURN_TYPE isfinite ( double a )

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

No branches or pull requests

2 participants