Why does AMD uProf keep crashing?
I have a simple 1 file C++ program that I want to profile. It uses some data structures I use in a bigger project and I want to know how frequently I'm missing the cache / general performance metrics. I am using an AMD Ryzen 5000 series CPU on Windows 10 compiling with MinGW (nuwen-distro)(g++ version 13.2). The program has no dependencies and only uses the STL. The file is called patterns.cpp and I compile it with g++ patterns.cpp -g -O0 -o p
. Ran with .\p
. I run the GUI application with AMD uProf and put in this executable's path. It runs the program but then 10% into the "Processing data" stage, it just crashes saying
"AMDProfilerService Crash! It looks like AMDProfilerService has crashed! Please relaunch..."
All I see in the profile log is
"Loaded debug information for... c:\windows\system32\ntoskrnl.exe"
This has happened repeatedly. What is the issue? It can profile a simple "Hello World" application so I don't know whats going on...
source code:
#include <iostream>
// #include <chrono>
#include <unordered_map>
#include <array>
#include <vector>
// Simulating Physics Stuff
struct CTransform
{
float pos[2];
};
struct CMovement
{
float vel[2];
float acc[2];
};
void UpdateTransform(CTransform &transf, CMovement &move, float dt)
{
transf.pos[0] += move.vel[0] * dt;
transf.pos[1] += move.vel[1] * dt;
move.vel[0] += move.acc[0] * dt;
move.vel[1] += move.acc[1] * dt;
}
// Entity is just a handle, DensePackMap tells you how to move data inside an (external) array(s) so that all data is densely packed with no gaps
using Entity = int;
struct IndexMoveInfo
{
size_t indexOfDestroyedEntity;
size_t indexOfLastEntity;
};
class DensePackMap
{
private:
std::unordered_map<Entity, size_t> m_entityToIndexMap;
std::unordered_map<size_t, Entity> m_indexToEntityMap;
public:
size_t length;
DensePackMap();
size_t AddEntity(Entity e);
IndexMoveInfo DestroyEntity(Entity e);
size_t GetIndex(Entity e);
};
int main()
{
DensePackMap map;
// std::array<CTransform, 1000> dataPos;
// std::array<CMovement, 1000> dataMov;
std::vector<CTransform> dataPos(1000);
std::vector<CMovement> dataMov(1000);
for (int i = 0; i < 1000; ++i)
{
size_t ind = map.AddEntity(i);
dataPos[ind].pos[0] = 0.0f;
dataPos[ind].pos[1] = 200.0f;
dataMov[ind].vel[0] = 0.0f;
dataMov[ind].vel[1] = 0.0f;
dataMov[ind].acc[0] = 0.0f;
dataMov[ind].acc[1] = -9.81f;
}
float dt = 0.01f;
for (int i = 0; i < 100; ++i)
{
for (int j = 0; j < 1000; ++j)
{
size_t ind = map.GetIndex(j);
auto &dataPosi = dataPos[ind];
auto &dataMovi = dataMov[ind];
UpdateTransform(dataPosi, dataMovi, dt);
}
}
std::cout << "Done!\n";
}
// Impl for DensePackMap
DensePackMap::DensePackMap() : length{0}
{
}
size_t DensePackMap::AddEntity(Entity e)
{
m_entityToIndexMap[e] = length;
m_indexToEntityMap[length] = e;
++length;
return length - 1;
}
IndexMoveInfo DensePackMap::DestroyEntity(Entity e)
{
Entity lastEntity = m_indexToEntityMap[length - 1];
size_t indexOfDestroyedEntity = m_entityToIndexMap[e];
IndexMoveInfo imi{indexOfDestroyedEntity, length - 1};
m_entityToIndexMap[lastEntity] = indexOfDestroyedEntity;
m_indexToEntityMap[indexOfDestroyedEntity] = lastEntity;
m_entityToIndexMap.erase(e);
m_indexToEntityMap.erase(length - 1);
--length;
return imi;
}
size_t DensePackMap::GetIndex(Entity e)
{
return m_entityToIndexMap.at(e);
}