ParallelFor with race conditions
-
Hallo everyone, I need to process a huge amount of data, organized in a 2d grid, like a bitmap. its more than 25 million data sets so I wanted to use ParallelFor for this.
However, the problem is: While I can iterate over the grid to get data to process, I need to write the results from processing each dataset into several other datasets in the grid (advection). So, if i just use parallelFor, there will likely be write access to the same datasets by several threads simultaneously.
What is the best way to do this?
thank you!
J
-
hello @juergenb and thanks for reaching us,
You have to use a lock system, we have our Lock Manual with the information you will need.
Of course if you have question feel free to ask them.
Cheers,
Manuel -
thank you!! That should get me going
I guess it is generally smarter to try and work around locks, right? To avoid threads waiting for each other?
-
hi,
that really depends on what you are doing.
There's different type of lock for different cases and scenario.That also depends on what you care first, speed or memory.
but the manual is pretty easy to understand, just pass the lock as a reference to your lambda function and you should be good to go.
Cheers,
Manuel