chore: init
This commit is contained in:
51
Student_OMP/src/core/mainCore.cpp
Executable file
51
Student_OMP/src/core/mainCore.cpp
Executable file
@@ -0,0 +1,51 @@
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include "ChronoFactory.h"
|
||||
|
||||
using std::cerr;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Imported *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
extern bool usePI();
|
||||
extern bool useHello();
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
int mainCore()
|
||||
{
|
||||
Chrono* ptrChrono = ChronoFactory::create();
|
||||
|
||||
bool isOk = true;
|
||||
isOk &= useHello();
|
||||
isOk &= usePI();
|
||||
|
||||
ptrChrono->stop();
|
||||
|
||||
cout << endl << endl;
|
||||
cout << "mainCore :" << *ptrChrono << endl;
|
||||
cout << "mainCore : ";
|
||||
if (isOk)
|
||||
{
|
||||
cout << "SUCCESS, Congratulation!";
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "FAILED, sorry!";
|
||||
}
|
||||
cout << endl << endl;
|
||||
|
||||
delete ptrChrono;
|
||||
|
||||
return isOk ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
51
Student_OMP/src/core/omp/01_Hello/helloOMP.cpp
Executable file
51
Student_OMP/src/core/omp/01_Hello/helloOMP.cpp
Executable file
@@ -0,0 +1,51 @@
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include "omp.h"
|
||||
#include "Omps.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
|
||||
void helloOMP1()
|
||||
{
|
||||
cout << endl << "[HelloOMP 1]" << endl;
|
||||
|
||||
// OMP (facultatif)
|
||||
const int NB_THREAD = Omps::setAndGetNaturalGranularity();
|
||||
cout << "\n[HELLO] nbThread = " << NB_THREAD << endl;
|
||||
|
||||
#pragma omp parallel
|
||||
{
|
||||
int tid = Omps::getTid();
|
||||
|
||||
//cout << "tid=" << tid << endl; // ligne couper
|
||||
printf("tid=%i\n", tid); //ligne non couper
|
||||
}
|
||||
}
|
||||
|
||||
void helloOMP2()
|
||||
{
|
||||
cout << endl << "[HelloOMP 2]" << endl;
|
||||
|
||||
// OMP (facultatif)
|
||||
const int NB_THREAD = Omps::setAndGetNaturalGranularity();
|
||||
cout << "\n[CBI] nbThread = " << NB_THREAD << 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
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
30
Student_OMP/src/core/omp/01_Hello/useHello.cpp
Executable file
30
Student_OMP/src/core/omp/01_Hello/useHello.cpp
Executable file
@@ -0,0 +1,30 @@
|
||||
#include <iostream>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Imported *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
extern void helloOMP1();
|
||||
extern void helloOMP2();
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
bool useHello()
|
||||
{
|
||||
cout << endl << "[HelloOMP]" << endl;
|
||||
|
||||
helloOMP1();
|
||||
helloOMP2();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
49
Student_OMP/src/core/omp/02_Slice/01_pi_sequentiel.cpp
Executable file
49
Student_OMP/src/core/omp/02_Slice/01_pi_sequentiel.cpp
Executable file
@@ -0,0 +1,49 @@
|
||||
#include "99_pi_tools.h"
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiSequentiel_OK(int n);
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
static double piSequentiel(int n);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiSequentiel_OK(int n)
|
||||
{
|
||||
return isAlgoPI_OK(piSequentiel, n, "Pi Sequentiel");
|
||||
}
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
double piSequentiel(int n) {
|
||||
const double delta_x = 1 / (double)n;
|
||||
double sum = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
double xi = i * delta_x;
|
||||
sum += fpi(xi);
|
||||
}
|
||||
|
||||
return sum * delta_x;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
77
Student_OMP/src/core/omp/02_Slice/02_pi_entrelacer_promotionTab.cpp
Executable file
77
Student_OMP/src/core/omp/02_Slice/02_pi_entrelacer_promotionTab.cpp
Executable file
@@ -0,0 +1,77 @@
|
||||
#include <omp.h>
|
||||
#include "Omps.h"
|
||||
#include "99_pi_tools.h"
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPEntrelacerPromotionTab_Ok(int n);
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
static double piOMPEntrelacerPromotionTab(int n);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPEntrelacerPromotionTab_Ok(int n)
|
||||
{
|
||||
return isAlgoPI_OK(piOMPEntrelacerPromotionTab, n, "Pi OMP Entrelacer promotionTab");
|
||||
}
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
/**
|
||||
* pattern cuda : excellent!
|
||||
*/
|
||||
double piOMPEntrelacerPromotionTab(int n)
|
||||
{
|
||||
const double delta_x = 1.0 / (double)n;
|
||||
const int NB_THREAD = Omps::setAndGetNaturalGranularity();
|
||||
double sum[NB_THREAD];
|
||||
|
||||
// Reduction intra thread
|
||||
#pragma omp parallel
|
||||
{
|
||||
|
||||
const int TID = Omps::getTid();
|
||||
int s = TID;
|
||||
|
||||
double sum_thread = 0;
|
||||
|
||||
while (s < n)
|
||||
{
|
||||
double xi = s * delta_x;
|
||||
sum_thread += fpi(xi);
|
||||
s += NB_THREAD;
|
||||
}
|
||||
sum[TID] = sum_thread;
|
||||
}
|
||||
|
||||
double sumTotal = 0;
|
||||
|
||||
for (int i = 0; i < NB_THREAD; i++)
|
||||
{
|
||||
sumTotal += sum[i];
|
||||
}
|
||||
|
||||
return sumTotal * delta_x;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
47
Student_OMP/src/core/omp/02_Slice/03_pi_entrelacer_critique.cpp
Executable file
47
Student_OMP/src/core/omp/02_Slice/03_pi_entrelacer_critique.cpp
Executable file
@@ -0,0 +1,47 @@
|
||||
#include <omp.h>
|
||||
#include "Omps.h"
|
||||
#include "99_pi_tools.h"
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPEntrelacerCritical_Ok(int n);
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
static double piOMPEntrelacerCritical(int n);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPEntrelacerCritical_Ok(int n)
|
||||
{
|
||||
return isAlgoPI_OK(piOMPEntrelacerCritical, n, "Pi OMP Entrelacer critical");
|
||||
}
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
double piOMPEntrelacerCritical(int n)
|
||||
{
|
||||
//TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
50
Student_OMP/src/core/omp/02_Slice/04_pi_entrelacer_atomic.cpp
Executable file
50
Student_OMP/src/core/omp/02_Slice/04_pi_entrelacer_atomic.cpp
Executable file
@@ -0,0 +1,50 @@
|
||||
#include <omp.h>
|
||||
#include "Omps.h"
|
||||
#include "99_pi_tools.h"
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPEntrelacerAtomic_Ok(int n);
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
static double piOMPEntrelacerAtomic(int n);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPEntrelacerAtomic_Ok(int n)
|
||||
{
|
||||
return isAlgoPI_OK(piOMPEntrelacerAtomic, n, "Pi OMP Entrelacer atomic");
|
||||
}
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
/**
|
||||
* Bonne performance, si!
|
||||
*/
|
||||
double piOMPEntrelacerAtomic(int n)
|
||||
{
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
50
Student_OMP/src/core/omp/02_Slice/05_pi_for_critical.cpp
Executable file
50
Student_OMP/src/core/omp/02_Slice/05_pi_for_critical.cpp
Executable file
@@ -0,0 +1,50 @@
|
||||
#include <omp.h>
|
||||
#include "Omps.h"
|
||||
#include "99_pi_tools.h"
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPforCritical_Ok(int n);
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
static double piOMPforCritique(int n);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPforCritical_Ok(int n)
|
||||
{
|
||||
return isAlgoPI_OK(piOMPforCritique, n, "Pi OMP for critique");
|
||||
}
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
/**
|
||||
* synchronisation couteuse!
|
||||
*/
|
||||
double piOMPforCritique(int n)
|
||||
{
|
||||
//TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
50
Student_OMP/src/core/omp/02_Slice/06_pi_for_atomic.cpp
Executable file
50
Student_OMP/src/core/omp/02_Slice/06_pi_for_atomic.cpp
Executable file
@@ -0,0 +1,50 @@
|
||||
#include <omp.h>
|
||||
#include "Omps.h"
|
||||
#include "99_pi_tools.h"
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPforAtomic_Ok(int n);
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
static double piOMPforAtomic(int n);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPforAtomic_Ok(int n)
|
||||
{
|
||||
return isAlgoPI_OK(piOMPforAtomic, n, "Pi OMP for atomic");
|
||||
}
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
/**
|
||||
* synchronisation couteuse!
|
||||
*/
|
||||
double piOMPforAtomic(int n)
|
||||
{
|
||||
//TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
53
Student_OMP/src/core/omp/02_Slice/07_pi_for_promotionTab.cpp
Executable file
53
Student_OMP/src/core/omp/02_Slice/07_pi_for_promotionTab.cpp
Executable file
@@ -0,0 +1,53 @@
|
||||
#include <omp.h>
|
||||
#include "Maths.h"
|
||||
#include "Omps.h"
|
||||
#include "99_pi_tools.h"
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPforPromotionTab_Ok(int n);
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
static double piOMPforPromotionTab(int n);
|
||||
static void syntaxeSimplifier(double* tabSumThread , int n);
|
||||
static void syntaxeFull(double* tabSumThread , int n);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPforPromotionTab_Ok(int n)
|
||||
{
|
||||
return isAlgoPI_OK(piOMPforPromotionTab, n, "Pi OMP for promotion tab");
|
||||
}
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
/**
|
||||
* De-synchronisation avec PromotionTab
|
||||
*/
|
||||
double piOMPforPromotionTab(int n)
|
||||
{
|
||||
//TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
51
Student_OMP/src/core/omp/02_Slice/08_pi_for_reduction.cpp
Executable file
51
Student_OMP/src/core/omp/02_Slice/08_pi_for_reduction.cpp
Executable file
@@ -0,0 +1,51 @@
|
||||
#include <omp.h>
|
||||
#include "Omps.h"
|
||||
#include "99_pi_tools.h"
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPforReduction_Ok(int n);
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
static double piOMPforReduction(int n);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
bool isPiOMPforReduction_Ok(int n)
|
||||
{
|
||||
return isAlgoPI_OK(piOMPforReduction, n, "Pi OMP for reduction-integrer");
|
||||
}
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Private *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
/**
|
||||
* pattern omp usefull : idem desyncronisation-promotionTab ,mais avec syntaxe plus courte!
|
||||
* Si on enleve le pragma, le code est le meme que le sequentiel!
|
||||
*/
|
||||
double piOMPforReduction(int n)
|
||||
{
|
||||
//TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
47
Student_OMP/src/core/omp/02_Slice/99_pi_tools.cpp
Executable file
47
Student_OMP/src/core/omp/02_Slice/99_pi_tools.cpp
Executable file
@@ -0,0 +1,47 @@
|
||||
#include "99_pi_tools.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "ChronoFactory.h"
|
||||
#include "Maths.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
double fpi(double x)
|
||||
{
|
||||
return 4 / (1 + x * x);
|
||||
}
|
||||
|
||||
bool isAlgoPI_OK(AlgoPI algoPI , int n , string title)
|
||||
{
|
||||
cout << endl << endl << "[" << title << " running ...]" << endl;
|
||||
cout << "\tn=" << n << endl;
|
||||
|
||||
Chrono* ptrChrono = ChronoFactory::create();
|
||||
double piHat = algoPI(n);
|
||||
ptrChrono->stop();
|
||||
|
||||
cout.precision(8);
|
||||
cout << "\tPi hat = " << piHat << endl;
|
||||
cout << "\tPi true = " << PI << endl;
|
||||
|
||||
bool isOk = Maths::isEquals(piHat, PI, 1e-6);
|
||||
cout << "\tisOk = " << isOk << endl;
|
||||
|
||||
cout.precision(3);
|
||||
cout<<"\ttime : "<<*ptrChrono<<endl;
|
||||
cout << endl;
|
||||
|
||||
delete ptrChrono;
|
||||
|
||||
return isOk;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
25
Student_OMP/src/core/omp/02_Slice/99_pi_tools.h
Executable file
25
Student_OMP/src/core/omp/02_Slice/99_pi_tools.h
Executable file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
// ptr fonction de type double xxx(int n)
|
||||
// ou xxx sera une methode de calcul de pi
|
||||
typedef double (*AlgoPI)(int);
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Methode *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
double fpi(double x);
|
||||
bool isAlgoPI_OK(AlgoPI algoPI, int n, string title);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
46
Student_OMP/src/core/omp/02_Slice/usePI.cpp
Executable file
46
Student_OMP/src/core/omp/02_Slice/usePI.cpp
Executable file
@@ -0,0 +1,46 @@
|
||||
#include <iostream>
|
||||
#include <limits.h>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Imported *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
extern bool isPiSequentiel_OK(int n);
|
||||
extern bool isPiOMPEntrelacerPromotionTab_Ok(int n);
|
||||
extern bool isPiOMPEntrelacerCritical_Ok(int n);
|
||||
extern bool isPiOMPEntrelacerAtomic_Ok(int n);
|
||||
extern bool isPiOMPforCritical_Ok(int n);
|
||||
extern bool isPiOMPforAtomic_Ok(int n);
|
||||
extern bool isPiOMPforPromotionTab_Ok(int n);
|
||||
extern bool isPiOMPforReduction_Ok(int n);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
bool usePI()
|
||||
{
|
||||
cout << endl << "[PI]" << endl;
|
||||
|
||||
int n = INT_MAX / 10;
|
||||
|
||||
bool isOk = true;
|
||||
isOk &= isPiSequentiel_OK(n);
|
||||
isOk &= isPiOMPEntrelacerPromotionTab_Ok(n);
|
||||
isOk &= isPiOMPEntrelacerCritical_Ok(n);
|
||||
isOk &= isPiOMPEntrelacerAtomic_Ok(n);
|
||||
isOk &= isPiOMPforCritical_Ok(n);
|
||||
isOk &= isPiOMPforAtomic_Ok(n);
|
||||
isOk &= isPiOMPforPromotionTab_Ok(n);
|
||||
isOk &= isPiOMPforReduction_Ok(n);
|
||||
|
||||
return isOk;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
46
Student_OMP/src/main.cpp
Executable file
46
Student_OMP/src/main.cpp
Executable file
@@ -0,0 +1,46 @@
|
||||
#include <iostream>
|
||||
#include <limits.h>
|
||||
#include "Limits.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Imported *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
extern int mainCore(void);
|
||||
extern int mainTest(void);
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
int main(void);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Public *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
cout << "main" << endl;
|
||||
|
||||
Limits::rappelTypeSize();
|
||||
|
||||
const bool IS_TEST = false;
|
||||
return IS_TEST ? mainTest() : mainCore();
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
44
Student_OMP/src/test/mainTest.cpp
Executable file
44
Student_OMP/src/test/mainTest.cpp
Executable file
@@ -0,0 +1,44 @@
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "CppTest.h"
|
||||
#include "Folders.h"
|
||||
|
||||
#include "TestHello.h"
|
||||
#include "TestPi.h"
|
||||
#include "Chrome.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
int mainTest()
|
||||
{
|
||||
Test::Suite testSuite;
|
||||
|
||||
testSuite.add(std::auto_ptr < Test::Suite > (new TestHello()));
|
||||
testSuite.add(std::auto_ptr < Test::Suite > (new TestPi()));
|
||||
|
||||
// run
|
||||
{
|
||||
string folder = "./out";
|
||||
string title = "testAll";
|
||||
string fileHTML = title + ".html";
|
||||
|
||||
Folders::mkdirP(folder);
|
||||
|
||||
int result = CppTest::run(folder, fileHTML, title, testSuite, OutputType::HTML); // HTML CONSOLE
|
||||
|
||||
Chrome::showHTML(folder, fileHTML); // to be commented if OutputType::CONSOLE
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
34
Student_OMP/src/test/unit/01_Test_Hello/TestHello.cpp
Executable file
34
Student_OMP/src/test/unit/01_Test_Hello/TestHello.cpp
Executable file
@@ -0,0 +1,34 @@
|
||||
#include "TestHello.h"
|
||||
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Imported *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
extern void helloOMP1();
|
||||
extern void helloOMP2();
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
TestHello::TestHello()
|
||||
{
|
||||
TEST_ADD(TestHello::testHelloOMP1);
|
||||
TEST_ADD(TestHello::testHelloOMP2);
|
||||
}
|
||||
|
||||
void TestHello::testHelloOMP1()
|
||||
{
|
||||
helloOMP1();
|
||||
}
|
||||
|
||||
void TestHello::testHelloOMP2()
|
||||
{
|
||||
helloOMP2();
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
25
Student_OMP/src/test/unit/01_Test_Hello/TestHello.h
Executable file
25
Student_OMP/src/test/unit/01_Test_Hello/TestHello.h
Executable file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "cpptest.h"
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
class TestHello: public Test::Suite
|
||||
{
|
||||
public:
|
||||
|
||||
TestHello();
|
||||
|
||||
private:
|
||||
|
||||
void testHelloOMP1();
|
||||
void testHelloOMP2();
|
||||
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
80
Student_OMP/src/test/unit/02_Test_Pi/TestPi.cpp
Executable file
80
Student_OMP/src/test/unit/02_Test_Pi/TestPi.cpp
Executable file
@@ -0,0 +1,80 @@
|
||||
#include "TestPi.h"
|
||||
#include <limits.h>
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Imported *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
extern bool isPiSequentiel_OK(int n);
|
||||
extern bool isPiOMPEntrelacerPromotionTab_Ok(int n);
|
||||
extern bool isPiOMPEntrelacerCritical_Ok(int n);
|
||||
extern bool isPiOMPEntrelacerAtomic_Ok(int n);
|
||||
extern bool isPiOMPforCritical_Ok(int n);
|
||||
extern bool isPiOMPforAtomic_Ok(int n);
|
||||
extern bool isPiOMPforPromotionTab_Ok(int n);
|
||||
extern bool isPiOMPforReduction_Ok(int n);
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
TestPi::TestPi()
|
||||
{
|
||||
this->n = INT_MAX / 10;
|
||||
|
||||
TEST_ADD(TestPi::testSequentiel);
|
||||
|
||||
TEST_ADD(TestPi::testEntrelacerPromotionTab);
|
||||
TEST_ADD(TestPi::testEntrelacerAtomic);
|
||||
TEST_ADD(TestPi::testEntrelacerCritical);
|
||||
|
||||
TEST_ADD(TestPi::testAtomic);
|
||||
TEST_ADD(TestPi::testCritical);
|
||||
TEST_ADD(TestPi::testPromotionTab);
|
||||
TEST_ADD(TestPi::testForReduction);
|
||||
}
|
||||
|
||||
void TestPi::testSequentiel()
|
||||
{
|
||||
TEST_ASSERT(isPiSequentiel_OK(n) == true);
|
||||
}
|
||||
|
||||
void TestPi::testEntrelacerPromotionTab()
|
||||
{
|
||||
TEST_ASSERT(isPiOMPEntrelacerPromotionTab_Ok(n) == true);
|
||||
}
|
||||
|
||||
void TestPi::testEntrelacerAtomic()
|
||||
{
|
||||
TEST_ASSERT(isPiOMPEntrelacerAtomic_Ok(n) == true);
|
||||
}
|
||||
|
||||
void TestPi::testEntrelacerCritical()
|
||||
{
|
||||
TEST_ASSERT(isPiOMPEntrelacerCritical_Ok(n) == true);
|
||||
}
|
||||
|
||||
void TestPi::testCritical()
|
||||
{
|
||||
TEST_ASSERT(isPiOMPforCritical_Ok(n) == true);
|
||||
}
|
||||
|
||||
void TestPi::testAtomic()
|
||||
{
|
||||
TEST_ASSERT(isPiOMPforAtomic_Ok(n) == true);
|
||||
}
|
||||
|
||||
void TestPi::testPromotionTab()
|
||||
{
|
||||
TEST_ASSERT(isPiOMPforPromotionTab_Ok(n) == true);
|
||||
}
|
||||
|
||||
void TestPi::testForReduction()
|
||||
{
|
||||
TEST_ASSERT(isPiOMPforReduction_Ok(n) == true);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
35
Student_OMP/src/test/unit/02_Test_Pi/TestPi.h
Executable file
35
Student_OMP/src/test/unit/02_Test_Pi/TestPi.h
Executable file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "cpptest.h"
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
class TestPi: public Test::Suite
|
||||
{
|
||||
public:
|
||||
|
||||
TestPi(void);
|
||||
|
||||
private:
|
||||
|
||||
void testSequentiel();
|
||||
void testEntrelacerPromotionTab();
|
||||
void testEntrelacerAtomic();
|
||||
void testEntrelacerCritical();
|
||||
void testCritical();
|
||||
void testAtomic();
|
||||
void testPromotionTab();
|
||||
void testForReduction();
|
||||
|
||||
private:
|
||||
|
||||
int n;
|
||||
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
Reference in New Issue
Block a user