int main (int argc, char * const argv[]) { // insert code here... printf("Matrix Multiplication Calculation...\n"); runCUDA(); printf("Done !!\n"); return 0; }
void mainLoop() { while (!glfwWindowShouldClose(m_window)) { glfwPollEvents(); runCUDA(); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_pbo); glBindTexture(GL_TEXTURE_2D, m_image); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glClear(GL_COLOR_BUFFER_BIT); // VAO, shader program, and texture already bound glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); glfwSwapBuffers(m_window); } glfwDestroyWindow(m_window); glfwTerminate(); }
void mainLoop() { double fps = 0; double timebase = 0; int frame = 0; while (!glfwWindowShouldClose(window)) { glfwPollEvents(); frame++; double time = glfwGetTime(); if (time - timebase > 1.0) { fps = frame / (time - timebase); timebase = time; frame = 0; } runCUDA(); std::ostringstream ss; ss << "["; ss.precision(1); ss << std::fixed << fps; ss << " fps] " << deviceName; glfwSetWindowTitle(window, ss.str().c_str()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); #if VISUALIZE glUseProgram(program[PROG_PLANET]); glBindVertexArray(planetVAO); glPointSize(2.0f); glDrawElements(GL_POINTS, N_FOR_VIS + 1, GL_UNSIGNED_INT, 0); glPointSize(1.0f); glUseProgram(0); glBindVertexArray(0); #endif glfwSwapBuffers(window); } glfwDestroyWindow(window); glfwTerminate(); }
int main(int argc, char** argv) { printHeader("Initializare"); initCUDA(); init(); printHeader("Calcul CPU"); cutilCheckError(cutStartTimer(timer)); // Calculeaza sampleul de control - CPU printf("Asteptati: Se calculeaza controlul pe CPU ... "); computeControl(); printf("DONE\n"); float time = cutGetTimerValue(timer); printf("Timp de calcul pe CPU = %f milisecunde\n",time); cutilCheckError(cutResetTimer(timer)); printHeader("Calcul CUDA"); // Se calculeaza pe CUDA printf("Asteptati: Se calculeaza pe CUDA ... "); runCUDA(); printf("DONE\n"); time = cutGetTimerValue(timer); printf("Timp de calcul pe GPU = %f milisecunde\n",time); printHeader("Verificare calcule"); // Se verifica daca s-a calculat corect pe CUDA printf("Se verifica daca rezultatul pe CUDA corespunde cu rezultatul pe CPU : "); verificaCalcule(); printHeader(""); cleanup(); printf("Apasa ENTER pentru a termina programul\n"); getchar(); return 0; }