chundoong-lab-ta/SamsungDS22/openmp-example/main.cpp

18 lines
315 B
C++
Raw Normal View History

2022-09-29 18:01:45 +09:00
#include <cstdio>
#include <omp.h>
void myfunc(int i) {
#pragma omp parallel for
for (int j = 0; j < 4; j++) {
int tid = omp_get_thread_num();
printf("tid=%d executing (i,j)=(%d,%d)\n", tid, i, j);
}
}
int main () {
#pragma omp parallel for num_threads(4)
for (int i = 0; i < 4; i++) {
myfunc(i);
}
}