13 #include "detail/common.h"
15 #include "detail/buffer_registry.h"
32 constexpr
dim(
int _x) :
x(_x) {}
33 constexpr
dim(
int _x,
int _y) :
x(_x),
y(_y) {}
34 constexpr
dim(
int _x,
int _y,
int _z) :
x(_x),
y(_y),
z(_z) {}
36 constexpr
int ndims()
const {
return 3 - (
y < 0) - (
z < 0); }
39 return x * (
y <= 0 ? 1 :
y) * (
z <= 0 ? 1 :
z);
42 #if XPU_IS_HIP || XPU_IS_CUDA
43 ::dim3 as_cuda_grid()
const { return ::dim3{(
unsigned int)
x, (
unsigned int)
y, (
unsigned int)
z}; }
132 #if XPU_IS_CUDA || XPU_IS_HIP
137 #if !XPU_IS_DEVICE_CODE
173 #if !XPU_IS_CUDA && !XPU_IS_HIP
184 #include "impl/common.tpp"
XPU_H XPU_D buffer(buffer< U > &&other)
XPU_H XPU_D buffer & operator=(const buffer< U > &other)
XPU_H XPU_D buffer & operator=(buffer< U > &&other)
XPU_H XPU_D T & operator*() const
Definition: common.h:165
XPU_H XPU_D buffer & operator=(const buffer &other)
XPU_H XPU_D buffer(const buffer< U > &other)
T value_type
Definition: common.h:89
buffer(size_t N, buffer_type type, T *data=nullptr)
Create a buffer with the given size.
void reset(size_t N, buffer_type type, T *data=nullptr)
buffer()=default
Create an emtpy buffer.
XPU_H XPU_D T * operator->() const
Definition: common.h:166
XPU_H XPU_D buffer(const buffer &other)
XPU_H XPU_D buffer & operator=(buffer &&other)
XPU_H XPU_D T & operator[](size_t i) const
Definition: common.h:168
XPU_H XPU_D T * get() const
Definition: common.h:163
XPU_H XPU_D ~buffer()
Free the buffer.
Definition: common.h:136
XPU_H XPU_D buffer(buffer &&other)
#define XPU_H
Function specifier for host functions. (Replaces host)
Definition: defines.h:33
#define XPU_D
Function specifier for device functions. (Replaces device)
Definition: defines.h:21
xpu default namespace.
Definition: common.h:17
buffer_type
Definition: common.h:77
@ buf_device
Definition: common.h:79
@ buf_stack
Definition: common.h:82
@ buf_io
Definition: common.h:81
@ buf_managed
Definition: common.h:80
@ buf_pinned
Definition: common.h:78
grid n_blocks(dim nblocks)
Construct a grid with the given number of blocks in each dimension.
grid n_threads(dim nthreads)
Construct a grid with the given number of threads in each dimension If the number of threads is not a...
driver_t
Definition: common.h:19
@ hip
Definition: common.h:22
@ cuda
Definition: common.h:21
@ sycl
Definition: common.h:23
@ cpu
Definition: common.h:20
constexpr dim(int _x)
Definition: common.h:32
constexpr int ndims() const
Definition: common.h:36
constexpr dim(int _x, int _y)
Definition: common.h:33
int y
Definition: common.h:28
constexpr int linear() const
Definition: common.h:38
int z
Definition: common.h:29
constexpr dim(int _x, int _y, int _z)
Definition: common.h:34
int x
Definition: common.h:27
3d execution grid describing the number of blocks and threads of a kernel Use 'n_blocks' or 'n_thread...
Definition: common.h:51
void get_compute_grid(dim &block_dim, dim &grid_dim) const
friend grid n_blocks(dim)
Construct a grid with the given number of blocks in each dimension.
dim nblocks
Definition: common.h:53
friend grid n_threads(dim)
Construct a grid with the given number of threads in each dimension If the number of threads is not a...
dim nthreads
Definition: common.h:54