8 #include "GLUTImageViewers.h"
13 /*----------------------------------------------------------------------*\
15 \*---------------------------------------------------------------------*/
17 /*--------------------------------------*\
19 \*-------------------------------------*/
21 extern int mainGL(void);
22 extern int mainFreeGL(void);
24 /*--------------------------------------*\
26 \*-------------------------------------*/
28 int main(int argc
, char** argv
);
30 /*--------------------------------------*\
32 \*-------------------------------------*/
34 static int start(void);
35 static void initCuda(int deviceId
);
37 /*----------------------------------------------------------------------*\
39 \*---------------------------------------------------------------------*/
41 /*--------------------------------------*\
43 \*-------------------------------------*/
45 int main(int argc
, char** argv
)
47 cout
<< "main" << endl
;
51 GLUTImageViewers::init(argc
, argv
);
54 Device::printAllSimple();
56 // Server Cuda1: in [0,5]
57 // Server Cuda2: in [0,2]
62 //cudaDeviceReset causes the driver to clean up all state.
63 // While not mandatory in normal operation, it is good practice.
64 HANDLE_ERROR(cudaDeviceReset());
74 /*--------------------------------------*\
76 \*-------------------------------------*/
78 void initCuda(int deviceId
)
80 // Check deviceId area
81 int nbDevice
= Device::getDeviceCount();
82 assert(deviceId
>= 0 && deviceId
< nbDevice
);
84 // Choose current device (state of host-thread)
85 HANDLE_ERROR(cudaSetDevice(deviceId
));
87 // Enable Interoperabilité OpenGL:
88 // - Create a cuda specifique contexte, shared between Cuda and GL
89 // - To be called before first call to kernel
90 // - cudaSetDevice ou cudaGLSetGLDevice are mutualy exclusive
91 HANDLE_ERROR(cudaGLSetGLDevice(deviceId
));
93 // It can be usefull to preload driver, by example to practice benchmarking! (sometimes slow under linux)
94 Device::loadCudaDriver(deviceId
);
95 // Device::loadCudaDriverAll();// Force driver to be load for all GPU
100 Device::printCurrent();
106 return mainGL(); // Bloquant, Tant qu'une fenetre est ouverte
114 /*----------------------------------------------------------------------*\
116 \*---------------------------------------------------------------------*/