Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Parallel computing, please I want the code in C or C++. Make sure that you have done all the mentioned requirements and please take screenshot

Parallel computing, please I want the code in C or C++. Make sure that you have done all the mentioned requirements and please take screenshot of the output to know and if everything is done correctly I give a thumb up
image text in transcribed
image text in transcribed
1 Description A versatile scholar, Eratosthenes of Cyrene (today Libya) lived approximately 275-195 BC. He was the first to estimate accurately the diameter of the earth. For several decades, he served as the director of the famous library in Alexandria. He was highly regarded in the ancient world, but unfortunately only fragments of his writing have survived. Eratosthenes died at an advanced age from voluntary starvation, induced by despair at his blindness. Eratosthenes also conceived the "Sieve of Eratosthenes", a method for identifying prime numbers. Therefore, in a first step the set of natural numbers P={2,,N} from 2 to an upper limit N (in arbitrary ordering) is formed. Then, after searching for the minimum element p of set P - the first prime number - all multiples of p are deleted from P. Successively repeating this step until p>N there are only prime numbers left. Example: N=15, i.e. termination for p=3(=15) 1. step: 2,3,4,5,6,7,8,9,10,11,12,13,14,15p=2 delete multiples: z,3,4,5,6,7,8,9,10,11,12,13,14,15 2. step: 3,5,7,9,11,13,15p=3 delete multiples: 3,5,7,9,11,13,15 termination (only prime numbers left), i.e. PRIME={2,3,5,7,11,13} 2 Implementation 1. Implement a program sieve in C or C++ following the algorithm described above. Think about sufficient data structures for storing the elements in order not to process any element more than once that has already been discarded from the set. Run your program for different values of N, i.e. 1,000,000, 5,000,000,10,000,000,25,000,000, and 50,000,000 if your computer permit. What do you observe? For control, always print the largest prime number found! 2. For a faster processing, parallelisation is inevitable. In a first (and simple) approach, scan your code for 'prominent' blocks of instructions that would benefit from multithreading. Extend these blocks of instructions with valid OpenMP directives in order University of Jeddah, KSA College of Computer Science and Engibeering to allow a parallel processing. Run your code for different values of N (see above) and different amount of threads ( 2,3 , and 4). What do you observe now? For control, always print the largest prime number found! 3. For further parallelization, message passing is the name of the game. Think about a sufficient parallelization strategy and what code changes have to be made. Extend your program sieve from (1.) - not the OpenMP version! - with the necessary parallel functionality using MPI. Try to think and use the collective communication commands. Run your program for different values of N, i.e. 1,000,000,5,000,000,10,000,000, 25,000,000, and 50,000,000 if your computer permit, and different amount of processes (i.e. 2,4, and 8). What do you observe now? For control, always print the largest prime number found! 3 Benchmark Sketch your results (i.e. execution times) of your OpenMP/MPI program for different N and different amount of processes in two diagrams showing speed-up or parallel efficiency. You can use any plotting tool (Excel, Python, etc.) of your choice. In order to 'benchmark' your results, also make a theoretical approach to compute speed-up and efficiency according to Amdahl. Therefore, estimate the serial part of your program and compute the corresponding speed-up and efficiency values. Compare those with the ones measured and discuss your observation! Please refer to Chapter 3 in introduction to parallel programming textbook: section 3.6.3 and 3.6.4 when you writing up the analysis part of your report

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions