| 39 | } |
| 40 | |
| 41 | GPUMemTracker::GPUMemorySnapshot GPUMemTracker::GetMemorySnapshot() |
| 42 | { |
| 43 | GPUMemorySnapshot memStat; |
| 44 | |
| 45 | { |
| 46 | std::lock_guard<std::mutex> g(m_mutex); |
| 47 | for (auto const & kv : m_memTracker) |
| 48 | { |
| 49 | TagMemorySnapshot & tagStat = memStat.m_tagStats[kv.first.first]; |
| 50 | tagStat.m_objectsCount++; |
| 51 | tagStat.m_alocatedInMb += kv.second.first; |
| 52 | tagStat.m_usedInMb += kv.second.second; |
| 53 | |
| 54 | memStat.m_summaryAllocatedInMb += kv.second.first; |
| 55 | memStat.m_summaryUsedInMb += kv.second.second; |
| 56 | } |
| 57 | memStat.m_averageAllocations = m_averageAllocations; |
| 58 | } |
| 59 | |
| 60 | auto constexpr kByteToMb = static_cast<float>(1024 * 1024); |
| 61 | for (auto & it : memStat.m_tagStats) |
| 62 | { |
| 63 | it.second.m_alocatedInMb /= kByteToMb; |
| 64 | it.second.m_usedInMb /= kByteToMb; |
| 65 | } |
| 66 | memStat.m_summaryAllocatedInMb /= kByteToMb; |
| 67 | memStat.m_summaryUsedInMb /= kByteToMb; |
| 68 | |
| 69 | return memStat; |
| 70 | } |
| 71 | |
| 72 | void GPUMemTracker::AddAllocated(std::string const & tag, uint32_t id, uint32_t size) |
| 73 | { |
no outgoing calls
no test coverage detected