diff --git a/rocclr/device/rocm/rocvirtual.cpp b/rocclr/device/rocm/rocvirtual.cpp index d2a9aa880e..0f203c3492 100644 --- a/rocclr/device/rocm/rocvirtual.cpp +++ b/rocclr/device/rocm/rocvirtual.cpp @@ -3365,17 +3365,14 @@ void VirtualGPU::submitPerfCounter(amd::PerfCounterCommand& vcmd) { if (!profileRef->initialize()) { LogError("Failed to initialize performance counter"); vcmd.setStatus(CL_INVALID_OPERATION); - } - - // create the AQL packet for start profiling - if (profileRef->createStartPacket() == nullptr) { + } else if (profileRef->createStartPacket() == nullptr) { LogError("Failed to create AQL packet for start profiling"); vcmd.setStatus(CL_INVALID_OPERATION); + } else { + dispatchCounterAqlPacket(profileRef->prePacket(), counter->gfxVersion(), false, + profileRef->api()); } - dispatchCounterAqlPacket(profileRef->prePacket(), counter->gfxVersion(), false, - profileRef->api()); - profileRef->release(); } else if (vcmd.getState() == amd::PerfCounterCommand::End) { // Since all performance counters should use the same profile, use the 1st