Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
652 views
in Technique[技术] by (71.8m points)

parallel processing - How to get the size of "_cl_devide_id" struct in openCL?

cl_device_id is defined as "typedef struct _cl_device_id *cl_device_id". In the openCL method clGetDeviceIDs, "devices" parameter is of the type "cl_device_id *" and returns a pointer to the list of devices available. I'm trying to pass the whole struct using memcpy to another variable. For which I need to know the size of the "_cl_device_id" struct.

question from:https://stackoverflow.com/questions/65660757/how-to-get-the-size-of-cl-devide-id-struct-in-opencl

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

_cl_device_id is internal to the platform (like all _cl_something structs). Furthermore, an OpenCL program can have multiple platforms loaded, and for each platform the struct sizes can (and likely will) be different.

All cl_objects in general are opaque pointers, and (in general) copying around hidden internal structs of a C library is a pretty extreme approach, almost guaranteed to screw things up (unless you're working on implementing a debugger or such).

But anyway leaving motivation aside, the answer is: you can't tell, since you don't know until the program actually runs and loads the OpenCL implementation(s).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...