本文整理汇总了C++中clGetProgramInfo函数的典型用法代码示例。如果您正苦于以下问题:C++ clGetProgramInfo函数的具体用法?C++ clGetProgramInfo怎么用?C++ clGetProgramInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clGetProgramInfo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: wine_clGetProgramInfo
cl_int WINAPI wine_clGetProgramInfo(cl_program program, cl_program_info param_name,
size_t param_value_size, void * param_value, size_t * param_value_size_ret)
{
cl_int ret;
TRACE("\n");
ret = clGetProgramInfo(program, param_name, param_value_size, param_value, param_value_size_ret);
return ret;
}
开发者ID:YongHaoWu,项目名称:wine-hub,代码行数:8,代码来源:opencl.c
示例2: printf
WebCLGetInfo WebCLProgram::getInfo(int param_name, ExceptionState& es) {
cl_int err = 0;
cl_uint uint_units = 0;
char program_string[4096];
RefPtr<WebCLContext> contextObj = nullptr;
RefPtr<WebCLDeviceList> deviceList = nullptr;
if (m_cl_program == NULL) {
es.throwWebCLException(
WebCLException::INVALID_PROGRAM,
WebCLException::invalidProgramMessage);
printf("Error: Invalid program object\n");
return WebCLGetInfo();
}
switch(param_name) {
case WebCL::PROGRAM_NUM_DEVICES:
err = clGetProgramInfo(m_cl_program, CL_PROGRAM_NUM_DEVICES,
sizeof(cl_uint), &uint_units, NULL);
if (err == CL_SUCCESS)
return WebCLGetInfo(static_cast<unsigned int>(uint_units));
break;
case WebCL::PROGRAM_SOURCE:
err = clGetProgramInfo(m_cl_program, CL_PROGRAM_SOURCE,
sizeof(program_string), &program_string,
NULL);
if (err == CL_SUCCESS)
return WebCLGetInfo(String(program_string));
break;
case WebCL::PROGRAM_CONTEXT:
return WebCLGetInfo(PassRefPtr<WebCLContext>(m_cl_context.get()));
break;
case WebCL::PROGRAM_DEVICES:
return WebCLGetInfo(m_cl_context->getDevices());
break;
default:
printf("Error: UNSUPPORTED program Info type = %d ",param_name);
es.throwWebCLException(
WebCLException::INVALID_PROGRAM,
WebCLException::invalidProgramMessage);
return WebCLGetInfo();
}
WebCLException::throwException(err, es);
return WebCLGetInfo();
}
开发者ID:junmin-zhu,项目名称:blink,代码行数:45,代码来源:WebCLProgram.cpp
示例3: cl_printBinaries
void cl_printBinaries(cl_program program) {
cl_uint program_num_devices;
clGetProgramInfo( program,
CL_PROGRAM_NUM_DEVICES,
sizeof(cl_uint),
&program_num_devices,
NULL
);
printf("Number of devices: %d\n", program_num_devices);
//size_t binaries_sizes[program_num_devices];
size_t * binaries_sizes = (size_t *)malloc(sizeof(size_t)*program_num_devices);
clGetProgramInfo( program,
CL_PROGRAM_BINARY_SIZES,
program_num_devices*sizeof(size_t),
binaries_sizes,
NULL
);
char** binaries = (char**)malloc(sizeof(char*)*program_num_devices);
for (unsigned int i = 0; i < program_num_devices; i++)
binaries[i] = (char*)malloc(sizeof(char)*(binaries_sizes[i]+1));
clGetProgramInfo(program, CL_PROGRAM_BINARIES, program_num_devices*sizeof(size_t), binaries, NULL);
for (unsigned int i = 0; i < program_num_devices; i++)
{
binaries[i][binaries_sizes[i]] = '\0';
printf("Program %d\n", i);
printf("%s\n", binaries[i]);
}
for (unsigned int i = 0; i < program_num_devices; i++)
free(binaries[i]);
free(binaries);
}
开发者ID:tofergregg,项目名称:OpenCLKernelScheduler,代码行数:45,代码来源:clutils.cpp
示例4: oclLogBinary
void oclLogBinary(cl_program clProg, cl_device_id clDev)
{
// Grab the number of devices associated with the program
cl_uint num_devices;
clGetProgramInfo(clProg, CL_PROGRAM_NUM_DEVICES, sizeof(cl_uint), &num_devices, NULL);
// Grab the device ids
cl_device_id* devices = (cl_device_id*) malloc(num_devices * sizeof(cl_device_id));
clGetProgramInfo(clProg, CL_PROGRAM_DEVICES, num_devices * sizeof(cl_device_id), devices, 0);
// Grab the sizes of the binaries
size_t* binary_sizes = (size_t*)malloc(num_devices * sizeof(size_t));
clGetProgramInfo(clProg, CL_PROGRAM_BINARY_SIZES, num_devices * sizeof(size_t), binary_sizes, NULL);
// Now get the binaries
char** ptx_code = (char**)malloc(num_devices * sizeof(char*));
for( unsigned int i=0; i<num_devices; ++i)
{
ptx_code[i] = (char*)malloc(binary_sizes[i]);
}
clGetProgramInfo(clProg, CL_PROGRAM_BINARIES, 0, ptx_code, NULL);
// Find the index of the device of interest
unsigned int idx = 0;
while((idx < num_devices) && (devices[idx] != clDev))
{
++idx;
}
// If the index is associated, log the result
if( idx < num_devices )
{
MITK_INFO<< "\n ---------------- \n Program Binary: \n -----------------------\n";
MITK_INFO<< ptx_code[idx];
}
free( devices );
free( binary_sizes );
for(unsigned int i=0; i<num_devices; ++i)
{
free(ptx_code[i]);
}
free( ptx_code );
}
开发者ID:151706061,项目名称:MITK,代码行数:44,代码来源:mitkOclUtils.cpp
示例5: cb
void cb(cl_program p,void* data)
{
clRetainProgram(p);
cl_device_id devid[1];
clGetProgramInfo(p,CL_PROGRAM_DEVICES,sizeof(cl_device_id),(void*)devid,NULL);
char bug[65536];
clGetProgramBuildInfo(p,devid[0],CL_PROGRAM_BUILD_LOG,65536*sizeof(char),bug,NULL);
clReleaseProgram(p);
LOGE("Build log \n %s\n",bug);
}
开发者ID:khaled777b,项目名称:AndroidOpenCL-Filter,代码行数:10,代码来源:processor.cpp
示例6: programInfo
bool programInfo(cl_program id, cl_program_info info, Value* buf, size_t length)
{
cl_int error = 0;
if((error = clGetProgramInfo(id, info,
sizeof(Value) * length, buf, nullptr)) != CL_SUCCESS)
{
reportError("programInfo(): ", error);
return false;
}
return true;
}
开发者ID:k0zmo,项目名称:clw,代码行数:11,代码来源:Program.cpp
示例7: CL_CPP_CONDITIONAL_RETURN_FALSE
bool CL_Program::GetCompiledBinaries(cl_uchar** ppBinaryArrayOutput) const
{
CL_CPP_CONDITIONAL_RETURN_FALSE(m_uNumDevices == 0);
CL_CPP_CONDITIONAL_RETURN_FALSE(!ppBinaryArrayOutput);
// Dynamically retreive the compiled source buffers.
cl_int iErrorCode = clGetProgramInfo(m_Program, CL_PROGRAM_BINARIES, 0, ppBinaryArrayOutput, NULL);
CL_CPP_CATCH_ERROR(iErrorCode);
CL_CPP_FORCE_RETURN_BOOL_BY_ERROR(iErrorCode);
}
开发者ID:brandonmbare,项目名称:CLcpp,代码行数:11,代码来源:CL_Program.cpp
示例8: save_binary
bool save_binary(const string& clbin)
{
size_t size = 0;
clGetProgramInfo(cpProgram, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &size, NULL);
if(!size)
return false;
vector<uint8_t> binary(size);
uint8_t *bytes = &binary[0];
clGetProgramInfo(cpProgram, CL_PROGRAM_BINARIES, sizeof(uint8_t*), &bytes, NULL);
if(!path_write_binary(clbin, binary)) {
opencl_error(string_printf("OpenCL failed to write cached binary %s.", clbin.c_str()));
return false;
}
return true;
}
开发者ID:fabiosantoscode,项目名称:emcycles,代码行数:20,代码来源:device_opencl.cpp
示例9: pclu_dump_binary
void
pclu_dump_binary(pclu_program* pgm, const char* path)
{
int errcode;
size_t bin_size;
errcode = clGetProgramInfo(pgm->program, CL_PROGRAM_BINARY_SIZES,
sizeof(size_t), &bin_size, 0);
pclu_check_call("clGetProgramInfo(BIN_SIZE)", errcode);
cl_uchar* binary = (cl_uchar*) malloc(bin_size);
errcode = clGetProgramInfo(pgm->program, CL_PROGRAM_BINARIES, bin_size, &binary, 0);
pclu_check_call("clGetProgramInfo(BINARIES)", errcode);
FILE* bf = fopen(path, "w");
fwrite((void*)binary, bin_size, 1, bf);
fclose(bf);
free(binary);
}
开发者ID:NatTuck,项目名称:cakemark,代码行数:20,代码来源:pclu.c
示例10: clGetProgramInfo
void Program::getInfo(cl_program_info paramName, size_t paramValueSize, void *paramValue) const
{
cl_int err = 0;
size_t written = 0;
err = clGetProgramInfo(programHandle(), paramName, paramValueSize, paramValue, &written);
if(err != CL_SUCCESS) {
throw OpenCLException(err);
}
}
开发者ID:mvaldenegro,项目名称:Epic-Framework,代码行数:11,代码来源:Program.cpp
示例11: oclGetProgBinary
// ****************************************************************************
// Method: oclGetProgBinary
//
// Purpose:
// Get the binary (PTX) of the program associated with the device
//
// Arguments:
// cpProgram OpenCL program
// cdDevice device of interest
// binary returned code
// length length of returned code
//
// Copyright 1993-2013 NVIDIA Corporation
//
// ****************************************************************************
inline void
oclGetProgBinary (cl_program cpProgram, cl_device_id cdDevice, char** binary, size_t* length)
{
// Grab the number of devices associated witht the program
cl_uint num_devices;
clGetProgramInfo(cpProgram, CL_PROGRAM_NUM_DEVICES, sizeof(cl_uint), &num_devices, NULL);
// Grab the device ids
cl_device_id* devices = (cl_device_id*) malloc(num_devices * sizeof(cl_device_id));
clGetProgramInfo(cpProgram, CL_PROGRAM_DEVICES, num_devices * sizeof(cl_device_id), devices, 0);
// Grab the sizes of the binaries
size_t* binary_sizes = (size_t*)malloc(num_devices * sizeof(size_t));
clGetProgramInfo(cpProgram, CL_PROGRAM_BINARY_SIZES, num_devices * sizeof(size_t), binary_sizes, NULL);
// Now get the binaries
char** ptx_code = (char**) malloc(num_devices * sizeof(char*));
for( unsigned int i=0; i<num_devices; ++i) {
ptx_code[i]= (char*)malloc(binary_sizes[i]);
}
clGetProgramInfo(cpProgram, CL_PROGRAM_BINARIES, 0, ptx_code, NULL);
// Find the index of the device of interest
unsigned int idx = 0;
while( idx<num_devices && devices[idx] != cdDevice ) ++idx;
// If it is associated prepare the result
if( idx < num_devices )
{
*binary = ptx_code[idx];
*length = binary_sizes[idx];
}
// Cleanup
free( devices );
free( binary_sizes );
for( unsigned int i=0; i<num_devices; ++i) {
if( i != idx ) free(ptx_code[i]);
}
free( ptx_code );
}
开发者ID:BuaaCompile,项目名称:Opencl-Benchmark,代码行数:56,代码来源:MathBasic.cpp
示例12: clGetProgramVersion
struct _cl_version clGetProgramVersion(cl_program program)
{
struct _cl_version version;
version.major = 0;
version.minor = 0;
cl_context context = NULL;
cl_int flag = clGetProgramInfo(program, CL_PROGRAM_CONTEXT,
sizeof(cl_context), &context, NULL);
if(flag != CL_SUCCESS)
return version;
return clGetContextVersion(context);
}
开发者ID:sanguinariojoe,项目名称:ocland,代码行数:12,代码来源:ocland_version.c
示例13: getProgramInfo
SEXP getProgramInfo(SEXP sProgram, SEXP sProgramInfo){
Rcpp::XPtr<cl_program> program(sProgram);
std::string programInfo = Rcpp::as<std::string>(sProgramInfo);
char cBuffer[1024];
if(programInfo == "CL_PROGRAM_SOURCE"){
std::cout << "get Program source\n";
clGetProgramInfo(*program, CL_PROGRAM_SOURCE, sizeof(cBuffer), cBuffer, NULL);
}
std::string retVal = cBuffer;
return Rcpp::wrap(retVal);
}
开发者ID:RyanHope,项目名称:ROpenCL,代码行数:12,代码来源:createContext.cpp
示例14: CL_CPP_CONDITIONAL_RETURN_VALUE
cl_uint CL_Program::GetReferenceCount() const
{
CL_CPP_CONDITIONAL_RETURN_VALUE(!m_Program, 0);
// Dynamically retrieve the current reference count for this kernel.
cl_uint uRefCount = 0;
cl_int iErrorCode = clGetProgramInfo(m_Program, CL_PROGRAM_REFERENCE_COUNT, sizeof(cl_uint), &uRefCount, NULL);
CL_CPP_CATCH_ERROR(iErrorCode);
return uRefCount;
}
开发者ID:brandonmbare,项目名称:CLcpp,代码行数:12,代码来源:CL_Program.cpp
示例15: create_kernel
static cl_kernel
create_kernel (UfoResourcesPrivate *priv,
cl_program program,
const gchar *kernel_name,
GError **error)
{
cl_kernel kernel;
gchar *name;
cl_int errcode = CL_SUCCESS;
if (kernel_name == NULL) {
gchar *source;
gsize size;
UFO_RESOURCES_CHECK_CLERR (clGetProgramInfo (program, CL_PROGRAM_SOURCE, 0, NULL, &size));
source = g_malloc0 (size);
UFO_RESOURCES_CHECK_CLERR (clGetProgramInfo (program, CL_PROGRAM_SOURCE, size, source, NULL));
name = get_first_kernel_name (source);
g_free (source);
}
else {
name = g_strdup (kernel_name);
}
kernel = clCreateKernel (program, name, &errcode);
g_free (name);
if (kernel == NULL || errcode != CL_SUCCESS) {
g_set_error (error,
UFO_RESOURCES_ERROR,
UFO_RESOURCES_ERROR_CREATE_KERNEL,
"Failed to create kernel `%s`: %s", kernel_name, ufo_resources_clerr (errcode));
return NULL;
}
priv->kernels = g_list_append (priv->kernels, kernel);
return kernel;
}
开发者ID:Dynalon,项目名称:ufo-core,代码行数:38,代码来源:ufo-resources.c
示例16: bfam_cl_kernel_from_string
cl_kernel
bfam_cl_kernel_from_string(cl_context ctx, char const *knl,
char const *knl_name, char const *options)
{
// create an OpenCL program (may have multiple kernels)
size_t sizes[] = { strlen(knl) };
cl_int status;
cl_program program = clCreateProgramWithSource(ctx, 1, &knl, sizes, &status);
BFAM_CL_CHECK(status, "clCreateProgramWithSource");
// build it
status = clBuildProgram(program, 0, NULL, options, NULL, NULL);
if (status != CL_SUCCESS)
{
// build failed, get build log and print it
cl_device_id dev;
BFAM_CL_SAFE_CALL(clGetProgramInfo(program, CL_PROGRAM_DEVICES,
sizeof(dev), &dev, NULL));
size_t log_size;
BFAM_CL_SAFE_CALL(clGetProgramBuildInfo(program, dev, CL_PROGRAM_BUILD_LOG,
0, NULL, &log_size));
char *log = (char *) bfam_malloc(log_size);
char devname[MAX_NAME_LEN];
BFAM_CL_SAFE_CALL(clGetDeviceInfo(dev, CL_DEVICE_NAME,
sizeof(devname), devname, NULL));
BFAM_CL_SAFE_CALL(clGetProgramBuildInfo(program, dev, CL_PROGRAM_BUILD_LOG,
log_size, log, NULL));
BFAM_LERROR("*** build of '%s' on '%s' failed:\n%s\n*** (end of error)\n",
knl_name, devname, log);
BFAM_ABORT("Building kernel from a string");
}
else
BFAM_CL_CHECK(status, "clBuildProgram");
// fish the kernel out of the program
cl_kernel kernel = clCreateKernel(program, knl_name, &status);
BFAM_CL_CHECK(status, "clCreateKernel");
BFAM_CL_SAFE_CALL(clReleaseProgram(program));
return kernel;
}
开发者ID:cburstedde,项目名称:bfam,代码行数:49,代码来源:bfam_opencl.c
示例17: dump_binaries
static cl_int dump_binaries(cl_program prog, const char *prefix) {
cl_int errcode;
cl_uint num_binaries, i;
size_t *binary_sizes;
unsigned char **binaries;
if ((errcode = clGetProgramInfo(prog, CL_PROGRAM_NUM_DEVICES, sizeof(cl_uint), &num_binaries, NULL)) != CL_SUCCESS)
return errcode;
binary_sizes = malloc(sizeof(size_t) * num_binaries);
binaries = malloc(sizeof(unsigned char *) * num_binaries);
if ((errcode = clGetProgramInfo(prog, CL_PROGRAM_BINARY_SIZES, sizeof(size_t) * num_binaries, binary_sizes, NULL)) != CL_SUCCESS)
return errcode;
for (i = 0; i != num_binaries; ++i)
binaries[i] = malloc(binary_sizes[i]);
if ((errcode = clGetProgramInfo(prog, CL_PROGRAM_BINARIES, sizeof(unsigned char *) * num_binaries, binaries, NULL)) != CL_SUCCESS)
return errcode;
for (i = 0; i != num_binaries; ++i) {
char name[64];
sprintf(name, "%s.bin%lu", prefix, (unsigned long) i);
FILE *f = fopen(name, "w");
fwrite(binaries[i], binary_sizes[i], 1, f);
fclose(f);
free(binaries[i]);
}
free(binary_sizes);
free(binaries);
return CL_SUCCESS;
}
开发者ID:delcypher,项目名称:klee-cl-bullet-benchmarks,代码行数:36,代码来源:clcc.c
示例18: dumpBinary
//Dumps a compiled kernel to a binary file
void dumpBinary(cl_program program,const char *kernelName)
{
//Get number of devices
cl_uint deviceCount = 0;
status = clGetProgramInfo(program,CL_PROGRAM_NUM_DEVICES,sizeof(cl_uint),&deviceCount,NULL);
if(status != CL_SUCCESS) exitOnError("Getting number of devices for the program(clGetProgramInfo)");
//Get sizes of compiled binaries for said devices
size_t *binSize = (size_t*)malloc(sizeof(size_t)*deviceCount);
status = clGetProgramInfo(program,CL_PROGRAM_BINARY_SIZES,(sizeof(size_t)*deviceCount),binSize,NULL);
if(status != CL_SUCCESS) exitOnError("Getting binary sizes for the program(clGetProgramInfo)");
char **bin = ( char**)malloc(sizeof(char*)*deviceCount);
for(cl_uint i = 0;i<deviceCount;i++) bin[i] = (char*)malloc(binSize[i]);
//Retrieve compiled binaries
status = clGetProgramInfo(program,CL_PROGRAM_BINARIES,(sizeof(size_t)*deviceCount),bin,NULL);
if(status != CL_SUCCESS) exitOnError("Getting program binaries(clGetProgramInfo)");
//Export binaries to files, appending CL_DEVICE_NAME to each filename
char binFileName[MAX_NAME_LENGTH];
for(cl_uint i = 0;i<deviceCount;i++)
{
char deviceName[MAX_NAME_LENGTH];
status = clGetDeviceInfo(devices[i],CL_DEVICE_NAME,MAX_NAME_LENGTH,deviceName,NULL);
if (status != CL_SUCCESS) exitOnError("Cannot get device name for given device number");
printf("Binary image of kernel %s created for device %s.\n",kernelName,deviceName);
sprintf(binFileName,"%s_%s.elf",kernelName,deviceName);
std::fstream outBinFile(binFileName, (std::fstream::out | std::fstream::binary));
if(outBinFile.fail()) exitOnError("Cannot open binary file");
outBinFile.write(bin[i],binSize[i]);
outBinFile.close();
}
for(cl_uint i = 0;i<deviceCount;i++) free(bin[i]);
}
开发者ID:JKolios,项目名称:RayTetra,代码行数:37,代码来源:gpuHandler.cpp
示例19: clGetProgramInfo
void OpenCLProgram::getBinary()
{
cl_uint program_num_devices;
cl_int err;
err = clGetProgramInfo(clProgram, CL_PROGRAM_NUM_DEVICES, sizeof(cl_uint), &program_num_devices, NULL);
assert(err == CL_SUCCESS);
if (program_num_devices == 0) {
std::cerr << "no valid binary was found" << std::endl;
return;
}
size_t binaries_sizes[program_num_devices];
err = clGetProgramInfo(clProgram, CL_PROGRAM_BINARY_SIZES, program_num_devices*sizeof(size_t), binaries_sizes, NULL);
assert(err = CL_SUCCESS);
char **binaries = new char*[program_num_devices];
for (size_t i = 0; i < program_num_devices; i++)
binaries[i] = new char[binaries_sizes[i]+1];
err = clGetProgramInfo(clProgram, CL_PROGRAM_BINARIES, program_num_devices*sizeof(size_t), binaries, NULL);
assert(err = CL_SUCCESS);
for (size_t i = 0; i < program_num_devices; i++) {
binaries[i][binaries_sizes[i]] = '\0';
std::cout << "Program " << i << ":" << std::endl;
std::cout << binaries[i];
}
for (size_t i = 0; i < program_num_devices; i++)
delete [] binaries[i];
delete [] binaries;
}
开发者ID:Giladx,项目名称:msalibs,代码行数:36,代码来源:MSAOpenCLProgram.cpp
示例20: string
string Program::sourceCode() const
{
if(!_ctx || isNull())
return string();
size_t size;
cl_int error;
if((error = clGetProgramInfo(_id, CL_PROGRAM_SOURCE,
0, nullptr, &size)) != CL_SUCCESS)
{
detail::reportError("Program::sourceCode(): ", error);
return string();
}
if(size == 0)
return string();
string buf;
buf.resize(size);
if(detail::programInfo(_id, CL_PROGRAM_SOURCE,
const_cast<char*>(buf.data()), size))
return string();
return buf;
}
开发者ID:k0zmo,项目名称:clw,代码行数:21,代码来源:Program.cpp
注:本文中的clGetProgramInfo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论