Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Student_OMP / src / cpp / core / omp / 01_hello / 01_helloOMP.cpp
1 #include <iostream>
2 #include <stdio.h>
3 #include "omp.h"
4 #include "OmpTools.h"
5
6 using std::cout;
7 using std::endl;
8
9 /*----------------------------------------------------------------------*\
10 |* Implementation *|
11 \*---------------------------------------------------------------------*/
12
13 /*--------------------------------------*\
14 |* Public *|
15 \*-------------------------------------*/
16
17 void helloOMP1(void)
18 {
19 cout << endl << "[HelloOMP 1]" << endl;
20
21 // OMP (facultatif)
22 const int NB_THREADS = OmpTools::setAndGetNaturalGranularity();
23 cout << "\n[HELLO] nbThread = " << NB_THREADS << endl;
24
25 #pragma omp parallel
26 {
27 int tid = OmpTools::getTid();
28
29 //cout << "tid=" << tid << endl; // ligne couper
30 printf("tid=%i\n", tid); //ligne non couper
31 }
32 }
33
34 void helloOMP2(void)
35 {
36 cout << endl << "[HelloOMP 2]" << endl;
37
38 // OMP (facultatif)
39 const int NB_THREADS = OmpTools::setAndGetNaturalGranularity();
40 cout << "\n[CBI] nbThread = " << NB_THREADS << endl;
41
42 int n = 20;
43 #pragma omp parallel for
44 for (int i = 1; i <= n; i++)
45 {
46 //cout << "HelloOMP(" << i << ")" << endl; // ligne couper
47 printf("HelloOMP(%i)\n", i); // ligne non couper
48 }
49 }
50
51 /*--------------------------------------*\
52 |* Private *|
53 \*-------------------------------------*/
54
55 /*----------------------------------------------------------------------*\
56 |* End *|
57 \*---------------------------------------------------------------------*/
58