unsupported_feature exception of C++ AMP
This blog post assumes you have read the introduction to C++ AMP exceptions.
An instance of the unsupported_feature exception type is thrown on invoking a parallel_for_each/ allocating an object on an accelerator which doesn’t support certain features needed for the execution to proceed.The table below lists the common scenarios that result in unsupported_feature exception.
Scenario |
Exception Message |
Code Snippet |
Texture object creation on CPU accelerator |
Feature not supported on cpu_accelerator |
accelerator a(accelerator::cpu_accelerator); accelerator_view av = a.default_view; concurrency::extent<1> ext(1024); try { texture<int,1> texInt(ext,av); } catch(unsupported_feature& ex) { std::cout<< ex.what() << std::endl; } |
Texture object creation with invalid combination of bits_per_channel and short-vector type |
The combination of the short vector type and bits-per-scalar-element for the texture is not supported. |
accelerator a; accelerator_view av = a.default_view; concurrency::extent<1> ext(1024); try { texture<float,1> texInt(ext,8,av); } catch(unsupported_feature& ex) { std::cout<< ex.what() << std::endl; } |
Read and write operations on textures not having bits-per-channel of value 32 |
Both read and write are detected on a texture with bits-per-scalar-element not equal to 32. |
try { concurrency::extent<1> ext(10); texture<int, 1> tex(ext, 16); parallel_for_each(tex.extent, [&](index<1> idx) restrict(amp) { auto value = tex[idx] + 1; tex.set(idx, value); }); } catch(unsupported_feature& ex) { std::cout<< ex.what() << std::endl; } |
My next blog post covers out_of_memory exception.