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

Method printInfo

src/backend/common/DefaultMemoryManager.cpp:288–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288void DefaultMemoryManager::printInfo(const char *msg, const int device) {
289 UNUSED(device);
290 const memory_info &current = this->getCurrentMemoryInfo();
291
292 printf("%s\n", msg);
293 printf(
294 "---------------------------------------------------------\n"
295 "| POINTER | SIZE | AF LOCK | USER LOCK |\n"
296 "---------------------------------------------------------\n");
297
298 lock_guard_t lock(this->memory_mutex);
299 for (const auto &kv : current.locked_map) {
300 const char *status_mngr = "Yes";
301 const char *status_user = "Unknown";
302 if (kv.second.user_lock) {
303 status_user = "Yes";
304 } else {
305 status_user = " No";
306 }
307
308 const char *unit = "KB";
309 double size = static_cast<double>(kv.second.bytes) / 1024;
310 if (size >= 1024) {
311 size = size / 1024;
312 unit = "MB";
313 }
314
315 printf("| %14p | %6.f %s | %9s | %9s |\n", kv.first, size, unit,
316 status_mngr, status_user);
317 }
318
319 for (const auto &kv : current.free_map) {
320 const char *status_mngr = "No";
321 const char *status_user = "No";
322
323 const char *unit = "KB";
324 double size = static_cast<double>(kv.first) / 1024;
325 if (size >= 1024) {
326 size = size / 1024;
327 unit = "MB";
328 }
329
330 for (const auto &ptr : kv.second) {
331 printf("| %14p | %6.f %s | %9s | %9s |\n", ptr, size, unit,
332 status_mngr, status_user);
333 }
334 }
335
336 printf("---------------------------------------------------------\n");
337}
338
339void DefaultMemoryManager::usageInfo(size_t *alloc_bytes, size_t *alloc_buffers,
340 size_t *lock_bytes, size_t *lock_buffers) {

Callers 4

printMemInfoFunction · 0.45
printMemInfoFunction · 0.45
printMemInfoFunction · 0.45
printMemInfoFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected