質問

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