docs/fragment__iterator__simt_8h_source.html
| | CUTLASS
CUDA Templates for Linear Algebra Subroutines and Solvers |
fragment_iterator_simt.h
[Go to the documentation of this file.](fragment iterator simt_8h.html)
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 **************************************************************************************************/
38 #pragma once
39
40 #include "cutlass/array.h"
41 #include "cutlass/layout/matrix.h"
42
43 #include "cutlass/epilogue/warp/simt_policy.h"
44
46
47 namespace cutlass {
48 namespace epilogue {
49 namespace warp {
50
52
54 template <
55typename WarpShape,
56typename Operator,
57typename Layout,
58typename MmaSimtPolicy
59 >
60 class FragmentIteratorSimt;
61
63
65 template <
66typename WarpShape_,
67typename Operator_ ,
68typename MmaSimtPolicy_
69 >
[70](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html) class FragmentIteratorSimt<WarpShape_, Operator_, layout::RowMajor, MmaSimtPolicy_> {
71 public:
72
[73](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#af8e1c494bbef813d7dbad0f33a3a1e53)using [WarpShape](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#af8e1c494bbef813d7dbad0f33a3a1e53) = WarpShape_;
[74](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a73e3fe9d37e657cc097d6616530b9b36)using Operator = Operator_;
[75](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#abdb233c59e0c5657e91d737a715e817b)using Layout = layout::RowMajor;
76
[78](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a8e8487fee1e71fe537e5927143b92ebc)using Policy = SimtPolicy<WarpShape, Operator, Layout, MmaSimtPolicy_>;
79
81using [Fragment](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#afaf52901287cfcadc0fe059e71b6842a) = Array<
82typename Operator::ElementC,
[83](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#afaf52901287cfcadc0fe059e71b6842a) Policy::kElementsPerIteration>;
84
86using [AccumulatorTile](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a0b889a6700c158328616c274a573dd5a) = Array<
87typename Operator::ElementC,
[88](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a0b889a6700c158328616c274a573dd5a) Policy::kAccumulatorElementCount>;
89
[90](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a798527db9b88dfa31149957a97c55a9d)using [OutputAccumulatorTile](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a798527db9b88dfa31149957a97c55a9d) = [AccumulatorTile](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a0b889a6700c158328616c274a573dd5a);
91
[93](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#ad586a2c18bfc47524b2fac72f42c1976)static int const kIterations = Policy::kIterations;
94
95 private:
96
98using AccessType = Array<typename Operator::ElementC, Policy::kElementsPerAccess>;
99
100 private:
101
102//
103// Data members
104//
105
107 AccessType const *accumulators_;
108
110int index_;
111
112 public:
113
[116](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a3dee783224164a08c24654aba39ddbdb)[FragmentIteratorSimt](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a3dee783224164a08c24654aba39ddbdb)([AccumulatorTile](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a0b889a6700c158328616c274a573dd5a) const &accum):
117 accumulators_(reinterpret_cast<AccessType const *>(&accum)),
118 index_(0) {
119
120 }
121
[124](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a71335e9f7fd399900035c397f1d5cfb1)FragmentIteratorSimt &[operator++](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a71335e9f7fd399900035c397f1d5cfb1)() {
125 ++index_;
126return *this;
127 }
128
[131](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a21f202bb39729599ab91d2e852c9bc7b)FragmentIteratorSimt &[operator--](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a21f202bb39729599ab91d2e852c9bc7b)() {
132 --index_;
133return *this;
134 }
135
[138](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a3bceefc9751d04598e063af41674549c)void [load](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a3bceefc9751d04598e063af41674549c)([Fragment](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#afaf52901287cfcadc0fe059e71b6842a) &frag, int index_offset = 0) const {
139
140 AccessType *frag_ptr = reinterpret_cast<AccessType *>(&frag);
141
143for (int n = 0; n < Policy::kAccessesPerIteration; ++n) {
144
145int accumulator_access_offset = index_ * Policy::kAccessesPerIteration + n;
146
147 frag_ptr[n] = accumulators_[accumulator_access_offset];
148 }
149 }
150 };
151
153
154 } // namespace warp
155 } // namespace epilogue
156 } // namespace cutlass
157
Definition: aligned_buffer.h:35
[cutlass::epilogue::warp::FragmentIteratorSimt< WarpShape_, Operator_, layout::RowMajor, MmaSimtPolicy_ >::OutputAccumulatorTile](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a798527db9b88dfa31149957a97c55a9d)
AccumulatorTile OutputAccumulatorTile
Definition: fragment_iterator_simt.h:90
cutlass::epilogue::warp::SimtPolicy
Definition: simt_policy.h:50
[cutlass::epilogue::warp::FragmentIteratorSimt< WarpShape_, Operator_, layout::RowMajor, MmaSimtPolicy_ >::WarpShape](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#af8e1c494bbef813d7dbad0f33a3a1e53)
WarpShape_ WarpShape
Definition: fragment_iterator_simt.h:73
Statically sized array of elements that accommodates all CUTLASS-supported numeric types and is safe ...
#define CUTLASS_PRAGMA_UNROLL
Definition: cutlass.h:110
cutlass::epilogue::warp::FragmentIteratorSimt
Fragment iterator for SIMT accumulator arrangements.
Definition: fragment_iterator_simt.h:60
[cutlass::epilogue::warp::FragmentIteratorSimt< WarpShape_, Operator_, layout::RowMajor, MmaSimtPolicy_ >::load](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a3bceefc9751d04598e063af41674549c)
CUTLASS_HOST_DEVICE void load(Fragment &frag, int index_offset=0) const
Loads a fragment from the referenced part of the accumulator tile.
Definition: fragment_iterator_simt.h:138
#define CUTLASS_HOST_DEVICE
Definition: cutlass.h:89
[cutlass::epilogue::warp::FragmentIteratorSimt< WarpShape_, Operator_, layout::RowMajor, MmaSimtPolicy_ >::AccumulatorTile](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a0b889a6700c158328616c274a573dd5a)
Array< typename Operator::ElementC, Policy::kAccumulatorElementCount > AccumulatorTile
This is the complete warp-level accumulator tile.
Definition: fragment_iterator_simt.h:88
[cutlass::epilogue::warp::FragmentIteratorSimt< WarpShape_, Operator_, layout::RowMajor, MmaSimtPolicy_ >::Fragment](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#afaf52901287cfcadc0fe059e71b6842a)
Array< typename Operator::ElementC, Policy::kElementsPerIteration > Fragment
This is the fragment size produced by one access of the iterator.
Definition: fragment_iterator_simt.h:83
[cutlass::epilogue::warp::FragmentIteratorSimt< WarpShape_, Operator_, layout::RowMajor, MmaSimtPolicy_ >::operator--](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a21f202bb39729599ab91d2e852c9bc7b)
CUTLASS_HOST_DEVICE FragmentIteratorSimt & operator--()
Decrements.
Definition: fragment_iterator_simt.h:131
Mapping function for row-major matrices.
Definition: layout/matrix.h:50
[cutlass::epilogue::warp::FragmentIteratorSimt< WarpShape_, Operator_, layout::RowMajor, MmaSimtPolicy_ >::FragmentIteratorSimt](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a3dee783224164a08c24654aba39ddbdb)
CUTLASS_HOST_DEVICE FragmentIteratorSimt(AccumulatorTile const &accum)
Constructs an iterator.
Definition: fragment_iterator_simt.h:116
Defines layout functions used by TensorRef and derived classes.
Defines basic structures needed for implementing the warp-scoped phase of the epilogue. These quantities assume a 'column-major' arrangement of SimtOp instructions, of which a row-oriented slice is visible per iteration.
[cutlass::epilogue::warp::FragmentIteratorSimt< WarpShape_, Operator_, layout::RowMajor, MmaSimtPolicy_ >::operator++](classcutlass_1_1epilogue_1_1warp_1_1FragmentIteratorSimt_3_01WarpShape 00_01Operator 00_01la3f2abc523201c1b0228df99119ab88e1.html#a71335e9f7fd399900035c397f1d5cfb1)
CUTLASS_HOST_DEVICE FragmentIteratorSimt & operator++()
Increments.
Definition: fragment_iterator_simt.h:124
Generated by 1.8.11