10 #include "GLUTImageViewers.h"
12 /*----------------------------------------------------------------------*\
14 \*---------------------------------------------------------------------*/
16 /*--------------------------------------*\
18 \*-------------------------------------*/
20 extern int mainGL(const vector
<string
>& args
);
21 extern int mainFreeGL(void);
23 /*--------------------------------------*\
25 \*-------------------------------------*/
27 int main(int argc
, char** argv
);
29 /*--------------------------------------*\
31 \*-------------------------------------*/
33 static int start(const vector
<string
>& args
);
34 static void initCuda(int deviceId
);
36 /*----------------------------------------------------------------------*\
38 \*---------------------------------------------------------------------*/
40 /*--------------------------------------*\
42 \*-------------------------------------*/
44 int main(int argc
, char** argv
)
46 cout
<< "main" << endl
;
50 GLUTImageViewers::init(argc
, argv
);
53 Device::printAllSimple();
55 // Server Cuda1: in [0,5]
56 // Server Cuda2: in [0,2]
60 for (int i
= 1; i
< argc
; ++i
)
61 args
.push_back(argv
[i
]);
63 int isOk
= start(args
);
65 //cudaDeviceReset causes the driver to clean up all state.
66 // While not mandatory in normal operation, it is good practice.
67 HANDLE_ERROR(cudaDeviceReset());
77 /*--------------------------------------*\
79 \*-------------------------------------*/
81 void initCuda(int deviceId
)
83 // Check deviceId area
84 int nbDevice
= Device::getDeviceCount();
85 assert(deviceId
>= 0 && deviceId
< nbDevice
);
87 // Choose current device (state of host-thread)
88 HANDLE_ERROR(cudaSetDevice(deviceId
));
90 // Enable Interoperabilit� OpenGL:
91 // - Create a cuda specifique contexte, shared between Cuda and GL
92 // - To be called before first call to kernel
93 // - cudaSetDevice ou cudaGLSetGLDevice are mutualy exclusive
94 HANDLE_ERROR(cudaGLSetGLDevice(deviceId
));
96 // It can be usefull to preload driver, by example to practice benchmarking! (sometimes slow under linux)
97 Device::loadCudaDriver(deviceId
);
98 // Device::loadCudaDriverAll();// Force driver to be load for all GPU
101 int start(const vector
<string
>& args
)
103 Device::printCurrent();
109 return mainGL(args
); // Bloquant, Tant qu'une fenetre est ouverte
117 /*----------------------------------------------------------------------*\
119 \*---------------------------------------------------------------------*/