29c63c5281
Change-Id: Ibcaca6869ce96d8802c5fa8ba241f43834d6f2a7 update - codeobj event implementation Change-Id: I4c12f26a19f2b31d9ac2211c3426a0e587a332b3 update2 - codeobj event implementation Change-Id: Ic877549a83542ae00352503471d881e847ebac9c test - codeobj event implementation Change-Id: I0618d3a93de94c3d7467372ba4a3d4ea5520bfc7 URI reference test - codeobj event implementation Change-Id: I6cf7e8a648cf012cb0708058b118a75e58f992b9 adding test/app - codeobj event implementation Change-Id: Idf4c197c7b9116ccde5ec50ff47a26a858bfab32 uri test fix - codeobj event implementation Change-Id: I7c385f82f516d9d8f2cd726366f00be3664006e3 uri test cleanup - codeobj event implementation Change-Id: I542d5baf88c048c8b4717af843b803cd93e8f3bc URI buffer fix - codeobj event implementation Change-Id: Iac65e04c03a0939935c10f53c6b580a2e33878f5 HSA events tests trace-check disabled Change-Id: I0f4d13aeeceb1d1a6e2191673eacbf9c7ae2ae52
90 wiersze
3.1 KiB
C++
90 wiersze
3.1 KiB
C++
/******************************************************************************
|
|
Copyright (c) 2018 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 <string.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "inc/roctracer.h"
|
|
#include "inc/roctracer_hsa.h"
|
|
#include <rocprofiler/rocprofiler.h>
|
|
|
|
#define PUBLIC_API __attribute__((visibility("default")))
|
|
#define CONSTRUCTOR_API __attribute__((constructor))
|
|
#define DESTRUCTOR_API __attribute__((destructor))
|
|
|
|
// Check returned HSA API status
|
|
void check_status(roctracer_status_t status) {
|
|
if (status != ROCTRACER_STATUS_SUCCESS) {
|
|
const char* error_string = roctracer_error_string();
|
|
fprintf(stderr, "ERROR: %s\n", error_string);
|
|
abort();
|
|
}
|
|
}
|
|
|
|
// codeobj callback
|
|
void codeobj_callback(uint32_t domain, uint32_t cid, const void* data, void* arg) {
|
|
const hsa_evt_data_t* evt_data = reinterpret_cast<const hsa_evt_data_t*>(data);
|
|
const uint32_t uri_length = evt_data->codeobj.uri_length;
|
|
const char* uri = evt_data->codeobj.uri;
|
|
printf("codeobj_callback domain(%u) cid(%u): load_delta(0x%lx) load_size(0x%lx) uri_length(%u) uri(\"%s\")\n",
|
|
domain,
|
|
cid,
|
|
evt_data->codeobj.load_delta,
|
|
evt_data->codeobj.load_size,
|
|
uri_length,
|
|
uri);
|
|
fflush(stdout);
|
|
}
|
|
|
|
void initialize() {
|
|
roctracer_status_t status = roctracer_enable_op_callback(ACTIVITY_DOMAIN_HSA_EVT, HSA_EVT_ID_CODEOBJ, codeobj_callback, NULL);
|
|
check_status(status);
|
|
}
|
|
|
|
void cleanup() {
|
|
roctracer_status_t status = roctracer_disable_domain_callback(ACTIVITY_DOMAIN_HSA_EVT);
|
|
check_status(status);
|
|
}
|
|
|
|
// Tool constructor
|
|
extern "C" PUBLIC_API void OnLoadToolProp(rocprofiler_settings_t* settings) {
|
|
// Enable HSA events intercepting
|
|
settings->hsa_intercepting = 1;
|
|
// Initialize profiling
|
|
initialize();
|
|
}
|
|
|
|
// Tool destructor
|
|
extern "C" PUBLIC_API void OnUnloadTool() {
|
|
// Final resources cleanup
|
|
cleanup();
|
|
}
|
|
|
|
extern "C" CONSTRUCTOR_API void constructor() {
|
|
printf("constructor\n"); fflush(stdout);
|
|
}
|
|
|
|
extern "C" DESTRUCTOR_API void destructor() {
|
|
OnUnloadTool();
|
|
}
|