Context Updates (#624)
* Improve error checks related to context create/start/stop/is_valid * Bump version to 0.2.1 * Track number of kernels associated with correlation id - add atomic kernel counter variable to context::correlation_id * Update lib/rocprofiler-sdk/hsa/queue.cpp - apply the +/- kernel count
Цей коміт міститься в:
зафіксовано
GitHub
джерело
7ab1a8015f
коміт
0fdb21c050
+1
-1
@@ -1 +1 @@
|
||||
0.2.0
|
||||
0.2.1
|
||||
|
||||
@@ -41,6 +41,10 @@ extern "C" {
|
||||
rocprofiler_status_t
|
||||
rocprofiler_create_context(rocprofiler_context_id_t* context_id)
|
||||
{
|
||||
// context already registered
|
||||
if(rocprofiler::context::get_registered_context(*context_id))
|
||||
return ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID;
|
||||
|
||||
// always set to none first
|
||||
*context_id = rocprofiler_context_none;
|
||||
|
||||
@@ -56,7 +60,8 @@ rocprofiler_create_context(rocprofiler_context_id_t* context_id)
|
||||
rocprofiler_status_t
|
||||
rocprofiler_start_context(rocprofiler_context_id_t context_id)
|
||||
{
|
||||
if(context_id.handle == rocprofiler_context_none.handle)
|
||||
if(context_id.handle == rocprofiler_context_none.handle ||
|
||||
!rocprofiler::context::get_registered_context(context_id))
|
||||
return ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND;
|
||||
|
||||
// if currently finalizing or finalized, don't allow starting a context
|
||||
@@ -69,7 +74,8 @@ rocprofiler_start_context(rocprofiler_context_id_t context_id)
|
||||
rocprofiler_status_t
|
||||
rocprofiler_stop_context(rocprofiler_context_id_t context_id)
|
||||
{
|
||||
if(context_id.handle == rocprofiler_context_none.handle)
|
||||
if(context_id.handle == rocprofiler_context_none.handle ||
|
||||
!rocprofiler::context::get_registered_context(context_id))
|
||||
return ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND;
|
||||
|
||||
return rocprofiler::context::stop_context(context_id);
|
||||
@@ -105,7 +111,8 @@ rocprofiler_context_is_valid(rocprofiler_context_id_t context_id, int* status)
|
||||
{
|
||||
*status = 0;
|
||||
|
||||
if(context_id.handle == rocprofiler_context_none.handle)
|
||||
if(context_id.handle == rocprofiler_context_none.handle ||
|
||||
!rocprofiler::context::get_registered_context(context_id))
|
||||
return ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND;
|
||||
|
||||
for(const auto& itr : rocprofiler::context::get_registered_contexts())
|
||||
@@ -117,6 +124,7 @@ rocprofiler_context_is_valid(rocprofiler_context_id_t context_id, int* status)
|
||||
return _ret;
|
||||
}
|
||||
}
|
||||
|
||||
return ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,6 +181,18 @@ correlation_id::sub_ref_count()
|
||||
return _ret;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
correlation_id::add_kern_count()
|
||||
{
|
||||
return m_kern_count.fetch_add(1);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
correlation_id::sub_kern_count()
|
||||
{
|
||||
return m_kern_count.fetch_sub(1);
|
||||
}
|
||||
|
||||
correlation_id*
|
||||
correlation_tracing_service::construct(uint32_t _init_ref_count)
|
||||
{
|
||||
|
||||
@@ -79,8 +79,13 @@ struct correlation_id
|
||||
uint32_t add_ref_count();
|
||||
uint32_t sub_ref_count();
|
||||
|
||||
uint32_t get_kern_count() const { return m_kern_count.load(); }
|
||||
uint32_t add_kern_count();
|
||||
uint32_t sub_kern_count();
|
||||
|
||||
private:
|
||||
std::atomic<uint32_t> m_ref_count = {};
|
||||
std::atomic<uint32_t> m_kern_count = {0};
|
||||
std::atomic<uint32_t> m_ref_count = {0};
|
||||
};
|
||||
|
||||
correlation_id*
|
||||
|
||||
@@ -192,6 +192,7 @@ AsyncSignalHandler(hsa_signal_value_t /*signal_v*/, void* data)
|
||||
<< "reference counter for correlation id " << _corr_id->internal << " from thread "
|
||||
<< _corr_id->thread_idx << " has no reference count";
|
||||
_corr_id->sub_ref_count();
|
||||
_corr_id->sub_kern_count();
|
||||
}
|
||||
|
||||
queue_info_session.queue.async_complete();
|
||||
@@ -380,7 +381,11 @@ WriteInterceptor(const void* packets,
|
||||
LOG_IF(FATAL, packet_type != HSA_PACKET_TYPE_KERNEL_DISPATCH)
|
||||
<< "get_kernel_id below might need to be updated";
|
||||
|
||||
if(corr_id) corr_id->add_ref_count();
|
||||
if(corr_id)
|
||||
{
|
||||
corr_id->add_ref_count();
|
||||
corr_id->add_kern_count();
|
||||
}
|
||||
|
||||
// Enqueue the signal into the handler. Will call completed_cb when
|
||||
// signal completes.
|
||||
|
||||
Посилання в новій задачі
Заблокувати користувача