get_time API: make public; extende with more time id: coarse and raw; added time error return value;

Change-Id: I1641eb2c38915222204617e07fc0bfb388bb8346
Bu işleme şunda yer alıyor:
Evgeny
2020-04-30 02:38:18 -05:00
ebeveyn 2df34c40ea
işleme 3ce98d33d4
7 değiştirilmiş dosya ile 122 ekleme ve 31 silme
+21 -12
Dosyayı Görüntüle
@@ -843,7 +843,7 @@ PUBLIC_API hsa_status_t rocprofiler_iterate_info(
uint32_t block_counters;
profile.events = &(counters_vec[0]->event);
status = rocprofiler::util::HsaRsrcFactory::Instance().AqlProfileApi()->hsa_ven_amd_aqlprofile_get_info(
&profile, HSA_VEN_AMD_AQLPROFILE_INFO_BLOCK_COUNTERS, &block_counters);
&profile, HSA_VEN_AMD_AQLPROFILE_INFO_BLOCK_COUNTERS, &block_counters);
if (status != HSA_STATUS_SUCCESS) continue;
info.metric.instances = query.instance_count;
@@ -898,24 +898,36 @@ PUBLIC_API hsa_status_t rocprofiler_queue_create_profiled(
void* data, uint32_t private_segment_size, uint32_t group_segment_size,
hsa_queue_t** queue)
{
return rocprofiler::InterceptQueue::QueueCreateTracked(agent, size, type, callback, data, private_segment_size, group_segment_size, queue);
API_METHOD_PREFIX
status = rocprofiler::InterceptQueue::QueueCreateTracked(
agent, size, type, callback, data, private_segment_size, group_segment_size, queue);
API_METHOD_SUFFIX
}
// Return time value for a given time ID and profiling timestamp
hsa_status_t rocprofiler_get_time(
PUBLIC_API hsa_status_t rocprofiler_get_time(
rocprofiler_time_id_t time_id,
uint64_t timestamp,
uint64_t* value_ns)
uint64_t* value_ns,
uint64_t* error_ns)
{
return rocprofiler::util::HsaRsrcFactory::Instance().GetTime(time_id, timestamp, value_ns);
API_METHOD_PREFIX
if (error_ns != NULL) {
*error_ns = 0;
status = rocprofiler::util::HsaRsrcFactory::Instance().GetTimeErr(time_id, error_ns);
}
if ((status == HSA_STATUS_SUCCESS) && (value_ns != NULL)) {
*value_ns = 0;
status = rocprofiler::util::HsaRsrcFactory::Instance().GetTimeVal(time_id, timestamp, value_ns);
}
API_METHOD_SUFFIX
}
// Set new callbacks. If a callback is NULL then it is disabled
} // extern "C"
///////////////////////////////////////////////////////////////////////////////////////////////////
// HSA API callbacks routines
// Static fields
//
bool rocprofiler::HsaInterceptor::enable_ = false;
thread_local bool rocprofiler::HsaInterceptor::recursion_ = false;;
rocprofiler_hsa_callbacks_t rocprofiler::HsaInterceptor::callbacks_{};
@@ -923,13 +935,10 @@ rocprofiler::HsaInterceptor::arg_t rocprofiler::HsaInterceptor::arg_{};
hsa_ven_amd_loader_1_01_pfn_t rocprofiler::HsaInterceptor::LoaderApiTable{};
rocprofiler::HsaInterceptor::mutex_t rocprofiler::HsaInterceptor::mutex_;
extern "C" {
// Set HSA callbacks. If a callback is NULL then it is disabled
PUBLIC_API hsa_status_t rocprofiler_set_hsa_callbacks(const rocprofiler_hsa_callbacks_t callbacks, void* arg) {
extern "C" PUBLIC_API hsa_status_t rocprofiler_set_hsa_callbacks(const rocprofiler_hsa_callbacks_t callbacks, void* arg) {
API_METHOD_PREFIX
rocprofiler::HsaInterceptor::SetCallbacks(callbacks, arg);
rocprofiler::InterceptQueue::SetSubmitCallback(callbacks.submit, arg);
API_METHOD_SUFFIX
}
} // extern "C"
+3 -2
Dosyayı Görüntüle
@@ -149,8 +149,9 @@ HsaRsrcFactory::HsaRsrcFactory(bool initialize_hsa) : initialize_hsa_(initialize
// Time correlation
const uint32_t corr_iters = 1000;
CorrelateTime(HsaTimer::TIME_ID_CLOCK_REALTIME, corr_iters);
CorrelateTime(HsaTimer::TIME_ID_CLOCK_MONOTONIC, corr_iters);
for (unsigned time_id = 0; time_id < HsaTimer::TIME_ID_NUMBER; time_id += 1) {
CorrelateTime((HsaTimer::time_id_t)time_id, corr_iters);
}
// System timeout
timeout_ = (timeout_ns_ == HsaTimer::TIMESTAMP_MAX) ? timeout_ns_ : timer_->ns_to_sysclock(timeout_ns_);
+22 -5
Dosyayı Görüntüle
@@ -183,7 +183,10 @@ class HsaTimer {
enum time_id_t {
TIME_ID_CLOCK_REALTIME = 0,
TIME_ID_CLOCK_MONOTONIC = 1,
TIME_ID_CLOCK_REALTIME_COARSE = 1,
TIME_ID_CLOCK_MONOTONIC = 2,
TIME_ID_CLOCK_MONOTONIC_COARSE = 3,
TIME_ID_CLOCK_MONOTONIC_RAW = 4,
TIME_ID_NUMBER
};
@@ -203,7 +206,7 @@ class HsaTimer {
}
// Method for timespec/ns conversion
timestamp_t timespec_to_ns(const timespec& time) const {
static timestamp_t timespec_to_ns(const timespec& time) {
return ((timestamp_t)time.tv_sec * 1000000000) + time.tv_nsec;
}
@@ -227,13 +230,22 @@ class HsaTimer {
void correlated_pair_ns(time_id_t time_id, uint32_t iters,
timestamp_t* timestamp_v, timestamp_t* time_v, timestamp_t* error_v) {
clockid_t clock_id = 0;
switch (clock_id) {
switch (time_id) {
case TIME_ID_CLOCK_REALTIME:
clock_id = CLOCK_REALTIME;
break;
case TIME_ID_CLOCK_REALTIME_COARSE:
clock_id = CLOCK_REALTIME_COARSE;
break;
case TIME_ID_CLOCK_MONOTONIC:
clock_id = CLOCK_MONOTONIC;
break;
case TIME_ID_CLOCK_MONOTONIC_COARSE:
clock_id = CLOCK_MONOTONIC_COARSE;
break;
case TIME_ID_CLOCK_MONOTONIC_RAW:
clock_id = CLOCK_MONOTONIC_RAW;
break;
default:
CHECK_STATUS("internal error: invalid time_id", HSA_STATUS_ERROR);
}
@@ -431,9 +443,14 @@ class HsaRsrcFactory {
time_error_[time_id] = error_v;
}
hsa_status_t GetTime(uint32_t time_id, uint64_t value, uint64_t* time) {
hsa_status_t GetTimeVal(uint32_t time_id, uint64_t time_stamp, uint64_t* time_value) {
if (time_id >= HsaTimer::TIME_ID_NUMBER) return HSA_STATUS_ERROR;
*time = value + time_shift_[time_id];
*time_value = time_stamp + time_shift_[time_id];
return HSA_STATUS_SUCCESS;
}
hsa_status_t GetTimeErr(uint32_t time_id, uint64_t* err) {
*err = time_error_[time_id];
return HSA_STATUS_SUCCESS;
}