36 #include <boost/algorithm/string.hpp>
37 #include <boost/lexical_cast.hpp>
38 #include <boost/format.hpp>
45 VECTOR_CLASS<cl::Platform> platforms;
46 cl::Platform::get(&platforms);
48 VECTOR_CLASS<cl::Device> devices;
49 for(
unsigned int i = 0; i < platforms.size(); i++)
53 platforms[i].getDevices(CL_DEVICE_TYPE_ALL, &devices);
55 for(
unsigned int j = 0; j < devices.size(); j++)
60 print(
"Number of platforms", platforms.size());
61 print(
"Number of devices", devices.size());
66 print(
"--- PlatformInfo ---",
"");
67 print(
"Name", platform.getInfo<CL_PLATFORM_NAME>());
68 print(
"Vendor", platform.getInfo<CL_PLATFORM_VENDOR>());
69 print(
"Version", platform.getInfo<CL_PLATFORM_VERSION>());
70 print(
"Profile", platform.getInfo<CL_PLATFORM_PROFILE>());
71 print(
"Extensions",
"");
72 printStringList(platform.getInfo<CL_PLATFORM_EXTENSIONS>());
77 print(
"--- DeviceInfo ---",
"");
78 print(
"Name", device.getInfo<CL_DEVICE_NAME>());
79 print(
"Vendor", device.getInfo<CL_DEVICE_VENDOR>());
80 print(
"Vendor id", device.getInfo<CL_DEVICE_VENDOR_ID>());
81 print(
"Device supports", device.getInfo<CL_DEVICE_VERSION>());
82 print(
"Graphics card driver", device.getInfo<CL_DRIVER_VERSION>());
83 print(
"Available", (device.getInfo<CL_DEVICE_AVAILABLE>() ?
"Yes" :
"No"));
84 print(
"Extensions",
"");
85 printStringList(device.getInfo<CL_DEVICE_EXTENSIONS>());
92 print(
"Compute Units", device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>());
93 print(
"Clock Frequency (MHz)", device.getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>());
94 print(
"Global Memory (MB)", (
double)device.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>()/1048576);
95 print(
"Max Allocateable Memory (MB)", (
double)device.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()/1048576);
96 print(
"Local Memory (KB)", device.getInfo<CL_DEVICE_LOCAL_MEM_SIZE>());
99 print(
"Device Profile", device.getInfo<CL_DEVICE_PROFILE>());
100 print(
"Error correction support", device.getInfo<CL_DEVICE_ERROR_CORRECTION_SUPPORT>() ?
"Yes" :
"No");
101 print(
"Profiling Timer Resolution", device.getInfo<CL_DEVICE_PROFILING_TIMER_RESOLUTION>());
102 print(
"Endian Little", device.getInfo<CL_DEVICE_ENDIAN_LITTLE>() ?
"Yes" :
"No");
103 print(
"Command queue properties", device.getInfo<CL_DEVICE_QUEUE_PROPERTIES>());
104 print(
"Execution capabilities", device.getInfo<CL_DEVICE_EXECUTION_CAPABILITIES>());
105 print(
"Host unified memory", device.getInfo<CL_DEVICE_HOST_UNIFIED_MEMORY>() ?
"Yes" :
"No");
108 print(
"Max work group size", device.getInfo<CL_DEVICE_MAX_WORK_GROUP_SIZE>());
109 int maxWorkItemDimensions = device.getInfo<CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS>();
110 print(
"Max work item dimensions", maxWorkItemDimensions);
113 print(
"Image support", device.getInfo<CL_DEVICE_IMAGE_SUPPORT>() ?
"Yes" :
"No");
114 print(
"Image2D max width", device.getInfo<CL_DEVICE_IMAGE2D_MAX_WIDTH>());
115 print(
"Image2D max height",device.getInfo<CL_DEVICE_IMAGE2D_MAX_HEIGHT>());
116 print(
"Image3D max width", device.getInfo<CL_DEVICE_IMAGE3D_MAX_WIDTH>());
117 print(
"Image3D max height", device.getInfo<CL_DEVICE_IMAGE3D_MAX_HEIGHT>());
118 print(
"Image3D max depth", device.getInfo<CL_DEVICE_IMAGE3D_MAX_DEPTH>());
123 print(
"--- ContextInfo ---",
"");
124 VECTOR_CLASS<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
125 print(
"Number of devices", devices.size());
126 for(
int i=0; i<devices.size(); ++i)
132 print(
"--- ProgramInfo ---",
"");
138 print(
"--- ProgramSource ---",
"");
139 cl::STRING_CLASS source = program.getInfo<CL_PROGRAM_SOURCE>();
140 print(
"",
"\n"+source);
145 print(
"--- KernelInfo ---",
"");
146 cl::STRING_CLASS functionName = kernel.getInfo<CL_KERNEL_FUNCTION_NAME>();
147 cl::Context context = kernel.getInfo<CL_KERNEL_CONTEXT>();
148 cl::Program program = kernel.getInfo<CL_KERNEL_PROGRAM>();
149 print(
"Function name", functionName);
157 print(
"--- MemoryInfo ---",
"");
158 cl::Context context = memory.getInfo<CL_MEM_CONTEXT>();
162 void OpenCLPrinter::printStringList(std::string list, std::string separator)
164 std::vector<std::string> strings;
165 boost::split(strings, list, boost::is_any_of(std::string(separator)));
166 std::vector<std::string>::iterator it;
167 for(it = strings.begin(); it != strings.end(); ++it)
171 void OpenCLPrinter::print(std::string name, std::string value,
int indents)
173 std::string stringIndents = getIndentation(indents);
174 std::cout << stringIndents << boost::format(
"%-30s %-20s\n") % name % value;
177 void OpenCLPrinter::print(std::string name,
int value,
int indents)
179 std::string stringValue = boost::lexical_cast<std::string>(value);
180 print(name, stringValue, indents);
183 std::string
const OpenCLPrinter::getIndentation(
unsigned int numberOfIndents)
185 std::string indentator =
"\t";
186 std::string retval(
"");
187 for(
unsigned int i=0; i < numberOfIndents; i++)
188 retval += indentator;
static void printMemoryInfo(cl::Memory memory)
static void printKernelInfo(cl::Kernel kernel)
static void printProgramSource(cl::Program program)
static void printProgramInfo(cl::Program program)
static void printDeviceInfo(cl::Device device, bool verbose=false)
static void printContextInfo(cl::Context context)
static void printPlatformInfo(cl::Platform platform)
static void printPlatformAndDeviceInfo()