Here is the test code:
#include <iostream>
#include <vector>
#include <ppl.h>
using namespace std;
int main() {
const size_t n = 1000000;
vector<bool> processed(n, false);
concurrency::parallel_for<size_t>(0, processed.size(), [&](size_t i) {
processed[i] = true;
});
for (size_t i = 0; i < processed.size(); ++i) {
if (!processed[i]) {
cerr << "i = " << i << endl;
}
}
return 0;
}
Compiling in VS2015 Version 14.0.25431.01 Update 3, I get output of some indices sometimes. Do not see it in Debug mode, only in Release, both for Win32 and x64. It is different indices every time I run it so it looks like parallel_for does not process some of the parallel loop iterations. Can anyone see what I'm doing wrong here?