error: 'std::numeric_limits<int>::infinity': no overloaded function has restriction specifiers that are compatible
with the ambient context 'trivial_kernel'
*data = std::numeric_limits<int>::infinity();
^
#include <iostream>
#include <hip/hip_runtime.h>
__global__ void
trivial_kernel(hipLaunchParm lp, int *data){
*data = std::numeric_limits<int>::infinity();
}
int main(void){
int *data;
hipMalloc((void**)&data, sizeof(int));
hipLaunchKernel(HIP_KERNEL_NAME(trivial_kernel), dim3(1), dim3(1), 0, 0, data);
int res = -1;
hipMemcpy(&res, data, sizeof(int), hipMemcpyDeviceToHost);
hipFree(data);
std::cout << res << std::endl;
return 0;
}
Using the
std::numeric_limits<_T>::infinity()function within a kernel returns compilation error:To reproduce use the following HIP code :