common.hip.hpp 804 Bytes
Newer Older
1
#pragma once
2
#include "data_type.hip.hpp"
3
4
5
6
#include "constant_integral.hip.hpp"
#include "Sequence.hip.hpp"
#include "Array.hip.hpp"
#include "functional.hip.hpp"
7

Chao Liu's avatar
Chao Liu committed
8
__device__ index_t get_thread_local_1d_id() { return threadIdx.x; }
Chao Liu's avatar
Chao Liu committed
9

Chao Liu's avatar
Chao Liu committed
10
__device__ index_t get_block_1d_id() { return blockIdx.x; }
11

12
13
14
15
16
17
18
19
20
21
22
template <class T1, class T2>
struct is_same
{
    static const bool value = false;
};

template <class T>
struct is_same<T, T>
{
    static const bool value = true;
};
Chao Liu's avatar
Chao Liu committed
23

Chao Liu's avatar
Chao Liu committed
24
#if DEVICE_BACKEND_CUDA
Chao Liu's avatar
Chao Liu committed
25
26
27
28
29
30
31
32
33
34
35
template <typename T>
__host__ __device__ constexpr T max(T a, T b)
{
    return a > b ? a : b;
}

template <typename T>
__host__ __device__ constexpr T min(T a, T b)
{
    return a < b ? a : b;
}
Chao Liu's avatar
Chao Liu committed
36
#endif
Chao Liu's avatar
Chao Liu committed
37

Chao Liu's avatar
Chao Liu committed
38
__host__ __device__ constexpr index_t integer_divide_ceil(index_t a, index_t b)
Chao Liu's avatar
Chao Liu committed
39
40
41
{
    return (a + b - 1) / b;
}