Skip to content

Commit

Permalink
Remove compatibility check from view comparison.
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Zientkiewicz <[email protected]>
  • Loading branch information
mzient committed Oct 26, 2021
1 parent 31d3119 commit adc26ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,26 @@


template <typename tag>
class resource : public cuda::memory_resource<cuda::memory_kind::pinned> {
class resource : public cuda::stream_ordered_memory_resource<cuda::memory_kind::managed> {
public:
int value = 0;
private:
void *do_allocate(size_t, size_t) override {
return nullptr;
}

void *do_allocate_async(size_t, size_t, cuda::stream_view) override {
return nullptr;
}

void do_deallocate(void *, size_t, size_t) {
}

void do_deallocate_async(void *, size_t, size_t, cuda::stream_view) override {
}

#ifdef _LIBCUDACXX_EXT_RTTI_ENABLED
bool do_is_equal(const cuda::memory_resource<cuda::memory_kind::pinned> &other) const noexcept override {
bool do_is_equal(const cuda::memory_resource<cuda::memory_kind::managed> &other) const noexcept override {
fprintf(stderr, "Comparison start: %p %p\n", this, &other);
if (auto *other_ptr = dynamic_cast<const resource *>(&other)) {
fprintf(stderr, "values: %d %d\n", value, other_ptr->value);
Expand All @@ -51,7 +58,7 @@ int main(int argc, char **argv) {
#if !defined(__CUDA_ARCH__) && defined(_LIBCUDACXX_EXT_RTTI_ENABLED)
resource<tag1> r1, r2, r3;
resource<tag2> r4;
cuda::basic_resource_view<resource<tag1>*, cuda::is_kind<cuda::memory_kind::pinned>> v1_null;
cuda::basic_resource_view<resource<tag1>*, cuda::is_kind<cuda::memory_kind::managed>> v1_null;
cuda::resource_view<cuda::memory_access::host> v2_null;
assert(v1_null == v2_null);
r1.value = 42;
Expand All @@ -65,8 +72,8 @@ int main(int argc, char **argv) {
assert(view_resource(&r1) != view_resource(&r3));
assert(view_resource(&r4) == view_resource(&r4));
cuda::resource_view<cuda::memory_access::host, cuda::memory_access::device> v1 = &r1;
cuda::resource_view<cuda::memory_access::device> v2 = &r2;
cuda::resource_view<cuda::memory_access::host> v3 = &r3;
cuda::stream_ordered_resource_view<cuda::memory_access::device> v2 = &r2;
cuda::resource_view<cuda::memory_access::host> v3 = &r3;
cuda::resource_view<cuda::memory_access::device, cuda::memory_access::host> v4 = &r4;
// compare views
assert(v1 == v2);
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions include/cuda/memory_resource
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,6 @@ public:
bool operator==(const cuda::basic_resource_view<_Ptr2, _Props2...> &__v2) const noexcept {
using __view1_t = basic_resource_view;
using __view2_t = basic_resource_view<_Ptr2, _Props2...>;
static_assert(cuda::is_view_convertible<__view1_t, __view2_t>::value || cuda::is_view_convertible<__view2_t, __view1_t>::value,
"The resource views are not compatible");
if (__pointer == nullptr || __v2.__pointer == nullptr)
return __pointer == nullptr && __v2.__pointer == nullptr;
return static_cast<const detail::memory_resource_base*>(__pointer)->is_equal(*__v2.__pointer);
Expand Down

0 comments on commit adc26ee

Please sign in to comment.