Skip to content

Instantly share code, notes, and snippets.

@motonacciu
Created July 27, 2012 20:26
Show Gist options
  • Select an option

  • Save motonacciu/3190322 to your computer and use it in GitHub Desktop.

Select an option

Save motonacciu/3190322 to your computer and use it in GitHub Desktop.
std::vector<double> vec(N);
// loop body as a lambda
auto body = [&](const int& i) { vec[i] = i*(i-1)*4*(i+1); };
assert(vec.size()%UnrollFact == 0 && "Vector size must be divisible by the Unrolling Factor");
auto start = std::chrono::system_clock::now();
for(size_t i = 0, size=vec.size(); i!=size; i+=UnrollFact) {
unroller( body, i, uint_<UnrollFact-1>() );
}
auto end = std::chrono::system_clock::now();
std::cout << "Elapsed time (in msecs): "
<< std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count()
<< std::endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment