Back to Cutlass

CUTLASS: aligned_buffer.h Source File

docs/aligned__buffer_8h_source.html

4.4.212.6 KB
Original Source

| | CUTLASS

CUDA Templates for Linear Algebra Subroutines and Solvers |

aligned_buffer.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 **************************************************************************************************/

30 #pragma once

31

32 #include "cutlass/cutlass.h"

33 #include "cutlass/array.h"

34

35 namespace cutlass {

36

38

40 template <

41typename T,

42int N,

43int Align = 16

44 >

45 struct AlignedBuffer {

46

48using Storage = uint8_t;

49

51static int const kCount = N;

52

54static int const kAlign = Align;

55

57static int const kBytes =

58 (sizeof_bits<T>::value * N + 7) / 8;

59

60 private:

61

63alignas(Align) Storage storage[kBytes];

64

65 public:

66

67//

68// C++ standard members

69//

70

71typedef T value_type;

72typedef size_t size_type;

73typedef ptrdiff_t difference_type;

74typedef value_type *pointer;

75typedef value_type const * const_pointer;

76

77using Array = Array<T, N>;

78using reference = typename Array::reference;

79using const_reference = typename Array::const_reference;

80

81 public:

82

83CUTLASS_HOST_DEVICE

84 pointer data() {

85return reinterpret_cast<pointer>(storage);

86 }

87

88CUTLASS_HOST_DEVICE

89 const_pointer data() const {

90return reinterpret_cast<pointer>(storage);

91 }

92

93CUTLASS_HOST_DEVICE

94Storage * raw_data() {

95return storage;

96 }

97

98CUTLASS_HOST_DEVICE

99Storage const * raw_data() const {

100return storage;

101 }

102

103

104CUTLASS_HOST_DEVICE

105constexpr bool empty() const {

106return ! kCount;

107 }

108

109CUTLASS_HOST_DEVICE

110constexpr size_type size() const {

111return kCount;

112 }

113

114CUTLASS_HOST_DEVICE

115constexpr size_type max_size() const {

116return kCount;

117 }

118 };

119

121

122 } // namespace cutlass

123

cutlass::AlignedBuffer::value_type

T value_type

Definition: aligned_buffer.h:71

cutlass::AlignedBuffer::const_pointer

value_type const * const_pointer

Definition: aligned_buffer.h:75

cutlass

Definition: aligned_buffer.h:35

constexpr

#define constexpr

Definition: platform.h:137

cutlass::AlignedBuffer::raw_data

CUTLASS_HOST_DEVICE Storage const * raw_data() const

Definition: aligned_buffer.h:99

cutlass::AlignedBuffer< Element, cutlass::MatrixShape::kCount >::const_reference

typename Array::const_reference const_reference

Definition: aligned_buffer.h:79

cutlass::AlignedBuffer::max_size

CUTLASS_HOST_DEVICE constexpr size_type max_size() const

Definition: aligned_buffer.h:115

cutlass::AlignedBuffer< Element, cutlass::MatrixShape::kCount >::Storage

uint8_t Storage

Internal storage type.

Definition: aligned_buffer.h:48

array.h

Statically sized array of elements that accommodates all CUTLASS-supported numeric types and is safe ...

cutlass::sizeof_bits

Defines the size of an element in bits.

Definition: numeric_types.h:42

cutlass::AlignedBuffer::kBytes

static int const kBytes

Number of storage elements.

Definition: aligned_buffer.h:57

CUTLASS_HOST_DEVICE

#define CUTLASS_HOST_DEVICE

Definition: cutlass.h:89

cutlass::AlignedBuffer

Modifies semantics of cutlass::Array<> to provide guaranteed alignment.

Definition: aligned_buffer.h:45

cutlass::AlignedBuffer::data

CUTLASS_HOST_DEVICE pointer data()

Definition: aligned_buffer.h:84

cutlass::AlignedBuffer::kCount

static int const kCount

Number of logical elements held in buffer.

Definition: aligned_buffer.h:51

cutlass::AlignedBuffer::kAlign

static int const kAlign

Alignment requirement in bytes.

Definition: aligned_buffer.h:54

cutlass::AlignedBuffer::raw_data

CUTLASS_HOST_DEVICE Storage * raw_data()

Definition: aligned_buffer.h:94

cutlass::AlignedBuffer< Element, cutlass::MatrixShape::kCount >::reference

typename Array::reference reference

Definition: aligned_buffer.h:78

cutlass::AlignedBuffer< Element, cutlass::MatrixShape::kCount >::Array

Array< Element, N > Array

Definition: aligned_buffer.h:77

cutlass::AlignedBuffer::size_type

size_t size_type

Definition: aligned_buffer.h:72

cutlass::AlignedBuffer::difference_type

ptrdiff_t difference_type

Definition: aligned_buffer.h:73

cutlass::AlignedBuffer::pointer

value_type * pointer

Definition: aligned_buffer.h:74

cutlass.h

Basic include for CUTLASS.

cutlass::AlignedBuffer::empty

CUTLASS_HOST_DEVICE constexpr bool empty() const

Definition: aligned_buffer.h:105

cutlass::AlignedBuffer::size

CUTLASS_HOST_DEVICE constexpr size_type size() const

Definition: aligned_buffer.h:110

cutlass::AlignedBuffer::data

CUTLASS_HOST_DEVICE const_pointer data() const

Definition: aligned_buffer.h:89


Generated by 1.8.11