MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / getDeviceInfo

Function getDeviceInfo

src/backend/opencl/platform.cpp:144–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144string getDeviceInfo() noexcept {
145 ostringstream info;
146 info << "ArrayFire v" << AF_VERSION << " (OpenCL, " << get_system()
147 << ", build " << AF_REVISION << ")\n";
148
149 vector<cl::Device*> devices;
150 try {
151 DeviceManager& devMngr = DeviceManager::getInstance();
152
153 common::lock_guard_t lock(devMngr.deviceMutex);
154 unsigned nDevices = 0;
155 for (auto& device : devMngr.mDevices) {
156 const Platform platform(device->getInfo<CL_DEVICE_PLATFORM>());
157
158 string dstr = device->getInfo<CL_DEVICE_NAME>();
159 bool show_braces =
160 (static_cast<unsigned>(getActiveDeviceId()) == nDevices);
161
162 string id = (show_braces ? string("[") : "-") +
163 to_string(nDevices) + (show_braces ? string("]") : "-");
164
165 size_t msize = device->getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>();
166 info << id << " " << getPlatformName(*device) << ": " << ltrim(dstr)
167 << ", " << msize / 1048576 << " MB";
168#ifndef NDEBUG
169 info << " -- ";
170 string devVersion = device->getInfo<CL_DEVICE_VERSION>();
171 string driVersion = device->getInfo<CL_DRIVER_VERSION>();
172 info << devVersion;
173 info << " -- Device driver " << driVersion;
174 info
175 << " -- FP64 Support: "
176 << (device->getInfo<CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE>() >
177 0
178 ? "True"
179 : "False");
180#endif
181 info << endl;
182
183 nDevices++;
184 }
185 } catch (const AfError& err) {
186 UNUSED(err);
187 info << "No platforms found.\n";
188 // Don't throw an exception here. Info should pass even if the system
189 // doesn't have the correct drivers installed.
190 }
191 return info.str();
192}
193
194string getPlatformName(const Device& device) {
195 const Platform platform(device.getInfo<CL_DEVICE_PLATFORM>());

Callers

nothing calls this directly

Calls 4

to_stringFunction · 0.85
get_systemFunction · 0.70
getActiveDeviceIdFunction · 0.70
getPlatformNameFunction · 0.70

Tested by

no test coverage detected