本文整理汇总了C++中runCuda函数的典型用法代码示例。如果您正苦于以下问题:C++ runCuda函数的具体用法?C++ runCuda怎么用?C++ runCuda使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了runCuda函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: display
void display(){
runCuda();
string title = "565Raytracer | " + utilityCore::convertIntToString(iterations) + " Frames";
glutSetWindowTitle(title.c_str());
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, pbo);
glBindTexture(GL_TEXTURE_2D, displayImage);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, 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);
//draw text
char displaystring[200];
strcpy ( displaystring, "Press H for help." );
drawText ( 50, 50, displaystring);
glutPostRedisplay();
glutSwapBuffers();
}
开发者ID:YuanhuiChen,项目名称:Project2-Pathtracer,代码行数:32,代码来源: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: Render
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
// Clear the backbuffer to a black color
float ClearColor[4] = {0, 0, 0, 0};
g_pd3dDevice->ClearRenderTargetView(g_pSwapChainRTV, ClearColor);
// Run CUDA to update vertex positions
runCuda();
// Draw frame
{
// Setup the world, view, and projection matrices
SetupMatrices();
// Render the vertex buffer contents
UINT stride = sizeof(CUSTOMVERTEX);
UINT offset = 0;
g_pd3dDevice->IASetVertexBuffers(0, 1, &g_pVB, &stride, &offset);
g_pSimpleTechnique->GetPassByIndex(0)->Apply(0);
g_pd3dDevice->Draw(g_NumVertices, 0);
}
// Present the backbuffer contents to the display
g_pSwapChain->Present(0, 0);
anim += 0.01f;
}
开发者ID:RashaveraQ,项目名称:CUDA-Samples,代码行数:32,代码来源:simpleD3D10.cpp
示例4: display
void display(){
// DEBUG: display only one frame
/*
if ( frame > 5 )
return;
*/
runCuda();
time_t seconds2 = time (NULL);
if(seconds2-seconds >= 1){
fps = fpstracker/(seconds2-seconds);
fpstracker = 0;
seconds = seconds2;
}
string title = "CIS565 Rasterizer | "+ utilityCore::convertIntToString((int)fps) + "FPS";
glutSetWindowTitle(title.c_str());
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, pbo);
glBindTexture(GL_TEXTURE_2D, displayImage);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, 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);
glutPostRedisplay();
glutSwapBuffers();
}
开发者ID:uriahjb,项目名称:Project4-Rasterizer,代码行数:34,代码来源:main.cpp
示例5: mainLoop
void mainLoop() {
while(!glfwWindowShouldClose(window)){
glfwPollEvents();
runCuda();
time_t seconds2 = time (NULL);
if(seconds2-seconds >= 1){
fps = fpstracker/(seconds2-seconds);
fpstracker = 0;
seconds = seconds2;
}
string title = "CIS565 Rasterizer | " + utilityCore::convertIntToString((int)fps) + " FPS";
glfwSetWindowTitle(window, title.c_str());
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
glBindTexture(GL_TEXTURE_2D, displayImage);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, 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(window);
}
glfwDestroyWindow(window);
glfwTerminate();
}
开发者ID:drerucha,项目名称:Project4-Rasterizer,代码行数:29,代码来源:main.cpp
示例6: main
int main( int argc, char *argv[] ) {
initDisplay();
// get number of SMs on this GPU
int devID;
/*cudaDeviceProp props;
cudaGetDevice(&devID);
cudaGetDeviceProperties(&props, devID);
check();
printf("using device %s \n", props.name);
printf("number of MPs %d \n", props.multiProcessorCount);
printf("max threads per block %d \n", props.maxThreadsPerBlock);
printf("max concurrent kernels %d \n", props.concurrentKernels);
printf("number of bodies %d \n", numBodies);
*/
if(argc == 2)
{
if(strcmp(argv[1], "--cpu") == 0)
{
gpu = false;
}
else if(strcmp(argv[1], "--gpu") == 0)
{
gpu = true;
}
else
{
printf("wrong argument %s \nallowed: NULL, --cpu, --gpu \n", argv[1]);
exit(EXIT_FAILURE);
}
}
if(randData){
loadDataRand(numBodies);
}else{
loadData("data/data.tab", numBodies);
}
init(numBodies);
printf("stop with CTRL+C\n");
do {
runCuda();
showGalaxy(h_particleData, numBodies, false);
//count++;
} while (count < 64);
printf("finished...\n");
if(gpu)
{
cudaFree(d_particleData);
}
closeWindow();
printf("close...\n");
return EXIT_SUCCESS;
}
开发者ID:ipa,项目名称:nbody,代码行数:58,代码来源:main.c
示例7: 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
示例8: 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
示例9: 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
示例10: display
////////////////////////////////////////////////////////////////////////////////
//! Display callback
////////////////////////////////////////////////////////////////////////////////
void display()
{
// run CUDA kernel to generate vertex positions
boost::shared_ptr<thrust::device_vector<ms::point> > dv = runCuda();
if (!dv)
return;
ms::gl_buffer<ms::point> glb(dv->size());
glb << *dv;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// set view matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, translate_z);
glRotatef(rotate_x, 1.0, 0.0, 0.0);
glRotatef(rotate_y, 0.0, 1.0, 0.0);
// render from the vbo
glBindBuffer(GL_ARRAY_BUFFER,
glb.buffer());
glVertexPointer(3, // GLint size
GL_FLOAT, // GLenum type
24, // GLsizei stride
0); // offset
// assert (displayable.size_bytes == mesh_width * mesh_height * sizeof(mephitis::point));
//glColor3f(1.0, 1.0, 1.0);
glColorPointer(3,
GL_FLOAT,
24,
(const GLvoid*)(sizeof(float) * 3));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_POINTS, // GLenum mode
0, // GLint first
glb.size() // GLsizei count
);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glutSwapBuffers();
glutPostRedisplay();
}
开发者ID:straszheim,项目名称:mephitis,代码行数:55,代码来源:main.cpp
示例11: display
////////////////////////////////////////////////////////////////////////////////
//! Display callback
////////////////////////////////////////////////////////////////////////////////
void display()
{
sdkStartTimer(&timer);
// run CUDA kernel to generate vertex positions
runCuda(&cuda_vbo_resource);
//簡易ライトセット
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, gkLightPos);
glLightfv(GL_LIGHT0, GL_DIFFUSE, gkLightDiff);
// glLightfv(GL_LIGHT0, GL_AMBIENT, gkLightAmb);
glEnable(GL_LIGHT1);
glLightfv(GL_LIGHT1, GL_POSITION, gkLightPos2);
glLightfv(GL_LIGHT1, GL_DIFFUSE, gkLightDiff2);
//Zバッファ有効
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// set view matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, translate_z);
glRotatef(rotate_x, 1.0, 0.0, 0.0);
glRotatef(rotate_y, 0.0, 1.0, 0.0);
// Earth
// glMaterialfv(GL_FRONT, GL_DIFFUSE, gkMaterial);
glutSolidSphere(50.0 * h_axis_radius, 20, 20);
glDisable(GL_LIGHTING);
// render from the vbo
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glVertexPointer(4, GL_FLOAT, 0, 0);
glEnableClientState(GL_VERTEX_ARRAY);
glColor3f(1.0, 1.0, 1.0);
glDrawArrays(GL_POINTS, 0, mesh_width * mesh_height);
glDisableClientState(GL_VERTEX_ARRAY);
glutSwapBuffers();
g_fAnim += 0.01f;
sdkStopTimer(&timer);
computeFPS();
}
开发者ID:RashaveraQ,项目名称:SolarWind_by_CUDA,代码行数:52,代码来源:display.cpp
示例12: 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
示例13: initCuda
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();
}
开发者ID:YuanhuiChen,项目名称:Project3-Rasterizer,代码行数:15,代码来源:main.cpp
示例14: display
////////////////////////////////////////////////////////////////////////////////
//! Display callback
////////////////////////////////////////////////////////////////////////////////
void display()
{
cutilCheckError(cutStartTimer(timer));
// run CUDA kernel to generate vertex positions
runCuda(vbo);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// set view matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, translate_z);
glRotatef(rotate_x, 1.0, 0.0, 0.0);
glRotatef(rotate_y, 0.0, 1.0, 0.0);
// render from the vbo
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glVertexPointer(4, GL_FLOAT, 0, 0);
glEnableClientState(GL_VERTEX_ARRAY);
glColor3f(1.0, 0.0, 0.0);
glDrawArrays(GL_POINTS, 0, mesh_width * mesh_height);
glDisableClientState(GL_VERTEX_ARRAY);
if (g_CheckRender && g_CheckRender->IsQAReadback() && g_Verify) {
// readback for QA testing
printf("> (Frame %d) Readback BackBuffer\n", frameCount);
g_CheckRender->readback( window_width, window_height );
g_CheckRender->savePPM(sOriginal[g_Index], true, NULL);
if (!g_CheckRender->PPMvsPPM(sOriginal[g_Index], sReference[g_Index], MAX_EPSILON_ERROR, 0.15f)) {
g_TotalErrors++;
}
else
{
printf( "TEST PASSED\n" );
}
g_Verify = false;
}
glutSwapBuffers();
glutPostRedisplay();
anim += 0.01;
cutilCheckError(cutStopTimer(timer));
computeFPS();
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:51,代码来源:simpleGL.cpp
示例15: initCuda
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();
}
开发者ID:YuanhuiChen,项目名称:Project2-Pathtracer,代码行数:16,代码来源:main.cpp
示例16: display
void display(){
runCuda();
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, pbo);
glBindTexture(GL_TEXTURE_2D, image);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, 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);
glutPostRedisplay();
glutSwapBuffers();
}
开发者ID:aparajithsairam,项目名称:Homework0,代码行数:16,代码来源:main.cpp
示例17: initCuda
void initCuda(){
// Use device with highest Gflops/s
cudaGLSetGLDevice( compat_getMaxGflopsDeviceId() );
initPBO(&pbo);
modelView = glm::lookAt(cameraPosition, lookat, up);
projection = glm::perspective(fovy, float(width) / float(height), zNear, zFar);
viewPort[0] = glm::vec4(-float(width)/2,0,0,0.0f);
viewPort[1] = glm::vec4(0,-(float)height/2,0,0.0f);
viewPort[2] = glm::vec4(0,0,1.f/2.0f,0.0f);
viewPort[3] = glm::vec4((float)width/2,(float)height/2,1.0f/2.0f,1.0f);
// Clean up on program exit
atexit(cleanupCuda);
runCuda();
}
开发者ID:tiansijie,项目名称:GPU-Rasterizer,代码行数:17,代码来源:main.cpp
示例18: display
void display(){
runCuda();
string title = "CIS565 Render | " + utilityCore::convertIntToString(iterations) + " Iterations";
glfwSetWindowTitle(title.c_str());
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, pbo);
glBindTexture(GL_TEXTURE_2D, displayImage);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, 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();
}
开发者ID:vimanyu,项目名称:Project2-Pathtracer,代码行数:18,代码来源:main.cpp
示例19: display
void display()
{
// run CUDA kernel
runCuda();
// Create a texture from the buffer
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, pbo);
// bind texture from PBO
glBindTexture(GL_TEXTURE_2D, textureID);
// Note: glTexSubImage2D will perform a format conversion if the
// buffer is a different format from the texture. We created the
// texture with format GL_RGBA8. In glTexSubImage2D we specified
// GL_BGRA and GL_UNSIGNED_INT. This is a fast-path combination
// Note: NULL indicates the data resides in device memory
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image_width, image_height,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
// Draw a single Quad with texture coordinates for each vertex.
glBegin(GL_QUADS);
glTexCoord2f(0.0f,1.0f);
glVertex3f(0.0f,0.0f,0.0f);
glTexCoord2f(0.0f,0.0f);
glVertex3f(0.0f,1.0f,0.0f);
glTexCoord2f(1.0f,0.0f);
glVertex3f(1.0f,1.0f,0.0f);
glTexCoord2f(1.0f,1.0f);
glVertex3f(1.0f,0.0f,0.0f);
glEnd();
// Don't forget to swap the buffers!
glutSwapBuffers();
// if animFlag is true, then indicate the display needs to be redrawn
if(animFlag) {
glutPostRedisplay();
animTime += animInc;
}
}
开发者ID:elf11,项目名称:GPGPU,代码行数:44,代码来源:callbacksPBO.cpp
示例20: display
void display()
{
static float fps = 0;
frame++;
int time=glutGet(GLUT_ELAPSED_TIME);
if (time - timebase > 1000) {
fps = frame*1000.0f/(time-timebase);
timebase = time;
frame = 0;
}
float executionTime = glutGet(GLUT_ELAPSED_TIME) - timeSinceLastFrame;
timeSinceLastFrame = glutGet(GLUT_ELAPSED_TIME);
runCuda();
char title[100];
sprintf( title, "Flocking Simulation [%0.2f fps] [%0.2fms] ", fps, executionTime);
glutSetWindowTitle(title);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
#if VISUALIZE == 1
glUseProgram(program[PASS_THROUGH]);
glEnableVertexAttribArray(positionLocation);
glBindBuffer(GL_ARRAY_BUFFER, planetVBO);
glVertexAttribPointer((GLuint)positionLocation, 4, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(velocityLocation);
glBindBuffer(GL_ARRAY_BUFFER, velocityVBO);
glVertexAttribPointer((GLuint)velocityLocation, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, planetIBO);
glPointSize(4.0f);
glDrawElements(GL_POINTS, N_FOR_VIS, GL_UNSIGNED_INT, 0);
glDisableVertexAttribArray(positionLocation);
// Draw_Axes();
#endif
glutPostRedisplay();
glutSwapBuffers();
}
开发者ID:wuhao1117,项目名称:NbodySim-and-FlockingSim-with-CUDA,代码行数:43,代码来源:main.cpp
注:本文中的runCuda函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论