LDLIBS = -fopenmp
near the top.
#include <omp.h>
#pragma omp parallel
int main() { vector<vector<PixelT>> image(XDIM,vector<PixelT>(YDIM)); #pragma omp parallel { for(int i = 0; i < XDIM; ++i) { ... } // end of for i loop } // parallel block
#pragma omp parallel for
#pragma omp parallel for for(int i = 0; i < #pragma omp parallel for for(int i = 0; i < image.size(); ++i) { image.size(); ++i) { ...
time finalProduct
Total time: 0.85 sec Loop time: 0.08 sec Write time: 0.77 sec
-w n
, set the width to be n, n ≥ 100
-h n
, set the height to be n, n ≥ 100
-t n
, set the number of threads to be n, n ≥ 1
-x
, do not write the file
-v
, be verbose
[bennett@mirkwood lab2]> finalProduct -v -w 1000 -h 1000 Creating a 1000 x 1000 image. Using 1 threads. Writing the output file to foo Total time: 2.09 sec Loop time: 0.20 sec Write time: 1.89 sec [bennett@mirkwood lab2]> finalProduct [bennett@mirkwood lab2]>
int omp_get_num_threads();
int id = omp_get_thread_num()+1; for() for() for() //image[i][j].color[k] = rand()%255; image[i][j].color[k] = 255/id; } } }
rand_r(unsigned int & seed)
is.