本文整理汇总了C++中OpenCLContext::createCommandQueue方法的典型用法代码示例。如果您正苦于以下问题:C++ OpenCLContext::createCommandQueue方法的具体用法?C++ OpenCLContext::createCommandQueue怎么用?C++ OpenCLContext::createCommandQueue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCLContext
的用法示例。
在下文中一共展示了OpenCLContext::createCommandQueue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
OpenCLMomentumV3::OpenCLMomentumV3(int _HASH_BITS, int _device_num) {
max_threads = 1<<30; // very big
HASH_BITS = _HASH_BITS;
device_num = _device_num;
OpenCLMain& main = OpenCLMain::getInstance();
// checks if device exists
if (main.getInstance().getNumDevices() <= device_num) {
printf("ERROR: DEVICE %d does not exist. Please limit your threads to one per device.\n", device_num);
assert(false);
}
// compiles
fprintf(stdout, "Starting OpenCLMomentum V3\n");
fprintf(stdout, "Device %02d: %s\n", device_num, main.getDevice(device_num)->getName().c_str());
cl_ulong maxWorkGroupSize = main.getDevice(device_num)->getMaxWorkGroupSize();
fprintf(stdout, "Max work group size: %llu\n", maxWorkGroupSize);
if (maxWorkGroupSize < max_threads) max_threads = maxWorkGroupSize;
OpenCLContext *context = main.getDevice(device_num)->getContext();
std::vector<std::string> program_filenames;
program_filenames.push_back("opencl/opencl_cryptsha512.h");
program_filenames.push_back("opencl/cryptsha512_kernel.cl");
program_filenames.push_back("opencl/OpenCLMomentumV3.cl");
OpenCLProgram *program = context->loadProgramFromFiles(program_filenames);
// prealoc kernels
OpenCLKernel *kernel = program->getKernel("kernel_sha512");
OpenCLKernel *kernel_cleanup = program->getKernel("kernel_clean_hash_table");
// only one queue, helps with memory leaking
queue = context->createCommandQueue(main.getDevice(device_num));
size_t BLOCKSIZE = max_threads;
// allocate internal structure
cl_message = context->createBuffer(sizeof(uint8_t)*32, CL_MEM_READ_ONLY, NULL);
internal_hash_table = context->createBuffer(sizeof(uint32_t)*(1<<HASH_BITS), CL_MEM_READ_WRITE, NULL);
temp_collisions = context->createBuffer(sizeof(collision_struct)*getCollisionCeiling(), CL_MEM_WRITE_ONLY, NULL);
temp_collisions_count = context->createBuffer(sizeof(size_t), CL_MEM_READ_WRITE, NULL);
// sets args
kernel_cleanup->resetArgs();
kernel_cleanup->addGlobalArg(internal_hash_table);
kernel->resetArgs();
kernel->addGlobalArg(cl_message);
kernel->addGlobalArg(internal_hash_table);
uint32_t ht_size = 1<<HASH_BITS;
kernel->addScalarUInt(ht_size);
kernel->addGlobalArg(temp_collisions);
kernel->addGlobalArg(temp_collisions_count);
}