Commit graph

35 Commits

Autor SHA1 Nachricht Datum
Ammar ELWazir dbfe955d57 Fixing initialization of ROCTx for the tool in the default constructor
Change-Id: I12a3bbde4420a9eb8d734c546169a11cb23237dd
2023-10-30 16:53:21 +00:00
gobhardw d4c2546336 SWDEV-408936 solving rocprof hang due to early initialization
Change-Id: Ia9c52f3b4c7ff191054cef40208f26b28f021378
2023-10-25 20:02:27 +05:30
Benjamin Welton 38ba63030d Added ROCTRACER_BUFFER_SIZE to set buffer size
[SWDEV-418917] reported that timing skew was being introduced by
roctracer. Most of the cause of this problem seems to stem from outrunning
the double buffering scheme that we use in memory_pool (part of the
reason for this outrun is due to File writing being slow). A semi-quick
fix that may be able to last until RocProf v2 is complete is to allow
adjustment of the buffer size. ROCTRACER_BUFFER_SIZE env variable was
introduced here which allows setting the buffer size of tracer tool.

By increasing the buffer size, an ~8% reduction in execution time when timing
on the program side. This should also reduce the frequency of large delays
when we outrun the buffer. Note: increasing this size dramatically can cause
slow startups (i.e. above 50MB).

Change-Id: I98c4316cfe93a043623ae2669cfe1a5abb55c990
2023-10-18 18:06:54 +00:00
Ammar ELWazir 04d0bd4874 SWDEV-288134: Workaround to enable roctracer early
Change-Id: Iae21dbfd9f50dcf2e317130c6dc8328f17eba553
2023-06-20 21:59:19 +00:00
Laurent Morichetti 8a575d8d6e Remove the thread local begin_timestamp stack
Using a thread_local object is problematic as the thread local
destructors are called first before any global destructor, making
the object invalid while tearing down the process.

rocblas uses a global destructor to clean up the loaded HIP modules
and ends up calling hip_executable_destroy after the timestamp stack
is destructed. As a result the begin timestamp for that API function
is 0.

The solution is to store the phase_enter timestamp in the phase_data.

Change-Id: If143f4d123dfb111c72fb20365431d07e73fc570
2022-09-30 15:01:08 -07:00
Laurent Morichetti b664937ebd Use the "safe" Stack for begin_timestamp
The tracer tool needs to remember the begin timestamps for API
callbacks, and uses a thread_local std::stack for that purpose.

The issue with thread_local objects is that they are destructed
before anything else when the main thread exits. To work around
that issue, we use a "safe" stack in the roctracer API.

Use the same "safe" stack in the tracer tool.

Change-Id: I0d69d4eb44f0205f4102d0d5ef9803a1ec1800a5
2022-09-26 13:44:55 -07:00
Laurent Morichetti 4856d33959 SWDEV-355896 - Fix a data corruption error in post processing
The post-processing script cannot handle HIP ops without a correlation
ID. The correlation ID is needed to connect the record to a HIP stream
and originating thread.

This issue was exposed by a change to the tracer API to report
asynchronous activities even if their originating synchronous API
activity (callback) is not enabled. This was a flow in the API.

Also fix an issue with the API filtering. Undefined API names should
not cause an exception, they should be ignored.

Change-Id: Iab2221af6180ade2b9c2eb10c256c3a73d872e9f
2022-09-13 08:21:13 -07:00
Laurent Morichetti db69cc1c9f Fix the Loader
Instead of dlopen'ing RTLD_NOLOAD a library (for example libamdhip64.so)
and rely on the dynamic linker search path, search through the already
loaded shared objects for a library with a matching name.

Change-Id: I3e74d432bd7ca68df8927ca435b290e86aaaf9e9
2022-09-08 20:58:07 -07:00
Laurent Morichetti 57867e4803 Use fatal() and warning() for logging errors
Change-Id: I4d525ed2a7dba72beff6fbe43383015e55465fcd
2022-09-06 19:38:16 -07:00
Laurent Morichetti 61c232bc69 Fix nested timestamps
Change-Id: I6385d52cc858670a116f5c2eb65e4f19be73190f
2022-09-06 19:38:16 -07:00
Laurent Morichetti c2b87b1fd7 Bring the HSA_EVT callbacks back to the roctracer
Change-Id: I26080b264d7989880ba7e9f00502cc680b2256d7
2022-09-06 19:38:12 -07:00
Laurent Morichetti bddb9850de Remove roctracer_mark
This function has been deprecated since ROCm-2.9, use ROCTX's
roctxMark(const char* message) as a replacement for roctracer_mark.

Change-Id: Ie4aeae1db238453fc4451746cc9a338032ba817f
2022-08-19 10:38:41 -07:00
Ammar ELWazir 4cd7497a87 Fixing issues caused by the plugin patches
- Multithreaded Applications and plugin destruction
- Fixing Async-copy trace in file plugin
- Adding the assert checkups for every trace buffer flush function

Change-Id: I96e096fd7ee2604931200a0b446edb5ce49959dd
2022-08-19 00:01:02 -04:00
Ammar ELWazir b7e1f74054 Adding File Plugin
- Added File plugin as the default plugin
- Moved the flush functions to the plugins
- Improved the flush to file implementation

Change-Id: I80dd448eb8147a8ea4aa63b39bd1d0a4baf7252b
2022-08-11 12:06:13 -05:00
Ammar ELWazir 1c7c5cc112 Adding Plugin Interface
- Add roctracer plugins hooks
- Add Roctracer plugin environment variable
- Add the plugin class
- Add the plugin implementation

Change-Id: I12ee2e2be035abac14864764fb76837a4533cf60
2022-08-11 10:13:36 -05:00
Ammar ELWazir 591db0b718 Changing NULL to nullptr (Tracer Tool)
Change-Id: I567bf7944599922e5d402e55142c2915ae24fb69
2022-08-08 20:45:34 -05:00
Ammar ELWazir 2e08b7d8f8 Fixing HIP Callback Data Arguments
Change-Id: I0bd9686024eed8fa757cb9fd7042b0f9508c5af5
2022-07-28 19:29:04 -05:00
Laurent Morichetti 05d3cf3529 Cleanup roctracer_hsa.h
Remove declarations that are not meant to be part of the public API.

Change-Id: I47d9e83bf41bdb2f7ac25a1507200b51c616049b
2022-07-27 02:16:15 -04:00
Laurent Morichetti e282a82e29 Fix HSA intercept
Move the HSA intercept to the OnLoad function, so that it is available
as soon as the ROCR is loaded.

Layer the HSA API wrappers on top of the basic HSA activity intercept.

Change-Id: Ie636d59755543cda181e76ec29f0b55081136b63
2022-07-27 02:15:43 -04:00
Ammar ELWazir 054456bcf8 SWDEV-342613: Tracer Tool Optimizations Ready for plugins
This commit is for code cleanup and for optimizing kernel name search
in the API callback, making sure to get the kernel name accurately
for the hip functions that have any kernel names

Change-Id: Ie9ab917c895748bfb8eee9ddfcbcad81a0b9a9fa
2022-07-26 18:58:31 -05:00
Laurent Morichetti 2513f9f51f Add TraceBuffer entry construction/destruction
Change-Id: I354f36b0d7a0baea0efb75d5e81f169b5f969542
2022-07-26 16:23:59 -07:00
Laurent Morichetti a7cac4b4c9 Fix a SEGV in std::atoi
When ROCP_TRUNCATE_NAMES is not set, getenv returns NULL and std::atoi
crashes. Check that getenv returns a non-NULL string before calling
std::atoi.

Change-Id: Ie479a481f8d23f034b425d14e3cfefb3d62c84e8
2022-07-15 01:06:46 -07:00
Sriraksha Nagaraj e3db2beca7 SWDEV-342302 - Fixing basenames options in case of hip trace
Added a function to truncate the kernel names in case of hip trace.

Change-Id: Ida769679ccc38432538ce74c11c395d6a930018e
2022-07-13 08:20:36 -04:00
Ammar ELWazir 581c37502f SWDEV-342613: Adding typedef for timestamps
Adding roctracer_timestamp_t to be unified type for every timestamp in the roctracer project

Change-Id: I22f18c303bd2d02d1e6079b76da6b128eb384fdd
2022-07-08 21:08:35 -04:00
Sriraksha Nagaraj 4484718571 SWDEV-323976:Adding support to display correlation-ids in hsa-trace files
Change-Id: Ie01658c1f55624b4986542853a9a85a4ca40866d
2022-06-27 07:54:22 -04:00
Laurent Morichetti d32cf96cd4 Use the new ROCR support to automatically load tool libraries
The ROCR now detects already loaded tool libraries and calls OnLoad/
OnUnload in the order specified with HSA_AMD_TOOL_ORDER.

It is no longer necessary to set the HSA_TOOLS_LIB environment variable
to load the roctracer API. The roctracer tool library should be
pre-loaded with LD_PRELOAD.

Change-Id: I6de1b1bd4f93caa08d3554aad2376d242c74fb7e
2022-06-24 16:45:03 -07:00
Ammar ELWazir 8c28237a2c Changing hcc to hip in hip activity file handle
Change-Id: If4207b72757775d31404768807fe1ad1204521f6
2022-06-21 19:03:33 -04:00
Laurent Morichetti 836bab37d3 Remove EvtStats from the tracer_tool
The same information can be generated from the hcc_ops_trace.txt file,
so in a later commit, will add a stage to the tblextr.py script to
generate the .csv files when ROCP_STATS_OPT=1.

Change-Id: I3d1575e096bedf98c66068d9a4ca141421e5bb9d
2022-06-09 15:20:14 -07:00
Laurent Morichetti e9b3b7c9a0 Remove the tracer tool's constructor and destructor functions
Change-Id: I12d88af726074fb15f8159580c85c12888f72172
2022-05-24 21:50:47 -07:00
Laurent Morichetti 15f65a4d27 Fix typos
Change-Id: I90df287a3b0f501a5dcb4b37a2bd3b9d5695f582
2022-05-24 23:53:01 -04:00
Laurent Morichetti 1c450082af Add ROCtracer version information
Change-Id: I10b268790d2dc4f3a3ad8624b2f553da6f3ccc8e
2022-05-24 23:52:29 -04:00
Laurent Morichetti 1e8e53da1d Move exception.h to the roctracer
Only the roctracer API is using exceptions to return error codes to the
client application.

Change-Id: I92e5bd1a044dbde0c80dd9ef87e606550c3ff790
2022-05-24 23:52:07 -04:00
Laurent Morichetti 8ee9d859ed Remove internal functions from the ROCtracer API
The roctracer_load, roctracer_unload, and roctrace_flush_buf functions
are not part of the ROCtracer API, and should not be exposed in the API
header file, but keep the functions in the library for backward
compatibility.

Add src/roctracer/backward_compat.cpp to implement retired functions.

Add test/app/backward_compat_test.cpp to test that the retired functions
are still accessible in the latest roctracer library.

Change-Id: I4c94310a7bfccfeae9384dac5db18fc79b4c5b17
2022-05-24 15:52:29 -07:00
Tony Tye a4db4084db Improve error reporting and error codes
Make error codes more informative and have negative values. This is an
ABI break but it does not appear known tools are relying on the exact
error codes.

Use logging for all errors so that roctracer_error_string will be able
to return last error message.

Make internal errors fatal and abort.

Do not use the tracer API exceptions in the tracer tool.

Change-Id: Ie8ed3d50e5ad26625ac9d1263f7e048edb5584c0
2022-05-24 15:32:56 -04:00
Laurent Morichetti b34e9c2ee4 File reorganization
Move the tracer_tool from the 'test' directory to the 'src' directory.

Change-Id: I13768b9610cd359f78a66147f0255ab1e4c657e9
2022-05-20 10:36:38 -07:00