Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix is_placeholder() condition for generic accessors #30

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions include/simsycl/sycl/accessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,10 @@ class accessor : public simsycl::detail::property_interface {

void swap(accessor &other) { return std::swap(*this, other); }

bool is_placeholder() const { return !m_required; }
bool is_placeholder() const {
SIMSYCL_CHECK(m_required != nullptr);
return !*m_required;
}

size_type byte_size() const noexcept {
SIMSYCL_CHECK(m_buffer != nullptr);
Expand Down Expand Up @@ -334,6 +337,7 @@ class accessor : public simsycl::detail::property_interface {
requires(AccessMode != access_mode::atomic)
{
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
return m_buffer->data[detail::get_linear_index(m_buffer->range, index)];
}
Expand All @@ -352,6 +356,7 @@ class accessor : public simsycl::detail::property_interface {
requires(AccessTarget == target::device)
{
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
return m_buffer->data;
}
Expand All @@ -360,6 +365,7 @@ class accessor : public simsycl::detail::property_interface {
requires(AccessTarget == target::host_task)
{
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
return m_buffer->data;
}
Expand All @@ -369,6 +375,7 @@ class accessor : public simsycl::detail::property_interface {
requires(AccessTarget == target::device)
{
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
return accessor_ptr<IsDecorated>(m_buffer->data);
}
Expand Down Expand Up @@ -433,6 +440,7 @@ class accessor : public simsycl::detail::property_interface {
void require() {
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_guard != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
m_guard->check_access_from_command_group({m_access_offset, m_access_range, AccessMode});
*m_required = true;
}
Expand Down Expand Up @@ -537,7 +545,10 @@ class accessor<DataT, 0, AccessMode, AccessTarget, IsPlaceholder> : public simsy

void swap(accessor &other) { return std::swap(*this, other); }

bool is_placeholder() const { return !m_required; }
bool is_placeholder() const {
SIMSYCL_CHECK(m_required != nullptr);
return !*m_required;
}

size_type byte_size() const noexcept { return sizeof(DataT); }

Expand All @@ -555,6 +566,7 @@ class accessor<DataT, 0, AccessMode, AccessTarget, IsPlaceholder> : public simsy
requires(AccessMode != access_mode::atomic)
{
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
return *m_buffer->data;
}
Expand All @@ -563,6 +575,7 @@ class accessor<DataT, 0, AccessMode, AccessTarget, IsPlaceholder> : public simsy
requires(AccessMode != access_mode::atomic && AccessMode != access_mode::read)
{
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
*m_buffer->data = other;
return *this;
Expand All @@ -572,6 +585,7 @@ class accessor<DataT, 0, AccessMode, AccessTarget, IsPlaceholder> : public simsy
requires(AccessMode != access_mode::atomic && AccessMode != access_mode::read)
{
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
*m_buffer->data = std::move(other);
return *this;
Expand All @@ -584,6 +598,7 @@ class accessor<DataT, 0, AccessMode, AccessTarget, IsPlaceholder> : public simsy
requires(AccessTarget == target::device)
{
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
return m_buffer->data;
}
Expand All @@ -592,6 +607,7 @@ class accessor<DataT, 0, AccessMode, AccessTarget, IsPlaceholder> : public simsy
requires(AccessTarget == target::host_task)
{
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
return m_buffer->data;
}
Expand All @@ -601,6 +617,7 @@ class accessor<DataT, 0, AccessMode, AccessTarget, IsPlaceholder> : public simsy
requires(AccessTarget == target::device)
{
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
return accessor_ptr<IsDecorated>(m_buffer->data);
}
Expand Down Expand Up @@ -636,6 +653,7 @@ class accessor<DataT, 0, AccessMode, AccessTarget, IsPlaceholder> : public simsy
void require() {
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_guard != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
m_guard->check_access_from_command_group({0, 1, AccessMode});
*m_required = true;
}
Expand Down Expand Up @@ -1142,7 +1160,10 @@ class accessor<DataT, Dimensions, AccessMode, target::constant_buffer, IsPlaceho

friend bool operator==(const accessor &lhs, const accessor &rhs) = default;

bool is_placeholder() const { return !*m_required; }
bool is_placeholder() const {
SIMSYCL_CHECK(m_required != nullptr);
return !*m_required;
}

size_t get_size() const noexcept { return get_count() * sizeof(DataT); }

Expand Down Expand Up @@ -1220,6 +1241,7 @@ class accessor<DataT, Dimensions, AccessMode, target::constant_buffer, IsPlaceho
void require() {
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_guard != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
m_guard->check_access_from_command_group({m_access_offset, m_access_range, AccessMode});
*m_required = true;
}
Expand Down Expand Up @@ -1255,20 +1277,25 @@ class accessor<DataT, 0, AccessMode, target::constant_buffer, IsPlaceholder> fin

friend bool operator==(const accessor &lhs, const accessor &rhs) = default;

bool is_placeholder() const { return !m_required; }
bool is_placeholder() const {
SIMSYCL_CHECK(m_required != nullptr);
return !*m_required;
}

size_t get_size() const noexcept { return sizeof(DataT); }

size_t get_count() const noexcept { return 1; }

operator reference() const {
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
return *m_buffer->data;
}

global_ptr<DataT> get_pointer() const noexcept {
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
SIMSYCL_CHECK(*m_required);
return m_buffer->data;
}
Expand All @@ -1287,6 +1314,7 @@ class accessor<DataT, 0, AccessMode, target::constant_buffer, IsPlaceholder> fin
void require() {
SIMSYCL_CHECK(m_buffer != nullptr);
SIMSYCL_CHECK(m_guard != nullptr);
SIMSYCL_CHECK(m_required != nullptr);
m_guard->check_access_from_command_group({0, 1, AccessMode});
*m_required = true;
}
Expand Down
Loading