本文整理汇总了C++中cl::Kernel::bind方法的典型用法代码示例。如果您正苦于以下问题:C++ Kernel::bind方法的具体用法?C++ Kernel::bind怎么用?C++ Kernel::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cl::Kernel
的用法示例。
在下文中一共展示了Kernel::bind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: maxValueCL
int MaxValueSimple::maxValueCL(int* values, size_t len) {
try {
cl_int status = CL_SUCCESS;
/*** Ausgabe von Informationen ueber gewaehltes OpenCL-Device ***/
/* TODO logging
Logger::logDebug(
METHOD,
Logger::sStream << "max compute units: " << devices[0].getInfo<
CL_DEVICE_MAX_COMPUTE_UNITS> ());
Logger::logDebug(
METHOD,
Logger::sStream << "max work item sizes: "
<< devices[0].getInfo<CL_DEVICE_MAX_WORK_ITEM_SIZES> ()[0]);
Logger::logDebug(
METHOD,
Logger::sStream << "max work group sizes: "
<< devices[0].getInfo<CL_DEVICE_MAX_WORK_GROUP_SIZE> ());
Logger::logDebug(
METHOD,
Logger::sStream << "max global mem size (KB): "
<< devices[0].getInfo<CL_DEVICE_GLOBAL_MEM_SIZE> ()
/ 1024);
Logger::logDebug(
METHOD,
Logger::sStream << "max local mem size (KB): "
<< devices[0].getInfo<CL_DEVICE_LOCAL_MEM_SIZE> ()
/ 1024);
*/
/*** Erstellen und Vorbereiten der Daten ***/
cl::Buffer vBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
sizeof(cl_int) * len, &values[0], &status);
if (status != CL_SUCCESS) {
throw cl::Error(status, "cl::Buffer values");
}
cmdQ.finish();
/*** Arbeitsgroeszen berechnen ***/
// Anzahl der Work-Items = globalSize
// Work-Items pro Work-Group = localSize
const size_t MAX_GROUP_SIZE = devices[0].getInfo<
CL_DEVICE_MAX_WORK_GROUP_SIZE> ();
size_t globalSize;
size_t localSize;
do {
globalSize = len;
localSize = MaxValueSimple::calcWorkGroupSize(globalSize,
MAX_GROUP_SIZE);
if (localSize == 1) {
globalSize = ceil((double) len / WG_FAC) * WG_FAC;
localSize = MaxValueSimple::calcWorkGroupSize(globalSize,
MAX_GROUP_SIZE);
/* TODO logging
Logger::logDebug(
METHOD,
Logger::sStream << "GlobalSize has been extended to "
<< globalSize);
*/
}
/* TODO logging
Logger::logDebug(METHOD,
Logger::sStream << "globalSize: " << globalSize);
Logger::logDebug(METHOD,
Logger::sStream << "localSize: " << localSize);
*/
/*** Kernel-Argumente setzen ***/
status = kernel.setArg(0, vBuffer);
if (status != CL_SUCCESS) {
throw cl::Error(status, "Kernel.SetArg");
}
status = kernel.setArg(1, sizeof(cl_int) * localSize, NULL);
if (status != CL_SUCCESS) {
throw cl::Error(status, "Kernel.SetArg");
}
/*** Kernel ausfuehren und auf Abarbeitung warten ***/
cl::KernelFunctor func = kernel.bind(cmdQ, cl::NDRange(globalSize),
cl::NDRange(localSize));
event = func();
event.wait();
cmdQ.finish();
/*
runtimeKernel
+= event.getProfilingInfo<CL_PROFILING_COMMAND_END> ();
runtimeKernel
-= event.getProfilingInfo<CL_PROFILING_COMMAND_START> ();
*/
len = globalSize / localSize;
} while (globalSize > localSize && localSize > 1);
/*** Daten vom OpenCL-Device holen ***/
// TODO nur 1. element auslesen
status = cmdQ.enqueueReadBuffer(vBuffer, true, 0, sizeof(cl_int) * 1,
//.........这里部分代码省略.........