chore: init

This commit is contained in:
2025-09-19 15:36:37 +02:00
commit 9d707a253a
2190 changed files with 17598 additions and 0 deletions

View File

@@ -0,0 +1,110 @@
#pragma once
#include <math.h>
#include "Maths.h"
#include "Colors.cu.h"
/*----------------------------------------------------------------------*\
|* Declaration *|
\*---------------------------------------------------------------------*/
/*--------------------------------------*\
|* Public *|
\*-------------------------------------*/
class RipplingMath
{
/*--------------------------------------*\
|* Constructeur *|
\*-------------------------------------*/
public:
__device__ RipplingMath(uint w , uint h , float t) :
dim2(w / 2), //
t(t)
{
// rien
}
__device__
virtual ~RipplingMath()
{
// rien
}
/*--------------------------------------*\
|* Methode *|
\*-------------------------------------*/
public:
__device__
void colorIJ(uchar4* ptrColorIJ , int i , int j)
{
uchar levelGris = levelGray(i, j); // update levelGris
ptrColorIJ->x = levelGris;
ptrColorIJ->y = levelGris;
ptrColorIJ->z = levelGris;
ptrColorIJ->w = 255; //opaque
// Conseil:
// Etape 1 : Commencer par afficher une image uniforme grise (128 par exemple)
// pour valider tout le pipeline en amont
//
// Etape 2: Puis une fois que l'image grise est valider, attaquer rippling
// debug temp
// {
// ptrColorIJ->x = 128;
// ptrColorIJ->y = 128;
// ptrColorIJ->z = 128;
// ptrColorIJ->w = 255; // opacity facultatif
// }
}
private:
/*-------------*\
|* int *|
\*------------*/
__inline__
__device__
uchar levelGray(int i , int j )
{
float result;
dij(i, j, &result); // warning : dij return void. Ne peut pas etre "imbriquer dans une fonction"
result = result / 10.f;
// TODO Rippling GPU : cf formules math rippling.pdf (attribut dim2 = dim/2
}
__inline__
__device__
void dij(int i , int j , float* ptrResult)
{
//TODO Rippling GPU cf fonction math pdf
// Ne pas utiliser la fonction pow pour elever au carrer !
// Utiliser l'opérateur *
}
/*--------------------------------------*\
|* Attribut *|
\*-------------------------------------*/
private:
// Tools
int dim2; // dim2=dim/2
float t;
};
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,84 @@
#include "Thread2D.cu.h"
#include "Thread1D.cu.h"
#include "cudas.h"
#include "Indices.cu.h"
#include "RipplingMath.cu.h"
/*----------------------------------------------------------------------*\
|* Private *|
\*---------------------------------------------------------------------*/
static __device__ void ripplingBaseline(uchar4* tabPixelsGM , uint w , uint h , float t);
static __device__ void ripplingDemi(uchar4* tabPixelsGM , uint w , uint h , float t);
static __device__ void ripplingQuart(uchar4* tabPixelsGM , uint w , uint h , float t);
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
__global__ void rippling(uchar4* tabPixelsGM , uint w , uint h , float t)
{
ripplingBaseline(tabPixelsGM, w, h, t);
// ripplingDemi(tabPixelsGM, w, h, t);
// ripplingQuart(tabPixelsGM, w, h, t);
}
/*----------------------------------------------------------------------*\
|* private *|
\*---------------------------------------------------------------------*/
/**
* v1
*/
__inline__
__device__ void ripplingBaseline(uchar4* tabPixelsGM , uint w , uint h , float t)
{
// TODO instacier RipplingMath
const int TID = Thread2D::tid();
const int NB_THREAD = Thread2D::nbThread();
const int WH = w * h;
// TODO Rippling GPU pattern entrelacement
}
/**
* v2 : optimisation
*/
__inline__
__device__ void ripplingDemi(uchar4* tabPixelsGM , uint w , uint h , float t)
{
// Indication:
// (I1) Utiliser la symetrie horizontale de l'image
// (I2) Calculer que la demi partie superieur
// (I3) Ranger la couleur calculer dans la demi partie inferieur (effet miroir)
// Partez de la fin de l'image, peut-etre
// TODO Rippling GPU
}
/**
* v3 : optimsation : defi (difficile) (pas necessaire pour test performance)
*/
__inline__
__device__ void ripplingQuart(uchar4* tabPixelsGM , uint w , uint h , float t)
{
// Indication:
// (I1) Utiliser la symetrie horizontale et verticale de l'image
// (I2) Calculer que le quart en huat a gauche
// (I3) Ranger la couleur calculer dans les autres quarts
// Warning
// (w1) Necessaire sans doute pour passer le test performance
//
// Contrainte
// (C1) Utiliser toujours le pattern d'entrelacement
// TODO Rippling GPU
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,72 @@
#include "Rippling.h"
#include <iostream>
#include <assert.h>
#include <Kernel.h>
#include <assert.h>
using std::cout;
using std::endl;
/*----------------------------------------------------------------------*\
|* Imported *|
\*---------------------------------------------------------------------*/
extern __global__ void rippling(uchar4* tabPixelsGM,uint w, uint h,float t);
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
/*-------------------------*\
|* Constructeur *|
\*-------------------------*/
Rippling::Rippling(const Grid& grid , uint w , uint h , float dt , bool isVerbose) :
Animable_I<uchar4>(grid, w, h, "Rippling-Cuda-uchar4", isVerbose) // super classe
{
assert(w == h); // specific rippling
// Animation
this->dt = dt;
this->t = 0; // protected dans Animable
}
Rippling::~Rippling()
{
// rien
}
/*-------------------------*\
|* Methode *|
\*-------------------------*/
/**
* Override
* Call periodicly by the API
*
* Note : domaineMath pas use car image pas zoomable
*/
void Rippling::process(uchar4* tabPixelsGM , uint w , uint h , const DomaineMath& domaineMath)
{
// TODO Rippling
// lancer le kernel avec <<<dg,db>>>
// le kernel est importer ci-dessus (ligne 19)
assert(false); // to delete once implement
}
/**
* Override
* Call periodicly by the API
*/
void Rippling::animationStep()
{
t += dt;
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,57 @@
#pragma once
#include "cudas.h"
#include "Maths.h"
#include "Animable_I.h"
/*----------------------------------------------------------------------*\
|* Declaration *|
\*---------------------------------------------------------------------*/
class Rippling: public Animable_I<uchar4>
{
/*--------------------------------------*\
|* Constructor *|
\*-------------------------------------*/
public:
Rippling(const Grid& grid, uint w, uint h, float dt, bool isVerbose);
virtual ~Rippling(void);
/*--------------------------------------*\
|* Methodes *|
\*-------------------------------------*/
public:
/*-------------------------*\
|* Override Animable_I *|
\*------------------------*/
/**
* Call periodicly by the api
*/
virtual void process(uchar4* tabPixelsGM, uint w, uint h, const DomaineMath& domaineMath);
/**
* Call periodicly by the api
*/
virtual void animationStep();
/*--------------------------------------*\
|* Attributs *|
\*-------------------------------------*/
private:
// Inputs
float dt;
};
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,41 @@
#pragma once
#include <iostream>
#include <assert.h>
#include "Grid.h"
#include "Hardware.h"
#include "Couts.h"
/*----------------------------------------------------------------------*\
|* Impelmentation *|
\*---------------------------------------------------------------------*/
namespace rippling
{
class BestGrid
{
public:
static Grid get()
{
const int MP = Hardware::getMPCount();
const int CORE_MP = Hardware::getCoreCountMP();
// TODO Rippling
// to remove once coded
{
Couts::redln("aie aie aie, your best grid won t build itself");
assert(false);
}
}
};
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,71 @@
#include "Thread2D.cu.h"
#include "cudas.h"
#include "real_mandelbrot.h"
#include "MandelbrotMath.cu.h"
#include "DomaineMath.h"
#include "Indices.cu.h"
#include "Colors.cu.h"
/*----------------------------------------------------------------------*\
|* private *|
\*---------------------------------------------------------------------*/
// optimisation lookup table color
static __device__ void fill(uchar4* tabSM,int n);
static __device__ void color(uchar4* ptrColor,int k, int n);
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
__global__ void mandelbrot(uchar4* tabPixelsGM , uint w , uint h , DomaineMath domaineMath , int n)
{
// TODO Mandelbrot :
//
// entrelacement
// s -> (i,j) -> (x,y)
// appeler colorXY
double x;
double y;
//domaineMath.toXY(i, j, &x, &y); // x et y doivent etre en double! Caster ensuite en real lors du passage à colorXY
}
/*----------------------------------------------------------------------*\
|* private *|
\*---------------------------------------------------------------------*/
/**
* optimisation lookup table color (facultatif)
*/
__inline__
__device__ void fill(uchar4* tabSM,int n)
{
// Indications:
// (I1) tabSM a n cases
// (I2) La case k contient les couleurs en RVBA lorsque la suite s est arreter a k
// (I3) Utiliser la methode color ci-dessous pour vous aider
// (I4) Utiliser tabSM dans la partie mandelbrotMath, updater a cet effet quelques prototypes si necessaire
// Passer par exemple tabSM au constructeur de mandelbrotMath
//
// Warning
// (W1) Commencer d'abord sans cette piste d'optimisation
}
/**
* optimisation lookup table color (facultatif)
*/
__inline__
__device__ void color(uchar4* ptrColor,int k, int n)
{
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,157 @@
#pragma once
#include <math.h>
#include <cuda_fp16.h>
#include "real_mandelbrot.h"
#include "Maths.h"
#include "DomaineMath.h"
#include "Colors.cu.h"
/*--------------------------------------*\
|* Helper type *|
\*-------------------------------------*/
using mandelbrotReal::real;
#ifdef MANDELBROT_HALF
#define DEUX (half)2
#define QUATRE (half)4
#define ZERO (half)0
#endif
#ifdef MANDELBROT_FLOAT
#define DEUX 2.f
#define QUATRE 4.f
#define ZERO 0.f
#endif
#ifdef MANDELBROT_DOUBLE
#define DEUX 2.0
#define QUATRE 4.0
#define ZERO 0.0
#endif
class MandelbrotMath
{
/*--------------------------------------*\
|* Constructeur *|
\*-------------------------------------*/
public:
__device__ MandelbrotMath(int n) : //
n(n)
{
// rien
}
__device__
virtual ~MandelbrotMath()
{
// rien
}
/*--------------------------------------*\
|* Methode *|
\*-------------------------------------*/
public:
__device__
void colorXY(uchar4* ptrColorIJ , real x , real y)
{
// TODO Mandelbrot
// Calculer la suite en (x,y) et recuperer l'indice d'arret de la suite
// Colorier : Il faut convertir l'indice d'arret en une hue01!
// Calcul dans quel type? float
// Conseil:
// Etape 1 : Commencer par afficher une image uniforme grise (128 par exemple)
// pour valider tout le pipeline en amont
//
// Etape 2: Puis une fois que l'image grise est valider, attaquer montecarlo
// debug temp
// {
// ptrColorIJ->x = 128;
// ptrColorIJ->y = 128;
// ptrColorIJ->z = 128;
// ptrColorIJ->w = 255; // opacity facultatif
}
private:
/**
* Warning: define real in real_mandelbrot.h (real=float or real=double or real= half)
* Ce n'est que dans suite que l'on travaille avec le type real
*/
__inline__
__device__
int suite(real x , real y)
{ // TODO Mandelbrot
// Utiliser dans vos formules les variable :
//
// DEUX
// QUATRE
// ZERO
//
// definit au debut de ce fichier. Est-utile pour passer facilement d'une version fp64 (double) fp32(float) fp16(half)
// Calculer la suite en (x,y) jusqu'à n, à moins que critere arret soit atteint avant
// return le nombre d'element de la suite calculer, ie un entier
}
/////////////////////
// Warning:
////////////////////
//
// Un des risque est de faire une boucle infinie
//
// Analyse:
//
// Comme il n'y pas de ecran physiquement brancher sur le serveur, les kernels n'ont pas de timeout
// Le kernel n'est donc pas stopper apres les 2 secondes de timeout par defaut
// Vous avez donc un risque de laisser le serveur inutilisable pour les autres utilisateus de la machine
//
// Consequence:
//
// Checker bien votre code avant de le lancer
//
// Arreter bien votre processus:
// - carrer rouge eclipse
// - linux_kill_cuda (dans la trousse a outil d'exlipse)
// - a la racine du projet : cbicc cuda kill
//
// Verifier avec :
// htop que votre processus est bien detruit (filter .run)
// nvidia-smi --loop=1 que vous n'employez plus le gpu
//
// Sinon il y a de grandes chances qu'il faille redemarer le server et les autres utilisateurs de la machine ne vont pas etre content.
//
// Info:
//
// On peut tester l etat du serveur (pipeline de rendu openGL) via
//
// gl glxgears
//
// Si la fenetre mais du temps a s'ouvrir . c'est pas bon signe
// Si elle ne s'ouvre pas, je dois redemarer le server
/*--------------------------------------*\
|* Attribut *|
\*-------------------------------------*/
private:
// Inputs
int n;
};
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,82 @@
#include "Mandelbrot.h"
#include "GM.h"
#include <iostream>
#include <assert.h>
#include "Hardware.h"
#include "real_mandelbrot.h"
using std::cout;
using std::endl;
/*----------------------------------------------------------------------*\
|* Imported *|
\*---------------------------------------------------------------------*/
extern __global__ void mandelbrot(uchar4* tabPixelsGM, uint w, uint h,DomaineMath domaineMath, int n);
/*----------------------------------------------------------------------*\
|* private *|
\*---------------------------------------------------------------------*/
static string titre(int nMin , int nMax);
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
/*-------------------------*\
|* Constructeur *|
\*-------------------------*/
Mandelbrot::Mandelbrot(const Grid& grid , uint w , uint h , const DomaineMath& domaineMath , bool isVerbose , int nMin , int nMax) :
Animable_I<uchar4>(grid, w, h, titre(nMin, nMax), domaineMath, isVerbose), // super classe
variateurT(Interval<int>(nMin, nMax), 1), // tools animation
nMin(nMin), // Inputs animation
nMax(nMax) // Inputs animation
{
// Tools
this->t = nMin;
}
Mandelbrot::~Mandelbrot()
{
// rien
}
/*-------------------------*\
|* Methode *|
\*-------------------------*/
/**
* Override
* Call periodicly by the API
*/
void Mandelbrot::process(uchar4* tabPixelsGM , uint w , uint h , const DomaineMath& domaineMath)
{
assert(false); // to be removed once implemented
// TODO Mandelbrot
// lauch kernel (you find at line 18)
}
/**
* Override
* Call periodicly by the API
*/
void Mandelbrot::animationStep()
{
this->t = variateurT.varierAndGet();
}
string titre(int nMin , int nMax)
{
return "Mandelbrot-Cuda-uchar4-" + mandelbrotReal::realToString() + "-nMin" + std::to_string(nMin) + "-nMax" + std::to_string(nMax);
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,60 @@
#pragma once
#include "cudas.h"
#include "Maths.h"
#include "Animable_I.h"
#include "Variateur.cu.h"
/*----------------------------------------------------------------------*\
|* Declaration *|
\*---------------------------------------------------------------------*/
class Mandelbrot: public Animable_I<uchar4>
{
/*--------------------------------------*\
|* Constructor *|
\*-------------------------------------*/
public:
Mandelbrot(const Grid& grid , uint w , uint h , const DomaineMath& domaineMath , bool isVerbose , int nMin , int nMax);
virtual ~Mandelbrot(void);
/*--------------------------------------*\
|* Methodes *|
\*-------------------------------------*/
public:
/*-------------------------*\
|* Override Animable_I *|
\*------------------------*/
/**
* Call periodicly by the api
*/
virtual void process(uchar4* tabPixelsGM , uint w , uint h , const DomaineMath& domaineMath);
/**
* Call periodicly by the api
*/
virtual void animationStep();
/*--------------------------------------*\
|* Attributs *|
\*-------------------------------------*/
private:
// Inputs
int nMin;
int nMax;
// Tools
Variateur<int> variateurT;
};
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,65 @@
#pragma once
#include <iostream>
#include <assert.h>
#include "Grid.h"
#include "Hardware.h"
#include "real_mandelbrot.h"
#include "Couts.h"
/*----------------------------------------------------------------------*\
|* Impelmentation *|
\*---------------------------------------------------------------------*/
namespace mandelbrot
{
class BestGrid
{
public:
static Grid get()
{
const int MP = Hardware::getMPCount();
const int CORE_MP = Hardware::getCoreCountMP();
// fp64 (float 64 bits)
#ifdef MANDELBROT_DOUBLE
//TODO Mandelbrot
// to remove once coded
{
Couts::redln("aie aie aie, your best grid won t build itself");
assert(false);
}
#endif
// fp32 (float 32 bits)
#ifdef MANDELBROT_FLOAT
//TODO Mandelbrot
// to remove once coded
{
Couts::redln("aie aie aie, your best grid won t build itself");
assert(false);
}
#endif
// fp16 (float 32 bits)
#ifdef MANDELBROT_HALF
//TODO Mandelbrot
// to remove once coded
{
Couts::redln("aie aie aie, your best grid won t build itself");
assert(false);
}
#endif
}
};
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,120 @@
#pragma once
#include <iostream>
#include <assert.h>
#include "cuda_fp16.h"
/*----------------------------------------------------------------------*\
|* Declaration *|
\*---------------------------------------------------------------------*/
/*----------------------*\
|* public *|
\*---------------------*/
// Choose one of the two (either/either):
//#define MANDELBROT_DOUBLE
//#define MANDELBROT_FLOAT
#define MANDELBROT_HALF
/*----------------------*\
|* private *|
\*---------------------*/
namespace mandelbrotReal
{
// fp64 (float 64 bits)
#ifdef MANDELBROT_DOUBLE
//#define real double
using real=double;
#endif
// fp32 (float 32 bits)
#ifdef MANDELBROT_FLOAT
//#define real float
using real=float;
#endif
// fp16 (float 16 bits)
#ifdef MANDELBROT_HALF
//#define real half
using real=half;
#endif
static std::string realToString()
{
#ifdef MANDELBROT_DOUBLE
return "fp64";
#endif
#ifdef MANDELBROT_FLOAT
return "fp32";
#endif
#ifdef MANDELBROT_HALF
return "fp16";
#endif
}
static bool isFp16()
{
#ifdef MANDELBROT_DOUBLE
return false;
#endif
#ifdef MANDELBROT_FLOAT
return false;
#endif
#ifdef MANDELBROT_HALF
return true;
#endif
assert(false);
}
static bool isFp32()
{
#ifdef MANDELBROT_DOUBLE
return false;
#endif
#ifdef MANDELBROT_FLOAT
return true;
#endif
#ifdef MANDELBROT_HALF
return false;
#endif
assert(false);
}
static bool isFp64()
{
#ifdef MANDELBROT_DOUBLE
return true;
#endif
#ifdef MANDELBROT_FLOAT
return false;
#endif
#ifdef MANDELBROT_HALF
return false;
#endif
assert(false);
}
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,137 @@
#pragma once
#include <math.h>
#include "Maths.h"
#include "Limits.h"
#include "Sphere.h"
#define FLOAT_MAX 1e+6
#include "Colors.cu.h"
class RaytracingMath
{
public:
/*--------------------------------------*\
|* Constructor *|
\*-------------------------------------*/
__device__ RaytracingMath(Sphere* tabSpheresDev , int nbSpheres , float t) : //
tabSpheresDev(tabSpheresDev), //
nbSpheres(nbSpheres), //
t(t)
{
// Tools
black.x = 0;
black.y = 0;
black.z = 0;
}
__device__
virtual ~RaytracingMath()
{
// rien
}
/*--------------------------------------*\
|* Methodes *|
\*-------------------------------------*/
public:
__device__
void colorIJ(uchar4* ptrColorIJ , int i , int j)
{
// Note : On travaille sans domaineMath ici (choix), donc pas x y en double, mais i j en int
float2 xySol; // convertion simple en real, car la chaine de calul est ensuite ne real
xySol.x = i;
xySol.y = j;
colorIJ(xySol, ptrColorIJ); // update ptrColorIJ
ptrColorIJ->w = 255; // opacity facultatif
// Conseil:
// Etape 1 : Commencer par afficher une image uniforme grise (128 par exemple)
// pour valider tout le pipeline en amont
//
// Etape 2: Puis une fois que l'image grise est valider, attaquer raytracing
// debug temp
{
// ptrColorIJ->x = 128;
// ptrColorIJ->y = 128;
// ptrColorIJ->z = 128;
// ptrColorIJ->w = 255; // opacity facultatif
}
}
private:
__inline__
__device__
void colorIJ(const float2& xySol , uchar4* ptrColorXY)
//void colorIJ(float solX, reel solY , uchar4* ptrColorXY)
{
// TODO Raytracing
// process the color for the pixel (i,j)
// use methode of Sphere classe
// Indications:
//
// (I1) Voici la sequence des elements a calculer
//
// h2 (hCarrer)
// isEndessous
// dz
// distance
// brightness
//
// (I2) Voir les attributs de classes (en bas de ce fichier)
//
// (I3) Pour chaque pixel:
// (S1) Parcourir toutes les spheres (cf attributs)
// (S2) Pour chacune d'entre elle, regarder si vous etes en dessous
// (S3) Si vous etes en dessous, calculer la distance, et memoriser
// la sphere qui est la plus proche, de toutes celles deja parcourues
// (S4) Finalement prenez la hue de la sphere la plus proche
// (S5) Adapter la brightness selon la distance qui separe le pixel du centre projet de la sphere,
// pour un effet 3d plus realiste (truc d'infographiste)
//
// Debug truc:
//
// (D1) Mettez en commentaire le contenu de votre premier if et colorier en rvb en rouge!
// Vous devrier voir des decoupes de sphere dans les bords de l'image!
//
// Optimisations : Pistes:
//
// (O1) Essayer de supprimer la thread divergence
// (O2) Optimisation du dg db
// (O3) Minimiser acces a la GM (sphere i dans un registre : Sphere spherei=...), au lieu d'un pointeur? d'un indice?
// (O4) Stocker les attributs de la sphere la plus proche (hue par exemple) et pas la sphere elle meme
// (O5) ...
}
/*--------------------------------------*\
|* Attributs *|
\*-------------------------------------*/
private:
// Input
Sphere* tabSpheresDev;
int nbSpheres;
float t;
// Tools
uchar4 black;
};
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,127 @@
#include <assert.h>
#include "Thread2D.cu.h"
#include "Thread1D.cu.h"
#include "cudas.h"
#include "Indices.cu.h"
#include "Sphere.h"
#include "nbSphere.h"
#include "raytracingCM.cu.h"
#include "RaytracingMath.cu.h"
/*----------------------------------------------------------------------*\
|* Private *|
\*---------------------------------------------------------------------*/
static __device__ void work(uchar4* tabPixelsGM, uint w, uint h, float t, Sphere* tabSpheresDev, int nbSpheres);
static __device__ void copyDevtoSM(Sphere* tabSphereSM, Sphere* tabSphereDev, int nbSpheres);
static __device__ void copyDevtoSM(float* tabSM , float* tabDev , int n);
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
__global__ void kernelRaytacingGM(uchar4* tabPixelsGM , uint w , uint h , float t , Sphere* tabSpheresGM , int nbSpheres)
{
// TODO Raytracing GM
// Indications :
// (I1) Call methode work with good input
// (I2) work contain the algo
// (I3) The algo is the same with the GM,CM,SM of TP Ractracing
}
__global__ void kernelRaytacingSM(uchar4* tabPixelsGM , uint w , uint h , float t , Sphere* tabSpheresGM , int nbSpheres)
{
// TODO Raytracing SM
// Indications :
// (I1) Copier les sphere de GM to SM (voir methode de copie en bas)
// (I2) Call work with good input
// (I3) Implementer une methode copyGMtoSM
}
__global__ void kernelRaytacingCM(uchar4* tabPixelsGM , uint w , uint h , float t , int nbSpheres)
{
// TODO Raytracing CM
// Indications :
// (I1) call work with good input
// (I2) TAB_SPHERES_CM est une variable globale a ce fichier! (Voir le debut de ce fichier, include rayTracingCM.h)
}
__global__ void kernelRaytacingCM2SM(uchar4* tabPixelsGM , uint w , uint h , float t , int nbSpheres)
{
// TODO Raytracing CM2SM
// Indications :
// (I1) Copier les sphere de CM to SM (voir methode de copie en bas)
// (I2) Call work with good input
// (I3) Implementer une methode copyCMtoSM
// ou : Tip : renommer copyGMtoSM en copyDevToSM et utiliser copyDevToSM avec les bons inputs
}
/*--------------------------------------*\
|* private *|
\*-------------------------------------*/
/**
* Methode commune au 3 kernel ci-dessus.
* Ici on ne sait pas si derriere tabSpheresDev, c'est
* - de la GM?
* - de la SM?
* - de la CM?
* Pas d'importance, c'est un pointeur et on travail avec!
*/
__device__ void work(uchar4* tabPixelsGM , uint w , uint h , float t , Sphere* tabSpheresDev , int nbSpheres)
{
// TODO Raytracing work device side
// create RaytracingMath
// entrelacement
}
/*--------------------------------------*\
|* optimisation *|
\*-------------------------------------*/
__device__ void copyDevtoSM(Sphere* tabSphereSM , Sphere* tabSphereDev , int nbSpheres)
{
// TODO Raytracing
// v1 : copie sphere par sphere
{
// TODO en parallel
// Contraintes:
// (C1) En parallel
// (C2) Tous les threads doivent participer
}
// v2 : Optimisation (eviter les banks conflicts) copie de la zone memoire float par float,(ie 4 octets par 4 octets)
// {
// float* tabSM = (float*)(void*)tabSphereSM;
// float* tabDev = (float*)(void*)tabSphereDev;
// int n = nbSpheres * sizeof(Sphere) / sizeof(float);
//
// copyDevtoSM(tabSM, tabDev, n); // TODO coder copyDevtoSM ci-dessous
// }
}
/**
* tabSphereDev peut etre en GM ou en CM
* source tabDev
* destination tabSM
*/
__device__ void copyDevtoSM(float* tabSM , float* tabDev , int n)
{
// TODO Raytracing
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,279 @@
#include "Raytracing.h"
#include <iostream>
#include <assert.h>
#include "MM.h"
#include "GM.h"
#include "SphereCreator.h"
#include "Hardware.h"
#include "nbSphere.h"
#include "Bandwidth.h"
#include "ChronoFactory.h"
#include "Kernel.h"
using std::cout;
using std::endl;
using std::string;
/*--------------------------------------*\
|* Imported *|
\*-------------------------------------*/
__global__ void kernelRaytacingGM(uchar4* tabPixelsGM , uint w , uint h , float t , Sphere* tabSpheresGM , int nbSpheres);
__global__ void kernelRaytacingSM(uchar4* tabPixelsGM , uint w , uint h , float t , Sphere* tabSpheresGM , int nbSpheres);
__global__ void kernelRaytacingCM(uchar4* tabPixelsGM , uint w , uint h , float t , int nbSpheres);
__global__ void kernelRaytacingCM2SM(uchar4* tabPixelsGM , uint w , uint h , float t , int nbSpheres);
__host__ void uploadToCM(Sphere* tabSpheres , int nbSpheres);
/*--------------------------------------*\
|* Private *|
\*-------------------------------------*/
static string titre(const MemoryType& memoryType);
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
/*--------------------------------------*\
|* Constructeur *|
\*-------------------------------------*/
Raytracing::Raytracing(const Grid& grid , uint w , uint h , float dt , bool isVerbose , int nbSpheres , MemoryType memoryType) : //
Animable_I<uchar4>(grid, w, h, titre(memoryType), isVerbose), // super classe
memoryType(memoryType), //
dt(dt), //
nbSpheres(nbSpheres)
{
// Tools
this->sizeSpheres = nbSpheres * sizeof(Sphere);
this->t = 0;
// spheres
{
Chrono* ptrChrono = ChronoFactory::create();
SphereCreator sphereCreator(nbSpheres, w, h);
ptrChrono->stop();
if (isVerbose)
{
cout << "\n[SphereCreator] : " << *ptrChrono << endl;
}
delete ptrChrono;
uploadToDevice(sphereCreator.getTabSphere());
} // SphereCreator depiler, donc detruit, tabSphere cote host detruit!
}
Raytracing::~Raytracing()
{
switch (memoryType)
{
case GM:
{
// TODO Raytracing GM
assert(false); // to be removed once implemented
break;
}
case CM:
{
// Indication: Rien a detruire pour la CM
// Note : La duree de vie pour la CM est une duree processus.
// TODO Raytracing CM
assert(false); // to be removed once implemented
break;
}
case SM: // ou GM2SM (synonyme)
{
// Indication: Rien a detruire pour la SM
// Note : La duree de vie pour la SM est une duree de vie de kernel, seulement!
// Warning: Par contre si vous avez eu besoin de GM, il faut détruire la GM
// TODO Raytracing SM
assert(false); // to be removed once implemented
break;
}
case CM2SM:
{
// TODO Raytracing CM2SM
assert(false); // to be removed once implemented
break;
}
}
}
/*--------------------------------------*\
|* Methode *|
\*-------------------------------------*/
/**
* Override
*/
void Raytracing::process(uchar4* tabPixelsGM , uint w , uint h , const DomaineMath& domaineMath)
{
switch (memoryType)
{
case GM:
{
// Indication : Call the kernel kernelRaytacingGM (prototype at line 23, about)
// TODO Raytracing GM
assert(false); // to be removed once implemented
break;
}
case CM:
{
// TODO Raytracing SM
assert(false); // to be removed once implemented
break;
}
case SM:
{
// TODO Raytracing CM (attention a specifier la taille de tabSm <<<dg,db,sizeTabSM>>>
assert(false); // to be removed once implemented
break;
}
case CM2SM:
{
// TODO Raytracing CM2SM (attention a specifier la taille de tabSm <<<dg,db,sizeTabSM>>>
assert(false); // to be removed once implemented
break;
break;
}
}
}
/**
* Override
*/
void Raytracing::animationStep()
{
t += dt;
}
/**
* Override
*/
double Raytracing::getInputGO()
{
return NB_SPHERE * sizeof(Sphere) / ((double)1024 * (double)1024 * (double)1024);
}
/*--------------------------------------*\
|* Private *|
\*-------------------------------------*/
void Raytracing::uploadToDevice(Sphere* tabSpheres)
{
Bandwidth bandwidth(sizeSpheres, "\n" + titre(memoryType) + " : Host -> Device :");
switch (memoryType)
{
case GM:
{
// But : copier les spheres en GM
// Indicastions:
// (I1) MM pour la GM ( malloc et memcpy)
// (I2) Utiliser la classe GM
// (I3) Regarder bien les attributs de la classe dans le Raytracing.h
// TODO Raytracing GM uploadToDevice
assert(false); // to be removed once implemented
break;
}
case SM: // ou GM2SM (synonyme)
{
// Indications:
// (I1) Coter device, on copie GM to SM
// (I2) Il faut donc d'abord copier les spheres sur le device!
// (I3) Le code est donc le meme que GM
// TODO Raytracing SM uploadToDevice
assert(false); // to be removed once implemented
break;
}
case CM:
{
// But :
//
// Copier les spheres en CM
//
// Indications:
//
// (I1) Lisez raytracingCM.cu.h (dans la partie device). Tout est coder.
// (I2) Utiliser uploadToCM
//
// Notes:
//
// (N1) La CM utilise une variable globale cote device : TAB_SPHERES_CM
// (N2) Elle se trouve dans raytracingCM.cu.h (Ligne 12 environ)
// (N3) Pour cette raison:
// (a) Ce .h est cote device, car ce .h sera inclut cote device dans le fichier du kernel
// (b) On a pas acces cote host a TAB_SPHERES_CM
// (c) On vous fournit raytracingCM.cu.h qui solutionne tous les problemes
// (N4) Le nombre de sphere est defini dans nbSphere.h, qui sera inclut coter host et coter device,
// car on a besoin de connaitre cette quantiter des deux coters
// TODO Raytracing CM uploadToDevice
assert(false); // to be removed once implemented
break;
}
case CM2SM:
{
// Indications:
// (I1)Coter device, on copie CM to SM
// (I2) Il faut donc d'abord copier les spheres en CM
// (I3) Le code est donc le meme que CM
// TODO uploadToDevice CM2SM ://to be removed once implemented
assert(false);
break;
}
}
if (isVerbose)
{
cout << endl << bandwidth << endl;
}
}
string titre(const MemoryType& memoryType)
{
switch (memoryType)
{
case GM:
return "Raytracing-GM-uchar4";
case CM:
return "Raytracing-CM-uchar4";
case SM:
return "Raytracing-GM2SM-uchar4";
case CM2SM:
return "Raytracing-CM2SM-uchar4";
default:
{
assert(false);
return "ERROR";
}
}
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,72 @@
#pragma once
#include "cudas.h"
#include "Animable_I.h"
#include "Sphere.h"
#include "memoryType.h"
/*----------------------------------------------------------------------*\
|* Declaration *|
\*---------------------------------------------------------------------*/
class Raytracing: public Animable_I<uchar4>
{
/*--------------------------------------*\
|* Constructor *|
\*-------------------------------------*/
public:
Raytracing(const Grid& grid , uint w , uint h , float dt ,bool isVerbose ,int nbSpheres , MemoryType memoryType);
virtual ~Raytracing(void);
/*--------------------------------------*\
|* Methodes *|
\*-------------------------------------*/
public:
/*-------------------------*\
|* Override Animable_I *|
\*------------------------*/
/**
* Call periodicly by the api
*/
virtual void process(uchar4* tabPixelsGM , uint w , uint h , const DomaineMath& domaineMath);
/**
* Call periodicly by the api
*/
virtual void animationStep();
/**
* Override
*/
virtual double getInputGO();
private:
/*--------------------------------------*\
|* Attributs *|
\*-------------------------------------*/
void uploadToDevice(Sphere* tabSpheres);
private:
// Inputs
int nbSpheres;
float dt; // animation
// Tools
size_t sizeSpheres;
Sphere* tabSpheresGM;
MemoryType memoryType;
};
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,85 @@
#pragma once
#include <iostream>
#include <assert.h>
#include "Grid.h"
#include "Hardware.h"
#include "memoryType.h"
#include "Couts.h"
/*----------------------------------------------------------------------*\
|* Impelmentation *|
\*---------------------------------------------------------------------*/
namespace raytracing
{
class BestGrid
{
public:
static Grid get(MemoryType memoryType)
{
const int MP = Hardware::getMPCount();
const int CORE_MP = Hardware::getCoreCountMP();
switch (memoryType)
{
case GM:
{
// to remove once coded
{
Couts::redln("aie aie aie, your best grid won t build itself");
assert(false);
}
// TODO Raytracing
}
case CM:
{
// to remove once coded
{
Couts::redln("aie aie aie, your best grid won t build itself");
assert(false);
}
// TODO Raytracing
}
case SM:
{
// to remove once coded
{
Couts::redln("aie aie aie, your best grid won t build itself");
assert(false);
}
// TODO Raytracing
}
case CM2SM:
{
// to remove once coded
{
Couts::redln("aie aie aie, your best grid won t build itself");
assert(false);
}
// TODO Raytracing
}
default:
{
assert(false);
}
} // switch end
}
}
;
} // namespace
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,27 @@
#include <iostream>
#include "Mandelbrot.h"
#include "Mandelbrot_BestGrid.h"
using std::cout;
using std::cerr;
using std::endl;
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
extern Animable_I<uchar4>* createMandelbrot(const Grid& grid , uint w , uint h , const DomaineMath& domaineMath ,bool isVerbose, int nMin , int nMax)
{
return new Mandelbrot( grid , w , h , domaineMath , isVerbose, nMin , nMax);
}
extern Grid bestGridMandelbrot()
{
return mandelbrot::BestGrid::get();
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,29 @@
#include <iostream>
#include "Raytracing.h"
#include "Raytracing_BestGrid.h"
using std::cout;
using std::cerr;
using std::endl;
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
extern Animable_I<uchar4>* createRaytracing(const Grid& grid , uint w , uint h , float dt , bool isVerbose , int nbSpheres , MemoryType memoryType)
{
return new Raytracing(grid, w, h, dt, isVerbose, nbSpheres, memoryType);
}
extern Grid bestGridRaytracing(MemoryType memoryType)
{
return raytracing::BestGrid::get(memoryType);
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,27 @@
#include <iostream>
#include "Rippling.h"
#include "Rippling_BestGrid.h"
using std::cout;
using std::cerr;
using std::endl;
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
extern Animable_I<uchar4>* createRippling(const Grid& grid , uint w , uint h , float dt , bool isVerbose)
{
return new Rippling(grid, w, h, dt, isVerbose);
}
extern Grid bestGridRippling()
{
return rippling::BestGrid::get();
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,57 @@
#include <iostream>
#include "CudaContextImage.h"
#include "Limits.h"
using std::cout;
using std::cerr;
using std::endl;
/*----------------------------------------------------------------------*\
|* Imported *|
\*---------------------------------------------------------------------*/
extern int mainImage(const Args& args);
extern int mainBenchmark();
extern int mainBrutforce();
extern int mainTest();
/*----------------------------------------------------------------------*\
|* private *|
\*---------------------------------------------------------------------*/
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
int main(int argc , char** argv)
{
CudaContextImage cudaContext;
// public
{
cudaContext.deviceId = 2; // in [0,2] width Server Cuda3
cudaContext.launchMode = LaunchModeImage::IMAGE; // IMAGE BENCHMARKING BRUTFORCE TESTING
cudaContext.deviceDriver = DeviceDriver::LOAD_CURRENT; // LOAD_CURRENT LOAD_ALL
cudaContext.deviceInfo = DeviceInfo::ALL_SIMPLE; // NONE ALL ALL_SIMPLE CURRENT
}
// private
{
cudaContext.args.argc = argc;
cudaContext.args.argv = argv;
cudaContext.mainImage = mainImage;
cudaContext.mainBenchmark = mainBenchmark;
cudaContext.mainBrutforce = mainBrutforce;
cudaContext.mainTest = mainTest;
}
return cudaContext.process();
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,110 @@
#include <iostream>
#include <stdlib.h>
#include "RipplingProvider.h"
#include "MandelbrotProvider.h"
#include "RaytracingProviderGM.h"
#include "RaytracingProviderSM.h"
#include "RaytracingProviderCM.h"
#include "RaytracingProviderCM2SM.h"
#include "BenchmarkImage.h"
using std::cout;
using std::endl;
/*----------------------------------------------------------------------*\
|* Declaration *|
\*---------------------------------------------------------------------*/
/*--------------------------------------*\
|* Private *|
\*-------------------------------------*/
static void rippling();
static void mandelbrot();
static void raytracingGM();
static void raytracingCM();
static void raytracingSM();
static void raytracingCM2SM();
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
int mainBenchmark()
{
// Please, un a la fois!
rippling();
// mandelbrot(); // Conseil : use nFixe (by example nMin=nMax=80)
//
// raytracingGM();
// raytracingSM();
// raytracingCM();
// raytracingCM2SM();
return EXIT_SUCCESS;
}
/*--------------------------------------*\
|* Private *|
\*-------------------------------------*/
void rippling()
{
const double DURATION_MAX_S = 8;
RipplingProvider provider;
BenchmarkImage<uchar4>::run(&provider, DURATION_MAX_S);
}
void mandelbrot()
{
const double DURATION_MAX_S = 8;
MandelbrotProvider provider;
BenchmarkImage<uchar4>::run(&provider, DURATION_MAX_S);
}
void raytracingGM()
{
const double DURATION_MAX_S = 8;
RaytracingProviderGM provider;
BenchmarkImage<uchar4>::run(&provider, DURATION_MAX_S);
}
void raytracingCM()
{
const double DURATION_MAX_S = 8;
RaytracingProviderCM provider;
BenchmarkImage<uchar4>::run(&provider, DURATION_MAX_S);
}
void raytracingSM()
{
const double DURATION_MAX_S = 8;
RaytracingProviderSM provider;
BenchmarkImage<uchar4>::run(&provider, DURATION_MAX_S);
}
void raytracingCM2SM()
{
const double DURATION_MAX_S = 8;
RaytracingProviderCM2SM provider;
BenchmarkImage<uchar4>::run(&provider, DURATION_MAX_S);
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,147 @@
#include <iostream>
#include <stdlib.h>
#include "Iterator.h"
#include "BruteForce.h"
#include "Hardware.h"
#include "RipplingProvider.h"
#include "MandelbrotProvider.h"
#include "RaytracingProviderGM.h"
#include "RaytracingProviderSM.h"
#include "RaytracingProviderCM.h"
#include "RaytracingProviderCM2SM.h"
using std::cerr;
using std::cout;
using std::endl;
using std::to_string;
/*----------------------------------------------------------------------*\
|* Declaration *|
\*---------------------------------------------------------------------*/
/*--------------------------------------*\
|* Private *|
\*-------------------------------------*/
static void rippling(Matlab* ptrMatlab);
static void mandelbrot(Matlab* ptrMatlab);
static void raytracingGM(Matlab* ptrMatlab);
static void raytracingCM(Matlab* ptrMatlab);
static void raytracingSM(Matlab* ptrMatlab);
static void raytracingCM2SM(Matlab* ptrMatlab);
//tools
template<typename T>
static void bruteForce(ProviderUse_I* ptrProviderUse , Matlab* ptrMatlab , const PlotType& plotType , double durationMaxS = 0.5);
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
int mainBrutforce()
{
Matlab matlab;
// Please, un a la fois!
rippling(&matlab);
// mandelbrot(&matlab); // Conseil : use nFixe (by example nMin=nMax=100)
// raytracingGM(&matlab);
// raytracingCM(&matlab);
// raytracingSM(&matlab);
// raytracingCM2SM(&matlab);
matlab.play();
return EXIT_SUCCESS;
}
/*--------------------------------------*\
|* Private *|
\*-------------------------------------*/
void rippling(Matlab* ptrMatlab)
{
const double DURATION_MAX_S = 0.01; // 0.9 1 grid
const PlotType PLOT_TYPE = PlotType::ALL_GRAPHE;
RipplingProvider provider;
bruteForce<uchar4>((ProviderUse_I*)&provider, ptrMatlab, PLOT_TYPE, DURATION_MAX_S);
}
void mandelbrot(Matlab* ptrMatlab)
{
const double DURATION_MAX_S = 0.4; // 1 grid
const PlotType PLOT_TYPE = PlotType::ALL_GRAPHE;
MandelbrotProvider provider;
bruteForce<uchar4>((ProviderUse_I*)&provider, ptrMatlab, PLOT_TYPE, DURATION_MAX_S);
}
void raytracingGM(Matlab* ptrMatlab)
{
const double DURATION_MAX_S = 0.9; // 1 grid
const PlotType PLOT_TYPE = PlotType::ALL_GRAPHE;
RaytracingProviderGM provider;
bruteForce<uchar4>((ProviderUse_I*)&provider, ptrMatlab, PLOT_TYPE, DURATION_MAX_S);
}
void raytracingSM(Matlab* ptrMatlab)
{
const double DURATION_MAX_S = 0.9; // 1 grid
const PlotType PLOT_TYPE = PlotType::ALL_GRAPHE;
RaytracingProviderSM provider;
bruteForce<uchar4>((ProviderUse_I*)&provider, ptrMatlab, PLOT_TYPE, DURATION_MAX_S);
}
void raytracingCM(Matlab* ptrMatlab)
{
const double DURATION_MAX_S = 0.9; // 1 grid
const PlotType PLOT_TYPE = PlotType::ALL_GRAPHE;
RaytracingProviderCM provider;
bruteForce<uchar4>((ProviderUse_I*)&provider, ptrMatlab, PLOT_TYPE, DURATION_MAX_S);
}
void raytracingCM2SM(Matlab* ptrMatlab)
{
const double DURATION_MAX_S = 0.9; // 1 grid
const PlotType PLOT_TYPE = PlotType::ALL_GRAPHE;
RaytracingProviderCM2SM provider;
bruteForce<uchar4>((ProviderUse_I*)&provider, ptrMatlab, PLOT_TYPE, DURATION_MAX_S);
}
/*--------------------------------------*\
|* Tools *|
\*-------------------------------------*/
template<typename T>
void bruteForce(ProviderUse_I* ptrProviderUse , Matlab* ptrMatlab , const PlotType& plotType , double durationMaxS)
{
// Hardware
const int MP = Hardware::getMPCount();
const int CORE_MP = Hardware::getCoreCountMP();
const int NB_THREAD_BLOCK_MAX = Hardware::getMaxThreadPerBlock();
const int WARP_SIZE = Hardware::getWarpSize();
// dg
Iterator iteratorDGx(MP, 10 * MP, MP, Operator::ADD); // (min,max,step)
// db
Iterator iteratorDBx(CORE_MP, NB_THREAD_BLOCK_MAX, CORE_MP, Operator::ADD);
// Iterator iteratorDBx(WARP_SIZE, NB_THREAD_BLOCK_MAX, WARP_SIZE, Operator::ADD);
// Iterator iteratorDBx(CORE_MP, NB_THREAD_BLOCK_MAX, 2, Operator::MULTIPLY); // power2 (reduction)
// gridMaillage
GridMaillage gridMaillage(iteratorDGx, iteratorDBx);
BruteForce::run(ptrProviderUse, &gridMaillage, ptrMatlab, plotType, durationMaxS);
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,51 @@
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include "Args.h"
#include "cudas.h"
#include "RipplingProvider.h"
#include "MandelbrotProvider.h"
// Raytracing
#include "RaytracingProviderGM.h"
#include "RaytracingProviderSM.h"
#include "RaytracingProviderCM.h"
#include "RaytracingProviderCM2SM.h"
#include "Viewer.h"
using std::cout;
using std::endl;
using std::string;
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
int mainImage(const Args& args)
{
gpu::GLUTImageViewers::init(args.argc, args.argv); //only once
// ImageOption : (boolean,boolean) : (isSelection ,isAnimation,isOverlay,isShowHelp)
ImageOption zoomable(true, true, true, true);
ImageOption nozoomable(false, true, false, false);
Viewer<RipplingProvider> rippling(nozoomable, 0, 0); // imageOption px py
// Viewer<MandelbrotProvider> mandelbrot(zoomable, 0, 0);
// Viewer<RaytracingProviderGM> raytracingGM(nozoomable, 0, 0);
// Viewer<RaytracingProviderCM> raytracingCM(nozoomable, 0, 0);
// Viewer<RaytracingProviderSM> raytracingSM(nozoomable, 0, 0);
// Viewer<RaytracingProviderCM2SM> raytracingCM2SM(nozoomable, 0, 0);
// Common
gpu::GLUTImageViewers::runALL(); // Bloquant, Tant qu'une fenetre est ouverte
return EXIT_SUCCESS;
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/

View File

@@ -0,0 +1,87 @@
#include <stdlib.h>
#include <iostream>
#include "VTRippling.h"
#include "VTMandelbrot.h"
#include "VTRaytracingGM.h"
#include "VTRaytracingSM.h"
#include "VTRaytracingCM.h"
#include "VTRaytracingCM2SM.h"
#include "real_mandelbrot.h"
using std::string;
using std::cout;
using std::endl;
/*----------------------------------------------------------------------*\
|* Declaration *|
\*---------------------------------------------------------------------*/
static void rippling();
static void mandelbrot();
static void raytracing();
/*----------------------------------------------------------------------*\
|* Implementation *|
\*---------------------------------------------------------------------*/
/*--------------------------------------*\
|* Public *|
\*-------------------------------------*/
int mainTest()
{
// activer ci-dessous seulement le TP voulu (pas tous)
rippling();
//mandelbrot(); // fp16 only
//raytracing(); // voir code ci-dessous pour activer la version voulue
return EXIT_SUCCESS;
}
/*--------------------------------------*\
|* private *|
\*-------------------------------------*/
void rippling()
{
VTRippling test1;
test1.run();
}
/**
* fp16 only
*/
void mandelbrot()
{
assert(mandelbrotReal::isFp16());
VTMandelbrot test1;
test1.run();
}
/**
* activer ci-dessous la version souhaiter
*/
void raytracing()
{
VTRaytracingGM test1;
VTRaytracingSM test2;
VTRaytracingCM test3;
VTRaytracingCM2SM test4;
test1.run();
// test2.run();
// test3.run();
// test4.run();
}
/*----------------------------------------------------------------------*\
|* End *|
\*---------------------------------------------------------------------*/