15 #include <boost/algorithm/string.hpp>
16 #include <boost/lexical_cast.hpp>
17 #include <boost/format.hpp>
24 VECTOR_CLASS<cl::Platform> platforms;
25 cl::Platform::get(&platforms);
27 VECTOR_CLASS<cl::Device> devices;
28 for(
unsigned int i = 0; i < platforms.size(); i++)
32 platforms[i].getDevices(CL_DEVICE_TYPE_ALL, &devices);
34 for(
unsigned int j = 0; j < devices.size(); j++)
39 print(
"Number of platforms", platforms.size());
40 print(
"Number of devices", devices.size());
45 print(
"--- PlatformInfo ---",
"");
46 print(
"Name", platform.getInfo<CL_PLATFORM_NAME>());
47 print(
"Vendor", platform.getInfo<CL_PLATFORM_VENDOR>());
48 print(
"Version", platform.getInfo<CL_PLATFORM_VERSION>());
49 print(
"Profile", platform.getInfo<CL_PLATFORM_PROFILE>());
50 print(
"Extensions",
"");
51 printStringList(platform.getInfo<CL_PLATFORM_EXTENSIONS>());
56 print(
"--- DeviceInfo ---",
"");
57 print(
"Name", device.getInfo<CL_DEVICE_NAME>());
58 print(
"Vendor", device.getInfo<CL_DEVICE_VENDOR>());
59 print(
"Vendor id", device.getInfo<CL_DEVICE_VENDOR_ID>());
60 print(
"Device supports", device.getInfo<CL_DEVICE_VERSION>());
61 print(
"Graphics card driver", device.getInfo<CL_DRIVER_VERSION>());
62 print(
"Available", (device.getInfo<CL_DEVICE_AVAILABLE>() ?
"Yes" :
"No"));
63 print(
"Extensions",
"");
64 printStringList(device.getInfo<CL_DEVICE_EXTENSIONS>());
71 print(
"Compute Units", device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>());
72 print(
"Clock Frequency (MHz)", device.getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>());
73 print(
"Global Memory (MB)", (
double)device.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>()/1048576);
74 print(
"Max Allocateable Memory (MB)", (
double)device.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()/1048576);
75 print(
"Local Memory (KB)", device.getInfo<CL_DEVICE_LOCAL_MEM_SIZE>());
78 print(
"Device Profile", device.getInfo<CL_DEVICE_PROFILE>());
79 print(
"Error correction support", device.getInfo<CL_DEVICE_ERROR_CORRECTION_SUPPORT>() ?
"Yes" :
"No");
80 print(
"Profiling Timer Resolution", device.getInfo<CL_DEVICE_PROFILING_TIMER_RESOLUTION>());
81 print(
"Endian Little", device.getInfo<CL_DEVICE_ENDIAN_LITTLE>() ?
"Yes" :
"No");
82 print(
"Command queue properties", device.getInfo<CL_DEVICE_QUEUE_PROPERTIES>());
83 print(
"Execution capabilities", device.getInfo<CL_DEVICE_EXECUTION_CAPABILITIES>());
84 print(
"Host unified memory", device.getInfo<CL_DEVICE_HOST_UNIFIED_MEMORY>() ?
"Yes" :
"No");
87 print(
"Max work group size", device.getInfo<CL_DEVICE_MAX_WORK_GROUP_SIZE>());
88 int maxWorkItemDimensions = device.getInfo<CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS>();
89 print(
"Max work item dimensions", maxWorkItemDimensions);
92 print(
"Image support", device.getInfo<CL_DEVICE_IMAGE_SUPPORT>() ?
"Yes" :
"No");
93 print(
"Image2D max width", device.getInfo<CL_DEVICE_IMAGE2D_MAX_WIDTH>());
94 print(
"Image2D max height",device.getInfo<CL_DEVICE_IMAGE2D_MAX_HEIGHT>());
95 print(
"Image3D max width", device.getInfo<CL_DEVICE_IMAGE3D_MAX_WIDTH>());
96 print(
"Image3D max height", device.getInfo<CL_DEVICE_IMAGE3D_MAX_HEIGHT>());
97 print(
"Image3D max depth", device.getInfo<CL_DEVICE_IMAGE3D_MAX_DEPTH>());
102 print(
"--- ContextInfo ---",
"");
103 VECTOR_CLASS<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
104 print(
"Number of devices", devices.size());
105 for(
int i=0; i<devices.size(); ++i)
111 print(
"--- ProgramInfo ---",
"");
117 print(
"--- ProgramSource ---",
"");
118 cl::STRING_CLASS source = program.getInfo<CL_PROGRAM_SOURCE>();
119 print(
"",
"\n"+source);
124 print(
"--- KernelInfo ---",
"");
125 cl::STRING_CLASS functionName = kernel.getInfo<CL_KERNEL_FUNCTION_NAME>();
126 cl::Context context = kernel.getInfo<CL_KERNEL_CONTEXT>();
127 cl::Program program = kernel.getInfo<CL_KERNEL_PROGRAM>();
128 print(
"Function name", functionName);
136 print(
"--- MemoryInfo ---",
"");
137 cl::Context context = memory.getInfo<CL_MEM_CONTEXT>();
141 void OpenCLPrinter::printStringList(std::string list, std::string separator)
143 std::vector<std::string> strings;
144 boost::split(strings, list, boost::is_any_of(std::string(separator)));
145 std::vector<std::string>::iterator it;
146 for(it = strings.begin(); it != strings.end(); ++it)
150 void OpenCLPrinter::print(std::string name, std::string value,
int indents)
152 std::string stringIndents = getIndentation(indents);
153 std::cout << stringIndents << boost::format(
"%-30s %-20s\n") % name % value;
156 void OpenCLPrinter::print(std::string name,
int value,
int indents)
158 std::string stringValue = boost::lexical_cast<std::string>(value);
159 print(name, stringValue, indents);
162 std::string
const OpenCLPrinter::getIndentation(
unsigned int numberOfIndents)
164 std::string indentator =
"\t";
165 std::string retval(
"");
166 for(
unsigned int i=0; i < numberOfIndents; i++)
167 retval += indentator;