#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
void Test(int n) {
for(int i = 0; i < 10000; ++i) {
//do nothing, just waste time
}
printf("%d, ", n);
}
int main(int argc,char* argv[]) {
#pragma omp parallel for
for(int i = 0; i < 10; ++i)
Test(i);
}
g++ openmp.cpp -fopenmp
0, 3, 6, 4, 9, 1, 7, 5, 2, 8,
时间: 2024-12-15 00:29:58