| 1 |
/* |
| 2 |
* Copyright (C) 2020-2025 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
R"===( |
| 9 |
#define ALIGNED4(ptr) __builtin_assume(((size_t)ptr&0b11) == 0) |
| 10 |
|
| 11 |
// assumption is local work size = pattern size |
| 12 |
__kernel void FillBufferBytes( |
| 13 |
__global uchar* pDst, |
| 14 |
offset_t dstOffsetInBytes, |
| 15 |
const __global uchar* pPattern ) |
| 16 |
{ |
| 17 |
ALIGNED4(pDst); |
| 18 |
ALIGNED4(pPattern); |
| 19 |
idx_t gid = get_global_id(0); |
| 20 |
idx_t lid = get_local_id(0); |
| 21 |
idx_t dstIndex = dstOffsetInBytes + gid; |
| 22 |
pDst[dstIndex] = pPattern[lid]; |
| 23 |
} |
| 24 |
|
| 25 |
__kernel void FillBufferLeftLeftover( |
| 26 |
__global uchar* pDst, |
| 27 |
offset_t dstOffsetInBytes, |
| 28 |
const __global uchar* pPattern, |
| 29 |
const offset_t patternSizeInEls ) |
| 30 |
{ |
| 31 |
ALIGNED4(pDst); |
| 32 |
ALIGNED4(pPattern); |
| 33 |
idx_t gid = get_global_id(0); |
| 34 |
idx_t dstIndex = dstOffsetInBytes + gid; |
| 35 |
pDst[dstIndex] = pPattern[gid & (patternSizeInEls - 1)]; |
| 36 |
} |
| 37 |
|
| 38 |
__kernel void FillBufferMiddle( |
| 39 |
__global uchar* pDst, |
| 40 |
offset_t dstOffsetInBytes, |
| 41 |
const __global uint* pPattern, |
| 42 |
const offset_t patternSizeInEls ) |
| 43 |
{ |
| 44 |
ALIGNED4(pDst); |
| 45 |
ALIGNED4(pPattern); |
| 46 |
idx_t gid = get_global_id(0); |
| 47 |
((__global uint*)(pDst + dstOffsetInBytes))[gid] = pPattern[gid & (patternSizeInEls - 1)]; |
| 48 |
} |
| 49 |
|
| 50 |
__kernel void FillBufferRightLeftover( |
| 51 |
__global uchar* pDst, |
| 52 |
offset_t dstOffsetInBytes, |
| 53 |
const __global uchar* pPattern, |
| 54 |
const offset_t patternSizeInEls ) |
| 55 |
{ |
| 56 |
ALIGNED4(pDst); |
| 57 |
ALIGNED4(pPattern); |
| 58 |
idx_t gid = get_global_id(0); |
| 59 |
idx_t dstIndex = dstOffsetInBytes + gid; |
| 60 |
pDst[dstIndex] = pPattern[gid & (patternSizeInEls - 1)]; |
| 61 |
} |
| 62 |
|
| 63 |
__kernel void FillBufferImmediate( |
| 64 |
__global uchar* ptr, |
| 65 |
offset_t dstSshOffset, // Offset needed in case ptr has been adjusted for SSH alignment |
| 66 |
const uint value) |
| 67 |
{ |
| 68 |
ALIGNED4(ptr); |
| 69 |
idx_t gid = get_global_id(0); |
| 70 |
__global uint4* dstPtr = (__global uint4*)(ptr + dstSshOffset); |
| 71 |
dstPtr[gid] = value; |
| 72 |
} |
| 73 |
|
| 74 |
__kernel void FillBufferImmediateLeftOver( |
| 75 |
__global uchar* ptr, |
| 76 |
offset_t dstSshOffset, // Offset needed in case ptr has been adjusted for SSH alignment |
| 77 |
const uint value) |
| 78 |
{ |
| 79 |
ALIGNED4(ptr); |
| 80 |
idx_t gid = get_global_id(0); |
| 81 |
(ptr + dstSshOffset)[gid] = value; |
| 82 |
} |
| 83 |
|
| 84 |
__kernel void FillBufferSSHOffset( |
| 85 |
__global uchar* ptr, |
| 86 |
offset_t dstSshOffset, // Offset needed in case ptr has been adjusted for SSH alignment |
| 87 |
const __global uchar* pPattern, |
| 88 |
offset_t patternSshOffset // Offset needed in case pPattern has been adjusted for SSH alignment |
| 89 |
) |
| 90 |
{ |
| 91 |
ALIGNED4(ptr); |
| 92 |
ALIGNED4(pPattern); |
| 93 |
idx_t dstIndex = get_global_id(0); |
| 94 |
idx_t srcIndex = get_local_id(0); |
| 95 |
__global uchar* pDst = (__global uchar*)ptr + dstSshOffset; |
| 96 |
__global uchar* pSrc = (__global uchar*)pPattern + patternSshOffset; |
| 97 |
pDst[dstIndex] = pSrc[srcIndex]; |
| 98 |
} |
| 99 |
)===" |