8#ifndef BRICK_BRICK_DPC_H
9#define BRICK_BRICK_DPC_H
15static sycl::property_list properties{sycl::property::queue::enable_profiling()};
16static sycl::queue gpu_queue = sycl::queue(sycl::gpu_selector(), properties);
17static sycl::queue cpu_queue = sycl::queue(sycl::host_selector(), properties);
19static sycl::queue gpu_queue = sycl::queue(sycl::gpu_selector());
20static sycl::queue cpu_queue = sycl::queue(sycl::host_selector());
43 T *ptr = (T *) sycl::malloc_device(size, gpu_queue);
47 gpu_queue.memset(ptr, 0, size).wait_and_throw();
64 gpu_queue.memcpy((
void *) dst, (
void *) ptr, size).wait_and_throw();
76 sycl::free((
void *) ptr, gpu_queue);
80static const char *dpc_get_error_string(
dpcError_t e) {
85 default:
return "Unknown error";
89#define gpuMalloc(p, s) dpc_malloc(p, s)
90#define gpuMemcpy(d, p, s, k) dpc_memcpy(d, p, s, k)
91#define gpuFree(p) dpc_free(p)
92#define gpuMemcpyKind dpcMemcpyKind
93#define gpuMemcpyHostToDevice dpcMemcpyHostToDevice
94#define gpuMemcpyDeviceToHost dpcMemcpyDeviceToHost
95#define gpuSuccess dpc_success
96#define gpuGetErrorString(e) dpc_get_error_string(e)
120 static constexpr unsigned VECLEN =
cal_size<Folds...>::value;
121 static constexpr unsigned BRICKSIZE =
cal_size<BDims...>::value;
130 typename std::conditional<
sizeof...(BDims) ==
sizeof...(Folds), bool,
void>::type>
operator[](
unsigned b) {
132 typename std::conditional<
sizeof...(BDims) ==
sizeof...(Folds), bool,
void>::type>(
this, b, 0, 0, 0);
136 template<
unsigned ... Offsets>
139 unsigned off =
cal_offs<
sizeof...(BDims), Offsets...>::value;
140 return &dat[bInfo->
adj[b][off] * step];
144 dat = bData + offset;
dpcError_t
Definition: brick-dpc.h:23
@ dpc_success
Definition: brick-dpc.h:24
@ memcpy_failed
Definition: brick-dpc.h:25
@ malloc_failed
Definition: brick-dpc.h:26
dpcMemcpyKind
Definition: brick-dpc.h:29
@ dpcMemcpyHostToDevice
Definition: brick-dpc.h:30
@ dpcMemcpyDeviceToHost
Definition: brick-dpc.h:31
dpcError_t dpc_malloc(T **buffer, size_t size)
Interface to allocate memory on a DPCPP GPU with a similar footprint to CUDA.
Definition: brick-dpc.h:42
dpcError_t dpc_memcpy(T *dst, T *ptr, size_t size, dpcMemcpyKind type)
Copy data from host to DPCPP GPU. If data must be returned to the host after kernel execution,...
Definition: brick-dpc.h:62
dpcError_t dpc_free(T *ptr)
Free allocated memory on a DPCPP GPU.
Definition: brick-dpc.h:75
This file should not be directly included. It defines instructions for using bricklib with a GPU,...
#define FORCUDA
Overloaded attributes for potentially GPU-usable functions (in place of host device etc....
Definition: brick.h:25
Metadata related to bricks.
Definition: brick.h:97
adjlist adj
Adjacency list.
Definition: brick.h:101
Brick data structure.
Definition: brick-dpc.h:116
bElem * dat
Offsetted memory (BrickStorage)
Definition: brick-dpc.h:125
size_t step
Spacing between bricks in unit of bElem (BrickStorage)
Definition: brick-dpc.h:124
myBrickInfo * bInfo
Pointer to (possibly shared) metadata.
Definition: brick-dpc.h:123
DPCBrick(myBrickInfo *bInfo, bElem *bData, size_t bStep, unsigned offset)
Definition: brick-dpc.h:143
FORCUDA _BrickAccessor< mytype, Dim< BDims... >, Dim< Folds... >, typename std::conditional< sizeof...(BDims)==sizeof...(Folds), bool, void >::type > operator[](unsigned b)
Indexing operator returns: Accessing brick elements using [].
Definition: brick-dpc.h:130
DPCBrick< Dim< BDims... >, Dim< Folds... > > mytype
Shorthand for this struct's type.
Definition: brick-dpc.h:117
FORCUDA bElem * neighbor(unsigned b)
Return the adjacency list of brick b
Definition: brick-dpc.h:138
Generic base template, see Brick< Dim< BDims... >, Dim< Folds... > >
Definition: brick-dpc.h:100
Empty template to specify an n-D list.
Definition: brick.h:131
Generic base template for Accessing brick elements using [].
Definition: brick.h:215
Generic base template for Calculating the offset within the adjacency list.
Definition: brick.h:174
Generic base template for Calculate the product of n numbers in a template.
Definition: brick.h:143
#define bElem
Basic datatype for all brick elements.
Definition: vecscatter.h:13