Skip to content

Refactor mdspancuda::std::__detectably_invalid - #6733

Merged
fbusato merged 29 commits into
NVIDIA:mainfrom
fbusato:host-device-mdspan-accessible
Jan 8, 2026
Merged

Refactor mdspancuda::std::__detectably_invalid#6733
fbusato merged 29 commits into
NVIDIA:mainfrom
fbusato:host-device-mdspan-accessible

Conversation

@fbusato

Copy link
Copy Markdown
Contributor

Description

Replace old code in host/device/managed mdspan with https://nvidia.github.io/cccl/libcudacxx/extended_api/memory/is_pointer_accessible.html

@fbusatofbusato self-assigned this Nov 22, 2025
@fbusato
fbusato requested a review from a team as a code ownerNovember 22, 2025 02:03
@fbusato
fbusato requested a review from wmaxeyNovember 22, 2025 02:03
@fbusatofbusato changed the title Applies `is_pointer_accessible to mdspanApplies is_pointer_accessible to mdspanNov 22, 2025
@cccl-authenticator-appcccl-authenticator-appBot moved this from Todo to In Review in CCCLNov 22, 2025
@github-actions

This comment has been minimized.

Comment threadlibcudacxx/include/cuda/__mdspan/host_device_accessor.h Outdated
Comment threadlibcudacxx/include/cuda/__mdspan/host_device_accessor.h Outdated
Comment threadlibcudacxx/include/cuda/__mdspan/host_device_accessor.h Outdated
@github-project-automationgithub-project-automationBot moved this from In Review to In Progress in CCCLNov 22, 2025
fbusatoand others added 4 commits November 24, 2025 11:10
Co-authored-by: David Bayer <48736217+davebayer@users.noreply.github.com>
Co-authored-by: David Bayer <48736217+davebayer@users.noreply.github.com>
Co-authored-by: David Bayer <48736217+davebayer@users.noreply.github.com>
@fbusatofbusato moved this from In Progress to In Review in CCCLNov 24, 2025
@fbusato

Copy link
Copy Markdown
ContributorAuthor

@davebayer@miscco I'm starting thinking that we are doing the wrong thing for host/device/managed.
There are two problems:

  1. We cannot check the pointer validity in respect to the memory space for EVERY access. This involves multiple driver calls. This is too expensive even in debug mode.
  2. We cannot check the device accessibility on the host because its access is always wrong on the host side.

Ideally, mdspan itself should check the pointer during the creating, not during run-time. Two potential solutions:

  • cuda:std::mdpan checks __detectably_invalid.
  • Modify the host/device/managed_mdspan constructs to check the memory space.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment threadlibcudacxx/include/cuda/__mdspan/host_device_accessor.h Outdated
Comment threadlibcudacxx/include/cuda/__mdspan/host_device_accessor.h Outdated
Comment threadlibcudacxx/include/cuda/std/__mdspan/concepts.h Outdated
Comment threadlibcudacxx/include/cuda/std/__mdspan/mdspan.h Outdated
Comment threadlibcudacxx/include/cuda/std/__mdspan/mdspan.h Outdated
Comment threadlibcudacxx/include/cuda/std/__mdspan/mdspan.h Outdated
@github-project-automationgithub-project-automationBot moved this from In Review to In Progress in CCCLDec 8, 2025
fbusatoand others added 2 commits December 8, 2025 12:42
Co-authored-by: David Bayer <48736217+davebayer@users.noreply.github.com>
Co-authored-by: David Bayer <48736217+davebayer@users.noreply.github.com>
@fbusatofbusato changed the title Applies is_pointer_accessible to mdspanRefactor cuda::std::__detectably_invalidDec 17, 2025
@fbusatofbusato changed the title Refactor cuda::std::__detectably_invalidRefactor mdspancuda::std::__detectably_invalidDec 18, 2025
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-project-automationgithub-project-automationBot moved this from In Progress to In Review in CCCLJan 5, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment threadlibcudacxx/include/cuda/__mdspan/host_device_accessor.h
// - Direct-non-list-initializes ptr_ with cuda::std::move(p),
// - direct-non-list-initializes map_ with ext, and
// - value-initializes acc_.
#define _CCCL_DISABLE_MDSPAN_ACCESSOR_DETECT_INVALIDITY

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need that?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is very hard to reimplement all tests to work with the right accessor respect to the memory space.
I added this macro to disable the checks

@github-actions

This comment has been minimized.

@fbusato
fbusato enabled auto-merge (squash) January 7, 2026 18:00
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 10m: Pass: 100%/84 | Total: 1d 12h | Max: 1h 48m | Hits: 86%/197813

See results here.

@fbusato
fbusato merged commit 281f441 into NVIDIA:mainJan 8, 2026
96 checks passed
@github-project-automationgithub-project-automationBot moved this from In Review to Done in CCCLJan 8, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants

@fbusato@bernhardmgruber@miscco@davebayer