diff --git a/projects/rocprofiler-sdk/README.md b/projects/rocprofiler-sdk/README.md index 5e60fe46aa..adc70859e5 100644 --- a/projects/rocprofiler-sdk/README.md +++ b/projects/rocprofiler-sdk/README.md @@ -99,7 +99,7 @@ Please report issues on GitHub OR send an email to . Use 'rocm-smi' or 'amd-smi monitor' to see device number. sudo amd-smi set -g -l stable_std @@ -130,4 +130,4 @@ Please report issues on GitHub OR send an email to [!WARNING] -> The latest mainline version of AQLprofile can be found at [https://repo.radeon.com/rocm/misc/aqlprofile/](https://repo.radeon.com/rocm/misc/aqlprofile/). However, it's important to note that updates to the public AQLProfile may not occur as frequently as updates to the rocprofiler-sdk. This discrepancy could lead to a potential mismatch between the AQLprofile binary and the rocprofiler-sdk source. +> To use ROCprofiler-SDK, obtain the latest mainline version of AQLprofile from [here](https://github.com/ROCm/aqlprofile). diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/buffer.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/buffer.cpp index b2c034eebf..dd28cdc59e 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/buffer.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/buffer.cpp @@ -168,7 +168,7 @@ flush(rocprofiler_buffer_id_t buffer_id, bool wait) while(buff->syncer.test_and_set()) { std::this_thread::yield(); - std::this_thread::sleep_for(std::chrono::milliseconds{10}); + std::this_thread::sleep_for(std::chrono::microseconds{10}); } } diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/buffer.hpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/buffer.hpp index f0c249c84d..2644046213 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/buffer.hpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/buffer.hpp @@ -43,7 +43,7 @@ struct instance using buffer_t = common::container::record_header_buffer; mutable std::array buffers = {}; - mutable std::atomic_flag syncer = ATOMIC_FLAG_INIT; + mutable std::atomic_flag syncer = ATOMIC_FLAG_INIT; // writer and reader lock. mutable std::atomic buffer_idx = {}; // array index mutable std::atomic drop_count = {}; uint64_t watermark = 0; @@ -118,8 +118,14 @@ rocprofiler::buffer::instance::emplace(uint32_t category, uint32_t kind, Tp& val // get the index of the current buffer auto get_idx = [this]() { return buffer_idx.load(std::memory_order_acquire) % buffers.size(); }; + while(syncer.test_and_set()) + { + std::this_thread::yield(); + std::this_thread::sleep_for(std::chrono::microseconds{10}); + } auto idx = get_idx(); auto success = buffers.at(idx).emplace(category, kind, value); + syncer.clear(); if(!success) { if(buffers.at(idx).capacity() < sizeof(value)) @@ -138,8 +144,14 @@ rocprofiler::buffer::instance::emplace(uint32_t category, uint32_t kind, Tp& val do { buffer::flush(buffer_id, true); + while(syncer.test_and_set()) + { + std::this_thread::yield(); + std::this_thread::sleep_for(std::chrono::microseconds{10}); + } idx = get_idx(); success = buffers.at(idx).emplace(category, kind, value); + syncer.clear(); } while(!success); } else diff --git a/projects/rocprofiler-sdk/tests/bin/rocjpeg/rocjpeg_samples_utils.h b/projects/rocprofiler-sdk/tests/bin/rocjpeg/rocjpeg_samples_utils.h index 4a8a9fa15c..5078dbacd8 100644 --- a/projects/rocprofiler-sdk/tests/bin/rocjpeg/rocjpeg_samples_utils.h +++ b/projects/rocprofiler-sdk/tests/bin/rocjpeg/rocjpeg_samples_utils.h @@ -28,6 +28,7 @@ THE SOFTWARE. #include #include #include +#include #include #include #include