5. Enumeration
Jan 27, 2021
Measuring Efficiency
- for sequential computation time == work
- in parallel computation time
work
Example
P | T | W |
---|---|---|
1 | 100 | 100 |
2 | 50 | 100 |
3 | 40 | 120 |
4 | 30 | 120 |
Whether time or work is better, depends on the criteria.
Summation Tree to Array
Consider binary tree / array representation of A:
Assign
For any non-leaf node
Or use parity: if child == 2 * parent + 1 then left child else right child (knowing this is important in CREW PRAM model)
Processor Enumeration
Find out how many processors are available for use. Iterate bottom to top:
After finding available processors renumber them by looking at left neighbor then increment. Repeat at each tree height. After this pass processors have renumbered themselves.
Processor enumeration, bounds |
---|
This is log-efficient
-
calloc
is C command used to clear and allocate memory (related tomalloc
);- it writes 0 to allocated memory space
- solves the issue when counting 0s and there are inactive processors → clears beofre use
- Recall in PRAM, memory is initialized to 0s
-
If processor enumeration fails (dynamic failures) enumeration ends with an overestimate
- this is not a huge issue; other processors can pick up the work
- overestimate is bad as it leads to redundant work and kills efficiency
- (obviously) aim at exact number when enumerating but if unable to get exact number, overestimate is better than underestimate
- Runtime failures may cause overestimates
Ternary and higher degree trees
Ternary tree has degree 3
- tree height is
In general, for any Q-ary tree:
- tree height is