-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThread_info.cpp
More file actions
26 lines (25 loc) · 813 Bytes
/
Thread_info.cpp
File metadata and controls
26 lines (25 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "stdio.h"
#include <omp.h>
int main(int argc, char *argv[])
{
#pragma omp parallel
{
int NCPU,tid,NPR,NTHR;
/* get the total number of CPUs/cores available for OpenMP */
NCPU = omp_get_num_procs();
/* get the current thread ID in the parallel region */
tid = omp_get_thread_num();
/* get the total number of threads available in this parallel region */
NPR = omp_get_num_threads();
/* get the total number of threads requested */
NTHR = omp_get_max_threads();
/* only execute this on the master thread! */
if (tid == 0) {
printf("%i : NCPU\t= %i\n",tid,NCPU);
printf("%i : NTHR\t= %i\n",tid,NTHR);
printf("%i : NPR\t= %i\n",tid,NPR);
}
printf("%i : hello multicore user! I am thread %i out of %i\n",tid,tid,NPR);
}
return(0);
}