Task 5, 5* some fixes and cleanup
This commit is contained in:
parent
64c7aed176
commit
c8bf307391
154 changed files with 214851 additions and 93 deletions
Binary file not shown.
|
|
@ -10,7 +10,7 @@
|
|||
#include <cmath>
|
||||
using namespace std;
|
||||
|
||||
void benchmark(vector<double> &x, vector<double> &y, unsigned int N, unsigned int NLOOPS)
|
||||
void benchmark(vector<double> &x, vector<double> &y, unsigned int NLOOPS)
|
||||
{
|
||||
double sk = 0.0;
|
||||
for (int i = 0; i < NLOOPS; ++i)
|
||||
|
|
@ -92,8 +92,7 @@ int main(int argc, char const *argv[])
|
|||
for (int i = 0; i < NLOOPS; ++i)
|
||||
{
|
||||
sk = scalar(x, y);
|
||||
sk = scalar_trans(x, y);
|
||||
//sk = norm(x);
|
||||
sk = norm(x);
|
||||
}
|
||||
|
||||
double t1 = omp_get_wtime() - tstart; // OpenMP
|
||||
|
|
@ -124,7 +123,7 @@ int main(int argc, char const *argv[])
|
|||
cout << "done\n";
|
||||
cout << vr << endl;
|
||||
|
||||
N=2;
|
||||
N=200;
|
||||
//Data (re-)inizialiion
|
||||
for (unsigned int i = 0; i < N; ++i)
|
||||
{
|
||||
|
|
@ -147,9 +146,9 @@ int main(int argc, char const *argv[])
|
|||
|
||||
omp_set_schedule(omp_sched_static, 0);
|
||||
tstart = omp_get_wtime();
|
||||
benchmark(x, y, N, NLOOPS);
|
||||
t1 = omp_get_wtime()/NLOOPS;
|
||||
cout << "static (chunk 0) "<< (t1-tstart) << endl;
|
||||
benchmark(x, y, NLOOPS);
|
||||
t1 = (omp_get_wtime()-tstart)/NLOOPS;
|
||||
cout << "static (chunk 0) "<< t1 << endl;
|
||||
for(int i=0; i<= 5; i++)
|
||||
{
|
||||
|
||||
|
|
@ -159,30 +158,30 @@ int main(int argc, char const *argv[])
|
|||
// STATIC
|
||||
omp_set_schedule(omp_sched_static, chunk);
|
||||
tstart = omp_get_wtime();
|
||||
benchmark(x, y, N, NLOOPS);
|
||||
t1 = omp_get_wtime()/NLOOPS;
|
||||
std::cout << "static: " << (t1 - tstart) << " s\n";
|
||||
benchmark(x, y, NLOOPS);
|
||||
t1 = (omp_get_wtime()-tstart)/NLOOPS;
|
||||
std::cout << "static: "<< t1 << " s\n";
|
||||
|
||||
// DYNAMIC
|
||||
omp_set_schedule(omp_sched_dynamic, chunk);
|
||||
tstart = omp_get_wtime();
|
||||
benchmark(x, y, N, NLOOPS);
|
||||
t1 = omp_get_wtime()/NLOOPS;
|
||||
std::cout << "dynamic: " << (t1 - tstart) << " s\n";
|
||||
benchmark(x, y, NLOOPS);
|
||||
t1 = (omp_get_wtime()-tstart)/NLOOPS;
|
||||
std::cout << "dynamic: "<< t1 << " s\n";
|
||||
|
||||
// GUIDED
|
||||
omp_set_schedule(omp_sched_guided, chunk);
|
||||
tstart = omp_get_wtime();
|
||||
benchmark(x, y, N, NLOOPS);
|
||||
t1 = omp_get_wtime()/NLOOPS;
|
||||
std::cout << "guided: " << (t1 - tstart) << " s\n";
|
||||
benchmark(x, y, NLOOPS);
|
||||
t1 = (omp_get_wtime()-tstart)/NLOOPS;
|
||||
std::cout << "guided: "<< t1 << " s\n";
|
||||
|
||||
// AUTO
|
||||
omp_set_schedule(omp_sched_auto, chunk);
|
||||
tstart = omp_get_wtime();
|
||||
benchmark(x, y, N, NLOOPS);
|
||||
t1 = omp_get_wtime()/NLOOPS;
|
||||
std::cout << "auto: " << (t1 - tstart) << " s\n";
|
||||
benchmark(x, y, NLOOPS);
|
||||
t1 = (omp_get_wtime()-tstart)/NLOOPS;
|
||||
std::cout << "auto: "<< t1 << " s\n";
|
||||
cout << endl;
|
||||
}
|
||||
cout << endl;
|
||||
|
|
@ -194,7 +193,9 @@ int main(int argc, char const *argv[])
|
|||
|
||||
|
||||
vector<int> vec = reduction_vec_append(N);
|
||||
for(int i=0; i< N; i++)
|
||||
unsigned int n = vec.size();
|
||||
cout << "vec.size() = " << n << "\n";
|
||||
for(int i=0; i< n; i++)
|
||||
{
|
||||
cout << vec[i] << ", ";
|
||||
}
|
||||
|
|
|
|||
BIN
sheet5/1/main.o
BIN
sheet5/1/main.o
Binary file not shown.
|
|
@ -91,7 +91,7 @@ vector<int> reduction_vec(int n)
|
|||
|
||||
vector<int> reduction_vec_append(int n)
|
||||
{
|
||||
vector<int> vec(n);
|
||||
vector<int> vec;
|
||||
#pragma omp parallel default(none) shared(cout,n) reduction(VecAppend:vec)
|
||||
{
|
||||
int tid = omp_get_thread_num();
|
||||
|
|
@ -99,10 +99,7 @@ vector<int> reduction_vec_append(int n)
|
|||
vector<int> local(n);
|
||||
iota(local.begin(), local.end(), tid);
|
||||
|
||||
#pragma omp critical
|
||||
cout << tid << " : " << local.size() << endl;
|
||||
|
||||
vec = local;
|
||||
vec = local;
|
||||
}
|
||||
|
||||
return vec;
|
||||
|
|
|
|||
BIN
sheet5/1/mylib.o
BIN
sheet5/1/mylib.o
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue