| CUTLASS CUDA Templates for Linear Algebra Subroutines and Solvers

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

default_mma_core_sm50.h
Go to the documentation of this file.
1 /***************************************************************************************************
2 * Copyright (c) 2017-2019, 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 **************************************************************************************************/
32 #pragma once
33
34 #include "cutlass/cutlass.h"
35 #include "cutlass/array.h"
36
37 #include "cutlass/numeric_types.h"
38 #include "cutlass/matrix_shape.h"
39
40 #include "cutlass/layout/matrix.h"
41 #include "cutlass/transform/pitch_linear_thread_map.h"
42 #include "cutlass/transform/threadblock/regular_tile_iterator.h"
43
44 #include "cutlass/gemm/warp/mma_simt.h"
45 #include "cutlass/gemm/threadblock/default_mma_core.h"
46
48
49 namespace cutlass {
50 namespace gemm {
51 namespace threadblock {
52
54
63 template <
66 typename Shape_,
68 typename WarpShape_,
70 typename ElementA_,
72 typename ElementB_,
74 typename ElementC_,
76 typename LayoutC_,
78 typename Operator_>
79 struct DefaultMmaCore<Shape_, WarpShape_, GemmShape<1, 1, 1>, ElementA_,
80 layout::ColumnMajor, ElementB_, layout::RowMajor,
81 ElementC_, LayoutC_, arch::OpClassSimt, 2, Operator_,
82 > {
83 using Shape = Shape_;
84 using WarpShape = WarpShape_;
85 using InstructionShape = InstructionShape_;
86 using ElementA = ElementA_;
87 using LayoutA = layout::ColumnMajor;
88 using ElementB = ElementB_;
89 using LayoutB = layout::RowMajor;
90 using ElementC = ElementC_;
91 using LayoutC = LayoutC_;
92 using OperatorClass = arch::OpClassSimt;
93
95 using WarpCount = GemmShape<
96 Shape::kM / WarpShape::kM,
97 Shape::kN / WarpShape::kN,
98 Shape::kK / WarpShape::kK
99 >;
100
101 // Divisility requirements
102 static_assert(
103 !(Shape::kM % WarpShape::kM) &&
104 !(Shape::kN % WarpShape::kN),
105 "Threadblock-scoped GEMM should be divisible by warp-scoped GEMM size."
106 );
107
109 static int const kWarpSize = warp::WarpSize<arch::OpClassTensorOp>::value;
110
112 static int const kThreads = WarpCount::kCount * kWarpSize;
113
114 //
115 // Shared memory layouts
116 //
117
119 using SmemLayoutA = layout::ColumnMajor;
120
122 using SmemLayoutB = layout::RowMajor;
123
124 //
125 // Iterators to write to shared memory
126 //
127
129 using IteratorThreadMapA = transform::PitchLinearStripminedThreadMap<
130 layout::PitchLinearShape<Shape::kM, Shape::kK>,
131 kThreads,
132 1
133 >;
134
136 using SmemIteratorA = transform::threadblock::RegularTileIterator<
137 MatrixShape<Shape::kM, Shape::kK>,
138 ElementA,
139 SmemLayoutA,
140 1,
141 IteratorThreadMapA
142 >;
143
145 using IteratorThreadMapB = transform::PitchLinearStripminedThreadMap<
146 layout::PitchLinearShape<Shape::kN, Shape::kK>,
147 kThreads,
148 1
149 >;
150
152 using SmemIteratorB = transform::threadblock::RegularTileIterator<
153 MatrixShape<Shape::kK, Shape::kN>,
154 ElementB,
155 SmemLayoutB,
156 0,
157 IteratorThreadMapB
158 >;
159
160 //
161 // Warp-level matrix multiply operator
162 //
163
164 // Define the warp-level tensor op
165 using WarpMma = cutlass::gemm::warp::MmaSimt<
166 WarpShape,
167 ElementA,
168 SmemLayoutA,
169 ElementB,
170 SmemLayoutB,
171 ElementC,
172 LayoutC,
173 warp::MmaSimtPolicy<
174 MatrixShape<4, 8>,
175 layout::RowMajorInterleaved<2>,
176 GemmShape<
177 128 / sizeof_bits<ElementA>::value,
178 128 / sizeof_bits<ElementB>::value,
179 1>
180 >
181 >
182 >;
183
185 using MmaPolicy = MmaPolicy<
186 WarpMma,
187 MatrixShape<0, 0>,
188 MatrixShape<0, 0>,
189 WarpCount::kK
190 >;
191 };
192
194
195 } // namespace threadblock
196 } // namespace gemm
197 } // namespace cutlass
cutlass::MatrixShape
Describes the size of a matrix tile.
Definition: matrix_shape.h:42
cutlass
Definition: aligned_buffer.h:35
cutlass::gemm::threadblock::DefaultMmaCore< Shape_, WarpShape_, GemmShape< 1, 1, 1 >, ElementA_, layout::ColumnMajor, ElementB_, layout::RowMajor, ElementC_, LayoutC_, arch::OpClassSimt, 2, Operator_, >::WarpShape
WarpShape_ WarpShape
Definition: default_mma_core_sm50.h:84
cutlass::gemm::warp::WarpSize
Query the number of threads per warp.
Definition: gemm/warp/mma.h:43
cutlass::gemm::threadblock::DefaultMmaCore
Definition: default_mma_core.h:90
pitch_linear_thread_map.h
Templates implementing how threads are mapped to a given tile.
cutlass::gemm::threadblock::DefaultMmaCore< Shape_, WarpShape_, GemmShape< 1, 1, 1 >, ElementA_, layout::ColumnMajor, ElementB_, layout::RowMajor, ElementC_, LayoutC_, arch::OpClassSimt, 2, Operator_, >::MmaPolicy
MmaPolicy< WarpMma, MatrixShape< 0, 0 >, MatrixShape< 0, 0 >, WarpCount::kK > MmaPolicy
Policy used to define MmaPipelined.
Definition: default_mma_core_sm50.h:190
cutlass::gemm::warp::MmaSimt
Structure to compute the matrix product targeting CUDA cores and SIMT math instructions.
Definition: mma_simt.h:74
cutlass::gemm::threadblock::DefaultMmaCore< Shape_, WarpShape_, GemmShape< 1, 1, 1 >, ElementA_, layout::ColumnMajor, ElementB_, layout::RowMajor, ElementC_, LayoutC_, arch::OpClassSimt, 2, Operator_, >::ElementB
ElementB_ ElementB
Definition: default_mma_core_sm50.h:88
cutlass::gemm::threadblock::DefaultMmaCore< Shape_, WarpShape_, GemmShape< 1, 1, 1 >, ElementA_, layout::ColumnMajor, ElementB_, layout::RowMajor, ElementC_, LayoutC_, arch::OpClassSimt, 2, Operator_, >::OperatorClass
arch::OpClassSimt OperatorClass
Definition: default_mma_core_sm50.h:92
cutlass::layout::ColumnMajor
Mapping function for column-major matrices.
Definition: layout/matrix.h:142
cutlass::layout::PitchLinearShape
Template defining a shape used by pitch-linear operators.
Definition: pitch_linear.h:43
array.h
Statically sized array of elements that accommodates all CUTLASS-supported numeric types and is safe ...
cutlass::gemm::threadblock::DefaultMmaCore< Shape_, WarpShape_, GemmShape< 1, 1, 1 >, ElementA_, layout::ColumnMajor, ElementB_, layout::RowMajor, ElementC_, LayoutC_, arch::OpClassSimt, 2, Operator_, >::ElementC
ElementC_ ElementC
Definition: default_mma_core_sm50.h:90
cutlass::gemm::warp::MmaSimtPolicy
Describes the arrangement and configuration of per-lane operations in warp-level matrix multiply...
Definition: mma_simt_policy.h:46
matrix_shape.h
Defines a Shape template for matrix tiles.
cutlass::sizeof_bits
Defines the size of an element in bits.
Definition: numeric_types.h:42
cutlass::gemm::threadblock::DefaultMmaCore< Shape_, WarpShape_, GemmShape< 1, 1, 1 >, ElementA_, layout::ColumnMajor, ElementB_, layout::RowMajor, ElementC_, LayoutC_, arch::OpClassSimt, 2, Operator_, >::InstructionShape
InstructionShape_ InstructionShape
Definition: default_mma_core_sm50.h:85
default_mma_core.h
Defines basic properties needed by CTA-level GEMMs assuming expectations about data layout of the glo...
numeric_types.h
Top-level include for all CUTLASS numeric types.
cutlass::gemm::GemmShape
Shape of a matrix multiply-add operation.
Definition: include/cutlass/gemm/gemm.h:57
cutlass::transform::threadblock::RegularTileIterator
Definition: regular_tile_iterator.h:50
static_assert
#define static_assert(__e, __m)
Definition: platform.h:153
cutlass::layout::RowMajor
Mapping function for row-major matrices.
Definition: layout/matrix.h:50
cutlass::gemm::threadblock::DefaultMmaCore< Shape_, WarpShape_, GemmShape< 1, 1, 1 >, ElementA_, layout::ColumnMajor, ElementB_, layout::RowMajor, ElementC_, LayoutC_, arch::OpClassSimt, 2, Operator_, >::ElementA
ElementA_ ElementA
Definition: default_mma_core_sm50.h:86
cutlass::gemm::threadblock::DefaultMmaCore< Shape_, WarpShape_, GemmShape< 1, 1, 1 >, ElementA_, layout::ColumnMajor, ElementB_, layout::RowMajor, ElementC_, LayoutC_, arch::OpClassSimt, 2, Operator_, >::LayoutC
LayoutC_ LayoutC
Definition: default_mma_core_sm50.h:91
regular_tile_iterator.h
Templates implementing storing of tiles from pitch-linear rank=2 tensors.
matrix.h
Defines layout functions used by TensorRef and derived classes.
cutlass::gemm::threadblock::DefaultMmaCore< Shape_, WarpShape_, GemmShape< 1, 1, 1 >, ElementA_, layout::ColumnMajor, ElementB_, layout::RowMajor, ElementC_, LayoutC_, arch::OpClassSimt, 2, Operator_, >::Shape
Shape_ Shape
Definition: default_mma_core_sm50.h:83
cutlass::gemm::threadblock::DefaultMmaCore< Shape_, WarpShape_, GemmShape< 1, 1, 1 >, ElementA_, layout::ColumnMajor, ElementB_, layout::RowMajor, ElementC_, LayoutC_, arch::OpClassSimt, 2, Operator_, >::WarpMma
cutlass::gemm::warp::MmaSimt< WarpShape, ElementA, SmemLayoutA, ElementB, SmemLayoutB, ElementC, LayoutC, warp::MmaSimtPolicy< MatrixShape< 4, 8 >, layout::RowMajorInterleaved< 2 >, GemmShape< 128/sizeof_bits< ElementA >::value, 128/sizeof_bits< ElementB >::value, 1 > > > > WarpMma
Definition: default_mma_core_sm50.h:182
mma_simt.h
Templates implementing warp-level matrix multiply-accumulate operations.
cutlass.h
Basic include for CUTLASS.
cutlass::transform::PitchLinearStripminedThreadMap
Definition: pitch_linear_thread_map.h:59
cutlass::layout::RowMajorInterleaved
Definition: layout/matrix.h:237