Skip to main content

Chapter 4 long

Introduction to Parallel Algorithm Models.

Parallel algorithm models provide strategies for dividing a computational problem into smaller parts that can be processed simultaneously by multiple processors. The main goals are to speed up computation and handle larger problems. These models differ in how they divide the work (tasks or data) and manage the interaction between processors.

Individual Model Descriptions

1. Data Parallel Model

Core Concept: Performing the same operation on different pieces of data at the same time.

How it Works: The main data set is divided into chunks. Multiple processors execute the exact same instruction or sequence of instructions, but each processor works on its own chunk of data. Think: "Single Instruction, Multiple Data" (SIMD).

Key Characteristics:

Focuses on distributing the data across processors.

All processors typically run the same program/task.

Good for problems with large amounts of data that need similar processing (e.g., image processing, matrix operations).

Can be implemented using shared memory (single address space) or message passing.

Parallelism increases as the data size increases.

Overhead (like communication) can sometimes be hidden by overlapping it with computation.

Analogy: A teacher tells all students in a class to perform the same calculation (e.g., "add 5") but gives each student a different starting number.

2. Task Graph Model.

Core Concept: Representing a problem as a set of tasks with dependencies between them.

How it Works: The problem is broken down into smaller tasks. A graph shows which tasks must be completed before others can start (dependencies). Tasks that don't depend on each other can run in parallel.

Key Characteristics:

Focuses on the dependencies between different tasks.

Tasks are often mapped statically to processors to minimize communication based on the graph structure.

Good for problems where different tasks perform different computations.

A task only starts execution after its first tasks in the graph are finished.

Analogy: Following a recipe. You can chop vegetables (Task A) and preheat the oven (Task B) at the same time, but you must finish both before you can put the dish in the oven (Task C, which depends on A and B).

3. Work Pool Model (Task Pool)

Core Concept: Keeping a central pool of tasks that available processors can grab and execute.

How it Works: Tasks are placed into a shared pool (like a list or queue). Whenever a processor becomes idle, it takes a task from the pool and executes it. This continues until all tasks are done.


Key Characteristics:

Focuses on dynamic load balancing – keeps all processors busy as long as there are tasks.


Tasks are not pre-assigned to specific processors.


Good when tasks have unpredictable execution times 

Suitable when operations/tasks are large, but the data associated with each task might be small.


The pool can be managed centrally or decentrally.  


Analogy: A taxi stand (pool) where drivers (processors) pick up the next waiting passenger (task) when they become free.

4. Master-Slave Model (Master-Worker)

Core Concept: One main process (master) distributes tasks to several worker processes (slaves) and may collect results.


How it Works: The master breaks down the problem and assigns specific tasks to each slave. Slaves perform their assigned tasks and might send results back to the master.


Key Characteristics:

Centralized control resides with the master.


Tasks are often assigned before slaves start working, especially if the master can estimate the work involved.


Suitable for shared memory systems but can use message passing.


Slaves are typically assigned smaller, well-defined tasks.


Caution: The master can become a bottleneck if it can't assign tasks fast enough or if tasks are too small compared to communication time. Ensure task computation time dominates communication time.


Analogy: A construction site manager (master) assigning specific jobs (digging, bricklaying) to different workers (slaves).

5. Pipeline Model / Producer-Consumer Model

Core Concept: Data flows through a sequence of processing stages, with each stage handled by a different process or set of processes.


How it Works: A stream of data items goes through a series of transformations. Process 1 performs the first step, passes the result to Process 2 for the second step, and so on. Multiple data items can be in different stages of the pipeline simultaneously. The "Producer" creates data/tasks, puts them in a queue, and "Consumers" take them from the queue to process.


Key Characteristics:

Focuses on overlapping the processing of multiple data items in different stages.


Data flows sequentially through processes.


New data generates new tasks that enter the queue/pipeline.


Good for streaming data or problems where processing involves a fixed sequence of steps.


Can be implemented using queues (arrays, lists, etc.).


Analogy: An assembly line in a factory. Each station (process) performs one step on the product (data) before passing it to the next station. Multiple products are being worked on simultaneously at different stations.

6. Hybrid Model

Core Concept: Combining two or more different parallel models to solve a single problem.


How it Works: Different models might be used for different parts of the computation or at different levels. For example, a Master-Slave model could be used, where each slave then uses the Data Parallel model to perform its assigned task. Or, different phases of an algorithm might use different models sequentially.


Key Characteristics:

Used when a single model isn't sufficient or optimal for the entire problem.


Allows leveraging the strengths of multiple approaches.


Can be applied hierarchically (models within models) or sequentially (different models for different phases).


Analogy: Building a complex machine might involve an assembly line (Pipeline) for some parts, while other custom components are built individually by specialized teams (Master-Slave or Task Graph).

Comments

Popular posts from this blog

Chap#10

Network topologies Definition: Network topologies define how nodes (processors/computers) are interconnected in parallel and distributed systems. The choice of topology affects performance, scalability, and cost. Key Metrics: Degree: Number of links per node. (Formula: deg = connections per node) Example: In a linear array, each node (except ends) has 2 links. Diameter: Longest shortest path between any two nodes. (Formula: diam = max distance) Example: Linear array with 8 nodes has diameter 7 (P₀ to P₇). Bisection Width: Minimum links to cut to split the network into two halves. (Formula: bw = min cuts) Example: Binary tree has bw=1 (cutting the root disconnects it).4 1. Linear Array Define : Nodes are connected one after another in a straight line. Each node (except the ends) connects to two neighbors one on the left and one on the right. Explanation : Simple to build and easy to understand, but not efficient for large networks. Long distance between farthest nodes makes comm...
Asymmetric-key algorithms are algorithms used in cryptography that use two different keys  a public key for encryption and a private key for decryption. These keys are mathematically related, but the private key cannot be easily derived from the public key. Types: RSA (Rivest–Shamir–Adleman): It uses large prime numbers to generate the key pair and supports both encryption and digital signatures DSA (Digital Signature Algorithm): DSA is primarily used for creating digital signatures, ensuring the authenticity. Symmetric-key algorithms are algorithms for cryptography that use the same cryptographic keys for both encryption of plaintext and decryption of ciphertext  Types: Stream Cipher:  Stream Cipher Converts the plain text into cipher text by taking 1 byte of plain text at a time. Block cipher: Converts the plain text into cipher text by taking plain text's block at a time DES? DES stands for Data Encryption Standard . It is a symmetric-key algorithm used to enc...

Ai Mental Health & Cyber Safety Presentation

Module A - The Normalization Engine Linguistic Challenge: Roman Urdu lacks standardized orthography (e.g., "kesa" vs "kaisa"), creating orthographic "noise" that significantly degrades the accuracy of downstream AI models. Technical Role: Acts as a Sequence-to-Sequence (Seq2Seq) transliteration and lexical normalization layer to standardize inputs before analysis. Model: A specialized transformer architecture, specifically m2m100 fine-tuned on parallel corpora or UrduParaphraseBERT. Primary Dataset: Roman-Urdu-Parl (RUP). A large-scale parallel corpus of 6.37 million sentence pairs designed to support machine transliteration and word embedding training. Link: https://arxiv.org/abs/2503.21530 Outcome: Reduces orthographic noise by achieving up to 97.44% Char-BLEU accuracy for Roman-Urdu to Urdu conversion, ensuring Module B receives high-quality "clean" data for risk analysis. Module B - Risk Stratification (BERT) Heading: The "Safety ...