Skip to content

Instantly share code, notes, and snippets.

@RiccardoRossi
Created April 28, 2017 15:33
Show Gist options
  • Save RiccardoRossi/66bee0e774b24656fa647a2e360f704a to your computer and use it in GitHub Desktop.
Save RiccardoRossi/66bee0e774b24656fa647a2e360f704a to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <numeric>
int main() {
constexpr int size = 1024*1024;
std::vector<double> x;
x.reserve(size);
#pragma omp parallel for
for(int i = 0; i<size; ++i)
x[i] = 0.0;
x.resize(size);
double sum = 0.0;
for(int i = 0; i<size; ++i)
sum += x[i];
if(sum > 1.0)
std::cout << sum << std::endl;
else
std::cout << "sum is zero!!!!!" << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment