Created
July 27, 2012 20:26
-
-
Save motonacciu/3190322 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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