[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/ModuleWorks/taskflow/task_isolation/benchmarks/scan/omp.cpp [Back]  [Original]

#include "scan.hpp"
#include 

template 
void omp_scan(int n, const T* in, T* out, Op op, unsigned nthreads) {
  int i, chunk;
  std::vector last_value_chunk_array(nthreads+1);

  /* Parallel region begins */
  #pragma omp parallel shared(in, out, chunk) private(i) num_threads(nthreads)
  {
    const int num_threads = omp_get_num_threads();          // To get number of threads in machine
    float chunk_in_float = n/(float)num_threads;
    chunk = ceil(chunk_in_float);                           // Defining chunk values
    const int idthread = omp_get_thread_num();              // Get thread ID

    #pragma omp single
    {
      last_value_chunk_array[0] = 0;
    }

    int operation = 0;
    /* For region begins */
    #pragma omp for schedule(static, chunk) nowait
    for(i=0;i

Web Proxy Viewer  |  New URL  |  Original Page