• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cudaGLSetGLDevice函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cudaGLSetGLDevice函数的典型用法代码示例。如果您正苦于以下问题:C++ cudaGLSetGLDevice函数的具体用法?C++ cudaGLSetGLDevice怎么用?C++ cudaGLSetGLDevice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cudaGLSetGLDevice函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: initCuda

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();
}
开发者ID:vivreddy,项目名称:Project-0,代码行数:15,代码来源:main.cpp


示例2: initCuda

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();
}
开发者ID:armerpaul,项目名称:CUDA_RayTracer,代码行数:27,代码来源:simplePBO.cpp


示例3: cudaGLSetGLDevice

    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);

    };
开发者ID:nivertech,项目名称:cuda-course,代码行数:33,代码来源:graphics.cpp


示例4: init

void init()
{
    //std::cerr << "INIT CUDA.cpp!!!!" << std::endl;
    if (initialized) return;
    cudaGLSetGLDevice(0);
    initialized = true;
}
开发者ID:karlssonper,项目名称:cs248,代码行数:7,代码来源:CUDA.cpp


示例5: cudaGLSetGLDevice

void CudaBase::SetGLDevice()
{
    if(!CheckCUDevice()) return;
	std::cout<<" cuda set GL device\n";
	cudaGLSetGLDevice(0);
	HasDevice = 1;
}
开发者ID:ahmidou,项目名称:aphid,代码行数:7,代码来源:CudaBase.cpp


示例6: m_ifDataReady

	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);
	}
开发者ID:peng-mi,项目名称:DynamicVis,代码行数:33,代码来源:datamanager.cpp


示例7: main

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;
}
开发者ID:wuhao1117,项目名称:NbodySim-and-FlockingSim-with-CUDA,代码行数:30,代码来源:main.cpp


示例8: main

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;
}
开发者ID:CyborgYL,项目名称:Project-1,代码行数:33,代码来源:main.cpp


示例9: initGlWindow

    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
    };
开发者ID:Tener,项目名称:cuda-course,代码行数:32,代码来源:graphics.cpp


示例10: initCuda

void initCuda(){
  // Use device with highest Gflops/s
  cudaGLSetGLDevice(0);

  // Clean up on program exit
  atexit(cleanupCuda);
}
开发者ID:drerucha,项目名称:Project4-Rasterizer,代码行数:7,代码来源:main.cpp


示例11: main

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;
}
开发者ID:JohnDeCorato,项目名称:CS6650FinalProject,代码行数:35,代码来源:main.cpp


示例12: initCuda

void initCuda(){

	cudaGLSetGLDevice(0); 

	// Clean up on program exit
	atexit(cleanupCuda);

}
开发者ID:wang1262,项目名称:Project3-Pathtracer,代码行数:8,代码来源:main.cpp


示例13: init_parallel_component

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();
}
开发者ID:anojavan,项目名称:csinparallel,代码行数:8,代码来源:cuda.c


示例14: InitCuda

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);
}
开发者ID:DiracSea3921,项目名称:Project-0,代码行数:8,代码来源:main.cpp


示例15: HANDLE_ERROR

void glcu::init_cuda()
{
    cudaDeviceProp prop = {0};
    int dev;
    prop.major = 1;
    prop.minor = 0;
    HANDLE_ERROR(cudaChooseDevice(&dev, &prop));
    HANDLE_ERROR(cudaGLSetGLDevice(dev));
}
开发者ID:Answeror,项目名称:cg,代码行数:9,代码来源:glcu.cpp


示例16: initCuda

void initCuda() {
    // Use device with highest Gflops/s
    cudaGLSetGLDevice(0);

    rasterizeInit(width, height);

    // Clean up on program exit
    atexit(cleanupCuda);
}
开发者ID:terrynsun,项目名称:cis565-CUDA-Rasterizer,代码行数:9,代码来源:main.cpp


示例17: runTest

////////////////////////////////////////////////////////////////////////////////
//! 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;
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:59,代码来源:simpleGL.cpp


示例18: initCUDA

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
}
开发者ID:Guokr1991,项目名称:hos,代码行数:10,代码来源:HuygensOnSpeed.cpp


示例19: initCuda

void initCuda(){
  // Use device with highest Gflops/s
  cudaGLSetGLDevice( compat_getMaxGflopsDeviceId() );

  initPBO(&pbo);

  // Clean up on program exit
  atexit(cleanupCuda);

  runCuda();
}
开发者ID:uriahjb,项目名称:Project4-Rasterizer,代码行数:11,代码来源:main.cpp


示例20: initCuda

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();
}
开发者ID:pgurniak,项目名称:Project-0,代码行数:12,代码来源:main.cpp



注:本文中的cudaGLSetGLDevice函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cudaGetDevice函数代码示例发布时间:2022-05-30
下一篇:
C++ cudaFreeHost函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap