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]
57 const int deviceId
= 5;
61 for (int i
= 1; i
< argc
; ++i
)
62 args
.push_back(argv
[i
]);
64 int isOk
= start(args
);
66 //cudaDeviceReset causes the driver to clean up all state.
67 // While not mandatory in normal operation, it is good practice.
68 HANDLE_ERROR(cudaDeviceReset());
78 /*--------------------------------------*\
80 \*-------------------------------------*/
82 void initCuda(int deviceId
)
84 // Check deviceId area
85 int nbDevice
= Device::getDeviceCount();
86 assert(deviceId
>= 0 && deviceId
< nbDevice
);
88 // Choose current device (state of host-thread)
89 HANDLE_ERROR(cudaSetDevice(deviceId
));
91 // Enable Interoperabilit� OpenGL:
92 // - Create a cuda specifique contexte, shared between Cuda and GL
93 // - To be called before first call to kernel
94 // - cudaSetDevice ou cudaGLSetGLDevice are mutualy exclusive
95 HANDLE_ERROR(cudaGLSetGLDevice(deviceId
));
97 // It can be usefull to preload driver, by example to practice benchmarking! (sometimes slow under linux)
98 Device::loadCudaDriver(deviceId
);
99 // Device::loadCudaDriverAll();// Force driver to be load for all GPU
102 int start(const vector
<string
>& args
)
104 Device::printCurrent();
110 return mainGL(args
); // Bloquant, Tant qu'une fenêtre est ouverte.
118 /*----------------------------------------------------------------------*\
120 \*---------------------------------------------------------------------*/