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

Add Double-Buffer TMA Support for Pointwise and Normalization Kernels #2197

Open
rdspring1 opened this issue May 3, 2024 · 0 comments
Open
Labels

Comments

@rdspring1
Copy link
Collaborator

Pipelining - (Multiple mbarriers per TensorView)

Launch multiple TMA operations simultaneously but process each stage as they become available.

Motivation

Overlap data movement with computation

Pseudo-code

 for each stage of producer TV:
   launch TMA operation for stage
 end for

 for each stage of consumer:
   wait for corresponding TMA stage to become available
 end for

Example: Synchronous TMA

      uint64_t* T6 = reinterpret_cast<uint64_t*>(array + smem_offset + 8208LL);
      mbarrier::init(toSmem(T6), 1U);
      __syncthreads();
      if (b12) {
        uint64_t i26;
        i26 = mbarrier::arriveExpectTX(toSmem(T6), 4096U);
        Hopper::cpAsyncBulkTensorTileG2S((Hopper::CpAsyncBulkTensorTileG2SIndex<2>{ ptr4, a23, toSmem(T6) }), i6);
        mbarrier::wait(toSmem(T6), i26);
      }
      __syncthreads();
      mbarrier::inval(toSmem(T6));
      NVFUSER_UPDATE_MAGIC_ZERO;
      uint64_t* T7 = reinterpret_cast<uint64_t*>(array + smem_offset + 8192LL);
      mbarrier::init(toSmem(T7), 1U);
      __syncthreads();
      if (b12) {
        uint64_t i27;
        i27 = mbarrier::arriveExpectTX(toSmem(T7), 4096U);
        Hopper::cpAsyncBulkTensorTileG2S((Hopper::CpAsyncBulkTensorTileG2SIndex<2>{ ptr7, a23, toSmem(T7) }), i8);
        mbarrier::wait(toSmem(T7), i27);
      }
      __syncthreads();
      mbarrier::inval(toSmem(T7));
      NVFUSER_UPDATE_MAGIC_ZERO;
      
      // compute
@rdspring1 rdspring1 added the TMA label May 3, 2024
@rdspring1 rdspring1 changed the title Double-Buffer TMA Support for Pointwise and Normalization Kernels Add Double-Buffer TMA Support for Pointwise and Normalization Kernels May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant