Thanks to visit codestin.com
Credit goes to github.com

Skip to content

std::numeric_limits<_T>::infinity() compilation problem #374

Description

@ekondis

Using the std::numeric_limits<_T>::infinity() function within a kernel returns compilation error:

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();
                                                  ^

To reproduce use the following HIP code :

#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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions