reduction_common.hpp 770 Bytes
Newer Older
Chao Liu's avatar
Chao Liu committed
1
2
3
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.

Chao Liu's avatar
Chao Liu committed
4
#pragma once
5

Chao Liu's avatar
Chao Liu committed
6
#include "ck/utility/reduction_enums.hpp"
7

8
namespace ck {
9
10
11
12

struct float_equal_one
{
    template <class T>
13
    __host__ __device__ inline bool operator()(T x)
14
    {
15
        return x <= static_cast<T>(1.0f) and x >= static_cast<T>(1.0f);
16
17
18
19
20
21
    };
};

struct float_equal_zero
{
    template <class T>
22
    __host__ __device__ inline bool operator()(T x)
23
    {
24
        return x <= static_cast<T>(0.0f) and x >= static_cast<T>(0.0f);
25
26
27
    };
};

28
29
30
31
32
33
34
35
36
37
38
39
template <index_t N>
static constexpr __device__ index_t get_shift()
{
    return (get_shift<N / 2>() + 1);
};

template <>
constexpr __device__ index_t get_shift<1>()
{
    return (0);
}

Chao Liu's avatar
Chao Liu committed
40
} // namespace ck