I have this code:
Matrix mat;
for (int y=0; y<n; ++y)
{
    for (int x=0; x<m; ++x)
    {
        // do some small operation on mat(y,x)
    }
};
The serial computation is very slow (this double loop is called 500-1000 times), so as a first step I want to parallelize it with dispatch_apply.
Matrix mat;
dispatch_apply(PATCH_SIZE, _queue, ^(size_t y)
{
    for (int x=0; x<m; ++x)
    {
        // do some small operation on mat(y,x)
    }
});
The problem is with the variable mat, it's define as read-only inside the block. Is there a way to workaround this?
 
     
     
    