This is my situation. My code calls to a function which contains a timing loop to do the simulation (monte-carlo simulation)
e.g.
MyFUNC( …) {
//setting parameters
// timing loop (until the end of the simulation)
for (int i = 1; the_end; i++) {
//call CUDA kernel to do stuffs
//CPU code to update parameters
}
}
During my simulation, it will update the data (temporal-spatial) that I want to visualize, i.e. (x, y, z, data) or (x, y, data), as a 3D surface. The sample CUDA-OpenGL codes that I have read, basically, need a small function, invoked by the callback and does a the computation to update to the data after a single-time step, i.e.
MyFUNC_1step(…) {
// call CUDA kernel to do stuffs
// CPU code to update parameters
}
void display() {
MyFunC_1step();
//rendering
}
So, what I want is to keep my function MyFUNC as-is, and it will trigger the redisplayed by explicitly trigger something that tell the window to render (e.g. glutPostReDisplay()). This will allow me (1) keep running the simulation even after I close the window, (2) only update the display when I want (i.e. after a certain number of time steps of simulation). Do I have to use MPI to create one process to call the MyFUNC() and another process to call the main loop of GLUT (i.e. glutMainLoop)? or there is a better way. If I have to use MPI, how could I communicate with the window in a different process?
I’m not sure if my explanation is clear enough, please let me know.
Thank you,
Tuan