accelerator_view_removed exception of C++ AMP

This blog post assumes you have read the introduction to C++ AMP exceptions.

An instance of the accelerator_view_removed exception type is thrown to handle a Timeout Detection and Recovery ( TDR ) event while executing an operation on an accelerator.

Scenario

Exception Message

Code Snippet

TDR Event

ID3D11Device::RemoveDevice: Device removal has been triggered

/* Below is an instance where accelerator_view_removed

exception is thrown for a long running kernel.*/

array<int,1> deviceArray(dataVector.size(),dataVector);

try

{

   parallel_for_each(deviceArray.extent,[&](index<1> idx) restrict(amp)

   {

       // Long running computation

    });

    dataVector = deviceArray;

}

catch(accelerator_view_removed& ex)

{

     std::cout<< ex.what() << std::endl;

     std::cout<< ex.get_view_removed_reason() << std::endl;

}

 

Here comes to an end of C++ AMP Exception Series.

Happy C++ AMP Coding !! Smile