feat(Mandelbrot): add TP mandelbrot

This commit is contained in:
2025-11-27 18:41:30 +01:00
parent a892100308
commit 09ee32383f
11 changed files with 533 additions and 181 deletions

View 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>

View 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>

View File

@@ -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
1 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024
2 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024
3 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024
4 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024
5 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024
6 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024
7 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024
8 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024
9 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024
10 64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024

View File

@@ -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
1 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68
2 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136
3 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204
4 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272 272
5 340 340 340 340 340 340 340 340 340 340 340 340 340 340 340 340
6 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408 408
7 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476 476
8 544 544 544 544 544 544 544 544 544 544 544 544 544 544 544 544
9 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612
10 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680 680

View File

@@ -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
1 11261 21977 27704 28654 28277 28547 28629 28404 28310 28099 28086 28083 27716 27519 27791 28011
2 19038 28186 28672 29112 28426 28273 28146 28144 27978 27624 27759 27741 27325 27066 27341 27544
3 27172 28378 27808 28260 28006 28038 27917 27990 27496 27172 27343 27313 26925 26740 26918 27046
4 27677 28301 27408 28080 27452 27837 27162 27780 27046 26611 26934 26825 26609 26218 26593 26529
5 27585 27504 27616 27705 27863 27826 27102 27073 26633 26380 26509 26507 26361 25949 26339 26248
6 26661 27570 27783 28103 27632 27613 27589 27606 26069 25936 26088 26036 26011 25575 25894 25830
7 27632 27463 27391 27489 27242 27606 27584 26880 25818 25521 25840 25693 25640 25316 25482 25309
8 27657 27392 27302 27627 27038 27244 26594 27163 25196 24997 25035 25023 24712 24685 24668 24540
9 25842 24673 26280 26057 26492 25605 26130 25341 24431 23305 24874 23801 24877 23471 24577 23293
10 23284 25709 25062 26164 25511 27316 25176 24768 23921 22530 23529 22545 23692 22471 24333 22815

View File

@@ -20,19 +20,36 @@ static __device__ void color(uchar4* ptrColor,int k, int n);
|* Implementation *| |* 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 : // TODO Mandelbrot :
// //
// entrelacement // entrelacement
// s -> (i,j) -> (x,y) // s -> (i,j) -> (x,y)
// appeler colorXY // appeler colorXY
double x; double x = 0;
double y; 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 //domaineMath.toXY(i, j, &x, &y); // x et y doivent etre en double! Caster ensuite en real lors du passage à colorXY
} }
/*----------------------------------------------------------------------*\ /*----------------------------------------------------------------------*\
|* private *| |* private *|
@@ -42,8 +59,8 @@ __global__ void mandelbrot(uchar4* tabPixelsGM , uint w , uint h , DomaineMath d
* optimisation lookup table color (facultatif) * optimisation lookup table color (facultatif)
*/ */
__inline__ __inline__
__device__ void fill(uchar4* tabSM,int n) __device__
{ void fill(uchar4* tabSM,int n) {
// Indications: // Indications:
// (I1) tabSM a n cases // (I1) tabSM a n cases
// (I2) La case k contient les couleurs en RVBA lorsque la suite s est arreter a k // (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 // Warning
// (W1) Commencer d'abord sans cette piste d'optimisation // (W1) Commencer d'abord sans cette piste d'optimisation
} }
/** /**
* optimisation lookup table color (facultatif) * optimisation lookup table color (facultatif)
*/ */
__inline__ __inline__
__device__ void color(uchar4* ptrColor,int k, int n) __device__
{ void color(uchar4* ptrColor,int k, int n) {
} }
/*----------------------------------------------------------------------*\ /*----------------------------------------------------------------------*\
|* End *| |* End *|
\*---------------------------------------------------------------------*/ \*---------------------------------------------------------------------*/

View File

@@ -33,23 +33,22 @@ using mandelbrotReal::real;
#define ZERO 0.0 #define ZERO 0.0
#endif #endif
class MandelbrotMath class MandelbrotMath {
{
/*--------------------------------------*\ /*--------------------------------------*\
|* Constructeur *| |* Constructeur *|
\*-------------------------------------*/ \*-------------------------------------*/
public: public:
__device__ MandelbrotMath(int n) : // __device__
n(n) MandelbrotMath(int n) : //
{ n(n) {
// rien // rien
} }
__device__ __device__
virtual ~MandelbrotMath() virtual
{ ~MandelbrotMath() {
// rien // rien
} }
@@ -60,8 +59,7 @@ class MandelbrotMath
public: public:
__device__ __device__
void colorXY(uchar4* ptrColorIJ , real x , real y) void colorXY(uchar4* ptrColorIJ , real x , real y) {
{
// TODO Mandelbrot // TODO Mandelbrot
// Calculer la suite en (x,y) et recuperer l'indice d'arret de la suite // Calculer la suite en (x,y) et recuperer l'indice d'arret de la suite
@@ -80,6 +78,24 @@ class MandelbrotMath
// ptrColorIJ->y = 128; // ptrColorIJ->y = 128;
// ptrColorIJ->z = 128; // ptrColorIJ->z = 128;
// ptrColorIJ->w = 255; // opacity facultatif // 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: private:
@@ -90,8 +106,7 @@ class MandelbrotMath
*/ */
__inline__ __inline__
__device__ __device__
int suite(real x , real y) int suite(real x , real y) { // TODO Mandelbrot
{ // TODO Mandelbrot
// Utiliser dans vos formules les variable : // Utiliser dans vos formules les variable :
// //
@@ -103,6 +118,22 @@ class MandelbrotMath
// Calculer la suite en (x,y) jusqu'à n, à moins que critere arret soit atteint avant // 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 // 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;
} }
///////////////////// /////////////////////
@@ -150,7 +181,7 @@ class MandelbrotMath
// Inputs // Inputs
int n; int n;
}; };
/*----------------------------------------------------------------------*\ /*----------------------------------------------------------------------*\
|* End *| |* End *|

View File

@@ -40,10 +40,9 @@ Mandelbrot::Mandelbrot(const Grid& grid , uint w , uint h , const DomaineMath& d
// Tools // Tools
this->t = nMin; this->t = nMin;
} }
Mandelbrot::~Mandelbrot() Mandelbrot::~Mandelbrot() {
{
// rien // rien
} }
@@ -55,28 +54,24 @@ Mandelbrot::~Mandelbrot()
* Override * Override
* Call periodicly by the API * Call periodicly by the API
*/ */
void Mandelbrot::process(uchar4* tabPixelsGM , uint w , uint h , const DomaineMath& domaineMath) void Mandelbrot::process(uchar4* tabPixelsGM , uint w , uint h , const DomaineMath& domaineMath) {
{
assert(false); // to be removed once implemented
// TODO Mandelbrot // TODO Mandelbrot
// lauch kernel (you find at line 18) // lauch kernel (you find at line 18)
} mandelbrot<<<dg,db>>>(tabPixelsGM,w,h,domaineMath,t);
}
/** /**
* Override * Override
* Call periodicly by the API * Call periodicly by the API
*/ */
void Mandelbrot::animationStep() void Mandelbrot::animationStep() {
{
this->t = variateurT.varierAndGet(); 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); return "Mandelbrot-Cuda-uchar4-" + mandelbrotReal::realToString() + "-nMin" + std::to_string(nMin) + "-nMax" + std::to_string(nMax);
} }
/*----------------------------------------------------------------------*\ /*----------------------------------------------------------------------*\
|* End *| |* End *|
\*---------------------------------------------------------------------*/ \*---------------------------------------------------------------------*/

View File

@@ -10,8 +10,7 @@
|* Declaration *| |* Declaration *|
\*---------------------------------------------------------------------*/ \*---------------------------------------------------------------------*/
class Mandelbrot: public Animable_I<uchar4> class Mandelbrot: public Animable_I<uchar4> {
{
/*--------------------------------------*\ /*--------------------------------------*\
|* Constructor *| |* Constructor *|
\*-------------------------------------*/ \*-------------------------------------*/
@@ -53,7 +52,7 @@ class Mandelbrot: public Animable_I<uchar4>
// Tools // Tools
Variateur<int> variateurT; Variateur<int> variateurT;
}; };
/*----------------------------------------------------------------------*\ /*----------------------------------------------------------------------*\
|* End *| |* End *|

View File

@@ -12,49 +12,56 @@
|* Impelmentation *| |* Impelmentation *|
\*---------------------------------------------------------------------*/ \*---------------------------------------------------------------------*/
namespace mandelbrot namespace mandelbrot {
{
class BestGrid class BestGrid {
{
public: public:
static Grid get() static Grid get() {
{ // const int MP = Hardware::getMPCount();
const int MP = Hardware::getMPCount(); // const int CORE_MP = Hardware::getCoreCountMP();
const int CORE_MP = Hardware::getCoreCountMP();
// fp64 (float 64 bits) // fp64 (float 64 bits)
#ifdef MANDELBROT_DOUBLE #ifdef MANDELBROT_DOUBLE
//TODO Mandelbrot const int MP = Hardware::getMPCount();
// to remove once coded const int CORE_MP = Hardware::getCoreCountMP();
{
Couts::redln("aie aie aie, your best grid won t build itself"); dim3 dg(MP, 1, 1);
assert(false); dim3 db(CORE_MP, 1, 1);
} Grid grid(dg, db);
return grid;
#endif #endif
// fp32 (float 32 bits) // fp32 (float 32 bits)
#ifdef MANDELBROT_FLOAT #ifdef MANDELBROT_FLOAT
//TODO Mandelbrot const int MP = Hardware::getMPCount();
// to remove once coded const int CORE_MP = Hardware::getCoreCountMP();
{
Couts::redln("aie aie aie, your best grid won t build itself"); dim3 dg(MP, 1, 1);
assert(false); dim3 db(CORE_MP, 1, 1);
} Grid grid(dg, db);
return grid;
#endif #endif
// fp16 (float 32 bits) // fp16 (float 32 bits)
#ifdef MANDELBROT_HALF #ifdef MANDELBROT_HALF
//TODO Mandelbrot const int MP = Hardware::getMPCount();
// to remove once coded const int CORE_MP = Hardware::getCoreCountMP();
{
Couts::redln("aie aie aie, your best grid won t build itself"); dim3 dg(MP, 2, 1);
assert(false); dim3 db(CORE_MP, 4, 1);
} Grid grid(dg, db);
return grid;
#endif #endif
// default
Couts::redln("Oups, something went wrong on BestGrid settings");
assert(false); // unknown type
return Grid();
} }
}; };

View File

@@ -14,107 +14,101 @@
\*---------------------*/ \*---------------------*/
// Choose one of the two (either/either): // Choose one of the two (either/either):
//#define MANDELBROT_DOUBLE // #define MANDELBROT_DOUBLE // fp64
//#define MANDELBROT_FLOAT // #define MANDELBROT_FLOAT // fp32
#define MANDELBROT_HALF #define MANDELBROT_HALF // fp16
/*----------------------*\ /*----------------------*\
|* private *| |* private *|
\*---------------------*/ \*---------------------*/
namespace mandelbrotReal namespace mandelbrotReal {
{
// fp64 (float 64 bits) // fp64 (float 64 bits)
#ifdef MANDELBROT_DOUBLE #ifdef MANDELBROT_DOUBLE
//#define real double //#define real double
using real=double; using real=double;
#endif #endif
// fp32 (float 32 bits) // fp32 (float 32 bits)
#ifdef MANDELBROT_FLOAT #ifdef MANDELBROT_FLOAT
//#define real float //#define real float
using real=float; using real=float;
#endif #endif
// fp16 (float 16 bits) // fp16 (float 16 bits)
#ifdef MANDELBROT_HALF #ifdef MANDELBROT_HALF
//#define real half //#define real half
using real=half; using real=half;
#endif #endif
static std::string realToString() static std::string realToString() {
{
#ifdef MANDELBROT_DOUBLE #ifdef MANDELBROT_DOUBLE
return "fp64"; return "fp64";
#endif #endif
#ifdef MANDELBROT_FLOAT #ifdef MANDELBROT_FLOAT
return "fp32"; return "fp32";
#endif #endif
#ifdef MANDELBROT_HALF #ifdef MANDELBROT_HALF
return "fp16"; return "fp16";
#endif #endif
} }
static bool isFp16() static bool isFp16() {
{
#ifdef MANDELBROT_DOUBLE #ifdef MANDELBROT_DOUBLE
return false; return false;
#endif #endif
#ifdef MANDELBROT_FLOAT #ifdef MANDELBROT_FLOAT
return false; return false;
#endif #endif
#ifdef MANDELBROT_HALF #ifdef MANDELBROT_HALF
return true; return true;
#endif #endif
assert(false); assert(false);
} }
static bool isFp32() static bool isFp32() {
{
#ifdef MANDELBROT_DOUBLE #ifdef MANDELBROT_DOUBLE
return false; return false;
#endif #endif
#ifdef MANDELBROT_FLOAT #ifdef MANDELBROT_FLOAT
return true; return true;
#endif #endif
#ifdef MANDELBROT_HALF #ifdef MANDELBROT_HALF
return false; return false;
#endif #endif
assert(false); assert(false);
} }
static bool isFp64() static bool isFp64() {
{
#ifdef MANDELBROT_DOUBLE #ifdef MANDELBROT_DOUBLE
return true; return true;
#endif #endif
#ifdef MANDELBROT_FLOAT #ifdef MANDELBROT_FLOAT
return false; return false;
#endif #endif
#ifdef MANDELBROT_HALF #ifdef MANDELBROT_HALF
return false; return false;
#endif #endif
assert(false); assert(false);
} }
} }
/*----------------------------------------------------------------------*\ /*----------------------------------------------------------------------*\
|* End *| |* End *|
\*---------------------------------------------------------------------*/ \*---------------------------------------------------------------------*/