Skip to content

Add cp.async.bulk global -> shared support to cuda::memcpy_async - #501

Merged
miscco merged 28 commits into
NVIDIA:mainfrom
ahendriksen:add-memcpy-async-cp-async-bulk-global-to-shared-support
Oct 19, 2023
Merged

miscco merged 28 commits into
NVIDIA:mainfrom
ahendriksen:add-memcpy-async-cp-async-bulk-global-to-shared-support

Conversation

@ahendriksen

Copy link
Copy Markdown
Contributor

Description

Partially resolves #38 , #58

This PR adds support for 1D bulk TMA from global to shared memory in memcpy_async.

This PR adds:

  • A memcpy_async from global to shared memory with 16-byte aligned pointers that synchronizes with a block-scoped shared memory barrier now makes use of TMA, i.e., the cp.async.bulk PTX instruction.

This PR changes:

  • No dynamic dispatch for native types with alignment less than 4 bytes. (they go to the sync fallback mechanism immediately)
  • memcpy_async with a thread_scope_block barrier in remote cluster memory does not trap anymore, but falls back to synchronous copy mechanism.
  • A thread-scoped barrier in shared memory does not go through the async path anymore, but falls back to the synchronous fallback mechanism.
  • The synchronous fallback mechanism makes use of the native type alignment, issuing up to 16 byte wide loads. This used to be 1 byte wide loads.
  • A memcpy_async from global to shared memory with 16-byte aligned pointers that synchronizes with a block-scoped shared memory barrier used to issue cp.async.cg and now issues cp.async.bulk PTX instructions.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@miscco miscco left a comment

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.

This already looks great I have some general comments

  1. we should add nodiscard almost everywhere
  2. I would prefer if we used switches for the completion mechanisms
  3. Yoda conditions should be avoided

Comment thread libcudacxx/include/cuda/pipeline Resolved

@ahendriksen ahendriksen left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comments. I have applied all but one suggested change. See unresolved below.

Comment thread libcudacxx/include/cuda/pipeline Resolved
@ahendriksen
ahendriksen force-pushed the add-memcpy-async-cp-async-bulk-global-to-shared-support branch from 0e3676c to df07787 Compare October 16, 2023 10:16
@ahendriksen
ahendriksen marked this pull request as ready for review October 16, 2023 10:20
@ahendriksen
ahendriksen requested review from a team as code owners October 16, 2023 10:20
@ahendriksen
ahendriksen requested review from alliepiper and ericniebler and removed request for a team October 16, 2023 10:20

@ahendriksen ahendriksen left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comments. I have addressed them in follow-up commits. In addition, I found out that I dropped a __group argument in the pipeline interface as well. Fixed this.

@ahendriksen
ahendriksen force-pushed the add-memcpy-async-cp-async-bulk-global-to-shared-support branch from df07787 to 3506ca5 Compare October 17, 2023 10:02
It is now done in the memcpy_async_barrier and memcpy_async_pipeline
function. This made the memcpy_async_dispatch function so empty, that I
moved the mempcy_async_dispatch_device function body into it.
Comment thread libcudacxx/include/cuda/pipeline Resolved
@miscco
miscco merged commit b1924d6 into NVIDIA:main Oct 19, 2023
Sign up for free to 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.

[EPIC]: 1D TMA/BULK exposure via memcpy_async

3 participants