#ifndef COMMON_CPU #define COMMON_CPU #if defined(_OPENMP) #include #endif template void iterate_cpu(FunctorT functor, int N) { for(int idx = 0; idx < N; ++idx) { functor(idx); } } template void iterate_omp_cpu(FunctorT functor, int N, int n_threads) { #if defined(_OPENMP) omp_set_num_threads(n_threads); #pragma omp parallel for #endif for(int idx = 0; idx < N; ++idx) { functor(idx); } } #endif