'Usage of function clGetExtensionFunctionAddress
I'm new to OpenCL extensions and I try to use the extension function clImportMemoryARM witht code blow:
cl_mem buffer = NULL;
clImportMemoryARM = (clImportMemoryARMFunc)clGetExtensionFunctionAddressForPlatform(plt->platforms[0], "clImportMemoryARM");
buffer = clImportMemoryARM(plt->context[0], 0, NULL, NULL, 0, &ret);
But I recieved the error ‘clImportMemoryARMFunc’ was not declared in this scope in build, and I changed clImportMemoryARMFunc with clImportMemoryARM also recieved the error message error: assignment of function ‘_cl_mem clImportMemoryARM(cl_context, cl_mem_flags, const cl_import_properties_arm, void, size_t, cl_int). I just don't konw how to use the function like this, could any tech-savvy can solve the problem?
Thanks a lot!
Solution 1:[1]
It because the driver did not expose clImportMemoryARM to user so you have to define a function pointer youself like this:
typedef cl_mem(clImportMemoryARM_func)
(cl_context psContext,
cl_mem_flags bfFlags,
const cl_import_properties_arm *properties,
void * pvMemory,
size_t uiSize,
cl_int * piErrorCodeRet);
and then you can use function pointer to this API,like this:
clImportMemoryARM_func *clImportMemoryARM = NULL;
clImportMemoryARM = (clImportMemoryARM_func *)clGetExtensionFunctionAddressForPlatform(plt->platforms[0], "clImportMemoryARM");
Solution 2:[2]
You need to include cl_ext.h
:
#include <CL/cl_ext.h>
This file is part of OpenCL headers. This header should have all extensions which don't have "external dependencies" (like e.g OpenGL), and it also has clImportMemoryARM
and a bunch of other ARM functions and declarations.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Michael |
Solution 2 | mogu |