Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

span and parallel loop

I have problems understanding dynamic multithreading. I have this following algorithm:

Page 16, MAT-VEC http://mitpress.mit.edu/books/chapters/0262033844chap27.pdf

And in the text they say that "for MAT-VEC on an nxn matrix, the parallel initialization loop in lines 3–4 has span theta(lg n)"

And my question is why? I'm confused. So if somebody could explain what they mean, it will be a big help.

like image 285
Guest Avatar asked May 07 '11 01:05

Guest


People also ask

What is a parallel loop?

Parallel loops are one of the most widely used concepts to express parallelism in parallel languages and libraries. In general, a parallel loop is a loop whose iterations are executed at least partially concurrently by several threads or processes.

What is work and span?

the work is the total number of nodes in the graph, and the span is the number of nodes along the. longest path in the dag.1. Another way of thinking about it is: work is the running time of the program on one core, while span is the running time of the program on an infinite number of cores.


1 Answers

First of all, the definition of "span", for those who don't know it, is the length of the critical path. If you had an infinite number of CPUs, the span defines the minimum amount of time it could take to finish the algorithm.

In order to run a loop which has N iterations, the shortest way to do it is to spawn threads until you have N of them, then have each of the N threads perform one unit of work. Here's how it would work to spawn 8 threads:

time 0: thread0 spawns thread1
time 1: thread0 spawns thread2, thread1 spawns thread3
time 2: thread0 spawns thread4, thread1 spawns thread5, thread2 spawns thread6, thread3 spawns thread7
time 3: all 8 threads perform their task

This took 3 units of time with everything running in parallel to create 8 threads. Since lg(8) = 3, the algorithm's span is Θ(lg n).

like image 81
Gabe Avatar answered Nov 15 '22 23:11

Gabe