Multithreading in a loop C++

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Multithreading in a loop C++



I have a loop in a program coloring a Bitmap. It looks about like that:


for (int i = 0; i<1920; i++){
for (int j = 0; j < 1080; j++){
compute_pixel(i, j);
}
}



and I want to speed it up by using 8 cores of my CPU and give them different threads - one for a pixel, so that when i already have 8 cores in use (working on first 8 pixels) i want to assign the 9th pixel to the first core which finishes its job. What is the best way to achieve that?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

How to scale/resize CVPixelBufferRef in objective C, iOS