X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FBilatTools_Cuda_Image%2Fsrc%2Fcore%2FcudaImageTools%2Ffonctionel%2Fcpp%2FAnimateurFonctionelFreeGL.cpp;fp=WCudaMSE%2FBilatTools_Cuda_Image%2Fsrc%2Fcore%2FcudaImageTools%2Ffonctionel%2Fcpp%2FAnimateurFonctionelFreeGL.cpp;h=ad90374ad0d5e175ec452e29f06f12f6d933605e;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git diff --git a/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/cpp/AnimateurFonctionelFreeGL.cpp b/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/cpp/AnimateurFonctionelFreeGL.cpp new file mode 100755 index 0000000..ad90374 --- /dev/null +++ b/WCudaMSE/BilatTools_Cuda_Image/src/core/cudaImageTools/fonctionel/cpp/AnimateurFonctionelFreeGL.cpp @@ -0,0 +1,117 @@ +#include + +#include "cudaTools.h" +#include "Device.h" +#include "MathTools.h" +#include "StringTools.h" + +#include "Chronos.h" + +#include "AnimateurFonctionelFreeGL.h" + +using std::cout; +using std::endl; + +/*----------------------------------------------------------------------*\ + |* Declaration *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Imported *| + \*-------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +/*----------------------------------------------------------------------*\ + |* Implementation *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +AnimateurFonctionelFreeGL::AnimateurFonctionelFreeGL(AnimableFonctionel_I* ptrAnimable, int nbIteration) + { + // Input + this->nbIteration = nbIteration; + this->ptrAnimable = ptrAnimable; + + // Outputs + this->fps = -1; + this->timeElapseS = -1; + + start(); + printStat(); + } + +AnimateurFonctionelFreeGL::~AnimateurFonctionelFreeGL() + { + delete ptrAnimable; // discutable! + } + +int AnimateurFonctionelFreeGL::getFps(void) + { + return fps; + } + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +int AnimateurFonctionelFreeGL::start() + { + cout << "\n[AnimateurFreeGL] : started : " << ptrAnimable->getTitle() << endl; + + int w = ptrAnimable->getW(); + int h = ptrAnimable->getH(); + size_t size = w * h * sizeof(uchar4); + + uchar4* ptrDevImage; + HANDLE_ERROR(cudaMalloc((void**) &ptrDevImage, size)); + HANDLE_ERROR(cudaMemset(ptrDevImage, 0, size)); + + int i = 0; + Chronos chrono; + + DomaineMath* ptrDomaineMath=ptrAnimable->getDomaineMathInit(); + const char* messageError=ptrAnimable->getTitle().c_str(); + while (i < nbIteration) + { + ptrAnimable->runGPU(ptrDevImage,*ptrDomaineMath); + + Device::checkKernelError(messageError); + Device::synchronize(); // Important! + + ptrAnimable->animationStep(); + + i++; + } + + chrono.stop(); + HANDLE_ERROR(cudaFree(ptrDevImage)); + + this->timeElapseS = chrono.getDeltaTime(); + this->fps = nbIteration / timeElapseS; + + return fps; + } + +void AnimateurFonctionelFreeGL::printStat() + { + cout << endl; + cout << "Benchmark : [" << ptrAnimable->getTitle()<<"]" << endl; + cout << "#Iteration : " << nbIteration << endl; + cout << "#secondes : " << timeElapseS << " (s)" << endl; + cout << "#fps : " << fps << endl; + } + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/ +