I would like to know if CUDA provides a concept similar to std::floating_point but including all IEE754 types including e.g. __half. I provide below a sample code that test that __half template functions do not compile with std::floating_point.
#include <concepts>
#include <iostream>
#include <cuda_fp16.h>
template<std::floating_point T>
__host__ __device__ bool use_floating_point() {
return True;
}
int main() {
std::cout << "Is float a floating-point type?" << use_floating_point<float>() << '\n';
std::cout << "Is __half a floating-point type?" << use_floating_point<__half>() << '\n'; // Compilation error
return 0;
}
I think what you are looking for is
std::is_iec559, becauseis_floating_pointcovers only a limited set of types, whileis_iec559, to my understanding is supposed to match any type that implements IEE754.However, as @Artyer points out in a comment.
std::is_iec559<__half>isfalse.If you merely need
std::is_flaoting_pointplus__half, you can write your custom conceptLive Demo