gemm_shared_stream.h
Go to the documentation of this file.
/***************************************************************************************************
* Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
* * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************************************/
#pragma once
#include <cutlass/gemm/gemm_shared_tile.h>
namespace cutlass {
namespace gemm {
template <
typename Iterator_,
typename Transformer_ = Copy<typename Iterator_::Fragment> >
struct SharedLoadStream {
typedef Iterator_ Iterator;
typedef Transformer_ Transformer;
typedef typename Iterator::Fragment FetchedFragment;
typedef typename Transformer::OutputFragment TransformedFragment;
static_assert((platform::is_same<FetchedFragment, typename Transformer::InputFragment>::value),
"");
typedef TransformedFragment Fragment;
struct Params {
typename Iterator::Params iterator;
CUTLASS_HOST_DEVICE int initialize() { return iterator.initialize(); }
};
typedef typename Iterator::Storage SharedStorage;
CUTLASS_DEVICE SharedLoadStream() {}
CUTLASS_DEVICE SharedLoadStream(Params const &params, SharedStorage &shared_storage) {
this->initialize(params, shared_storage);
}
CUTLASS_DEVICE void initialize(Params const &params, SharedStorage &shared_storage) {
// The iterator.
iterator = Iterator(params.iterator, shared_storage);
// The transformer.
transformer = Transformer();
}
CUTLASS_DEVICE void copy(FetchedFragment &fetched) { shared_iterator_load(iterator, fetched); }
CUTLASS_DEVICE void copy(int d, FetchedFragment &fetched) {
shared_iterator_load(iterator, fetched, d);
}
CUTLASS_DEVICE void commit(FetchedFragment &fetched, TransformedFragment &transformed) {
transformer.transform(fetched, transformed);
}
CUTLASS_DEVICE void inc_stage() { iterator.inc_stage(); }
Iterator iterator;
Transformer transformer;
};
} // namespace gemm
} // namespace cutlass
cutlass::gemm::SharedLoadStream::copy
CUTLASS_DEVICE void copy(FetchedFragment &fetched)
Load the data from shared memory to the fetch fragment.
Definition: gemm_shared_stream.h:89
cutlass
Definition: convert.h:33
cutlass::shared_iterator_load
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::gemm::SharedLoadStream::initialize
CUTLASS_DEVICE void initialize(Params const &params, SharedStorage &shared_storage)
Initialize the stream.
Definition: gemm_shared_stream.h:81
cutlass::platform::is_same
std::is_same (false specialization)
Definition: platform.h:412
cutlass::gemm::SharedLoadStream::SharedStorage
Iterator::Storage SharedStorage
The storage in shared memory needed by that stream.
Definition: gemm_shared_stream.h:70
cutlass::gemm::SharedLoadStream::commit
CUTLASS_DEVICE void commit(FetchedFragment &fetched, TransformedFragment &transformed)
Commit the data.
Definition: gemm_shared_stream.h:97
cutlass::gemm::SharedLoadStream::inc_stage
CUTLASS_DEVICE void inc_stage()
Increment the stage.
Definition: gemm_shared_stream.h:102
cutlass::gemm::SharedLoadStream::SharedLoadStream
CUTLASS_DEVICE SharedLoadStream()
Ctor.
Definition: gemm_shared_stream.h:73
gemm_shared_tile.h
Defines iterators for efficiently loading and storing tiles to and from shared memory.
cutlass::gemm::SharedLoadStream
Definition: gemm_shared_stream.h:44
cutlass::gemm::SharedLoadStream::transformer
Transformer transformer
The transformer.
Definition: gemm_shared_stream.h:107
cutlass::gemm::SharedLoadStream::Fragment
TransformedFragment Fragment
Make sure the fragments match.
Definition: gemm_shared_stream.h:56
CUTLASS_HOST_DEVICE
#define CUTLASS_HOST_DEVICE
Definition: cutlass.h:46
cutlass::gemm::SharedLoadStream::copy
CUTLASS_DEVICE void copy(int d, FetchedFragment &fetched)
Load the data from shared memory to the fetch fragment.
Definition: gemm_shared_stream.h:92
static_assert
#define static_assert(__e, __m)
Definition: platform.h:145
cutlass::gemm::SharedLoadStream::Params::iterator
Iterator::Params iterator
The iterator params.
Definition: gemm_shared_stream.h:63
cutlass::gemm::SharedLoadStream::iterator
Iterator iterator
The iterator.
Definition: gemm_shared_stream.h:105
cutlass::gemm::SharedLoadStream::Params::initialize
CUTLASS_HOST_DEVICE int initialize()
Setup the params.
Definition: gemm_shared_stream.h:66
cutlass::gemm::SharedLoadStream::TransformedFragment
Transformer::OutputFragment TransformedFragment
The fragment that is obtained after the transformation by the transformer.
Definition: gemm_shared_stream.h:53
cutlass::gemm::SharedLoadStream::Params
The params.
Definition: gemm_shared_stream.h:61
cutlass::gemm::SharedLoadStream::FetchedFragment
Iterator::Fragment FetchedFragment
The fragment that is copied from shared memory.
Definition: gemm_shared_stream.h:51
cutlass::gemm::SharedLoadStream::Transformer
Transformer_ Transformer
The transformer.
Definition: gemm_shared_stream.h:48
cutlass::gemm::SharedLoadStream::Iterator
Iterator_ Iterator
The load iterator.
Definition: gemm_shared_stream.h:46
cutlass::gemm::SharedLoadStream::SharedLoadStream
CUTLASS_DEVICE SharedLoadStream(Params const &params, SharedStorage &shared_storage)
Ctor.
Definition: gemm_shared_stream.h:76