Parallel Programming in Native Code

Parallel programming using C++ AMP, PPL and Agents libraries.

invalid_compute_domain exception of C++ AMP

invalid_compute_domain exception of C++ AMP

  • Comments 0

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

An instance of the invalid_compute_domain exception type is thrown when the runtime fails to execute the AMP kernel for the compute domain specified at a parallel_for_each call site. The table below lists the common scenarios that result in invalid_compute_domain exception.

Scenario

Exception Message

Code Snippet

Invalid Extent at parallel_for_each

concurrency::parallel_for_each: unsupported compute domain,the extent of dimension 0 of the compute domain (-120)cannot be smaller than or equalto 0.

accelerator a;

concurrency::extent<1> ext(-120);

int x;

try

{

   parallel_for_each(ext, [=](index<1> idx) restrict(amp)

   {

       int y = x;

   });

}

catch(invalid_compute_domain& ex)

{

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

}

Extent not divisible by Tiled extent

concurrency::parallel_for_each(tiling): unsupported computedomain, the extent of dimension 0 of the computedomain (32) cannot be evenlydivided by the extent ofdimension 0 of the tile (6).

array<int,1> intArr(1024);

concurrency::extent<2> ext(32,32);

try

{

   parallel_for_each(ext.tile<6,6>(),[&](tiled_index<6,6> idx) restrict(amp){

      int y = idx.local[0];

   });

}

catch(invalid_compute_domain& ex)

{

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

}

In my next blog post, I will cover the unsupported_feature exception.

Blog - Comment List MSDN TechNet
  • Loading...
Leave a Comment
  • Please add 5 and 4 and type the answer here:
  • Post