本文整理汇总了C++中cl::CommandQueue类的典型用法代码示例。如果您正苦于以下问题:C++ CommandQueue类的具体用法?C++ CommandQueue怎么用?C++ CommandQueue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommandQueue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: EnqueueAdvancePathsKernel
void PathOCLRenderThread::EnqueueAdvancePathsKernel(cl::CommandQueue &oclQueue) {
PathOCLRenderEngine *engine = (PathOCLRenderEngine *)renderEngine;
const u_int taskCount = engine->taskCount;
// Micro kernels version
oclQueue.enqueueNDRangeKernel(*advancePathsKernel_MK_RT_NEXT_VERTEX, cl::NullRange,
cl::NDRange(taskCount), cl::NDRange(advancePathsWorkGroupSize));
oclQueue.enqueueNDRangeKernel(*advancePathsKernel_MK_HIT_NOTHING, cl::NullRange,
cl::NDRange(taskCount), cl::NDRange(advancePathsWorkGroupSize));
oclQueue.enqueueNDRangeKernel(*advancePathsKernel_MK_HIT_OBJECT, cl::NullRange,
cl::NDRange(taskCount), cl::NDRange(advancePathsWorkGroupSize));
oclQueue.enqueueNDRangeKernel(*advancePathsKernel_MK_RT_DL, cl::NullRange,
cl::NDRange(taskCount), cl::NDRange(advancePathsWorkGroupSize));
oclQueue.enqueueNDRangeKernel(*advancePathsKernel_MK_DL_ILLUMINATE, cl::NullRange,
cl::NDRange(taskCount), cl::NDRange(advancePathsWorkGroupSize));
oclQueue.enqueueNDRangeKernel(*advancePathsKernel_MK_DL_SAMPLE_BSDF, cl::NullRange,
cl::NDRange(taskCount), cl::NDRange(advancePathsWorkGroupSize));
oclQueue.enqueueNDRangeKernel(*advancePathsKernel_MK_GENERATE_NEXT_VERTEX_RAY, cl::NullRange,
cl::NDRange(taskCount), cl::NDRange(advancePathsWorkGroupSize));
oclQueue.enqueueNDRangeKernel(*advancePathsKernel_MK_SPLAT_SAMPLE, cl::NullRange,
cl::NDRange(taskCount), cl::NDRange(advancePathsWorkGroupSize));
oclQueue.enqueueNDRangeKernel(*advancePathsKernel_MK_NEXT_SAMPLE, cl::NullRange,
cl::NDRange(taskCount), cl::NDRange(advancePathsWorkGroupSize));
oclQueue.enqueueNDRangeKernel(*advancePathsKernel_MK_GENERATE_CAMERA_RAY, cl::NullRange,
cl::NDRange(taskCount), cl::NDRange(advancePathsWorkGroupSize));
}
开发者ID:yangzhengxing,项目名称:luxrender,代码行数:26,代码来源:pathoclthread.cpp
示例2: update
void MetaBallsApp::update()
{
std::vector<cl::Memory> acquire( { mClParticleBuf, mClMarchingRenderBuffer, mClMarchingDebugBuffer } );
mClCommandQueue.enqueueAcquireGLObjects( &acquire );
updateParticles();
updateMarching();
mClCommandQueue.enqueueReleaseGLObjects( &acquire );
}
开发者ID:ryanbartley,项目名称:Cinder-OpenCl,代码行数:8,代码来源:MetaBallsApp.cpp
示例3: runKernelLatency
int clPeak::runKernelLatency(cl::CommandQueue &queue, cl::Program &prog, device_info_t &devInfo)
{
if(!isKernelLatency)
return 0;
cl::Context ctx = queue.getInfo<CL_QUEUE_CONTEXT>();
cl_uint numItems = (devInfo.maxWGSize) * (devInfo.numCUs) * FETCH_PER_WI;
cl::NDRange globalSize = (numItems / FETCH_PER_WI);
cl::NDRange localSize = devInfo.maxWGSize;
int iters = devInfo.kernelLatencyIters;
float latency;
try
{
log->print(NEWLINE TAB TAB "Kernel launch latency : ");
log->xmlOpenTag("kernel_launch_latency");
log->xmlAppendAttribs("unit", "us");
cl::Buffer inputBuf = cl::Buffer(ctx, CL_MEM_READ_ONLY, (numItems * sizeof(float)));
cl::Buffer outputBuf = cl::Buffer(ctx, CL_MEM_WRITE_ONLY, (numItems * sizeof(float)));
cl::Kernel kernel_v1(prog, "global_bandwidth_v1_local_offset");
kernel_v1.setArg(0, inputBuf), kernel_v1.setArg(1, outputBuf);
// Dummy calls
queue.enqueueNDRangeKernel(kernel_v1, cl::NullRange, globalSize, localSize);
queue.enqueueNDRangeKernel(kernel_v1, cl::NullRange, globalSize, localSize);
queue.finish();
latency = 0;
for(int i=0; i<iters; i++)
{
cl::Event timeEvent;
queue.enqueueNDRangeKernel(kernel_v1, cl::NullRange, globalSize, localSize, NULL, &timeEvent);
queue.finish();
cl_ulong start = timeEvent.getProfilingInfo<CL_PROFILING_COMMAND_QUEUED>() / 1000;
cl_ulong end = timeEvent.getProfilingInfo<CL_PROFILING_COMMAND_START>() / 1000;
latency += (float)((int)end - (int)start);
}
latency /= iters;
log->print(latency); log->print(" us" NEWLINE);
log->xmlSetContent(latency);
log->xmlCloseTag();
}
catch(cl::Error error)
{
log->print(error.err() + NEWLINE);
log->print(TAB TAB "Tests skipped" NEWLINE);
return -1;
}
return 0;
}
开发者ID:nivertech,项目名称:clpeak,代码行数:54,代码来源:kernel_latency.cpp
示例4: enqueueNewMarker
cl::Event RuntimeMeasurementsManager::enqueueNewMarker(cl::CommandQueue queue) {
cl::Event event;
#if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
// Use deprecated API
queue.enqueueMarker(&event);
#else
queue.enqueueMarkerWithWaitList(NULL, &event)
#endif
queue.finish();
return event;
}
开发者ID:philliihd,项目名称:OpenCLUtilityLibrary,代码行数:12,代码来源:RuntimeMeasurementManager.cpp
示例5: copyFromDevice
void copyFromDevice(cl::CommandQueue &queue)
{
if(m_pElts==NULL)
throw cl::Error(CL_INVALID_MEM_OBJECT, "copyFromDevice - Buffer is not initialised.");
queue.enqueueReadBuffer(m_buffer, CL_TRUE, 0, m_cb, m_pElts);
}
开发者ID:alcides,项目名称:pcg_cl,代码行数:7,代码来源:opencl_buffer.hpp
示例6: kernel
void kernel(cl::Buffer& devOut, cl::CommandQueue& queue)
{
static std::once_flag compileFlag;
static cl::Program prog;
static cl::Kernel kern;
std::call_once(compileFlag,
[queue]() {
prog = cl::Program(queue.getInfo<CL_QUEUE_CONTEXT>(), fractal_ocl_kernel, true);
kern = cl::Kernel(prog, "julia");
});
//auto juliaOp = cl::make_kernel<Buffer, unsigned, unsigned>(kern);
static const NDRange local(8, 8);
NDRange global(local[0] * divup(DIMX, local[0]),
local[1] * divup(DIMY, local[1]));
kern.setArg(0, devOut);
kern.setArg(1, DIMX);
kern.setArg(2, DIMY);
queue.enqueueNDRangeKernel(kern, cl::NullRange, global, local);
//juliaOp(EnqueueArgs(queue, global, local), devOut, DIMX, DIMY);
}
开发者ID:syurkevi,项目名称:forge,代码行数:25,代码来源:fractal.cpp
示例7: runTestType
bool runTestType(cl::Context context, cl::CommandQueue queue)
{
cl_uint size = 1024 * 2 + 15;
std::vector<T> input(size);
std::cout << "##Testing scan for " << input.size() << " elements and type "
<< magnet::CL::detail::traits<T>::kernel_type();
for(size_t i = 0; i < input.size(); ++i)
input[i] = i+1;
// create input buffer using pinned memory
cl::Buffer bufferIn(context, CL_MEM_ALLOC_HOST_PTR |
CL_MEM_COPY_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(T) * input.size(), &input[0])
;
magnet::CL::scan<T> scanFunctor;
scanFunctor.build(queue, context);
scanFunctor(bufferIn, bufferIn);
std::vector<T> output(size);
queue.enqueueReadBuffer(bufferIn, CL_TRUE, 0, input.size() *
sizeof(T), &output[0]);
bool failed = !testOutput(input, output);
std::cout << (failed ? " FAILED" : " PASSED") << std::endl;
return failed;
}
开发者ID:BigMacchia,项目名称:DynamO,代码行数:32,代码来源:scan_test.cpp
示例8: runKernel
cl::Event runKernel(const cl::CommandQueue& queue, const cl::Kernel& kernel, const cl::NDRange& globalSize, const cl::NDRange& groupSize, std::vector<cl::Event>& events)
{
cl::Event event;
queue.enqueueNDRangeKernel(kernel, cl::NullRange, globalSize, groupSize, &events, &event);
events.push_back(event);
return event;
}
开发者ID:Jereq,项目名称:Raytracer,代码行数:7,代码来源:CLHelper.cpp
示例9: runTestType
void runTestType(cl::Context context, cl::CommandQueue queue)
{
cl_uint size = 2 << 10;
std::vector<T> input(size);
std::cout << "##Testing bitonic sort for " << input.size() << " elements and type "
<< magnet::CL::detail::traits<T>::kernel_type()
<< std::endl;
for(size_t i = 0; i < input.size(); ++i)
input[i] = input.size() - i - 1;
// create input buffer using pinned memory
cl::Buffer bufferIn(context, CL_MEM_ALLOC_HOST_PTR |
CL_MEM_COPY_HOST_PTR | CL_MEM_READ_WRITE,
sizeof(T) * input.size(), &input[0])
;
magnet::CL::bitonicSort<T> bitonicSortFunctor;
bitonicSortFunctor.build(queue, context);
bitonicSortFunctor(bufferIn);
std::vector<T> output(size);
queue.enqueueReadBuffer(bufferIn, CL_TRUE, 0, input.size() *
sizeof(T), &output[0]);
if (!testOutput(input, output))
M_throw() << "Incorrect output for size "
<< input.size()
<< " and type "
<< magnet::CL::detail::traits<T>::kernel_type();
}
开发者ID:BigMacchia,项目名称:DynamO,代码行数:34,代码来源:bitonicsort_test.cpp
示例10: addkernelarg
inline void OpenCL::addkernelarg(std::size_t i, std::vector<T> const & arg, cl::Kernel & kernel,cl::CommandQueue &quene) const
{
cl::Buffer buffer(this->context,CL_MEM_READ_WRITE,arg.size()*sizeof(T));
// std::cout << "enqeue\n";
quene.enqueueWriteBuffer(buffer,CL_FALSE,0,sizeof(T)*arg.size(),&(arg[0]));
kernel.setArg(i,buffer);
}
开发者ID:crysxd,项目名称:Parallel-Computing-and-Algorithms-X033537-Project,代码行数:8,代码来源:OpenCL.cpp
示例11: const
inline void OpenCL::addkernelarg(std::size_t i, T const (& arg)[N], cl::Kernel & kernel,cl::CommandQueue &quene) const
{
cl::Buffer buffer(this->context,CL_MEM_READ_WRITE,N*sizeof(T));
// std::cout << "enqeue\n";
quene.enqueueWriteBuffer(buffer,CL_FALSE,0,sizeof(T)*N,&arg);
kernel.setArg(i,buffer);
}
开发者ID:crysxd,项目名称:Parallel-Computing-and-Algorithms-X033537-Project,代码行数:8,代码来源:OpenCL.cpp
示例12: release
CL::Event OGLSharedFramebuffer::release(CL::CommandQueue& queue, const CL::Event& evt)
{
if (_shared) {
CL::Event e = queue.enq_GL_release(_cl_buffer->get(),
"release framebuffer", evt);
return e;
} else {
assert(_local);
CL::Event e = queue.enq_read_buffer(*_cl_buffer, _local, _tex_buffer.get_size(),
"read framebuffer", evt);
queue.wait_for_events(e);
_tex_buffer.load(_local);
return CL::Event();
}
}
开发者ID:yzhwang,项目名称:micropolis,代码行数:17,代码来源:Framebuffer.cpp
示例13: read
void read(const cl::CommandQueue &q, size_t offset, size_t size, T *host,
bool blocking = false) const
{
if (size)
q.enqueueReadBuffer(
buffer, blocking ? CL_TRUE : CL_FALSE,
sizeof(T) * offset, sizeof(T) * size, host
);
}
开发者ID:1ibrium,项目名称:vexcl,代码行数:9,代码来源:device_vector.hpp
示例14: L2Norm
real L2Norm(const Buffer3D & in,cl::CommandQueue & q)
{
cl::Buffer ans (CLContextLoader::getContext(),CL_MEM_READ_WRITE,sizeof(real)*in.width()*in.height()*in.depth());
CLContextLoader::getRedL2NormKer().setArg(0,in());
CLContextLoader::getRedL2NormKer().setArg(1,ans());
q.enqueueNDRangeKernel(CLContextLoader::getRedL2NormKer(),
cl::NDRange(0),
cl::NDRange(in.width()*in.height()*in.depth()),
getBestWorkspaceDim(cl::NDRange(in.width()*in.height()*in.depth())));
ans = performReduction(ans,CLContextLoader::getRedSumAllKer(),q,in.width()*in.height()*in.depth());
real res;
q.enqueueReadBuffer(ans,true,0,sizeof(real),&res);
return sqrt(res);
}
开发者ID:sbabbi,项目名称:multigrid,代码行数:18,代码来源:auxiliary.cpp
示例15: copyToDeviceAsync
cl::Event copyToDeviceAsync(cl::CommandQueue &queue)
{
if(m_pElts==NULL)
throw cl::Error(CL_INVALID_MEM_OBJECT, "copyToDevice - Buffer is not initialised.");
cl::Event complete;
queue.enqueueWriteBuffer(m_buffer, CL_FALSE, 0, m_cb, m_pElts, NULL, &complete);
return complete;
}
开发者ID:alcides,项目名称:pcg_cl,代码行数:9,代码来源:opencl_buffer.hpp
示例16: acquire
CL::Event OGLSharedFramebuffer::acquire(CL::CommandQueue& queue, const CL::Event& e)
{
if (_shared) {
return queue.enq_GL_acquire(_cl_buffer->get(),
"acquire framebuffer", e);
} else {
return e;
}
}
开发者ID:yzhwang,项目名称:micropolis,代码行数:9,代码来源:Framebuffer.cpp
示例17: sumTest
void sumTest(cl::Buffer queue_data, cl::Buffer queue_metadata,
cl::Buffer& device_result, int iterations,
ProgramCache& cache,
cl::CommandQueue& queue)
{
cl::Context context = queue.getInfo<CL_QUEUE_CONTEXT>();
std::vector<std::string> sources;
sources.push_back("ParallelQueue");
sources.push_back("ParallelQueueTests");
cl::Program& program = cache.getProgram(sources);
cl::Kernel sum_test_kernel(program, "sum_test");
cl::Device device = queue.getInfo<CL_QUEUE_DEVICE>();
int warp_size = sum_test_kernel
.getWorkGroupInfo<CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE>(device);
std::cout << "warp size: " << warp_size << std::endl;
int max_group_size = device.getInfo<CL_DEVICE_MAX_WORK_ITEM_SIZES>()[0];
int queue_num_threads = 512;
if(queue_num_threads > max_group_size)
queue_num_threads = max_group_size;
cl::LocalSpaceArg local_queue
= cl::__local(sizeof(int) * queue_num_threads * 2);
cl::LocalSpaceArg reduction_buffer
= cl::__local(sizeof(int) * queue_num_threads);
cl::LocalSpaceArg got_work
= cl::__local(sizeof(int));
cl::LocalSpaceArg prefix_sum_input
= cl::__local(sizeof(int) * queue_num_threads);
cl::LocalSpaceArg prefix_sum_output
= cl::__local(sizeof(int) * queue_num_threads);
sum_test_kernel.setArg(0, queue_data);
sum_test_kernel.setArg(1, queue_metadata);
sum_test_kernel.setArg(2, device_result);
sum_test_kernel.setArg(3, iterations);
sum_test_kernel.setArg(4, local_queue);
sum_test_kernel.setArg(5, reduction_buffer);
sum_test_kernel.setArg(6, got_work);
sum_test_kernel.setArg(7, prefix_sum_input);
sum_test_kernel.setArg(8, prefix_sum_output);
cl::NDRange nullRange;
cl::NDRange global(queue_num_threads, 1);
cl::NDRange local(queue_num_threads, 1);
cl_int status = queue.enqueueNDRangeKernel(sum_test_kernel,
nullRange, global, local);
}
开发者ID:sharmaashish,项目名称:emory-cci-fast-ia-gsoc,代码行数:56,代码来源:parallelQueueTest.cpp
示例18: clear
CL::Event Framebuffer::clear(CL::CommandQueue& queue, const CL::Event& e)
{
_clear_kernel.set_arg(0, _cl_buffer->get());
vec4 color = config.clear_color();
_clear_kernel.set_arg(1, vec4(powf(color.x, 2.2),
powf(color.y, 2.2),
powf(color.z, 2.2), 1000));
return queue.enq_kernel(_clear_kernel, _size.x * _size.y, 256,
"clear framebuffer", e);
}
开发者ID:yzhwang,项目名称:micropolis,代码行数:10,代码来源:Framebuffer.cpp
示例19: findMinSeamVert
void findMinSeamVert(cl::Context &ctx,
cl::CommandQueue &cmdQueue,
cl::Event &event,
std::vector<cl::Event> &deps,
cl::Buffer &energyMatrix,
cl::Buffer &vertMinEnergy,
cl::Buffer &vertMinIdx,
int width,
int height,
int pitch,
int colsRemoved) {
cl_int errNum;
errNum = findMinSeamVertKernel.setArg(0, energyMatrix);
errNum |= findMinSeamVertKernel.setArg(1, vertMinEnergy);
errNum |= findMinSeamVertKernel.setArg(2, vertMinIdx);
errNum |= findMinSeamVertKernel.setArg(3, cl::__local(256 * sizeof(float)));
errNum |= findMinSeamVertKernel.setArg(4, cl::__local(256 * sizeof(float)));
errNum |= findMinSeamVertKernel.setArg(5, width);
errNum |= findMinSeamVertKernel.setArg(6, height);
errNum |= findMinSeamVertKernel.setArg(7, pitch);
errNum |= findMinSeamVertKernel.setArg(8, colsRemoved);
if (errNum != CL_SUCCESS) {
std::cerr << "Error setting findMinSeamVert arguments." << std::endl;
exit(-1);
}
// This kernel could be written to use more than one work group, but its probably not worth it.
cl::NDRange offset = cl::NDRange(0);
cl::NDRange localWorkSize = cl::NDRange(256);
cl::NDRange globalWorkSize = cl::NDRange(256);
errNum = cmdQueue.enqueueNDRangeKernel(findMinSeamVertKernel,
offset,
globalWorkSize,
localWorkSize,
&deps,
&event);
if (errNum != CL_SUCCESS) {
std::cerr << "Error enqueuing computeSeams kernel for execution." << std::endl;
exit(-1);
}
/** DEBUG **/
// int deviceResultIdx[1];
// float deviceResultEnergy[1];
// mem::read(ctx, cmdQueue, deviceResultIdx, vertMinIdx);
// mem::read(ctx, cmdQueue, deviceResultEnergy, vertMinEnergy);
// std::cout << "deviceResultIdx = " << deviceResultIdx[0] << std::endl;
// std::cout << "deviceResultEnergy = " << deviceResultEnergy[0] << std::endl;
}
开发者ID:amidvidy,项目名称:seamcarve-opencl,代码行数:55,代码来源:kernel.hpp
示例20: simulationStep
void simulationStep() {
try {
// copy
auto buffer = cl::Buffer(context, CL_MEM_READ_ONLY,
sizeof(unsigned char) * 4 * fieldWidth * fieldHeight,
nullptr, nullptr);
queue.enqueueWriteBuffer(buffer, CL_TRUE, 0,
sizeof(unsigned char) * 4 * fieldWidth * fieldHeight,
visualizationBufferCPU, NULL, NULL);
// enque
stepKernel.setArg(2, buffer);
cl::NDRange global((size_t) (fieldWidth * fieldHeight));
queue.enqueueNDRangeKernel(stepKernel, cl::NullRange, global, cl::NullRange);
// read back
queue.enqueueReadBuffer(visualizationBufferGPU, CL_TRUE, 0,
sizeof(unsigned char) * 4 * fieldWidth * fieldHeight,
visualizationBufferCPU, NULL, NULL);
// finish
queue.finish();
} catch (cl::Error err) {
std::cout << "Error: " << err.what() << "(" << err.err() << ")" << std::endl;
exit(3);
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fieldWidth, fieldHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
visualizationBufferCPU);
}
开发者ID:steindani,项目名称:gpgpu_gameoflife,代码行数:30,代码来源:GameOfLife.cpp
注:本文中的cl::CommandQueue类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论