periodic trace flushing

[ROCm/roctracer commit: c73b98c2c5]
Este commit está contenido en:
Evgeny
2020-01-27 20:42:22 -06:00
padre a41e035ada
commit 2bc58d21f5
Se han modificado 2 ficheros con 35 adiciones y 4 borrados
+1
Ver fichero
@@ -81,6 +81,7 @@ eval_test "tool SYS/HSA test" ./test/MatrixTranspose
# Tracing control <delay:length:rate>
export ROCTRACER_DOMAIN="hip"
eval_test "tool period test" "ROCP_CTRL_RATE=10:100000:1000000 ./test/MatrixTranspose"
eval_test "tool flushing test" "ROCP_FLUSH_RATE=100000 ./test/MatrixTranspose"
# HSA test
export ROCTRACER_DOMAIN="hsa"
+34 -4
Ver fichero
@@ -123,19 +123,19 @@ void* control_thr_fun(void*) {
const uint32_t len_us = control_len_us % 1000000;
const uint32_t dist_sec = control_dist_us / 1000000;
const uint32_t dist_us = control_dist_us % 1000000;
bool start = true;
bool to_start = true;
sleep(delay_sec);
usleep(delay_us);
while (1) {
if (start) {
start = false;
if (to_start) {
to_start = false;
roctracer_start();
sleep(len_sec);
usleep(len_us);
} else {
start = true;
to_start = true;
roctracer_stop();
sleep(dist_sec);
usleep(dist_us);
@@ -143,6 +143,20 @@ void* control_thr_fun(void*) {
}
}
// Flushing control thread
uint32_t control_flush_us = 0;
void* flush_thr_fun(void*) {
const uint32_t dist_sec = control_flush_us / 1000000;
const uint32_t dist_us = control_flush_us % 1000000;
while (1) {
sleep(dist_sec);
usleep(dist_us);
roctracer_flush_activity();
roctracer::TraceBufferBase::FlushAll();
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// rocTX annotation tracing
@@ -784,6 +798,22 @@ extern "C" PUBLIC_API bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
}
}
const char* flush_str = getenv("ROCP_FLUSH_RATE");
if (flush_str != NULL) {
sscanf(flush_str, "%d", &control_flush_us);
if (control_flush_us == 0) {
fprintf(stderr, "ROCTracer: control flush rate bad value\n");
abort();
}
fprintf(stdout, "ROCTracer: trace control flush rate(%uus)\n", control_flush_us); fflush(stdout);
pthread_t thread;
pthread_attr_t attr;
int err = pthread_attr_init(&attr);
if (err) { errno = err; perror("pthread_attr_init"); abort(); }
err = pthread_create(&thread, &attr, flush_thr_fun, NULL);
}
// Enable KFD API callbacks/activity
if (trace_kfd) {
kfd_api_file_handle = open_output_file(output_prefix, "kfd_api_trace.txt");