This is fairly easy using the Boost.Compute C++ wrapper library for OpenCL:
// get the default device
boost::compute::device device = boost::compute::system::default_device();
// print out memory sizes
std::cout << "device: " << device.name() << std::endl;
std::cout << " global memory size: "
<< device.get_info<cl_ulong>(CL_DEVICE_GLOBAL_MEM_SIZE) / 1024 / 1024
<< " MB"
<< std::endl;
std::cout << " local memory size: "
<< device.get_info<cl_ulong>(CL_DEVICE_LOCAL_MEM_SIZE) / 1024
<< " KB"
<< std::endl;
std::cout << " constant memory size: "
<< device.get_info<cl_ulong>(CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE) / 1024
<< " KB"
<< std::endl;
Which will print something like this:
device: Tahiti
global memory size: 2511 MB
local memory size: 32 KB
constant memory size: 64 KB
See the memory_limits.cpp example for the full source code.