문제

Is there any way from a kernel (GPU Code) to find out which device the code is running on? You can find blockIdx, threadIdx, blockDim and gridDim, but any way to find the CUDA device id?

For those who wonder, i plan to use it in a OptiX program to have more control over OptiX buffers.

올바른 솔루션이 없습니다

다른 팁

This works in OptiX 3.0 and 3.5 but I can't guarantee it will always work. We should provide a real API for this in a future version.

namespace rti_internal_register
{
    __device__ unsigned reg_device_id;
}

rtBuffer<uchar4, 2> output_buffer;

RT_PROGRAM void pinhole_camera()
{
    if( rti_internal_register::reg_device_id == 0 )
        output_buffer[launch_index] = make_color( make_float3( 0.5, 0.0, 0.0 ) );
    else
        output_buffer[launch_index] = make_color( make_float3( 0.0, 0.5, 0.0 ) );
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top