34 lines
719 B
C++
34 lines
719 B
C++
#include <algorithm>
|
|
#include <iostream>
|
|
#include <iterator>
|
|
|
|
#include <pfor/pfor.h>
|
|
#include <pfor/traits.h>
|
|
|
|
constexpr long n = 10;
|
|
|
|
#define OPERAND(T, ID) \
|
|
T ID##_; \
|
|
auto ID = pfor::Operand<T, class TID##ID>{ID##_}
|
|
|
|
template<typename T, std::size_t n>
|
|
void printArray(std::array<T, n> const& array) {
|
|
std::copy(std::begin(array), std::end(array), std::ostream_iterator<T>(std::cout, " "));
|
|
std::cout << std::endl;
|
|
}
|
|
|
|
int main() {
|
|
using Type = std::array<int, n>;
|
|
OPERAND(Type, a);
|
|
|
|
std::generate_n(std::begin(a_), n, [i=1]() mutable { return i++; });
|
|
|
|
pfor::Index i;
|
|
|
|
pfor::parallelFor<pfor::ForLoopUnrolling<4>::template Template>(pfor::Range{0, n},
|
|
a[i] = 3*a[i]
|
|
);
|
|
|
|
printArray(a_);
|
|
}
|