online_driver_common.hpp 841 Bytes
Newer Older
1
2
#ifndef ONLINE_DRIVER_COMMON_HPP
#define ONLINE_DRIVER_COMMON_HPP
3

4
namespace ck_driver {
5

Chao Liu's avatar
Chao Liu committed
6
7
8
9
10
11
12
inline auto get_ck_hip_online_compile_common_flag()
{
    std::string param = " -std=c++17";

    return param;
}

13
14
// greatest common divisor, aka highest common factor
inline int gcd(int x, int y)
15
{
16
    if(x < 0)
17
    {
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
        return gcd(-x, y);
    }
    else if(y < 0)
    {
        return gcd(x, -y);
    }
    else if(x == y || x == 0)
    {
        return y;
    }
    else if(y == 0)
    {
        return x;
    }
    else if(x > y)
    {
        return gcd(x % y, y);
    }
36
37
    else
    {
38
39
40
        return gcd(x, y % x);
    }
}
41

42
43
44
45
46
47
48
template <typename X,
          typename... Ys,
          typename std::enable_if<sizeof...(Ys) >= 2, bool>::type = false>
auto gcd(X x, Ys... ys)
{
    return gcd(x, gcd(ys...));
}
49

50
} // namespace ck_driver
51
#endif