X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FStudent_OMP%2Fsrc%2Fcpp%2Fcore%2Fomp%2F01_hello%2F01_helloOMP.cpp;fp=WCudaMSE%2FStudent_OMP%2Fsrc%2Fcpp%2Fcore%2Fomp%2F01_hello%2F01_helloOMP.cpp;h=b4b2e49c0bded65c584ec7d032ecd29e478480d9;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git diff --git a/WCudaMSE/Student_OMP/src/cpp/core/omp/01_hello/01_helloOMP.cpp b/WCudaMSE/Student_OMP/src/cpp/core/omp/01_hello/01_helloOMP.cpp new file mode 100755 index 0000000..b4b2e49 --- /dev/null +++ b/WCudaMSE/Student_OMP/src/cpp/core/omp/01_hello/01_helloOMP.cpp @@ -0,0 +1,58 @@ +#include +#include +#include "omp.h" +#include "OmpTools.h" + +using std::cout; +using std::endl; + +/*----------------------------------------------------------------------*\ + |* Implementation *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +void helloOMP1(void) + { + cout << endl << "[HelloOMP 1]" << endl; + + // OMP (facultatif) + const int NB_THREADS = OmpTools::setAndGetNaturalGranularity(); + cout << "\n[HELLO] nbThread = " << NB_THREADS << endl; + +#pragma omp parallel + { + int tid = OmpTools::getTid(); + + //cout << "tid=" << tid << endl; // ligne couper + printf("tid=%i\n", tid); //ligne non couper + } + } + +void helloOMP2(void) + { + cout << endl << "[HelloOMP 2]" << endl; + + // OMP (facultatif) + const int NB_THREADS = OmpTools::setAndGetNaturalGranularity(); + cout << "\n[CBI] nbThread = " << NB_THREADS << endl; + + int n = 20; +#pragma omp parallel for + for (int i = 1; i <= n; i++) + { + //cout << "HelloOMP(" << i << ")" << endl; // ligne couper + printf("HelloOMP(%i)\n", i); // ligne non couper + } + } + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/ +