Previous | Next --- Slide 30 of 60
Back to Lecture Thumbnails
kayvonf

Question: I'm posting this question now that we've seen a number of implementations of dynamic work assignment via a task queue in class. Could someone give me a few examples that we've seen/discussed so far? (for example in the implementation ISPC, CUDA, or even OpenMP?)

BryceToTheCore

One example related to Assignment 1 would be the assignment of row of work when rendering an image such as the Mandelbrot.

One can have an atomic counter that indicates the next row of pixels to be rendered. Each thread does its work, then safely queries and updates the counter and then proceeds to render the pixels in the row related to the index that it has queried. In this way the work can balance itself out.

CUDA semantically probably works in the same way. When we activate CUDA kernel's we specify block sizes and a number of blocks that we want to create. Semantically we are just defining a distribution on the work that we have to do. The CUDA implementation does not spawn all of the work at once, but rather spawns work for each of its processors and then puts the remaining work in a queue. CUDA then takes work from the queue as it completes jobs. in this way, CUDA can help balance out big jobs and small jobs. The important point is that we are not explicitly mapping jobs to processors, but rather we are telling CUDA what execution paths that we want to run our code through.

amaliujia

For ISPC, we can just indicate a for each loop to show Compiler independence among tasks. These tasks could be assigned dynamically.

landuo

OpenMP allows the programmer to specify scheduling policy. In assignment 3, I have tried to use #pragma omp parallel for schedule (dynamic, 200) syntax to create a dynamically scheduled worker pool.

abist

In the first class of the semester when you had students add up numbers, if each student picked up a number from the table when he/she were done, that would be an example of dynamic assignment.

Also, @BryceToTheCore I think the Mandelbrot in Assignment 1 was static and not dynamic.