我正在尝试在C ++ 11中并行化动态编程算法 使用这种方法:
void buildBaseCases() {
cout << "Building base cases" << endl;
for (unsigned int i = 0; i < BOARD_SIZE; ++i)
{
buildBaseCase(i);
}
cout << "Done building base cases" << endl;
}
所以,我的并行化版本将是:
void buildBaseCases() {
cout << "Building base cases" << endl;
#pragma omp parallel
{
#pragma omp for
for (unsigned int i = 0; i < BOARD_SIZE; ++i)
{
buildBaseCase(i);
}
}
cout << "Done building base cases" << endl;
}
然而,这导致valgrind抱怨内存泄漏。 我是否误解了你应该使用openMP的方式,还是有什么可疑的东西?