Ask Your Question

parallel for thread dependency

asked 2014-06-08 10:15:07 -0500

Hello everyone, Is it possible to configure "parallel_for_" thread dependency? For example, I would like to perform an operation on every pixel of a cv::Mat. Can I configure threads to be dependent of their left neighbor , so they'll start execute only after the left neighbor processing is done?

Thanks! Danny.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-06-11 03:06:11 -0500

I don't think it's a good idea to have one thread per pixel on the CPU. You should create some image blocks (with overlapping) and use a loop inside each tile. Therefore, it's easy to manage the dependency. Usually a number of threads equal to the number of cores is a good choice, but depending on your computation a higher/smaller number of threads could be better. It's a trial and error process... And you still can use parallel_for_ without the dependency issue.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2014-06-08 10:15:07 -0500

Seen: 191 times

Last updated: Jun 11 '14