Cutlass
CUDA Templates for Linear Algebra Subroutines and Solvers
gemm_shared_stream.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  **************************************************************************************************/
29 #pragma once
30 
32 
33 namespace cutlass {
34 namespace gemm {
35 
37 
38 template <
40  typename Iterator_,
42  typename Transformer_ = Copy<typename Iterator_::Fragment> >
43 
46  typedef Iterator_ Iterator;
48  typedef Transformer_ Transformer;
49 
51  typedef typename Iterator::Fragment FetchedFragment;
53  typedef typename Transformer::OutputFragment TransformedFragment;
56  "");
59 
61  struct Params {
63  typename Iterator::Params iterator;
64 
66  CUTLASS_HOST_DEVICE int initialize() { return iterator.initialize(); }
67  };
68 
70  typedef typename Iterator::Storage SharedStorage;
71 
73  CUTLASS_DEVICE SharedLoadStream() {}
74 
76  CUTLASS_DEVICE SharedLoadStream(Params const &params, SharedStorage &shared_storage) {
77  this->initialize(params, shared_storage);
78  }
79 
81  CUTLASS_DEVICE void initialize(Params const &params, SharedStorage &shared_storage) {
82  // The iterator.
83  iterator = Iterator(params.iterator, shared_storage);
84  // The transformer.
86  }
87 
89  CUTLASS_DEVICE void copy(FetchedFragment &fetched) { shared_iterator_load(iterator, fetched); }
90 
92  CUTLASS_DEVICE void copy(int d, FetchedFragment &fetched) {
93  shared_iterator_load(iterator, fetched, d);
94  }
95 
97  CUTLASS_DEVICE void commit(FetchedFragment &fetched, TransformedFragment &transformed) {
98  transformer.transform(fetched, transformed);
99  }
100 
102  CUTLASS_DEVICE void inc_stage() { iterator.inc_stage(); }
103 
108 };
109 
111 
112 } // namespace gemm
113 } // namespace cutlass
CUTLASS_DEVICE void copy(FetchedFragment &fetched)
Load the data from shared memory to the fetch fragment.
Definition: gemm_shared_stream.h:89
Definition: convert.h:33
CUTLASS_DEVICE void shared_iterator_load(InputIterator &iterator, Fragment &fragment)
Loads a fragment from a shared memory input iterator.
Definition: iterator_access.h:75
CUTLASS_DEVICE void initialize(Params const &params, SharedStorage &shared_storage)
Initialize the stream.
Definition: gemm_shared_stream.h:81
std::is_same (false specialization)
Definition: platform.h:412
Iterator::Storage SharedStorage
The storage in shared memory needed by that stream.
Definition: gemm_shared_stream.h:70
CUTLASS_DEVICE void commit(FetchedFragment &fetched, TransformedFragment &transformed)
Commit the data.
Definition: gemm_shared_stream.h:97
CUTLASS_DEVICE void inc_stage()
Increment the stage.
Definition: gemm_shared_stream.h:102
CUTLASS_DEVICE SharedLoadStream()
Ctor.
Definition: gemm_shared_stream.h:73
Defines iterators for efficiently loading and storing tiles to and from shared memory.
Definition: gemm_shared_stream.h:44
Transformer transformer
The transformer.
Definition: gemm_shared_stream.h:107
TransformedFragment Fragment
Make sure the fragments match.
Definition: gemm_shared_stream.h:56
#define CUTLASS_HOST_DEVICE
Definition: cutlass.h:46
CUTLASS_DEVICE void copy(int d, FetchedFragment &fetched)
Load the data from shared memory to the fetch fragment.
Definition: gemm_shared_stream.h:92
#define static_assert(__e, __m)
Definition: platform.h:145
Iterator::Params iterator
The iterator params.
Definition: gemm_shared_stream.h:63
Iterator iterator
The iterator.
Definition: gemm_shared_stream.h:105
CUTLASS_HOST_DEVICE int initialize()
Setup the params.
Definition: gemm_shared_stream.h:66
Transformer::OutputFragment TransformedFragment
The fragment that is obtained after the transformation by the transformer.
Definition: gemm_shared_stream.h:53
The params.
Definition: gemm_shared_stream.h:61
Iterator::Fragment FetchedFragment
The fragment that is copied from shared memory.
Definition: gemm_shared_stream.h:51
Transformer_ Transformer
The transformer.
Definition: gemm_shared_stream.h:48
Iterator_ Iterator
The load iterator.
Definition: gemm_shared_stream.h:46
CUTLASS_DEVICE SharedLoadStream(Params const &params, SharedStorage &shared_storage)
Ctor.
Definition: gemm_shared_stream.h:76