0% found this document useful (0 votes)
4 views1 page

Lab 5. Exercises

The document outlines five tasks for a lab on parallel programming, including counting odd numbers in a range, calculating a histogram from an array of integers, searching for a target string in an array, performing matrix multiplication, and implementing a parallel quicksort algorithm. Each task emphasizes the use of threads for concurrent processing and proper synchronization. The document serves as a guide for implementing these parallel algorithms in C.

Uploaded by

23020787
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Lab 5. Exercises

The document outlines five tasks for a lab on parallel programming, including counting odd numbers in a range, calculating a histogram from an array of integers, searching for a target string in an array, performing matrix multiplication, and implementing a parallel quicksort algorithm. Each task emphasizes the use of threads for concurrent processing and proper synchronization. The document serves as a guide for implementing these parallel algorithms in C.

Uploaded by

23020787
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab 5: Parallel Programming

1. Implement a parallel program that counts how many odd numbers exist in a range
(e.g., 1 to 10 million). Each thread should handle a subrange and maintain a local counter.
The final count is the sum of all thread-local counters.

2. Implement a parallel histogram calculator.


- Given an array of integers (e.g., pixel values from 0-255), each thread counts the
frequency of numbers in its chunk.
- Combine the frequency counts at the end to produce the final histogram.

3. Implement a parallel program to search for a target string in a large array of strings.
Each thread searches a chunk of the array. If one thread finds the string, it reports the
index and stops all other threads. Use a shared flag to synchronize early stopping.

4. Implement a parallel matrix multiplication program using threads. Given two NxN
matrices A and B, write a C program that computes matrix C = A * B in parallel. Each
thread should handle one row of the resulting matrix. Ensure proper synchronization
and memory management.

5. Implement a parallel quicksort algorithm using threads.


- Given an array of integers, recursively partition the array around a pivot.
- Spawn new threads to sort the left and right partitions concurrently.
- For small partitions (<= THRESHOLD), use sequential quicksort.

1 Advanced Programming Techniques (ELT 3296)

You might also like