9d091e1a7e205b421968254ddaa76e1d4aaee0b4
7 #include "GLUTImageViewers_GPU.h"
9 /*----------------------------------------------------------------------*\
11 \*---------------------------------------------------------------------*/
13 /*--------------------------------------*\
15 \*-------------------------------------*/
17 extern int mainGL(void);
18 extern int mainFreeGL(void);
20 /*--------------------------------------*\
22 \*-------------------------------------*/
24 int main(int argc
, char** argv
);
26 /*--------------------------------------*\
28 \*-------------------------------------*/
30 static int start(void);
31 static void initCuda(int deviceId
);
33 /*----------------------------------------------------------------------*\
35 \*---------------------------------------------------------------------*/
37 /*--------------------------------------*\
39 \*-------------------------------------*/
41 int main(int argc
, char** argv
)
45 gpu::GLUTImageViewers::init(argc
, argv
);
47 // Device::printAll();
48 Device::printAllSimple();
50 // Server Cuda1: in [0,5]
51 // Server Cuda2: in [0,2]
58 //cudaDeviceReset causes the driver to clean up all state.
59 // While not mandatory in normal operation, it is good practice.
60 HANDLE_ERROR(cudaDeviceReset());
70 /*--------------------------------------*\
72 \*-------------------------------------*/
74 void initCuda(int deviceId
)
76 // Check deviceId area
77 int nbDevice
= Device::getDeviceCount();
78 assert(deviceId
>= 0 && deviceId
< nbDevice
);
80 // Choose current device (state of host-thread)
81 HANDLE_ERROR(cudaSetDevice(deviceId
));
83 // Enable Interoperabilité OpenGL:
84 // - Create a cuda specifique contexte, shared between Cuda and GL
85 // - To be called before first call to kernel
86 // - cudaSetDevice ou cudaGLSetGLDevice are mutualy exclusive
87 HANDLE_ERROR(cudaGLSetGLDevice(deviceId
));
89 // It can be usefull to preload driver, by example to practice benchmarking! (sometimes slow under linux)
90 Device::loadCudaDriver(deviceId
);
91 // Device::loadCudaDriverAll();// Force driver to be load for all GPU
96 Device::printCurrent();
102 return mainGL(); // Bloquant, Tant qu'une fenetre est ouverte
110 /*----------------------------------------------------------------------*\
112 \*---------------------------------------------------------------------*/