dimension.hpp 722 Bytes
Newer Older
Chao Liu's avatar
Chao Liu committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef CK_DIMENSION_HPP
#define CK_DIMENSION_HPP

#include "common_header.hpp"

namespace ck {

template <index_t Length>
struct Dimension
{
    __host__ __device__ static constexpr auto GetLength() { return Number<Length>{}; }
};

template <index_t Length, index_t Stride>
Chao Liu's avatar
Chao Liu committed
15
struct NativeDimension
Chao Liu's avatar
Chao Liu committed
16
{
Chao Liu's avatar
Chao Liu committed
17
18
    __host__ __device__ static constexpr auto GetLength() { return Number<Length>{}; }

Chao Liu's avatar
Chao Liu committed
19
20
    __host__ __device__ static constexpr auto GetStride() { return Number<Stride>{}; }

Chao Liu's avatar
Chao Liu committed
21
    __host__ __device__ static constexpr index_t GetOffset(index_t i) { return i * Stride; }
Chao Liu's avatar
Chao Liu committed
22

Chao Liu's avatar
Chao Liu committed
23
    __host__ __device__ static constexpr index_t GetOffsetDiff(index_t i_diff)
Chao Liu's avatar
Chao Liu committed
24
    {
Chao Liu's avatar
Chao Liu committed
25
        return i_diff * Stride;
Chao Liu's avatar
Chao Liu committed
26
27
28
29
30
    }
};

} // namespace ck
#endif