void initCuda(){ // Use device with highest Gflops/s #if CUDA_VERSION >= 5000 cudaGLSetGLDevice( gpuGetMaxGflopsDeviceId() ); #else cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); #endif initPBO(&pbo); // Clean up on program exit atexit(cleanupCuda); runCuda(); }
void init() { //std::cerr << "INIT CUDA.cpp!!!!" << std::endl; if (initialized) return; cudaGLSetGLDevice(0); initialized = true; }
void initCuda(){ // Use device with highest Gflops/s cudaGLSetGLDevice(0); // Clean up on program exit atexit(cleanupCuda); }
void initCuda() { // First initialize OpenGL context, so we can properly set the GL // for CUDA. NVIDIA notes this is necessary in order to achieve // optimal performance with OpenGL/CUDA interop. use command-line // specified CUDA device, otherwise use device with highest Gflops/s int devCount= 0; cudaGetDeviceCount(&devCount); if( devCount < 1 ) { printf("No GPUS detected\n"); exit(EXIT_FAILURE); } cudaGLSetGLDevice( 0 ); //Set Up scenary setup_scene(); createPBO(&pbo); createTexture(&textureID,image_width,image_height); // Clean up on program exit atexit(cleanupCuda); runCuda(); }
void CudaBase::SetGLDevice() { if(!CheckCUDevice()) return; std::cout<<" cuda set GL device\n"; cudaGLSetGLDevice(0); HasDevice = 1; }
CDataManager::CDataManager() : m_ifDataReady(false), m_MinTime(0), m_MaxTime(0), /*m_CurTime(0), m_TimeRange(0),*/ \ m_CurTimeData(NULL),m_TimeRangeData(NULL), m_TimeWindowData(NULL), m_TimeStepData(NULL), \ /*m_StartIdx(0), m_EndIdx(0),*/ /*m_TimeStep(TIMESTEP),*/ /*m_RangeStep(RANGESTEP), */\ m_RangeRatio(RANGERATIO), m_BrushType(Brush_One), m_filterType(NONE), m_CurrentTimesliderIdx(0), \ m_ifSkip(false),m_dataUpdateStyle(UPDATE_STYLE), m_RawData(NULL), \ m_CurrentFilter(-1),m_CurrentFilterEX(-1),m_CurrentFilterNEX(-1), \ m_BasedFilteredData(NULL), m_ExclusiveFilter(NULL), m_NegExclusiveFilter(NULL) { gpuDeviceInit(0); cudaGLSetGLDevice(0); m_ExclusiveFilter = new CFilter(); m_NegExclusiveFilter = new CFilter(); m_RawData = new CRawData(); m_RawData->SetDataManager(this); m_BasedFilteredData = new CFilteredData(); m_CurTimeData = new CCurTime(); m_TimeRangeData = new CTimeRange(); m_TimeWindowData = new CTimeWindow(); m_TimeStepData = new CTimeStep(); AddRelation( m_CurTimeData, m_TimeWindowData, false); AddRelation( m_TimeRangeData, m_TimeWindowData, false); m_TimeStepData->SetTimeStep(TIMESTEP); //Registeration AddRelation( m_RawData, m_BasedFilteredData, true ); AddRelation( m_ExclusiveFilter, m_BasedFilteredData, false ); AddRelation( m_NegExclusiveFilter, m_BasedFilteredData, false ); AddRelation( m_TimeWindowData, m_BasedFilteredData, false); }
int main(int argc, char** argv) { // Launch CUDA/GL init(argc, argv); cudaGLSetGLDevice( compat_getMaxGflopsDeviceId() ); cudaGLRegisterBufferObject( planetVBO ); cudaGLRegisterBufferObject( velocityVBO ); #if VISUALIZE == 1 initCuda(N_FOR_VIS); #else initCuda(2*128); #endif projection = glm::perspective(fovy, float(width)/float(height), zNear, zFar); view = glm::lookAt(cameraPosition, glm::vec3(0.0, 0.0, 0), glm::vec3(0,1,0)); projection = projection * view; initShaders(program); glEnable(GL_DEPTH_TEST); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMotionFunc(mouseMotion); glutMainLoop(); return 0; }
void initGlWindow(int argc, char ** argv){ #ifdef USE_OPENGL cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); if( !glfwInit() ) { cerr << "Failed to initalize GLFW" << endl; exit( 1 ); } if ( !glfwOpenWindow( width, height, 8, 8, 8, 8, 8, 8, GLFW_WINDOW ) ) { cerr << "Failed to open window" << endl; exit( 1 ); } glewInit(); if (! glewIsSupported("GL_VERSION_2_0 ")) { cerr << "ERROR: Support for necessary OpenGL extensions missing." << endl; exit( 1 ); } //glEnable(GL_POINT_SMOOTH); glViewport(0, 0, height, width); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, 0.0, 1.0); #endif };
void GLManager::initGlWindow(){ cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); if( !glfwInit() ) { std::cerr << "Failed to initalize GLFW" << std::endl; exit( 1 ); } glfwOpenWindowHint( GLFW_WINDOW_NO_RESIZE, GL_TRUE ); if ( !glfwOpenWindow( width, height, 8, 8, 8, 8, 8, 8, GLFW_WINDOW ) ) { std::cerr << "Failed to open window" << std::endl; exit( 1 ); } glewInit(); if (! glewIsSupported("GL_VERSION_2_0 ")) { std::cerr << "ERROR: Support for necessary OpenGL extensions missing." << std::endl; exit( 1 ); } glViewport(0, 0, height, width); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0); };
void InitCuda(){ // Default to device ID 0. If you have more than one GPU and want to test a non-default one, // change the device ID. cudaGLSetGLDevice(0); // Clean up on program exit atexit(CleanupCuda); }
void initCuda(){ cudaGLSetGLDevice(0); // Clean up on program exit atexit(cleanupCuda); }
void init_parallel_component() { /*DEBUG("Looking for CUDA devices\n");*/ /*device_query();*/ DEBUG("Setting CUDA GL device\n"); cudaError_t cuda_err = cudaGLSetGLDevice(0); check_cuda_error(); }
void initCuda() { // Use device with highest Gflops/s cudaGLSetGLDevice(0); rasterizeInit(width, height); // Clean up on program exit atexit(cleanupCuda); }
void glcu::init_cuda() { cudaDeviceProp prop = {0}; int dev; prop.major = 1; prop.minor = 0; HANDLE_ERROR(cudaChooseDevice(&dev, &prop)); HANDLE_ERROR(cudaGLSetGLDevice(dev)); }
//////////////////////////////////////////////////////////////////////////////// //! Run a simple test for CUDA //////////////////////////////////////////////////////////////////////////////// CUTBoolean runTest(int argc, char** argv) { if (!cutCheckCmdLineFlag(argc, (const char **)argv, "noqatest") || cutCheckCmdLineFlag(argc, (const char **)argv, "noprompt")) { g_bQAReadback = true; fpsLimit = frameCheckNumber; } // First initialize OpenGL context, so we can properly set the GL for CUDA. // This is necessary in order to achieve optimal performance with OpenGL/CUDA interop. if (CUTFalse == initGL(argc, argv)) { return CUTFalse; } // use command-line specified CUDA device, otherwise use device with highest Gflops/s if( cutCheckCmdLineFlag(argc, (const char**)argv, "device") ) cutilGLDeviceInit(argc, argv); else { cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); } // Create the CUTIL timer cutilCheckError( cutCreateTimer( &timer)); // register callbacks glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMouseFunc(mouse); glutMotionFunc(motion); if (g_bQAReadback) { g_CheckRender = new CheckBackBuffer(window_width, window_height, 4); g_CheckRender->setPixelFormat(GL_RGBA); g_CheckRender->setExecPath(argv[0]); g_CheckRender->EnableQAReadback(true); } // create VBO createVBO(&vbo); // run the cuda part runCuda(vbo); // check result of Cuda step checkResultCuda(argc, argv, vbo); atexit(cleanup); // start rendering mainloop glutMainLoop(); cudaThreadExit(); return CUTTrue; }
void initCUDA(int argc, char **argv) { int dev = 1; #ifdef CALC_ON_GPU cuUtilsSafeCall( cudaGetDeviceCount(&dev) ); cuUtilsSafeCall( cudaSetDevice(dev-1) ); //cuUtilsSafeCall( cudaDeviceReset() ); cuUtilsSafeCall( cudaGLSetGLDevice(dev-1) ); // pick the first GPU to link with openGL context of this thread #endif }
void initCuda(){ // Use device with highest Gflops/s cudaGLSetGLDevice( compat_getMaxGflopsDeviceId() ); initPBO(&pbo); // Clean up on program exit atexit(cleanupCuda); runCuda(); }
void initCuda(){ // Use device with highest Gflops/s // Had to update this to remove cutil version cudaGLSetGLDevice( gpuGetMaxGflopsDeviceId() ); initPBO(&pbo); // Clean up on program exit atexit(cleanupCuda); runCuda(); }
CUTBoolean initGL(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowSize(10, 10); int bla = glutCreateWindow("Cuda GL Interop (VBO)"); glutDisplayFunc(dumm_display); // initialize necessary OpenGL extensions glewInit(); if (! glewIsSupported("GL_VERSION_2_0 ")) { fprintf(stderr, "ERROR: Support for necessary OpenGL extensions missing."); fflush(stderr); return CUTFalse; } // default initialization glClearColor(0.0, 0.0, 0.0, 1.0); glDisable(GL_DEPTH_TEST); // viewport glViewport(0, 0, 10, 10); // projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (GLfloat)10 / (GLfloat) 10, 0.1, 10.0); CUT_CHECK_ERROR_GL(); // start gui for the main application //cudaError_t error = cudaGLSetGLDevice(0); //cutilGLDeviceInit(argc, argv); int deviceCount; cutilSafeCallNoSync(cudaGetDeviceCount(&deviceCount)); if (deviceCount == 0) { fprintf(stderr, "CUTIL CUDA error: no devices supporting CUDA.\n"); exit(-1); } int dev = 0; cudaDeviceProp deviceProp; cutilSafeCallNoSync(cudaGetDeviceProperties(&deviceProp, dev)); if (deviceProp.major < 1) { fprintf(stderr, "cutil error: device does not support CUDA.\n"); exit(-1); } printf("gpu=%s\n", deviceProp.name); cutilSafeCall(cudaGLSetGLDevice(dev)); glutDestroyWindow(bla); return CUTTrue; }
void set_device(int device, bool withopengl) { cudaDeviceProp props; cutilSafeCall(cudaGetDeviceProperties(&props, device)); std::cout << "Using " << props.name << "\n"; if (withopengl) cutilSafeCall(cudaGLSetGLDevice(device)); else cutilSafeCall(cudaSetDevice(device)); }
void SimCudaHelper::InitializeGL(int cudaDevice) { cudaDevice = Init(cudaDevice); cudaError res = cudaGLSetGLDevice(cudaDevice); if (res != cudaSuccess) { CheckError("cudaGLSetGLDevice failed"); } else { cout << "CUDA: Successful cudaGLSetGLDevice\n"; } }
bool initCUDA( int argc, char **argv) { return true; if ( cutCheckCmdLineFlag(argc, (const char **)argv, "device")) { cutilGLDeviceInit(argc, argv); } else { cudaGLSetGLDevice (cutGetMaxGflopsDeviceId()); } return true; }
void runGraphicsTest(int argc, char** argv) { printf("MarchingCubes "); if (g_bFBODisplay) printf("[w/ FBO] "); if (g_bOpenGLQA) printf("[Readback Comparisons] "); printf("\n"); if ( cutCheckCmdLineFlag(argc, (const char **)argv, "device")) { printf("[%s]\n", argv[0]); printf(" Does not explicitly support -device=n in OpenGL mode\n"); printf(" To use -device=n, the sample must be running w/o OpenGL\n\n"); printf(" > %s -device=n -qatest\n", argv[0]); printf("exiting...\n"); exit(0); } // First initialize OpenGL context, so we can properly set the GL for CUDA. // This is necessary in order to achieve optimal performance with OpenGL/CUDA interop. if(CUTFalse == initGL(&argc, argv)) { return; } cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); // register callbacks glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMouseFunc(mouse); glutMotionFunc(motion); glutIdleFunc(idle); glutReshapeFunc(reshape); initMenus(); // Initialize CUDA buffers for Marching Cubes initMC(argc, argv); cutilCheckError( cutCreateTimer( &timer)); if (g_bOpenGLQA) { g_CheckRender = new CheckBackBuffer(window_width, window_height, 4); g_CheckRender->setPixelFormat(GL_RGBA); g_CheckRender->setExecPath(argv[0]); g_CheckRender->EnableQAReadback(true); } // start rendering mainloop glutMainLoop(); cudaThreadExit(); }
void NetworkAccessTest::testCase1() { #ifdef USE_CUDA QVERIFY( cudaSuccess == cudaGLSetGLDevice( 0 ) ); #ifndef __APPLE__ // glewInit is not needed on Mac QVERIFY( 0==glewInit() ); #endif pVbo vbo( new Vbo(1024, GL_ARRAY_BUFFER, GL_STATIC_DRAW)); MappedVbo<float> mapping(vbo, DataStorageSize(256,1,1)); DataStorage<float>::ptr copy( new DataStorage<float>(*mapping.data) ); mappedVboTestCuda( copy ); QVERIFY2(true, "Failure"); #endif }
void initCuda(){ // Use device with highest Gflops/s cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); initPBO(&pbo); dptr=NULL; cudaGLMapBufferObject((void**)&dptr, pbo); clearPBOpos(dptr,width,height); cudaGLUnmapBufferObject(pbo); // Clean up on program exit atexit(cleanupCuda); SetScissorWindow(glm::vec4(300,300,500,500)); texture.mapptr = stbi_load("cow.jpeg",&texture.width, &texture.height,&texture.depth,0); runCuda(); }
void CUDARenderer::initCUDA() { gpuErrchk(cudaSetDevice(0)); gpuErrchk(cudaGLSetGLDevice(0)); gpuErrchk(cudaMalloc((void **)&d_scene, sizeof(SlowScene))); gpuErrchk(cudaMemcpy(d_scene, &h_scene, sizeof(SlowScene), cudaMemcpyHostToDevice)); setImageInfo(h_info); gpuErrchk(cuCtxSetLimit(CU_LIMIT_STACK_SIZE, 1024 * 10)); dimBlock = dim3(THREAD_DIM, THREAD_DIM, 1); dimGrid = dim3(h_info.width / dimBlock.x + (h_info.width % dimBlock.x > 0), h_info.height / dimBlock.y + (h_info.height % dimBlock.y > 0), 1); snapshot.init(); }
bool CudaDeviceContext::Initialize() { // see if any cuda device is available. int deviceCount = 0; cudaGetDeviceCount(&deviceCount); message("CUDA device count: %d\n", deviceCount); if (deviceCount <= 0) { return false; } cudaGLSetGLDevice(_GetCudaDeviceForCurrentGLContext()); _initialized = true; return true; }
void initCuda(){ // Use device with highest Gflops/s cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); initPBO(&pbo); paraMap = new float[(int)renderCam->resolution.x *(int)renderCam->resolution.y]; effectiveRayMap =new int[(int)renderCam->resolution.x *(int)renderCam->resolution.y]; initialRayMap = new ray[(int)renderCam->resolution.x * (int)renderCam->resolution.y]; generateRayMap(renderCam, targetFrame); // Clean up on program exit atexit(cleanupCuda); runCuda(); }
int main(int argc, char** argv) { // Launch CUDA/GL init(argc, argv); cudaGLSetGLDevice( compat_getMaxGflopsDeviceId() ); cudaGLRegisterBufferObject( planetVBO ); #if VISUALIZE == 1 initCuda(N_FOR_VIS); #else initCuda(2*128); #endif projection = glm::perspective(fovy, float(width)/float(height), zNear, zFar); view = camera.getViewMatrix(); projection = projection * view; GLuint passthroughProgram; initShaders(program); glUseProgram(program[HEIGHT_FIELD]); glActiveTexture(GL_TEXTURE0); glEnable(GL_DEPTH_TEST); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }
int main(int argc, char** argv) { // Launch CUDA/GL init(argc, argv); cudaGLSetGLDevice(0); initPBO(&pbo); cudaGLRegisterBufferObject( planetVBO ); initCuda(N_FOR_VIS); projection = glm::perspective(fovy, float(width)/float(height), zNear, zFar); view = glm::lookAt(cameraPosition, glm::vec3(0), glm::vec3(0,0,1)); projection = projection * view; GLuint passthroughProgram; initShaders(program); glUseProgram(program[HEIGHT_FIELD]); glActiveTexture(GL_TEXTURE0); glEnable(GL_DEPTH_TEST); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }