099ac7c72d
* Enabling codeobj and thread trace samples * Updating aqlprofile_v2 header * Codeobj and thread trace samples with output log files * Fixing clang format * Cmake formatting * Adding coverage to codeobj * Comment trace sample * Adding ATT Parser API * Fixing forwarding to aqlprofile * Clang formatting * Clang tidy * Adding option to print memory kernels * Clang format * Remove default from switch case * Separating client/main on codeobj sample for ASAn * Formatting * Gbaraldi/att tool rebase (#801) * Enabling codeobj and thread trace samples * Updating aqlprofile_v2 header * Codeobj and thread trace samples with output log files * Fixing clang format * Cmake formatting * Adding coverage to codeobj * Comment trace sample * Removing python from workflow * Adding ATT Parser API * Fixing forwarding to aqlprofile * Clang formatting * Clang tidy * Adding option to print memory kernels * Clang format * Remove default from switch case * Separating client/main on codeobj sample for ASAn * Formatting * Enabling codeobj and thread trace samples * Updating aqlprofile_v2 header * Codeobj and thread trace samples with output log files * Fixing clang format * Cmake formatting * Adding coverage to codeobj * Comment trace sample * Adding ATT Parser API * Fixing forwarding to aqlprofile * Clang formatting * Clang tidy * Adding option to print memory kernels * Clang format * Remove default from switch case * Separating client/main on codeobj sample for ASAn * Formatting * Fix codeobj library * Allow thread trace in parallel with other service * Zeroing the HSA signals * Adding exception wrappers in ATT sample * Removed force configure * Remove force configure from ISA decode * Removing codecov flag * Gbaraldi/att tool tests (#828) * Adding tests for codeobj ISA decode * Adding ATT tests * Adding ATT integration tests * Formatting * Changing codeobj binary extension * Renaming codeobj library spaces * Fixing samples * Formatting * Formatting * Fixing int test * Fixing linker error * Fixing memory fault * Moving kernel ot inside namespace * ASAN linking fix * Removing unecessary headers * Formatting * Fixing target_cu * Remove codeobj binary * Revert "Remove codeobj binary" This reverts commit 7d286f89d8096bc36925cd79cd742a5e6d10d179. * Enable memory snapshot * adding comgr --------- Co-authored-by: Ammar ELWazir <ammar.elwazir@amd.com>
84 lines
4.0 KiB
C++
84 lines
4.0 KiB
C++
// MIT License
|
|
//
|
|
// Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
|
|
//
|
|
// 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.
|
|
|
|
#include <rocprofiler-sdk/rocprofiler.h>
|
|
|
|
#include "lib/rocprofiler-sdk/aql/helpers.hpp"
|
|
#include "lib/rocprofiler-sdk/context/context.hpp"
|
|
#include "lib/rocprofiler-sdk/hsa/agent_cache.hpp"
|
|
|
|
extern "C" {
|
|
rocprofiler_status_t ROCPROFILER_API
|
|
rocprofiler_configure_thread_trace_service(rocprofiler_context_id_t context_id,
|
|
rocprofiler_att_parameter_t* parameters,
|
|
size_t num_parameters,
|
|
rocprofiler_att_dispatch_callback_t dispatch_callback,
|
|
rocprofiler_att_shader_data_callback_t shader_callback,
|
|
void* callback_userdata)
|
|
{
|
|
auto* ctx = rocprofiler::context::get_mutable_registered_context(context_id);
|
|
if(!ctx) return ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_STARTED;
|
|
if(ctx->thread_trace) return ROCPROFILER_STATUS_ERROR_SERVICE_ALREADY_CONFIGURED;
|
|
|
|
auto thread_tracer = std::make_shared<rocprofiler::thread_trace_parameter_pack>();
|
|
|
|
thread_tracer->context_id = context_id;
|
|
thread_tracer->dispatch_cb_fn = dispatch_callback;
|
|
thread_tracer->shader_cb_fn = shader_callback;
|
|
thread_tracer->callback_userdata = callback_userdata;
|
|
|
|
for(size_t p = 0; p < num_parameters; p++)
|
|
{
|
|
const rocprofiler_att_parameter_t& param = parameters[p];
|
|
if(param.type > ROCPROFILER_ATT_PARAMETER_LAST)
|
|
return ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT;
|
|
|
|
switch(param.type)
|
|
{
|
|
case ROCPROFILER_ATT_PARAMETER_TARGET_CU: thread_tracer->target_cu = param.value; break;
|
|
case ROCPROFILER_ATT_PARAMETER_SHADER_ENGINE_MASK:
|
|
thread_tracer->shader_engine_mask = param.value;
|
|
break;
|
|
case ROCPROFILER_ATT_PARAMETER_BUFFER_SIZE:
|
|
thread_tracer->buffer_size = param.value;
|
|
break;
|
|
case ROCPROFILER_ATT_PARAMETER_SIMD_SELECT:
|
|
thread_tracer->simd_select = param.value;
|
|
break;
|
|
case ROCPROFILER_ATT_PARAMETER_OCCUPANCY_MODE_ENABLE:
|
|
return ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED;
|
|
case ROCPROFILER_ATT_PARAMETER_PERFCOUNTERS_CTRL:
|
|
return ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED;
|
|
case ROCPROFILER_ATT_PARAMETER_PERFCOUNTER:
|
|
return ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED;
|
|
case ROCPROFILER_ATT_PARAMETER_LAST: return ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT;
|
|
}
|
|
// for(int i = 0; i < parameters.perfcounter_num; i++)
|
|
// thread_tracer->perfcounters.emplace_back(parameters.perfcounter[i]);
|
|
}
|
|
|
|
ctx->thread_trace = std::make_shared<rocprofiler::ThreadTracer>(thread_tracer);
|
|
|
|
return ROCPROFILER_STATUS_SUCCESS;
|
|
}
|
|
}
|