accessing elements of cl::Buffer?

is it possible somehow to access elements of cl::Buffer, like

cl::Buffer buf;

cout << buf[4];

operator[] is not defined for cl::Buffer - but is there any other way?

thank you.

You’d have to read the buffer into program memory first–i.e. a cl_float array–using clEnqueueReadBuffer(…) . Look at any openCL sample that uses this function for an example, but direct buffer reading is disabled for architectural reasons; the OCL backend is supposed to take care of the buffer memory management, not the application.