ad90374ad0d5e175ec452e29f06f12f6d933605e
6 #include "StringTools.h"
10 #include "AnimateurFonctionelFreeGL.h"
15 /*----------------------------------------------------------------------*\
17 \*---------------------------------------------------------------------*/
19 /*--------------------------------------*\
21 \*-------------------------------------*/
23 /*--------------------------------------*\
25 \*-------------------------------------*/
27 /*--------------------------------------*\
29 \*-------------------------------------*/
31 /*----------------------------------------------------------------------*\
33 \*---------------------------------------------------------------------*/
35 /*--------------------------------------*\
37 \*-------------------------------------*/
39 AnimateurFonctionelFreeGL::AnimateurFonctionelFreeGL(AnimableFonctionel_I
* ptrAnimable
, int nbIteration
)
42 this->nbIteration
= nbIteration
;
43 this->ptrAnimable
= ptrAnimable
;
47 this->timeElapseS
= -1;
53 AnimateurFonctionelFreeGL::~AnimateurFonctionelFreeGL()
55 delete ptrAnimable
; // discutable!
58 int AnimateurFonctionelFreeGL::getFps(void)
63 /*--------------------------------------*\
65 \*-------------------------------------*/
67 int AnimateurFonctionelFreeGL::start()
69 cout
<< "\n[AnimateurFreeGL] : started : " << ptrAnimable
->getTitle() << endl
;
71 int w
= ptrAnimable
->getW();
72 int h
= ptrAnimable
->getH();
73 size_t size
= w
* h
* sizeof(uchar4
);
76 HANDLE_ERROR(cudaMalloc((void**) &ptrDevImage
, size
));
77 HANDLE_ERROR(cudaMemset(ptrDevImage
, 0, size
));
82 DomaineMath
* ptrDomaineMath
=ptrAnimable
->getDomaineMathInit();
83 const char* messageError
=ptrAnimable
->getTitle().c_str();
84 while (i
< nbIteration
)
86 ptrAnimable
->runGPU(ptrDevImage
,*ptrDomaineMath
);
88 Device::checkKernelError(messageError
);
89 Device::synchronize(); // Important!
91 ptrAnimable
->animationStep();
97 HANDLE_ERROR(cudaFree(ptrDevImage
));
99 this->timeElapseS
= chrono
.getDeltaTime();
100 this->fps
= nbIteration
/ timeElapseS
;
105 void AnimateurFonctionelFreeGL::printStat()
108 cout
<< "Benchmark : [" << ptrAnimable
->getTitle()<<"]" << endl
;
109 cout
<< "#Iteration : " << nbIteration
<< endl
;
110 cout
<< "#secondes : " << timeElapseS
<< " (s)" << endl
;
111 cout
<< "#fps : " << fps
<< endl
;
114 /*----------------------------------------------------------------------*\
116 \*---------------------------------------------------------------------*/