我有8个处理器可供使用。 我想进行以下并行调整大小:
vector<vector <int> > test;
test.resize(10000);
#pragma omp parallel num_threads(8)
{
#pragma omp for
for (int i = 0;i < 10000;i++)test[i].resize(500000);
}
我注意到这个程序没有使用100%的处理器性能,而只使用了15%。当我修改代码时,
vector<vector <int> > test;
test.resize(1000000);
#pragma omp parallel num_threads(8)
{
#pragma omp for
for (int i = 0;i < 1000000;i++)test[i].resize(5000);
}
该程序使用了约60%的处理器资源。我不明白这种现象——在两种情况下,我希望它会使用100%的处理器资源。我是否有所遗漏?