本文整理汇总了C++中cutilCheckError函数的典型用法代码示例。如果您正苦于以下问题:C++ cutilCheckError函数的具体用法?C++ cutilCheckError怎么用?C++ cutilCheckError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cutilCheckError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: benchmark
void
benchmark(int iterations)
{
// allocate memory for result
unsigned int *d_result;
unsigned int size = width * height * sizeof(unsigned int);
cutilSafeCall( cudaMalloc( (void**) &d_result, size));
// warm-up
gaussianFilterRGBA(d_img, d_result, d_temp, width, height, sigma, order, nthreads);
cutilSafeCall( cudaThreadSynchronize() );
cutilCheckError( cutStartTimer( timer));
// execute the kernel
for(int i=0; i<iterations; i++) {
gaussianFilterRGBA(d_img, d_result, d_temp, width, height, sigma, order, nthreads);
}
cutilSafeCall( cudaThreadSynchronize() );
cutilCheckError( cutStopTimer( timer));
// check if kernel execution generated an error
cutilCheckMsg("Kernel execution failed");
printf("Processing time: %f (ms)\n", cutGetTimerValue( timer));
printf("%.2f Mpixels/sec\n", (width*height*iterations / (cutGetTimerValue( timer) / 1000.0f)) / 1e6);
cutilSafeCall(cudaFree(d_result));
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:30,代码来源:recursiveGaussian-host.cpp
示例2: display
// This is the normal display path
void display(void)
{
cutilCheckError(cutStartTimer(timer));
// Sobel operation
Pixel *data = NULL;
// map PBO to get CUDA device pointer
cutilSafeCall(cudaGraphicsMapResources(1, &cuda_pbo_resource, 0));
size_t num_bytes;
cutilSafeCall(cudaGraphicsResourceGetMappedPointer((void **)&data, &num_bytes,
cuda_pbo_resource));
//printf("CUDA mapped PBO: May access %ld bytes\n", num_bytes);
sobelFilter(data, imWidth, imHeight, g_SobelDisplayMode, imageScale, blockOp, pointOp );
cutilSafeCall(cudaGraphicsUnmapResources(1, &cuda_pbo_resource, 0));
glClear(GL_COLOR_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, texid);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo_buffer);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, imWidth, imHeight,
GL_LUMINANCE, GL_UNSIGNED_BYTE, OFFSET(0));
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glBegin(GL_QUADS);
glVertex2f(0, 0); glTexCoord2f(0, 0);
glVertex2f(0, 1); glTexCoord2f(1, 0);
glVertex2f(1, 1); glTexCoord2f(1, 1);
glVertex2f(1, 0); glTexCoord2f(0, 1);
glEnd();
glBindTexture(GL_TEXTURE_2D, 0);
if (g_CheckRender && g_CheckRender->IsQAReadback() && g_Verify) {
printf("> (Frame %d) readback BackBuffer\n", frameCount);
g_CheckRender->readback( imWidth, imHeight );
g_CheckRender->savePPM ( sOriginal_ppm[g_Index], true, NULL );
if (!g_CheckRender->PPMvsPPM(sOriginal_ppm[g_Index], sReference_ppm[g_Index], MAX_EPSILON_ERROR, 0.15f)) {
g_TotalErrors++;
}
g_Verify = false;
}
glutSwapBuffers();
cutilCheckError(cutStopTimer(timer));
computeFPS();
glutPostRedisplay();
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:58,代码来源:FunctionPointers.cpp
示例3: fpsDisplay
void fpsDisplay()
{
cutilCheckError(cutStartTimer(timer));
display();
cutilCheckError(cutStopTimer(timer));
computeFPS();
}
开发者ID:elf11,项目名称:GPGPU,代码行数:9,代码来源:simpleGLmain.cpp
示例4: cleanup
void cleanup()
{
cutilCheckError(cutStopTimer(timer));
cutilCheckError(cutDeleteTimer( timer));
cudaFree(a_d);cudaFree(b_d);cudaFree(r_d);
cudaThreadExit();
}
开发者ID:elf11,项目名称:GPGPU,代码行数:10,代码来源:main.cpp
示例5: display
// display results using OpenGL
void display()
{
cutilCheckError(cutStartTimer(timer));
// execute filter, writing results to pbo
unsigned int *d_result;
//DEPRECATED: cutilSafeCall( cudaGLMapBufferObject((void**)&d_result, pbo) );
cutilSafeCall(cudaGraphicsMapResources(1, &cuda_pbo_resource, 0));
size_t num_bytes;
cutilSafeCall(cudaGraphicsResourceGetMappedPointer((void **)&d_result, &num_bytes,
cuda_pbo_resource));
runSelect(d_result);
// DEPRECATED: cutilSafeCall(cudaGLUnmapBufferObject(pbo));
cutilSafeCall(cudaGraphicsUnmapResources(1, &cuda_pbo_resource, 0));
// Common display code path
{
glClear(GL_COLOR_BUFFER_BIT);
// load texture from pbo
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
glBindTexture(GL_TEXTURE_2D, texid);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
// fragment program is required to display floating point texture
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
glDisable(GL_DEPTH_TEST);
glBegin(GL_QUADS);
{
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glTexCoord2f(1, 0);
glVertex2f(1, 0);
glTexCoord2f(1, 1);
glVertex2f(1, 1);
glTexCoord2f(0, 1);
glVertex2f(0, 1);
}
glEnd();
glBindTexture(GL_TEXTURE_TYPE, 0);
glDisable(GL_FRAGMENT_PROGRAM_ARB);
}
glutSwapBuffers();
glutReportErrors();
cutilCheckError(cutStopTimer(timer));
computeFPS();
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:55,代码来源:bilateralFilter.cpp
示例6: runBenchmark
void runBenchmark(int iterations)
{
cutilCheckError(cutStartTimer(timer));
for (int i = 0; i < iterations; ++i)
{
psystem->update(timestep);
}
cutilCheckError(cutStopTimer(timer));
float milliseconds = cutGetTimerValue(timer);
printf("%d particles, total time for %d iterations: %0.3f ms\n", numParticles, iterations, milliseconds);
printf("Test PASSED\n");
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:13,代码来源:particles.cpp
示例7: display
// display results using OpenGL
void display()
{
cutilCheckError(cutStartTimer(timer));
// execute filter, writing results to pbo
unsigned int *d_result;
cutilSafeCall(cudaGLMapBufferObject((void**)&d_result, pbo));
gaussianFilterRGBA(d_img, d_result, d_temp, width, height, sigma, order, nthreads);
cutilSafeCall(cudaGLUnmapBufferObject(pbo));
// load texture from pbo
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
glBindTexture(GL_TEXTURE_2D, texid);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
// display results
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glBegin(GL_QUADS);
glTexCoord2f(0, 1); glVertex2f(0, 0);
glTexCoord2f(1, 1); glVertex2f(1, 0);
glTexCoord2f(1, 0); glVertex2f(1, 1);
glTexCoord2f(0, 0); glVertex2f(0, 1);
glEnd();
glDisable(GL_TEXTURE_2D);
if (g_CheckRender && g_CheckRender->IsQAReadback() && g_Verify) {
// readback for QA testing
printf("> (Frame %d) Readback BackBuffer\n", frameCount);
g_CheckRender->readback( width, height );
g_CheckRender->savePPM(sOriginal[g_Index], true, NULL);
if (!g_CheckRender->PPMvsPPM(sOriginal[g_Index], sReference[g_Index], MAX_EPSILON_ERROR, 0.50f )) {
g_TotalErrors++;
}
g_Verify = false;
}
glutSwapBuffers();
cutilCheckError(cutStopTimer(timer));
computeFPS();
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:50,代码来源:recursiveGaussian-host.cpp
示例8: 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
示例9: cleanup
void cleanup()
{
if (g_bQAReadback) {
cudaFree(d_pos);
cudaFree(d_normal);
} else {
cutilCheckError( cutDeleteTimer( timer ));
deleteVBO(&posVbo, &cuda_posvbo_resource);
deleteVBO(&normalVbo, &cuda_normalvbo_resource);
}
cudppDestroyPlan(scanplan);
cutilSafeCall(cudaFree(d_edgeTable));
cutilSafeCall(cudaFree(d_triTable));
cutilSafeCall(cudaFree(d_numVertsTable));
cutilSafeCall(cudaFree(d_voxelVerts));
cutilSafeCall(cudaFree(d_voxelVertsScan));
cutilSafeCall(cudaFree(d_voxelOccupied));
cutilSafeCall(cudaFree(d_voxelOccupiedScan));
cutilSafeCall(cudaFree(d_compVoxelArray));
if (d_volume) cutilSafeCall(cudaFree(d_volume));
if (g_CheckRender) {
delete g_CheckRender; g_CheckRender = NULL;
}
if (g_FrameBufferObject) {
delete g_FrameBufferObject; g_FrameBufferObject = NULL;
}
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:33,代码来源:marchingCubes.cpp
示例10: checkResultCuda
////////////////////////////////////////////////////////////////////////////////
//! Check if the result is correct or write data to file for external
//! regression testing
////////////////////////////////////////////////////////////////////////////////
void checkResultCuda(int argc, char** argv, const GLuint& vbo)
{
cutilSafeCall(cudaGLUnregisterBufferObject(vbo));
// map buffer object
glBindBuffer(GL_ARRAY_BUFFER_ARB, vbo );
float* data = (float*) glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
// check result
if(cutCheckCmdLineFlag(argc, (const char**) argv, "regression")) {
// write file for regression test
cutilCheckError(cutWriteFilef("./data/regression.dat",
data, mesh_width * mesh_height * 3, 0.0));
}
// unmap GL buffer object
if(! glUnmapBuffer(GL_ARRAY_BUFFER)) {
fprintf(stderr, "Unmap buffer failed.\n");
fflush(stderr);
}
cutilSafeCall(cudaGLRegisterBufferObject(vbo));
CUT_CHECK_ERROR_GL();
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:29,代码来源:simpleGL.cpp
示例11: main
// Main program
int main(int argc, char** argv)
{
// Create the CUTIL timer
cutilCheckError( cutCreateTimer( &timer));
if (CUTFalse == initGL(argc, argv)) {
return CUTFalse;
}
initCuda(argc, argv);
CUT_CHECK_ERROR_GL();
// register callbacks
glutDisplayFunc(fpsDisplay);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutMotionFunc(motion);
// start rendering mainloop
glutMainLoop();
// clean up
cudaThreadExit();
cutilExit(argc, argv);
}
开发者ID:elf11,项目名称:GPGPU,代码行数:26,代码来源:simpleGLmain.cpp
示例12: cleanup
void cleanup()
{
cutilCheckError( cutDeleteTimer( timer));
if(h_img)cutFree(h_img);
cutilSafeCall(cudaFree(d_img));
cutilSafeCall(cudaFree(d_temp));
// Refer to boxFilter_kernel.cu for implementation
freeTextures();
//DEPRECATED: cutilSafeCall(cudaGLUnregisterBufferObject(pbo));
cudaGraphicsUnregisterResource(cuda_pbo_resource);
glDeleteBuffersARB(1, &pbo);
glDeleteTextures(1, &texid);
glDeleteProgramsARB(1, &shader);
if (g_CheckRender) {
delete g_CheckRender;
g_CheckRender = NULL;
}
if (g_FrameBufferObject) {
delete g_FrameBufferObject;
g_FrameBufferObject = NULL;
}
}
开发者ID:yyzreal,项目名称:gpuocelot,代码行数:26,代码来源:boxFilter.cpp
示例13: compareResults
void compareResults(bool regression, int numBodies)
{
nbodyCUDA->update(0.001f);
// check result
if(regression)
{
// write file for regression test
cutilCheckError( cutWriteFilef( "./data/regression.dat",
nbodyCUDA->getArray(BodySystem::BODYSYSTEM_POSITION),
numBodies, 0.0));
}
else
{
nbodyCPU = new BodySystemCPU(numBodies);
nbodyCPU->setArray(BodySystem::BODYSYSTEM_POSITION, hPos);
nbodyCPU->setArray(BodySystem::BODYSYSTEM_VELOCITY, hVel);
nbodyCPU->update(0.001f);
float* cudaPos = nbodyCUDA->getArray(BodySystem::BODYSYSTEM_POSITION);
float* cpuPos = nbodyCPU->getArray(BodySystem::BODYSYSTEM_POSITION);
// custom output handling when no regression test running
// in this case check if the result is equivalent to the expected
// solution
CUTBoolean res = cutComparefe( cpuPos, cudaPos, numBodies, .0005f);
printf( "Test %s\n", (1 == res) ? "PASSED" : "FAILED");
}
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:31,代码来源:nbody.cpp
示例14: 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
示例15: cleanup
void cleanup()
{
cutilCheckError( cutDeleteTimer( timer));
deleteVBO(&vbo);
if (g_CheckRender) {
delete g_CheckRender; g_CheckRender = NULL;
}
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:10,代码来源:simpleGL.cpp
示例16: _selectDemo
void _selectDemo(int index)
{
assert(index < numDemos);
activeParams = demoParams[index];
camera_trans[0] = camera_trans_lag[0] = activeParams.m_x;
camera_trans[1] = camera_trans_lag[1] = activeParams.m_y;
camera_trans[2] = camera_trans_lag[2] = activeParams.m_z;
reset(numBodies, NBODY_CONFIG_SHELL);
cutilCheckError(cutResetTimer(demoTimer));
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:11,代码来源:nbody.cpp
示例17: init
void init(int numParticles, uint3 gridSize)
{
psystem = new ParticleSystem(numParticles, gridSize);
psystem->reset(ParticleSystem::CONFIG_GRID);
renderer = new ParticleRenderer;
renderer->setParticleRadius(psystem->getParticleRadius());
renderer->setColorBuffer(psystem->getColorBuffer());
cutilCheckError(cutCreateTimer(&timer));
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:11,代码来源:particles.cpp
示例18: initCuda
void initCuda()
{
// allocate device memory
cutilSafeCall( cudaMalloc( (void**) &d_img, (width * height * sizeof(unsigned int)) ));
cutilSafeCall( cudaMalloc( (void**) &d_temp, (width * height * sizeof(unsigned int)) ));
// Refer to boxFilter_kernel.cu for implementation
initTexture(width, height, h_img);
cutilCheckError( cutCreateTimer( &timer));
}
开发者ID:yyzreal,项目名称:gpuocelot,代码行数:11,代码来源:boxFilter.cpp
示例19: _init
void _init(int numBodies, int numDevices, int p, int q, bool bUsePBO, bool useHostMem, bool useCpu)
{
if (useCpu)
{
m_nbodyCpu = new BodySystemCPU<T>(numBodies);
m_nbody = m_nbodyCpu;
m_nbodyCuda = 0;
}
else
{
m_nbodyCuda = new BodySystemCUDA<T>(numBodies, numDevices, p, q, bUsePBO, useHostMem);
m_nbody = m_nbodyCuda;
m_nbodyCpu = 0;
}
// allocate host memory
m_hPos = new T[numBodies*4];
m_hVel = new T[numBodies*4];
m_hColor = new float[numBodies*4];
m_nbody->setSoftening(activeParams.m_softening);
m_nbody->setDamping(activeParams.m_damping);
if (useCpu) {
cutilCheckError(cutCreateTimer(&timer));
cutilCheckError(cutStartTimer(timer));
} else {
cutilSafeCall( cudaEventCreate(&startEvent) );
cutilSafeCall( cudaEventCreate(&stopEvent) );
cutilSafeCall( cudaEventCreate(&hostMemSyncEvent) );
}
if (!benchmark && !compareToCPU)
{
m_renderer = new ParticleRenderer;
_resetRenderer();
}
cutilCheckError(cutCreateTimer(&demoTimer));
cutilCheckError(cutStartTimer(demoTimer));
}
开发者ID:AnkurAnandapu,项目名称:ocelot-fork,代码行数:41,代码来源:nbody.cpp
示例20: initParticles
// initialize particle system
void initParticles(int numParticles, bool bUseVBO, bool bUseGL)
{
psystem = new ParticleSystem(numParticles, bUseVBO, bUseGL);
psystem->reset(ParticleSystem::CONFIG_RANDOM);
if (bUseVBO) {
renderer = new SmokeRenderer(numParticles);
renderer->setLightTarget(vec3f(0.0, 1.0, 0.0));
cutilCheckError(cutCreateTimer(&timer));
}
}
开发者ID:voxels,项目名称:KinectCudaSmokeParticles,代码行数:13,代码来源:particleDemo.cpp
注:本文中的cutilCheckError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论