在用了 #pragma omp parallel for ,设置num_threads 为2后,
程序的线程数不断增加, 内存数也不断增加,
为什么会有这种情况呢?
- C/C++ code
#pragma omp parallel for shared(elementIndexToBoundsSet, elementIndexToSizeSet, bufferPtr) private(currentCoord) firstprivate(elementIndex, threadId) num_threads(numOfThreads) for (int i = 0; i < bufferSize; i++) { // Get element index elementIndex = bufferPtr[i]; // In case no element - continue if (elementIndex == 0) continue; // One time read of the threadId if (threadId == -1) threadId = omp_get_thread_num(); // Update element size elementIndexToSizeSet->at(threadId)->at(elementIndex)++; }
------解决方案--------------------
我也想知道