Hi there,
I'm using maxon::ParallelFor()
to process 2-dimensional grids of values. Works like a charm!
After noticing maxon::ParallelImage
in the documentation, I thought it might be worth a try to use that. After all, images are but 2-dimensional grids, too.
Here's the original code using ParallelFor
:
// Worker lambda to build the grid
const UInt gridWidth = gridRef.GetWidth();
const UInt gridHeight = gridRef.GetHeight();
auto worker = [&gridRef, &myObj, gridWidth, someParameter] (UInt y)
{
for (Uint x = 0; x < gridWidth; ++x)
gridRef(x, y) = myObj->Calculate(x, y, someParameter);
};
// Execute worker
maxon::ParallelFor::Dynamic(0, gridHeight, worker);
Here's the code using ParallelImage
:
// Worker lambda to build the grid
const UInt gridWidth = gridRef.GetWidth();
const UInt gridHeight = gridRef.GetHeight();
auto worker = [&gridRef, &myObj, someParameter] (maxon::Int x, maxon::Int y)
{
gridRef(x, y) = myObj->Calculate(x, y, someParameter);
};
// Execute worker
maxon::ParallelImage::Process(gridWidth, gridHeight, 10, worker);
The strange thing is that, while ParallelFor()
works perfectly, ParallelImage()
never calculates the last line and column of the grid. I tried calling Process()
with gridWidth + 1
, gridHeight + 1
, and experimented with different tile sizes, with no success whatsoever.
Questions:
- Why does this happen?
- Are there any rules I need to stick to (e.g.
gridWidth
orgridHeight
need to be multiples of 8, or whatever, orgridWidth
andgridHeight
need to be dividable bytileSize
)?
Thanks in advance for help!
Cheers,
Frank