Cutlass
CUDA Templates for Linear Algebra Subroutines and Solvers
igemm_global_tile.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  **************************************************************************************************/
33 #pragma once
34 
35 #include <cutlass/coord.h>
37 #include <cutlass/matrix_traits.h>
38 
39 namespace cutlass {
40 namespace gemm {
41 
43 
44 template <GemmOperand::Kind kOperand_,
45  MatrixLayout::Kind kLayout_,
46  typename Scalar_,
47  typename Tile_,
48  typename Threads_,
49  int kAccessSize_>
51  // Which GEMM operand?
52  kOperand_,
53  // The layout.
54  kLayout_,
55  // The scalar.
56  Scalar_,
57  // The tile.
58  Tile_,
59  // The threads.
60  Threads_,
61  // The number of scalars per LDG/STG.
62  kAccessSize_> {
66  typedef typename Base::Threads Threads;
70  typedef Shape<Base::Tile::kH / Base::Threads::kH / 4,
71  4,
72  Base::Tile::kW / Base::Threads::kW,
73  Base::Tile::kC / Base::kAccessSize>
75 
77  struct ThreadOffset {
79  Coord<4> operator()() const {
80  int thread_offset_h = threadIdx.x / Threads::kW * ThreadsDelta::kH;
81  int thread_offset_w = threadIdx.x % Threads::kW * ThreadsDelta::kW;
82 
83  return make_Coord(0, thread_offset_h, thread_offset_w, 0);
84  }
85  };
86 
87  public:
90 };
91 
93 
94 } // namespace gemm
95 } // namespace cutlass
Computes the thread offset in (H, W) based on thread ID.
Definition: igemm_global_tile.h:77
Definition: convert.h:33
Defines iterators for efficiently loading and storing to global memory.
Definition: gemm_global_tile.h:70
A Coord is a coordinate of arbitrary rank into a tensor or matrix.
CUTLASS_HOST_DEVICE Coord< 1 > make_Coord(int _0)
Helper to make a 2-element coordinate.
Definition: coord.h:241
Shape< Base::Threads::kH *4, 1, Base::Threads::kW, Base::kAccessSize > Delta
The strides in each dimension between different loads/stores.
Definition: igemm_global_tile.h:68
static int const kH
The height of the cube.
Definition: shape.h:68
GemmGlobalTileTraits< kOperand_, kLayout_, Scalar_, Tile_, Threads_, kAccessSize_ > Base
The base class.
Definition: igemm_global_tile.h:64
Shape< Base::Tile::kH/Base::Threads::kH/4, 4, Base::Tile::kW/Base::Threads::kW, Base::Tile::kC/Base::kAccessSize > Iterations
The number of iterations needed to load/store the tile.
Definition: igemm_global_tile.h:74
#define CUTLASS_HOST_DEVICE
Definition: cutlass.h:46
Definition: igemm_global_tile.h:50
A Shape implementing Layout Concept describing the dimensions of a cube.
Definition: shape.h:64
static int const kW
The width of the cube.
Definition: shape.h:70
Kind
Definition: matrix_traits.h:36
static int const kAccessSize
The number of scalars per LDG/STG.
Definition: gemm_global_tile.h:80
Kind
Definition: matrix_traits.h:43
ReshapeThreads< Tile, Threads_ >::Threads Threads
The threads shape.
Definition: gemm_global_tile.h:87
Defines properties of matrices used to denote layout and operands to GEMM kernels.
Shape< 1, 4, Base::Tile::kC > ThreadsDelta
The threads strides.
Definition: igemm_global_tile.h:89
CUTLASS_HOST_DEVICE Coord< 4 > operator()() const
Definition: igemm_global_tile.h:79
Base::Threads Threads
The threads.
Definition: igemm_global_tile.h:66