Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 - First, I want to know the validity of this information: If the number of threads increases, the speedup increases. 2 - If this

1- First, I want to know the validity of this information: If the number of threads increases, the speedup increases.
2- If this information is correct, my code should work correctly when I increase the number of threads in the terminal. I was trying to increase the number of n, but it did not work.
(what is the problem anParallel Execution Time: 1.39998e-06 seconds
Serial Execution Time: 1.10001e-06 seconds
Speedup: 0.785731
Efficiency: 0.785731
810,1516,20,100,199,500
PS C:\Users\thekr\Desktop\Parallel_computing_project\x64\Debug>./Parallel_computing_project 2
Parallel Execution Time: 1.99999e-06 seconds
Serial Execution Time: 1.50001e-06 seconds
Speedup: 0.750011
Efficiency: 0.375005
810151620100199500
PS C:\Users\thekr\Desktop\Parallel_computing_project\x64\Debug>./Parallel_computing_project 3
Parallel Execution Time: 1.89999e-06 seconds
Serial Execution Time: 1.40001e-06 seconds
Speedup: 0.736853
Efficiency: 0.245618
810,151620100199500
PS C:\Users\thekr\Desktop\Parallel_computing_project\x64\Debug>./Parallel_computing_project 4
Parallel Execution Time: 1.80001e-06 seconds
Serial Execution Time: 1.50001e-06 seconds
Speedup: 0.833333
Efficiency: 0.208333
810151620100199500
PS C:\Users\thekr\Desktop\Parallel_computing_project\x64\Debug>./Parallel_computing_project 16
Parallel Execution Time: 3.09999e-06 seconds
Serial Execution Time: 2.29999e-06 seconds
Speedup: 0.741933
Efficiency: 0.0463708
8,10,15,16,20,100,199,500
PS C:\Users\thekr\Desktop\Parallel_computing_project\x64\Debug>|d how can I correct it? Can you provide me with the code after modification?)
#include
#include
#include
#include
#include
using namespace std;
void Parallel_sort(vector& X, double& parallel_execution_time)
{
unsigned int i, j, count, N = X.size();
vector tmp(N);
double start_time = omp_get_wtime();
#pragma omp parallel for private(i, j, count) shared(X, tmp)
for (i =0; i N; i++)
{
count =0;
for (j =0; j N; j++)
if (X[j] X[i]||(X[j]== X[i] && j i))
count++;
tmp[count]= X[i];
}
double end_time = omp_get_wtime();
parallel_execution_time = end_time - start_time;
copy(tmp.begin(), tmp.end(), X.begin());
}
void Serial_sort(vector& X, double& serial_execution_time)
{
double start_time = omp_get_wtime();
sort(X.begin(), X.end());
double end_time = omp_get_wtime();
serial_execution_time = end_time - start_time;
}
int main(int argc, char* argv[])
{
//if (argc !=2){
//cout "Usage: " argv[0]"" endl;
//return 1;
//}
int num_threads = atoi(argv[1]);
omp_set_num_threads(num_threads);
vector num ={5,2,8,1,8};
double parallel_execution_time =0.0;
Parallel_sort(num, parallel_execution_time);
double serial_execution_time =0.0;
Serial_sort(num, serial_execution_time);
cout "Parallel Execution Time: " parallel_execution_time " seconds" endl;
cout "Serial Execution Time: " serial_execution_time " seconds" endl;
double speedup = serial_execution_time / parallel_execution_time;
cout "Speedup: " speedup endl;
double efficiency = speedup / num_threads;
cout "Efficiency: " efficiency endl;
for (const auto& n : num){
cout n "";
}
cout endl;
return 0;
}
image text in transcribed

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

Define strategy.

Answered: 1 week ago

Question

What factors affect occupational accidents?

Answered: 1 week ago