[rocprofv3] signal handler fix (#332)

* rocprofv3: LD_PRELOAD for signal and sigaction

- wrappers around `signal` and `sigaction` to prevent applications which install signal handlers to replace the rocprofv3 signal handlers
- minor tweaks to buffer sizes (use page_size instead of
KiB)

* [DO NOT COMMIT] extra logging

* Switch git submodule url for perfetto

- use GitHub URL as this is more accessible

* Update ring_buffer<Tp>

- account for alignment padding

* Update buffered_output

- track number of bytes stored
- add nullptr checks

* Update tmp_file_buffer

- track number of bytes
- read_tmp_file does not create tmp file if it does not already exist

* Update tmp_file

- add exists member function for checking whether temporary file already exists
- tweak remove() implementation

* Update config.hpp

- add option to enable/disable signal handlers
- add option for minimum_output_bytes

* Make signal, sigaction functions visible

* rocprofv3 tool updates

- chained signals
- override the signal handler(s) installed by the application
- improve cleanup of temporary files
- support minimum output bytes

* Add commandline support

* fixing test

* minor fix

* minor fix

* fix clang issue

* fix

* Adding docs

* review comments

* review changes

* review

* YUV pulldown additions to rocdecode

* More rocdecode changes

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
Co-authored-by: Jonathan R. Madsen <Jonathan.Madsen@amd.com>
Co-authored-by: Benjamin Welton <bewelton@amd.com>

[ROCm/rocprofiler-sdk commit: 87badfbd15]
Dieser Commit ist enthalten in:
Nagaraj, Sriraksha
2025-04-17 23:10:52 -05:00
committet von GitHub
Ursprung 3fc9374295
Commit 2e7d0b3aec
22 geänderte Dateien mit 866 neuen und 107 gelöschten Zeilen
@@ -71,6 +71,7 @@ struct file_buffer
file_buffer& operator=(file_buffer&&) noexcept = default;
domain_type domain = {};
uint64_t nbytes = 0;
ring_buffer_t<Tp> buffer = {};
tmp_file file;
};
@@ -110,7 +111,13 @@ offload_buffer(domain_type type)
ROCP_CI_LOG_IF(WARNING, _fs.tellg() != _fs.tellp()) // this should always be true
<< "tellg=" << _fs.tellg() << ", tellp=" << _fs.tellp();
auto _nbytes = (filebuf->buffer.count() * filebuf->buffer.data_size());
ROCP_TRACE << fmt::format(
"offloading {} B from {} buffer to tmp file", _nbytes, get_domain_column_name(type));
filebuf->file.file_pos.emplace(_fs.tellp());
filebuf->nbytes += _nbytes;
filebuf->buffer.save(_fs);
filebuf->buffer.clear();
@@ -206,10 +213,13 @@ read_tmp_file(domain_type type)
return;
}
auto _lk = std::lock_guard<std::mutex>{filebuf->file.file_mutex};
auto& _fs = filebuf->file.stream;
if(_fs.is_open()) _fs.close();
filebuf->file.open(std::ios::binary | std::ios::in);
auto _lk = std::lock_guard<std::mutex>{filebuf->file.file_mutex};
if(filebuf->file.exists())
{
auto& _fs = filebuf->file.stream;
if(_fs.is_open()) _fs.close();
filebuf->file.open(std::ios::binary | std::ios::in);
}
}
} // namespace tool
} // namespace rocprofiler