Commit 155bb1fd authored by Paul's avatar Paul
Browse files

Add lazy index calculations

parent 551c2e45
......@@ -31,11 +31,36 @@
namespace migraphx {
extern "C" __device__ __attribute__((const)) size_t __ockl_get_global_id(uint);
extern "C" __device__ __attribute__((const)) size_t __ockl_get_local_id(uint);
extern "C" __device__ __attribute__((const)) size_t __ockl_get_group_id(uint);
struct index
{
index_int global = 0;
index_int local = 0;
index_int group = 0;
struct global_read
{
__device__ operator index_int() const
{
return index_int{blockIdx.x} * index_int{blockDim.x} + index_int{threadIdx.x}; // NOLINT
}
};
struct local_read
{
__device__ operator index_int() const
{
return threadIdx.x; // NOLINT
}
};
struct group_read
{
__device__ operator index_int() const
{
return blockIdx.x; // NOLINT
}
};
global_read global{};
local_read local{};
group_read group{};
#ifdef MIGRAPHX_NGLOBAL
constexpr index_constant<MIGRAPHX_NGLOBAL> nglobal() const { return {}; }
......@@ -98,9 +123,9 @@ struct index
}
};
inline __device__ index make_index()
inline __device__ __attribute__((const)) index make_index()
{
return index{blockIdx.x * blockDim.x + threadIdx.x, threadIdx.x, blockIdx.x}; // NOLINT
return index{};
}
} // namespace migraphx
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment