نمودار کامیت

235 کامیت‌ها

مولف SHA1 پیام تاریخ
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
Laurent Morichetti 96bcac0f47 Split hsa_prof_str.h
Split the public and private HSA profiler/tracer interfaces. Only the
public interface should be exposed in include/roctracer.

Change-Id: I7e4424cd90023693350c31e6b02caca8c984ba84
2022-07-14 21:20:30 -04: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
Ranjith Ramakrishnan 709e300d9b SWDEV-321112: Use GNUInstallDirs
Use GNUInstallDirs variables to determine the location of BINDIR,
LIBDIR, INCLUDEDIR, DATADIR, DOCDIR, LIBEXECDIR.

Depends-On: Id11f862fb4bdb2425d68f455074172c38814ec92
Change-Id: I6459a4531ef899321a5e2d8050cf8b553e89a968
2022-07-07 10:36:39 -07:00
Laurent Morichetti 3adc56bd9b Add the roctracer-tests package
The roctracer-tests package contains all the roctracer test binaries
and scripts needed to run the testsuite outside of the build directory.

Change-Id: Id11f862fb4bdb2425d68f455074172c38814ec92
2022-07-05 17:03:21 -04:00
Laurent Morichetti 957084de07 Rename project ROCTRACER -> roctracer
Change-Id: I83d47025aad59dc37a53ec82452b639fc8ffb478
2022-07-02 22:05:25 -07: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
Ammar ELWazir 7cbee920b7 Enabling ROCP_STATS_OPT
Enabling the new methodology of ROCP_STATS_OPT of getting HIP activities while the application is running

Change-Id: I94b3311b0740db804643dba0e4f77c1f9de0319b
2022-06-21 14:58:28 -05:00
Laurent Morichetti 44dbb56fce Fix warnings due to deprecated include path
In file included from roctracer/src/roctracer/tracker.h:24,
                 from roctracer/src/roctracer/roctracer.cpp:44:
/opt/rocm/hsa/include/hsa/amd_hsa_signal.h:26:246: note: ‘#pragma message: amd_hsa_signal.h has moved to ...’
   26 | ssage("amd_hsa_signal.h has moved to ...")
      |                                          ^

Change-Id: I38d151d836688083a4fdb0e86a04fc40923a369f
2022-06-18 13:50:33 -07: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 ef3b2a8aa8 Add a data region to the memory pool
Some records may need to point to data with the same lifetime as the
records themselves. One solution is to store the data at the end of
the memory pool buffer. Records in the buffer grow up, and the data
grows down. When the buffer is flushed both records and data are
recycled.

Change-Id: I278fa84478236bf895f7c2d152d47d4256987392
2022-06-08 18:34:23 -04: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 6d7a39ae7e Fix ROCTX function attributes
Change-Id: I32ebbacba7df9059574c31831b13fb2a923fcc97
2022-05-24 23:52:51 -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 c0cbcdff1d Move callback_table.h to the util directory
The CallbackTable utility is shared by multiple APIs, so move it out
of the roctracer directory.

Change-Id: Ie2378dca8a4f90bd334dbe2d39ced37c9e790ed0
2022-05-24 15:52:31 -07: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 1e7783af58 Add a ROCTX test
Change-Id: I90dab2f349ade6cbfc86f0399c8b9ca905de23b3
2022-05-23 23:10:26 -04:00
Laurent Morichetti 7ebae10571 Document the ROCTX API
Change-Id: I63a04139d1640ea5d52f6143cf2e9bfc0614a894
2022-05-23 23:10:02 -04:00
Laurent Morichetti 13fe79ab09 Fix CMakeLists.txt conventions
Fix indentation, quoting, and white spaces.

Change-Id: I5e5e95b961e83e5957bdd137ef9893615396bb53
2022-05-20 12:31:25 -07: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
Laurent Morichetti 0377c5a191 Add symbol versioning
Add symbol versioning to the roctracer64 and roctx64 library, and only
expose the OnLoad and OnUnload tracer_tool symbols.

Change-Id: I7f160fc3e568567fd1146ff5b9c0aef3bdcccf53
2022-05-20 10:36:38 -07:00
Laurent Morichetti 3773384af8 CMakeLists.txt cleanup
Add custom_commands to generate the HSA code objects
Remove the configure time file generation and add custom commands to
generate them at build time.

Change-Id: I167dd9befc6c73f32224935eaab74510922b26f4
2022-05-20 10:36:38 -07:00
Tony Tye c837bcad78 Eliminate static inline in api
Change-Id: Ia25636ca4a7e4b6d763ef8d6003845e7d1df5f50
2022-05-18 15:23:19 +00:00
Tony Tye feb652e45d Improve pool error checking
Check if a default pool is defined when enabling activities.

Set default pool to undefined if it is deleted.

Disable activities associated with the pool when it is deleted.

Document restrictions on deleting pools.

Change-Id: Ide466b55cab12ca2dd67d9f26b578f421e45a376
2022-05-18 15:23:19 +00:00
Laurent Morichetti 37ab921f02 Cleanup roctracer.cpp
Minor cosmetic changes.

Change-Id: Ie5a904c757aa933d83ca6e496726e47fe7032620
2022-05-12 20:15:54 -04:00
Ammar ELWazir 2f5313a0c7 Fixing cmake_modules
Removing unused definitions and compile options
Using cmake variables to set the options needed
Changing the visibility to make it specific for the targets

Change-Id: I80cf0997cd28897d5a06a58c7225ba40dfc51e2d
2022-05-11 19:25:43 -04:00
Laurent Morichetti 67481bd295 Fix memory leaks in roctracer
Each thread has a thread-local record_pair_stack. The stack is
dynamically allocated on first use, but is not detroyed when the
thread exits.

Replaced record_pair_stack pointers with record_pair_stack instances,
the intances are constructed on first odr-use, and destructed when the
thread exits.

Also, converted the cb_journal and act_journal to instances.

Change-Id: I186ac29da477f194880a1ab599f4be5715a23063
2022-05-10 12:08:06 -07:00
Laurent Morichetti a794247c55 Optimize rotcx markers
Improve the roctx markers performance when the tracer is not engaged
(the application is not running with rocprof).

The performance of roctx push/pop, measured with:

-----------------------------------------------------------------------
  auto start = std::chrono::steady_clock::now();
  for (int i = 0; i < 10000000; ++i) {
    roctxRangePush ("A");
    roctxRangePop ();
  }
  auto end = std::chrono::steady_clock::now();
  std::cout << "ns = " << std::chrono::nanoseconds(end - start).count()
      / 10000000 << std::endl;
-----------------------------------------------------------------------

w/o rocprof | with rocprof | commit
       92ns |       770ns  | 0d6e132: Cleanup CallbackTable::Get
       28ns |       712ns  | 6421bd5: Cleanup ROCTX's implementation
       20ns |       664ns  | 7f0e5e5: Remove the roctx range message...
        6ns |       665ns  | this commit

Change-Id: Id679dcbd0fb190a3179be98a9b2c1db151efee3d
2022-05-10 12:08:06 -07:00
Laurent Morichetti 3d0198c395 Remove the roctx range message stack
The range message stack is mirrored in case ranges are pushed or popped
while tracing is stopped (by the tracer tool?). When a stop event is
reported, the tracer tool emits RangePop events by unwinding the stack,
then when the start event is reported, it emits RangePush events again
by unwinding the stack. The issue is that the RangePush events should
be emitted in reverse order.

For example:

RangePush(M1); RangePush(M2); \
  TracerStop; RangePop; RangePop; \
...; \
  TracerStart; RangePush(M2); RangePush(M1); \ <- In the wrong order
RangePop; RangePop;

It could be fixed by reversing the stack in RangeStackIterate but is it
worth it? The roctx range markers are supposed to be unintrusive so that
they can be left in the application even when it isn't being traced.

Simplifying the roctx API and reducing its added latency by removing
the range message stack mirroring seems like the better choise.

TODO: A future change should make roctx events immune to tracer start
and tracer stop requests. Or simply remove roctracer_start/stop.

Change-Id: Ie4d76afb5ce8d263848dcf1b599af394db56ddab
2022-05-10 12:08:06 -07:00
Laurent Morichetti 713db1fce5 Cleanup ROCTX's implementation
Remove thread_data_init. The C++ standard guarantees that the thread
local variable is initialized before its first odr-use and destructed
when the thread exits. Use a global initializer to set the reference
from the message stack instance in the map.

Remove roctracer_error_string. This does not belong to this library.
ROCTX does not expose errors to the application. The only functions
returning errors are returning -1 (Push/Pop).

Remove memory leaks due to strdup on the ranges messages. The memory
for the messages is guaranteed to be valid for the duration of the
callback, and it is the application's responsibility to strdup the
strings if it needs to extend the message's lifetime.

Add a lock to the RegisterApiCallback implementation. Iterating the
message stack map must be synchronized as a new thread could be adding
a new value to the map.

Change-Id: Iaf5b07ebc9efe4061cb01327d4c7034888727816
2022-05-10 12:08:06 -07:00
Laurent Morichetti 6e4055503c Merge "Cleanup CallbackTable::Get" into amd-staging 2022-05-10 14:55:20 -04:00
Laurent Morichetti e8909158b3 Merge "Remove unused open_output_file/close_output_file" into amd-staging 2022-05-10 14:55:10 -04:00
Laurent Morichetti 9cecf30131 Merge "Fix a hang in './test/hsa/ctrl ctrl_hsa_input_trace'" into amd-staging 2022-05-10 14:54:11 -04:00
Laurent Morichetti fe0adfd37b Merge "Remove now unused hsa_rsrc_factory" into amd-staging 2022-05-10 14:54:01 -04:00
Laurent Morichetti 7c4f7625b1 Merge "Consolidate all sources of timestamps" into amd-staging 2022-05-10 14:53:36 -04:00
Laurent Morichetti 4aeb76f7a8 Cleanup CallbackTable::Get
Make CallbackTable::Get return the callback_function/user_arg pair
as an actual return value instead of returning it through arguments
pointers.

Change-Id: Ia2dfcdad8c237a09620518ad67af94add47220da
2022-05-10 08:13:18 -07:00
Laurent Morichetti cb040b7def Remove unused open_output_file/close_output_file
Change-Id: I0e5118b814617cb605949c99e5f0dc235f6edac0
2022-05-10 08:13:18 -07:00
Laurent Morichetti 11887f596a Fix a hang in './test/hsa/ctrl ctrl_hsa_input_trace'
At the end of the test, the tracer tool is unloaded and the active
memory pools are flushed. In the flush callback, to get the activity
operation string, the RocpLoader instance is neeeded, and if the
RocpLoader is not already loaded, it attempts to dlopen the rocprofiler
library.

Calling dlopen from a global destructor hangs because the dynamic
loader lock is already owned (e.g. by dlclose).

To temporarily work around the issue, instanciate the RocpLoader when
the activities needing it are enabled.

Change-Id: I712c66d88c43694fe53a95d6a61d7b22abb75262
2022-05-10 08:13:18 -07:00
Laurent Morichetti 4ced94b9a2 Remove now unused hsa_rsrc_factory
Change-Id: I66175eb9fae2e7e61400af77a0c89be9c39e770e
2022-05-10 08:13:18 -07:00
Laurent Morichetti f8462b8637 Consolidate all sources of timestamps
System clock timestamps should only come from a single source:
util::timestamp_ns(). Externally, this function is exposed as
roctracer_get_timestamp() (used by the tracer tool).

Removed the now unused HSA Runtime Utilities which were never part
of the ROCtracer API.

Change-Id: I044b7f4da60fd8fdb771b0c877622a3143f0e815
2022-05-10 08:13:09 -07:00
Ammar ELWazir 502ea835b9 Solving issue with using clang as the compiler
Change-Id: I4fa7b24af7008a30b0300b57ccbf1bc82dbfd66e
2022-05-09 17:41:33 -05:00
Ammar ELWazir 78869032ad SWDEV-335490: Unused variables
Compilers doesn't see assert as a usage of the variables, I added [[maybe_unused]] to the variables that are used only in assert to make sure that the compiler is skipping them in the check. Note: [[maybe_unused]] is introduced in C++17

Change-Id: I96bb53cb2ab55ee7120681c2d279271c0075095d
2022-05-04 11:24:28 -04:00