Skip to content

Commit

Permalink
fixup! Introduce new CGF diagnostics utility
Browse files Browse the repository at this point in the history
  • Loading branch information
psalz committed Apr 17, 2023
1 parent 56b845c commit 11f522d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include/accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class accessor<DataT, Dims, Mode, target::device> : public detail::accessor_base

#if !defined(__SYCL_DEVICE_ONLY__)
if(detail::is_embedded_hydration_id(m_device_ptr)) {
if(detail::cgf_diagnostics::is_available()) {
if(detail::cgf_diagnostics::is_available() && detail::cgf_diagnostics::get_instance().is_checking()) {
detail::cgf_diagnostics::get_instance().register_accessor(detail::extract_hydration_id(m_device_ptr), target::device);
}

Expand Down Expand Up @@ -624,7 +624,7 @@ class accessor<DataT, Dims, Mode, target::host_task> : public detail::accessor_b
m_virtual_buffer_range = other.m_virtual_buffer_range;

if(detail::is_embedded_hydration_id(m_host_ptr)) {
if(detail::cgf_diagnostics::is_available()) {
if(detail::cgf_diagnostics::is_available() && detail::cgf_diagnostics::get_instance().is_checking()) {
detail::cgf_diagnostics::get_instance().register_accessor(detail::extract_hydration_id(m_host_ptr), target::host_task);
}

Expand Down
4 changes: 3 additions & 1 deletion include/cgf_diagnostics.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ class cgf_diagnostics {
check(target::host_task, kernel, &buffer_accesses, non_void_side_effects_count);
}

bool is_checking() const { return m_is_checking; }

void register_accessor(const hydration_id hid, const target tgt) {
if(!m_is_checking) return;
assert(m_is_checking);
assert(hid - 1 < m_expected_buffer_accesses->get_num_accesses());
if(tgt != m_expected_target) {
throw std::runtime_error(fmt::format("Accessor {} for buffer {} has wrong target ('{}' instead of '{}').", hid - 1,
Expand Down

0 comments on commit 11f522d

Please sign in to comment.