本文整理汇总了C++中cl::CommandQueue::enqueueUnmapMemObject方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandQueue::enqueueUnmapMemObject方法的具体用法?C++ CommandQueue::enqueueUnmapMemObject怎么用?C++ CommandQueue::enqueueUnmapMemObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cl::CommandQueue
的用法示例。
在下文中一共展示了CommandQueue::enqueueUnmapMemObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowU8ImageGPUBuffer
int ShowU8ImageGPUBuffer(cl::CommandQueue command_queue,
cl::Buffer buffer,
int width,
int height)
{
unsigned char *cpu = (unsigned char *)command_queue.enqueueMapBuffer(buffer,
CL_TRUE,
CL_MAP_WRITE,
0,
width * height);
Mat img_to_show(height, width, CV_8U, cpu);
ResizeImage(img_to_show, width, height);
imshow("u8", img_to_show);
waitKey();
command_queue.enqueueUnmapMemObject(buffer, cpu);
return (0);
}
示例2: runTransferBandwidthTest
//.........这里部分代码省略.........
} else
{
Timer timer;
timer.start();
for(int i=0; i<iters; i++)
{
queue.enqueueReadBuffer(clBuffer, CL_TRUE, 0, (numItems * sizeof(float)), arr);
}
queue.finish();
timed = timer.stopAndTime();
}
timed /= iters;
gbps = ((float)numItems * sizeof(float)) / timed / 1e3f;
log->print(gbps); log->print(NEWLINE);
log->xmlRecord("enqueuereadbuffer", gbps);
///////////////////////////////////////////////////////////////////////////
// enqueueMapBuffer
log->print(TAB TAB TAB "enqueueMapBuffer(for read) : ");
queue.finish();
timed = 0;
if(useEventTimer)
{
for(int i=0; i<iters; i++)
{
cl::Event timeEvent;
void *mapPtr;
mapPtr = queue.enqueueMapBuffer(clBuffer, CL_TRUE, CL_MAP_READ, 0, (numItems * sizeof(float)), NULL, &timeEvent);
queue.finish();
queue.enqueueUnmapMemObject(clBuffer, mapPtr);
queue.finish();
timed += timeInUS(timeEvent);
}
} else
{
for(int i=0; i<iters; i++)
{
Timer timer;
void *mapPtr;
timer.start();
mapPtr = queue.enqueueMapBuffer(clBuffer, CL_TRUE, CL_MAP_READ, 0, (numItems * sizeof(float)));
queue.finish();
timed += timer.stopAndTime();
queue.enqueueUnmapMemObject(clBuffer, mapPtr);
queue.finish();
}
}
timed /= iters;
gbps = ((float)numItems * sizeof(float)) / timed / 1e3f;
log->print(gbps); log->print(NEWLINE);
log->xmlRecord("enqueuemapbuffer", gbps);
///////////////////////////////////////////////////////////////////////////
// memcpy from mapped ptr
log->print(TAB TAB TAB TAB "memcpy from mapped ptr : ");
queue.finish();
timed = 0;
for(int i=0; i<iters; i++)
示例3: runTransferBandwidthTest
//.........这里部分代码省略.........
}
} else
{
Timer timer;
timer.start();
for(int i=0; i<iters; i++)
{
queue.enqueueReadBuffer(clBuffer, CL_TRUE, 0, (numItems * sizeof(float)), arr);
}
queue.finish();
timed = timer.stopAndTime();
}
timed /= iters;
gbps = ((float)numItems * sizeof(float)) / timed / 1e3f;
cout << gbps << endl;
///////////////////////////////////////////////////////////////////////////
// enqueueMapBuffer
cout << TAB TAB TAB "enqueueMapBuffer(for read) : "; cout.flush();
queue.finish();
timed = 0;
if(useEventTimer)
{
for(int i=0; i<iters; i++)
{
cl::Event timeEvent;
void *mapPtr;
mapPtr = queue.enqueueMapBuffer(clBuffer, CL_TRUE, CL_MAP_READ, 0, (numItems * sizeof(float)), NULL, &timeEvent);
queue.finish();
queue.enqueueUnmapMemObject(clBuffer, mapPtr);
queue.finish();
timed += timeInUS(timeEvent);
}
} else
{
for(int i=0; i<iters; i++)
{
Timer timer;
void *mapPtr;
timer.start();
mapPtr = queue.enqueueMapBuffer(clBuffer, CL_TRUE, CL_MAP_READ, 0, (numItems * sizeof(float)));
queue.finish();
timed += timer.stopAndTime();
queue.enqueueUnmapMemObject(clBuffer, mapPtr);
queue.finish();
}
}
timed /= iters;
gbps = ((float)numItems * sizeof(float)) / timed / 1e3f;
cout << gbps << endl;
///////////////////////////////////////////////////////////////////////////
// memcpy from mapped ptr
cout << TAB TAB TAB TAB "memcpy from mapped ptr : "; cout.flush();
queue.finish();
timed = 0;
for(int i=0; i<iters; i++)
{