Home CPSC 425

Lab 5: OpenMP

 

Objective

To get experience parallelizing programs with OpenMP.


 

Task

For this lab, you will parallelize a sequential program for finding the prime factorization of a number, factor.c

This program will need to be compiled with the "-lm" option because it uses the math functions ceil and sqrt.

You should insert OpenMP directives such that the behavior of the program is the same, but performance is improved. You should be able to get the large test case (6569152) to complete in less than one second when you're done.

If the prime factors are printed in a different order, that is OK. The set of prime factors must be the same, however!

Below is an example run of the serial program:

$ ./factor 2311260
2
2
3
5
7
5503

$ ./factor 6569152
2
2
2
2
2
2
102643

Note that there are much more optimal serial algorithms for this task, but you only need to parallelize the existing solution.


 

Analysis

After completing the parallelized version, test your program with the following parameters:

ThreadsValueTime
12311260 
82311260 
16569152 
86569152 

 

Submitting

When you're finished, submit both the source code and the analysis (in a text document or comment) to Canvas.

Copyright © 2024 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.