dimension.hpp 658 Bytes
Newer Older
Chao Liu's avatar
Chao Liu committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#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>
struct NativeDimension : Dimension<Length>
{
    __host__ __device__ static constexpr auto GetStride() { return Number<Stride>{}; }

    __host__ __device__ static constexpr index_t GetOffset(index_t id) { return id * Stride; }

    __host__ __device__ static constexpr index_t GetOffsetDiff(index_t id_diff)
    {
        return id_diff * Stride;
    }
};

} // namespace ck
#endif