#include "omp.h" #include #include using namespace std; template class OmpMap { private: OutTask (*fun) (InTask t); int nw; public: OmpMap(OutTask (*fun) (InTask t), int nw):fun(fun),nw(nw) {} // map over std:vector std::vector compute(std::vector v) { int i, n = v.size(); vector * r = new vector(n); #pragma omp parallel for num_threads(nw) private(i) for(i=0; i &v) { int i, n = v.size(); #pragma omp parallel for num_threads(nw) private(i) for(i=0; i " << __omp_t1_s321 - __omp_t0_s321 << " msecs" << std::endl;} template class OmpStencil_1d { private: std::vector stencil; OutTask (*fun)(std::vector v); int nw; OutTask computeStencil(std::vector v, int i) { std::vector thisStencil(stencil.size() + 1); for(int j=0; j=v.size()) { // std::cout << "k " << k << " v.size() " << v.size() ; k = (k) - v.size(); // std::cout << " k' = " << k << std::endl; } thisStencil[j] = v[k]; } thisStencil[stencil.size()] = v[i]; std::cout << "==::> " ; for(int s=0; s v), std::vector stencil, int nw) :fun(fun), stencil(stencil), nw(nw) {} std::vector * compute(std::vector v) { std::vector * res = new std::vector(v.size()); #pragma omp parallel for num_threads(nw) for(int i=0; i