feat(Mandelbrot): add TP mandelbrot
This commit is contained in:
140
Student_Cuda_Image/out/Mandelbrot_fp16_justesse.html
Normal file
140
Student_Cuda_Image/out/Mandelbrot_fp16_justesse.html
Normal file
@@ -0,0 +1,140 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="CppTest - https://github.com/cpptest/cpptest" />
|
||||
|
||||
<title>Mandelbrot_fp16_justesse </title>
|
||||
|
||||
<style type="text/css" media="screen">
|
||||
<!--
|
||||
hr {
|
||||
width: 100%;
|
||||
border-width: 0px;
|
||||
height: 1px;
|
||||
color: #cccccc;
|
||||
background-color: #cccccc;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
table {
|
||||
width:100%;
|
||||
border-collapse:separate;
|
||||
border-spacing: 2px;
|
||||
border:0px;
|
||||
}
|
||||
tr {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
td {
|
||||
margin:0px;
|
||||
padding:1px;
|
||||
}
|
||||
.table_summary {
|
||||
}
|
||||
.table_suites {
|
||||
}
|
||||
.table_suite {
|
||||
}
|
||||
.table_result {
|
||||
margin: 0px 0px 1em 0px;
|
||||
}
|
||||
.tablecell_title {
|
||||
background-color: #a5cef7;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tablecell_success {
|
||||
background-color: #efefe7;
|
||||
}
|
||||
|
||||
.tablecell_error {
|
||||
color: #ff0808;
|
||||
background-color: #efefe7;
|
||||
font-weight: bold;
|
||||
}
|
||||
p.spaced {
|
||||
margin: 0px;
|
||||
padding: 1em 0px 2em 0px;
|
||||
}
|
||||
p.unspaced {
|
||||
margin: 0px;
|
||||
padding: 0px 0px 2em 0px;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1><a name="top"></a>Mandelbrot_fp16_justesse </h1>
|
||||
|
||||
<div style="text-align:right">
|
||||
Designed by <a href="https://github.com/cpptest/cpptest">CppTest</a>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<h2>Summary</h2>
|
||||
<table summary="Summary of test results" class="table_summary">
|
||||
<tr>
|
||||
<td style="width:30%" class="tablecell_title">Tests</td>
|
||||
<td style="width:30%" class="tablecell_title">Errors</td>
|
||||
<td style="width:30%" class="tablecell_title">Success</td>
|
||||
<td style="width:10%" class="tablecell_title">Time (s)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:30%" class="tablecell_success">1</td>
|
||||
<td style="width:30%" class="tablecell_success">0</td>
|
||||
<td style="width:30%" class="tablecell_success">100%</td>
|
||||
<td style="width:10%" class="tablecell_success">2.000000</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr />
|
||||
|
||||
<h2>Test suites</h2>
|
||||
<table summary="Test Suites" class="table_suites">
|
||||
<tr>
|
||||
<td class="tablecell_title">Name</td>
|
||||
<td style="width:10%" class="tablecell_title">Tests</td>
|
||||
<td style="width:10%" class="tablecell_title">Errors</td>
|
||||
<td style="width:10%" class="tablecell_title">Success</td>
|
||||
<td style="width:10%" class="tablecell_title">Time (s)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tablecell_success"><a href="#TestImageCuda">TestImageCuda</a></td>
|
||||
<td style="width:10%" class="tablecell_success">1</td>
|
||||
<td style="width:10%" class="tablecell_success">0</td>
|
||||
<td style="width:10%" class="tablecell_success">100%</td>
|
||||
<td style="width:10%" class="tablecell_success">2.000000</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr />
|
||||
|
||||
<h3><a name="TestImageCuda"></a>Suite: TestImageCuda</h3>
|
||||
<table summary="Details for suite TestImageCuda" class="table_suite">
|
||||
<tr>
|
||||
<td class="tablecell_title">Name</td>
|
||||
<td style="width:10%" class="tablecell_title">Errors</td>
|
||||
<td style="width:10%" class="tablecell_title">Success</td>
|
||||
<td style="width:10%" class="tablecell_title">Time (s)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tablecell_success">allTests</td>
|
||||
<td class="tablecell_success">0</td>
|
||||
<td class="tablecell_success">true</td>
|
||||
<td class="tablecell_success">2.000000</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="spaced"><a href="#top">Back to top</a>
|
||||
</p>
|
||||
<hr />
|
||||
|
||||
|
||||
<p>
|
||||
<a href="http://validator.w3.org/#validate-by-upload">
|
||||
Valid XHTML 1.0 Strict
|
||||
</a>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
140
Student_Cuda_Image/out/Mandelbrot_fp16_performance.html
Normal file
140
Student_Cuda_Image/out/Mandelbrot_fp16_performance.html
Normal file
@@ -0,0 +1,140 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="CppTest - https://github.com/cpptest/cpptest" />
|
||||
|
||||
<title>Mandelbrot_fp16_performance </title>
|
||||
|
||||
<style type="text/css" media="screen">
|
||||
<!--
|
||||
hr {
|
||||
width: 100%;
|
||||
border-width: 0px;
|
||||
height: 1px;
|
||||
color: #cccccc;
|
||||
background-color: #cccccc;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
table {
|
||||
width:100%;
|
||||
border-collapse:separate;
|
||||
border-spacing: 2px;
|
||||
border:0px;
|
||||
}
|
||||
tr {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
td {
|
||||
margin:0px;
|
||||
padding:1px;
|
||||
}
|
||||
.table_summary {
|
||||
}
|
||||
.table_suites {
|
||||
}
|
||||
.table_suite {
|
||||
}
|
||||
.table_result {
|
||||
margin: 0px 0px 1em 0px;
|
||||
}
|
||||
.tablecell_title {
|
||||
background-color: #a5cef7;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tablecell_success {
|
||||
background-color: #efefe7;
|
||||
}
|
||||
|
||||
.tablecell_error {
|
||||
color: #ff0808;
|
||||
background-color: #efefe7;
|
||||
font-weight: bold;
|
||||
}
|
||||
p.spaced {
|
||||
margin: 0px;
|
||||
padding: 1em 0px 2em 0px;
|
||||
}
|
||||
p.unspaced {
|
||||
margin: 0px;
|
||||
padding: 0px 0px 2em 0px;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1><a name="top"></a>Mandelbrot_fp16_performance </h1>
|
||||
|
||||
<div style="text-align:right">
|
||||
Designed by <a href="https://github.com/cpptest/cpptest">CppTest</a>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<h2>Summary</h2>
|
||||
<table summary="Summary of test results" class="table_summary">
|
||||
<tr>
|
||||
<td style="width:30%" class="tablecell_title">Tests</td>
|
||||
<td style="width:30%" class="tablecell_title">Errors</td>
|
||||
<td style="width:30%" class="tablecell_title">Success</td>
|
||||
<td style="width:10%" class="tablecell_title">Time (s)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:30%" class="tablecell_success">1</td>
|
||||
<td style="width:30%" class="tablecell_success">0</td>
|
||||
<td style="width:30%" class="tablecell_success">100%</td>
|
||||
<td style="width:10%" class="tablecell_success">12.000000</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr />
|
||||
|
||||
<h2>Test suites</h2>
|
||||
<table summary="Test Suites" class="table_suites">
|
||||
<tr>
|
||||
<td class="tablecell_title">Name</td>
|
||||
<td style="width:10%" class="tablecell_title">Tests</td>
|
||||
<td style="width:10%" class="tablecell_title">Errors</td>
|
||||
<td style="width:10%" class="tablecell_title">Success</td>
|
||||
<td style="width:10%" class="tablecell_title">Time (s)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tablecell_success"><a href="#TestPerformance_RunnableGPU_A">TestPerformance_RunnableGPU_A</a></td>
|
||||
<td style="width:10%" class="tablecell_success">1</td>
|
||||
<td style="width:10%" class="tablecell_success">0</td>
|
||||
<td style="width:10%" class="tablecell_success">100%</td>
|
||||
<td style="width:10%" class="tablecell_success">12.000000</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr />
|
||||
|
||||
<h3><a name="TestPerformance_RunnableGPU_A"></a>Suite: TestPerformance_RunnableGPU_A</h3>
|
||||
<table summary="Details for suite TestPerformance_RunnableGPU_A" class="table_suite">
|
||||
<tr>
|
||||
<td class="tablecell_title">Name</td>
|
||||
<td style="width:10%" class="tablecell_title">Errors</td>
|
||||
<td style="width:10%" class="tablecell_title">Success</td>
|
||||
<td style="width:10%" class="tablecell_title">Time (s)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tablecell_success">performanceOnly</td>
|
||||
<td class="tablecell_success">0</td>
|
||||
<td class="tablecell_success">true</td>
|
||||
<td class="tablecell_success">12.000000</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="spaced"><a href="#top">Back to top</a>
|
||||
</p>
|
||||
<hr />
|
||||
|
||||
|
||||
<p>
|
||||
<a href="http://validator.w3.org/#validate-by-upload">
|
||||
Valid XHTML 1.0 Strict
|
||||
</a>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,10 @@
|
||||
64,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024
|
||||
64,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024
|
||||
64,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024
|
||||
64,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024
|
||||
64,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024
|
||||
64,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024
|
||||
64,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024
|
||||
64,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024
|
||||
64,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024
|
||||
64,128,192,256,320,384,448,512,576,640,704,768,832,896,960,1024
|
||||
|
@@ -0,0 +1,10 @@
|
||||
68,68,68,68,68,68,68,68,68,68,68,68,68,68,68,68
|
||||
136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136
|
||||
204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204
|
||||
272,272,272,272,272,272,272,272,272,272,272,272,272,272,272,272
|
||||
340,340,340,340,340,340,340,340,340,340,340,340,340,340,340,340
|
||||
408,408,408,408,408,408,408,408,408,408,408,408,408,408,408,408
|
||||
476,476,476,476,476,476,476,476,476,476,476,476,476,476,476,476
|
||||
544,544,544,544,544,544,544,544,544,544,544,544,544,544,544,544
|
||||
612,612,612,612,612,612,612,612,612,612,612,612,612,612,612,612
|
||||
680,680,680,680,680,680,680,680,680,680,680,680,680,680,680,680
|
||||
|
@@ -0,0 +1,10 @@
|
||||
11261,21977,27704,28654,28277,28547,28629,28404,28310,28099,28086,28083,27716,27519,27791,28011
|
||||
19038,28186,28672,29112,28426,28273,28146,28144,27978,27624,27759,27741,27325,27066,27341,27544
|
||||
27172,28378,27808,28260,28006,28038,27917,27990,27496,27172,27343,27313,26925,26740,26918,27046
|
||||
27677,28301,27408,28080,27452,27837,27162,27780,27046,26611,26934,26825,26609,26218,26593,26529
|
||||
27585,27504,27616,27705,27863,27826,27102,27073,26633,26380,26509,26507,26361,25949,26339,26248
|
||||
26661,27570,27783,28103,27632,27613,27589,27606,26069,25936,26088,26036,26011,25575,25894,25830
|
||||
27632,27463,27391,27489,27242,27606,27584,26880,25818,25521,25840,25693,25640,25316,25482,25309
|
||||
27657,27392,27302,27627,27038,27244,26594,27163,25196,24997,25035,25023,24712,24685,24668,24540
|
||||
25842,24673,26280,26057,26492,25605,26130,25341,24431,23305,24874,23801,24877,23471,24577,23293
|
||||
23284,25709,25062,26164,25511,27316,25176,24768,23921,22530,23529,22545,23692,22471,24333,22815
|
||||
|
@@ -20,19 +20,36 @@ static __device__ void color(uchar4* ptrColor,int k, int n);
|
||||
|* Implementation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
__global__ void mandelbrot(uchar4* tabPixelsGM , uint w , uint h , DomaineMath domaineMath , int n)
|
||||
{
|
||||
__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;
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
|
||||
const int TID = Thread2D::tid();
|
||||
const int NB_THREAD = Thread2D::nbThread();
|
||||
const int WH = w * h;
|
||||
|
||||
MandelbrotMath mm(n);
|
||||
|
||||
int s = TID;
|
||||
|
||||
while ( s < WH) {
|
||||
int i = s / w;
|
||||
int j = s % w;
|
||||
domaineMath.toXY(i, j, &x, &y);
|
||||
mm.colorXY(&tabPixelsGM[s], (real)x, (real)y);
|
||||
s += NB_THREAD;
|
||||
}
|
||||
|
||||
//domaineMath.toXY(i, j, &x, &y); // x et y doivent etre en double! Caster ensuite en real lors du passage à colorXY
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* private *|
|
||||
@@ -42,8 +59,8 @@ __global__ void mandelbrot(uchar4* tabPixelsGM , uint w , uint h , DomaineMath d
|
||||
* optimisation lookup table color (facultatif)
|
||||
*/
|
||||
__inline__
|
||||
__device__ void fill(uchar4* tabSM,int n)
|
||||
{
|
||||
__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
|
||||
@@ -54,18 +71,17 @@ __device__ void fill(uchar4* tabSM,int n)
|
||||
// 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)
|
||||
{
|
||||
__device__
|
||||
void color(uchar4* ptrColor,int k, int n) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -33,25 +33,24 @@ using mandelbrotReal::real;
|
||||
#define ZERO 0.0
|
||||
#endif
|
||||
|
||||
class MandelbrotMath
|
||||
{
|
||||
class MandelbrotMath {
|
||||
/*--------------------------------------*\
|
||||
|* Constructeur *|
|
||||
\*-------------------------------------*/
|
||||
|
||||
public:
|
||||
|
||||
__device__ MandelbrotMath(int n) : //
|
||||
n(n)
|
||||
{
|
||||
__device__
|
||||
MandelbrotMath(int n) : //
|
||||
n(n) {
|
||||
// rien
|
||||
}
|
||||
}
|
||||
|
||||
__device__
|
||||
virtual ~MandelbrotMath()
|
||||
{
|
||||
virtual
|
||||
~MandelbrotMath() {
|
||||
// rien
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------*\
|
||||
|* Methode *|
|
||||
@@ -60,8 +59,7 @@ class MandelbrotMath
|
||||
public:
|
||||
|
||||
__device__
|
||||
void colorXY(uchar4* ptrColorIJ , real x , real y)
|
||||
{
|
||||
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
|
||||
@@ -75,12 +73,30 @@ class MandelbrotMath
|
||||
// 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
|
||||
}
|
||||
// {
|
||||
// ptrColorIJ->x = 128;
|
||||
// ptrColorIJ->y = 128;
|
||||
// ptrColorIJ->z = 128;
|
||||
// ptrColorIJ->w = 255; // opacity facultatif
|
||||
// }
|
||||
|
||||
int itr = suite(x, y);
|
||||
|
||||
if (itr >= n) {
|
||||
ptrColorIJ->x = 0;
|
||||
ptrColorIJ->y = 0;
|
||||
ptrColorIJ->z = 0;
|
||||
ptrColorIJ->w = 255; // opacity facultatif
|
||||
} else {
|
||||
Colors::HSB_TO_RVB(
|
||||
( (float)itr ) / ( (float)(this->n-1) ),
|
||||
1.f,
|
||||
1.f,
|
||||
ptrColorIJ
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -90,20 +106,35 @@ class MandelbrotMath
|
||||
*/
|
||||
__inline__
|
||||
__device__
|
||||
int suite(real x , real y)
|
||||
{ // TODO Mandelbrot
|
||||
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)
|
||||
// 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
|
||||
}
|
||||
// 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
|
||||
|
||||
real a = ZERO;
|
||||
real b = ZERO;
|
||||
real tmp = ZERO;
|
||||
|
||||
int itr = -1;
|
||||
|
||||
while ( (a*a + b*b <= QUATRE) && (itr < n) ) {
|
||||
tmp = a;
|
||||
a = x + (a*a - b*b);
|
||||
b = DEUX * tmp * b + y;
|
||||
itr++;
|
||||
}
|
||||
|
||||
return itr;
|
||||
|
||||
}
|
||||
|
||||
/////////////////////
|
||||
// Warning:
|
||||
@@ -150,7 +181,7 @@ class MandelbrotMath
|
||||
// Inputs
|
||||
int n;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
|
||||
@@ -40,10 +40,9 @@ Mandelbrot::Mandelbrot(const Grid& grid , uint w , uint h , const DomaineMath& d
|
||||
// Tools
|
||||
this->t = nMin;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Mandelbrot::~Mandelbrot()
|
||||
{
|
||||
Mandelbrot::~Mandelbrot() {
|
||||
// rien
|
||||
}
|
||||
|
||||
@@ -55,28 +54,24 @@ Mandelbrot::~Mandelbrot()
|
||||
* 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
|
||||
void Mandelbrot::process(uchar4* tabPixelsGM , uint w , uint h , const DomaineMath& domaineMath) {
|
||||
// TODO Mandelbrot
|
||||
// lauch kernel (you find at line 18)
|
||||
}
|
||||
mandelbrot<<<dg,db>>>(tabPixelsGM,w,h,domaineMath,t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override
|
||||
* Call periodicly by the API
|
||||
*/
|
||||
void Mandelbrot::animationStep()
|
||||
{
|
||||
void Mandelbrot::animationStep() {
|
||||
this->t = variateurT.varierAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
string titre(int nMin , int nMax)
|
||||
{
|
||||
string titre(int nMin , int nMax) {
|
||||
return "Mandelbrot-Cuda-uchar4-" + mandelbrotReal::realToString() + "-nMin" + std::to_string(nMin) + "-nMax" + std::to_string(nMax);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
|* Declaration *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
class Mandelbrot: public Animable_I<uchar4>
|
||||
{
|
||||
class Mandelbrot: public Animable_I<uchar4> {
|
||||
/*--------------------------------------*\
|
||||
|* Constructor *|
|
||||
\*-------------------------------------*/
|
||||
@@ -53,7 +52,7 @@ class Mandelbrot: public Animable_I<uchar4>
|
||||
|
||||
// Tools
|
||||
Variateur<int> variateurT;
|
||||
};
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
|* End *|
|
||||
|
||||
@@ -12,49 +12,56 @@
|
||||
|* Impelmentation *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
namespace mandelbrot
|
||||
{
|
||||
namespace mandelbrot {
|
||||
|
||||
class BestGrid
|
||||
{
|
||||
class BestGrid {
|
||||
|
||||
public:
|
||||
|
||||
static Grid get()
|
||||
{
|
||||
const int MP = Hardware::getMPCount();
|
||||
const int CORE_MP = Hardware::getCoreCountMP();
|
||||
static Grid get() {
|
||||
// const int MP = Hardware::getMPCount();
|
||||
// const int CORE_MP = Hardware::getCoreCountMP();
|
||||
|
||||
// fp64 (float 64 bits)
|
||||
#ifdef MANDELBROT_DOUBLE
|
||||
// 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
|
||||
const int MP = Hardware::getMPCount();
|
||||
const int CORE_MP = Hardware::getCoreCountMP();
|
||||
|
||||
// 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
|
||||
dim3 dg(MP, 1, 1);
|
||||
dim3 db(CORE_MP, 1, 1);
|
||||
Grid grid(dg, db);
|
||||
|
||||
// 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
|
||||
return grid;
|
||||
#endif
|
||||
|
||||
// fp32 (float 32 bits)
|
||||
#ifdef MANDELBROT_FLOAT
|
||||
const int MP = Hardware::getMPCount();
|
||||
const int CORE_MP = Hardware::getCoreCountMP();
|
||||
|
||||
dim3 dg(MP, 1, 1);
|
||||
dim3 db(CORE_MP, 1, 1);
|
||||
Grid grid(dg, db);
|
||||
|
||||
return grid;
|
||||
#endif
|
||||
|
||||
// fp16 (float 32 bits)
|
||||
#ifdef MANDELBROT_HALF
|
||||
const int MP = Hardware::getMPCount();
|
||||
const int CORE_MP = Hardware::getCoreCountMP();
|
||||
|
||||
dim3 dg(MP, 2, 1);
|
||||
dim3 db(CORE_MP, 4, 1);
|
||||
Grid grid(dg, db);
|
||||
|
||||
return grid;
|
||||
#endif
|
||||
// default
|
||||
Couts::redln("Oups, something went wrong on BestGrid settings");
|
||||
assert(false); // unknown type
|
||||
return Grid();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -14,107 +14,101 @@
|
||||
\*---------------------*/
|
||||
|
||||
// Choose one of the two (either/either):
|
||||
//#define MANDELBROT_DOUBLE
|
||||
//#define MANDELBROT_FLOAT
|
||||
#define MANDELBROT_HALF
|
||||
// #define MANDELBROT_DOUBLE // fp64
|
||||
// #define MANDELBROT_FLOAT // fp32
|
||||
#define MANDELBROT_HALF // fp16
|
||||
|
||||
/*----------------------*\
|
||||
|* private *|
|
||||
\*---------------------*/
|
||||
|
||||
namespace mandelbrotReal
|
||||
{
|
||||
namespace mandelbrotReal {
|
||||
|
||||
// fp64 (float 64 bits)
|
||||
#ifdef MANDELBROT_DOUBLE
|
||||
//#define real double
|
||||
using real=double;
|
||||
#endif
|
||||
// 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
|
||||
// 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
|
||||
// fp16 (float 16 bits)
|
||||
#ifdef MANDELBROT_HALF
|
||||
//#define real half
|
||||
using real=half;
|
||||
#endif
|
||||
|
||||
static std::string realToString()
|
||||
{
|
||||
static std::string realToString() {
|
||||
|
||||
#ifdef MANDELBROT_DOUBLE
|
||||
return "fp64";
|
||||
#endif
|
||||
#ifdef MANDELBROT_DOUBLE
|
||||
return "fp64";
|
||||
#endif
|
||||
|
||||
#ifdef MANDELBROT_FLOAT
|
||||
return "fp32";
|
||||
#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);
|
||||
}
|
||||
#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 *|
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user