#include <iostream>#include <omp.h>#define ARRAY_SIZE 100using namespace std;int main(){ int threadIds[ARRAY_SIZE] = { 0 };#PRagma omp parallel for for(int i = 0; i < ARRAY_SIZE; ++i) { //這里循環(huán)迭代器是一個(gè)私有變量,所有不需要用private子句明顯指明 threadIds[i] = omp_get_thread_num(); } cout << "thread id : /n"; for(auto e : threadIds) { cout << e << " "; } cout << endl; cin.get(); return 0;}二、運(yùn)行結(jié)果
1、當(dāng)ARRAY_SIZE為100時(shí)運(yùn)行效果如下
2、當(dāng)ARRAY_SIZE為1000時(shí)運(yùn)行效果如下
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注