61f35b0204
A trace buffer is used to efficiently store synchronous event records so that they can be processed later, possibly in a different thread, when the buffer is flushed. This helps reduce the latency added by tracing API calls. The API does not need to use trace buffers as synchronous events are directly reported to the client with callbacks, and asynchronous events (activities) are saved in memory pools. The implentation of HSA asynchronous memory copy activities was using a trace buffer shared with the tracer tool to write the records to a file (async_copy_trace.txt), instead of using a memory pool and reporting the activity to the client. Removed the asynchronous memory copies trace buffer, and updated hsa_async_copy_handler to use the pool specified when the activity was enabled. Updated the tracer tool to read HSA_OP_ID_COPY records out of the default memory pool and write them to async_copy_trace.txt. Move trace_buffer.h to test/tool as tracer_tool.cpp is now the only file using it. Change-Id: Ida95aba2eaf3c3f2a979ed6c2b060374017b7424
71 lines
2.1 KiB
C++
71 lines
2.1 KiB
C++
/* Copyright (c) 2018-2022 Advanced Micro Devices, Inc.
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
THE SOFTWARE. */
|
|
|
|
#ifndef INC_ROCTRACER_HSA_H_
|
|
#define INC_ROCTRACER_HSA_H_
|
|
|
|
#include <hsa.h>
|
|
#include <hsa_ext_amd.h>
|
|
|
|
#include <roctracer.h>
|
|
#include <rocprofiler/activity.h>
|
|
|
|
// HSA OP ID enumeration
|
|
enum hsa_op_id_t {
|
|
HSA_OP_ID_DISPATCH = 0,
|
|
HSA_OP_ID_COPY = 1,
|
|
HSA_OP_ID_BARRIER = 2,
|
|
HSA_OP_ID_RESERVED1 = 3,
|
|
HSA_OP_ID_NUMBER
|
|
};
|
|
|
|
#ifdef __cplusplus
|
|
#include <iostream>
|
|
#include <hsa_api_trace.h>
|
|
|
|
namespace roctracer {
|
|
namespace hsa_support {
|
|
enum { HSA_OP_ID_async_copy = 0 };
|
|
|
|
extern CoreApiTable CoreApiTable_saved;
|
|
extern AmdExtTable AmdExtTable_saved;
|
|
extern ImageExtTable ImageExtTable_saved;
|
|
|
|
struct ops_properties_t {
|
|
void* table;
|
|
void* reserved1[3];
|
|
};
|
|
|
|
}; // namespace hsa_support
|
|
|
|
typedef hsa_support::ops_properties_t hsa_ops_properties_t;
|
|
}; // namespace roctracer
|
|
|
|
#include "hsa_ostream_ops.h"
|
|
|
|
|
|
#else // !__cplusplus
|
|
typedef void* hsa_amd_queue_intercept_handler;
|
|
typedef void* hsa_amd_runtime_queue_notifier;
|
|
#endif //! __cplusplus
|
|
|
|
#include <hsa_prof_str.h>
|
|
#endif // INC_ROCTRACER_HSA_H_
|