X-Git-Url: http://git.euphorik.ch/?p=GPU.git;a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2FmainFreeGL.cpp;h=e5d126d6b53c18668eb35e576db01f45c214350d;hp=2e54befe20cbbf5dc5825a01becb89335ab53c8e;hb=1c4b2276e7157acde9a3014b68d5d1667a7d6a44;hpb=f8259dce248a4411c3bc64cecb9fc268c4fd81d6 diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/mainFreeGL.cpp b/WCudaMSE/Student_Cuda_Image/src/cpp/core/mainFreeGL.cpp index 2e54bef..e5d126d 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/mainFreeGL.cpp +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/mainFreeGL.cpp @@ -1,13 +1,14 @@ #include #include #include +using namespace std; #include "Device.h" #include "cudaTools.h" +#include "Chronos.h" -using std::cout; -using std::endl; -using std::string; +#include "RayTracingProvider.h" +#include "RayTracingParams.h" /*----------------------------------------------------------------------*\ |* Declaration *| @@ -33,17 +34,62 @@ int mainFreeGL(void); |* Implementation *| \*---------------------------------------------------------------------*/ +void run(uchar4* ptrDevPixels, int dw, int dh, int dg, int db, int nbFrame) + { + cout << "Raytracing Without GL "; +#if CURRENT_MEMORY_MODEL == MEMORY_MODEL_GLOBAL + cout << "(Global memory)" << endl; +#elif CURRENT_MEMORY_MODEL == MEMORY_MODEL_CONSTANT + cout << "(Constant memory)" << endl; +#elif CURRENT_MEMORY_MODEL == MEMORY_MODEL_SHARED + cout << "(Shared memory)" << endl; +#endif + + cout << "Nb frames: " << nbFrame << endl; + + RayTracing* rayTracing = RayTracingProvider::create(dw, dh, dg, db); + + Chronos chronos; + chronos.start(); + + for (int i = 0; i < nbFrame; i++) + rayTracing->runGPU(ptrDevPixels); + + HANDLE_ERROR(cudaDeviceSynchronize()); + + chronos.stop(); + + cout << "Time: " << chronos << endl; + cout << "-------------------" << endl; + } + /*--------------------------------------*\ |* Public *| \*-------------------------------------*/ int mainFreeGL(void) { - cout << "\n[FPS] : Free GL, please wait ..." << endl; + const int NB_FRAME_TO_RENDER = 100; + const int dw = 16 * 50; + const int dh = 16 * 50; + + // dg : 8 -> 128. + const int dgStart = 8; + const int dgStop = 128; - rippling0FreeGL(1000); // bad technique + // db : 8 -> 32 + const int dbStart = 8; + const int dbStop = 32; + + uchar4* ptrDevPixels; + HANDLE_ERROR(cudaMalloc(&ptrDevPixels, dw * dh * sizeof(uchar4))); + + run(ptrDevPixels, dw, dh, 32, 32, NB_FRAME_TO_RENDER); + return EXIT_SUCCESS; - // TODO : add other tp here ... + for (int dg = dgStart; dg <= dgStop; dg *= 2) + for (int db = dbStart; db <= dbStop; db *= 2) + run(ptrDevPixels, dw, dh, dg, db, NB_FRAME_TO_RENDER); return EXIT_SUCCESS; }