7-Tree Sum Parallel Algorithm & Applications
7-Tree Sum Parallel Algorithm & Applications
2
WHAT IS PARALLEL ALGORITHM ?
3
TREE SUM PARALLEL ALGORITHM
• A "tree sum parallel algorithm"
utilizes the concept of a parallel
"reduce" operation on a tree structure
to efficiently calculate the sum of all
node values in a tree by dividing the
computation across multiple
processors, typically by traversing the
tree in a bottom-up manner where
each node accumulates the sum of its
children's values, eventually reaching
the root with the total sum.
4
TREE SUM PARALLEL ALGORITHM
5
KEY POINTS ABOUT TREE SUM PARALLEL ALGORITHM:
• Data structure:
• The input tree is usually represented as a binary tree for simplicity, but the concept can
be applied to any tree structure.
• Parallel paradigm:
• The algorithm employs a divide-and-conquer strategy, where each processor calculates
the sum of its subtree and then aggregates the results upwards towards the root.
• Up-sweep phase:
• This is the primary computation phase where nodes recursively calculate their partial
sums by adding the sums of their children.
• Down-sweep phase (optional):
• In some implementations, a down-sweep phase may be used to propagate the
calculated sum from the root back down to the leaves if necessary.
6
KEY POINTS ABOUT TREE SUM PARALLEL ALGORITHM:
8
APPLICATIONS OF TREE SUM PARALLEL
• Data Aggregation:
ALGORITHMS:
• Used in hierarchical data structures like file systems or
organizational charts.
• E.g., summing the sizes of files in a directory tree.
• Scientific Computing:
• Frequently used in physics simulations, where spatial data is
represented as octrees or quadtrees.
• Machine Learning:
• Efficient processing of decision trees, random forests, or gradient-
boosted trees.
9
APPLICATIONS OF TREE SUM PARALLEL
ALGORITHMS:
• Graphics and Rendering:
• In computer graphics, spatial partitioning trees (e.g., BSP trees,
quadtrees) are used to compute metrics like total illumination or
scene complexity.
• Database Query Optimization:
• When databases use hierarchical data structures like B-trees,
parallel algorithms speed up aggregation queries.
• Network Analysis:
• Summing up values in network hierarchies (e.g., summing traffic
or latency across routers).
10
ALGORITHM
• Tree OVERVIEW
Representation:
• The tree can be a binary tree, general tree, or a
specific variant.
• Each node in the tree contains a value (e.g., an
integer).
• Parallel Strategy:
• The sum is computed recursively, where the work for
each subtree is distributed among parallel processors.
• Processors compute the sum for subtrees
independently and combine the results at their parent
nodes.
11
ALGORITHM OVERVIEW
• Steps:
• Divide: Partition the tree into smaller subtrees at each
level.
• Compute in Parallel: Each processor computes the
sum of its assigned subtree.
• Combine: Combine the results from child nodes into the
parent node in parallel.
• Base Case:
• For a leaf node, the sum is simply the value of the node.
12
PERFORMANCE
• The time complexity of a parallel tree sum algorithm
depends on the tree structure and the number of
processors.
• Assuming an ideal scenario (perfect load balancing and
no overhead), the time complexity is proportional to
the height of the tree: O(logn), where n is the
number of nodes in a balanced binary tree.
• The space complexity includes the overhead of
managing parallel threads and the recursive stack.
13
PREFIX SUM ARRAY – IMPLEMENTATION AND
APPLICATIONS IN COMPETITIVE PROGRAMMING
• Given an array arr[] of size N, find the prefix sum of the array. A prefix sum
array is another array prefixSum[] of the same size, such that the value
of prefixSum[i] is arr[0] + arr[1] + arr[2] . . . arr[i].
14
PARALLEL ALGORITHM MODELS
15
TYPES OF PARALLEL MODELS
16
TYPES OF PARALLEL MODELS
• The Task Graph Model
• The task dependency graph is being used by the parallel algorithms for
describing the computations it performs. Therefore, the use of
interrelationships among the tasks in the task dependency graph can be
used for reducing the interaction costs.
• This model can be used effectively for solving problems in which tasks are
associated with a large amount of data as compared to that actual
computation.
• The parallelism that is described with the task dependency graph where
each task is an independent task is known as task parallelism.
17
Dense Matrix Finding the minimum
Multiplication number
18
TYPES OF PARALLEL MODELS
• Work Pool Model
• The work pool model is also
known as the task pool model.
This model makes use of a
dynamic mapping approach for
task assignment in order to
handle load balancing. The size
of some processes or tasks is
small and requires less time.
19
TYPES OF PARALLEL MODELS
• Master-Slave Model
• Master Slave Model is also known as
Manager- worker model. The work is
being divided among the process. In
this model, there are two different
types of processes namely master
process and slave process. One or
more process acts as a master and
the remaining all other process acts
as a slave.
20
TYPES OF PARALLEL MODELS
• The Pipeline Model
• The Pipeline Model is also known as the Producer-Consumer
model. This model is based on the passing of a data stream
through the processes that are arranged in succession.
• Hybrid Model
• A hybrid model is the combination of more than one parallel
model. This combination can be applied sequentially or
hierarchically to the different phases of the parallel algorithm.
21
Parallel LU factorization A combination of master-
algorithm slave, work pool, and data
graph model.
22
THANK YOU
23