'AMP C++ index<1> iteration
I have written other code which outputs different accelerator info, however I am having a bit of trouble understanding completely the following below.
I am having a bit of a hard time understanding how this piece of code works (I wrote this particular bit from memory and with a BIT of understanding)
try
{
concurrency::parallel_for_each(av3.extent, [=](concurrency::index<1> idx) restrict(amp)
{
av3[idx] = av1[idx] + av2[idx];
});
av3.synchronize();
}
The size of av1,2,3 is 2 to the power of 24, so theoretically av3.extent should be launching 16+million threads on the GPU.
Note that the lambda is capturing all by value on purpose etc.
My question comes in with the index<1> idx (index<1> symbolising it is 1 dimension, however with the computation of av3[idx] = av1[idx] + av2[idx] how is the index of for example "av1" indexed when there is no "i" for the try and catch? How does idx know what iteration it is on for that particular index?
I.e. how does idx know that it is placing the value 4 into av2 element [5] when there is no "i" to specify the current iteration index.
Does "try" contain some sort of iterator? that index(N) uses as an indexer? I couldn't find much online about it.
I am also aware of parallel_for resource protection so no need for mutexes etc and all of the other intelligent things that it does.
Think I may have solved this, idx is directly correlated to a specific thread ID, hence that is how it gets indexed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
