Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 5eb663d

Browse files
[SYCL] Add work-around for fill bug in memcpy2d tests (#1688)
Due to a bug with queue::fill on some hardware when offsetting access, memcpy2d and copy2d would fail verification. This commit uses a custom fill operation to work around this. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent c231a9a commit 5eb663d

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

SYCL/USM/copy2d.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,22 +237,21 @@ int test(queue &Q, T ExpectedVal1, T ExpectedVal2) {
237237
T *USMMemSrc = allocate<T, SrcAllocKind>(SRC_ELEMS, Q);
238238
T *USMMemDst1 = allocate<T, DstAllocKind>(DST_ELEMS, Q);
239239
T *USMMemDst2 = allocate<T, DstAllocKind>(DST_ELEMS, Q);
240-
event Src1FillEvent =
241-
fill<SrcAllocKind>(Q, USMMemSrc, ExpectedVal1, DST_ELEMS);
242-
event Src2FillEvent =
243-
fill<SrcAllocKind>(Q, USMMemSrc + DST_ELEMS, ExpectedVal2, DST_ELEMS);
240+
event SrcFillEvent =
241+
fill_with<SrcAllocKind>(Q, USMMemSrc, SRC_ELEMS, [=](size_t I) {
242+
return I < DST_ELEMS ? ExpectedVal1 : ExpectedVal2;
243+
});
244244
event Dst1MemsetEvent =
245245
memset<DstAllocKind>(Q, USMMemDst1, 0, DST_ELEMS * sizeof(T));
246246
event Dst2MemsetEvent =
247247
memset<DstAllocKind>(Q, USMMemDst2, 0, DST_ELEMS * sizeof(T));
248248
event FirstCopyEvent = doCopy2D<T, PathKind>(
249249
Q, USMMemSrc, RECT_WIDTH, USMMemDst1, RECT_WIDTH, RECT_WIDTH,
250-
RECT_HEIGHT,
251-
{Src1FillEvent, Src2FillEvent, Dst1MemsetEvent, Dst2MemsetEvent});
252-
doCopy2D<T, PathKind>(Q, USMMemSrc + DST_ELEMS, RECT_WIDTH, USMMemDst2,
253-
RECT_WIDTH, RECT_WIDTH, RECT_HEIGHT,
254-
{FirstCopyEvent, Src1FillEvent, Src2FillEvent,
255-
Dst1MemsetEvent, Dst2MemsetEvent})
250+
RECT_HEIGHT, {SrcFillEvent, Dst1MemsetEvent, Dst2MemsetEvent});
251+
doCopy2D<T, PathKind>(
252+
Q, USMMemSrc + DST_ELEMS, RECT_WIDTH, USMMemDst2, RECT_WIDTH,
253+
RECT_WIDTH, RECT_HEIGHT,
254+
{FirstCopyEvent, SrcFillEvent, Dst1MemsetEvent, Dst2MemsetEvent})
256255
.wait();
257256
std::vector<T> Results;
258257
Results.resize(SRC_ELEMS);

SYCL/USM/memcpy2d.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,23 +240,22 @@ int test(queue &Q, T ExpectedVal1, T ExpectedVal2) {
240240
T *USMMemSrc = allocate<T, SrcAllocKind>(SRC_ELEMS, Q);
241241
T *USMMemDst1 = allocate<T, DstAllocKind>(DST_ELEMS, Q);
242242
T *USMMemDst2 = allocate<T, DstAllocKind>(DST_ELEMS, Q);
243-
event Src1FillEvent =
244-
fill<SrcAllocKind>(Q, USMMemSrc, ExpectedVal1, DST_ELEMS);
245-
event Src2FillEvent =
246-
fill<SrcAllocKind>(Q, USMMemSrc + DST_ELEMS, ExpectedVal2, DST_ELEMS);
243+
event SrcFillEvent =
244+
fill_with<SrcAllocKind>(Q, USMMemSrc, SRC_ELEMS, [=](size_t I) {
245+
return I < DST_ELEMS ? ExpectedVal1 : ExpectedVal2;
246+
});
247247
event Dst1MemsetEvent =
248248
memset<DstAllocKind>(Q, USMMemDst1, 0, DST_ELEMS * sizeof(T));
249249
event Dst2MemsetEvent =
250250
memset<DstAllocKind>(Q, USMMemDst2, 0, DST_ELEMS * sizeof(T));
251251
event FirstMemcpyEvent = doMemcpy2D<T, PathKind>(
252252
Q, USMMemDst1, RECT_WIDTH * sizeof(T), USMMemSrc,
253253
RECT_WIDTH * sizeof(T), RECT_WIDTH * sizeof(T), RECT_HEIGHT,
254-
{Src1FillEvent, Src2FillEvent, Dst1MemsetEvent, Dst2MemsetEvent});
255-
doMemcpy2D<T, PathKind>(Q, USMMemDst2, RECT_WIDTH * sizeof(T),
256-
USMMemSrc + DST_ELEMS, RECT_WIDTH * sizeof(T),
257-
RECT_WIDTH * sizeof(T), RECT_HEIGHT,
258-
{FirstMemcpyEvent, Src1FillEvent, Src2FillEvent,
259-
Dst1MemsetEvent, Dst2MemsetEvent})
254+
{SrcFillEvent, Dst1MemsetEvent, Dst2MemsetEvent});
255+
doMemcpy2D<T, PathKind>(
256+
Q, USMMemDst2, RECT_WIDTH * sizeof(T), USMMemSrc + DST_ELEMS,
257+
RECT_WIDTH * sizeof(T), RECT_WIDTH * sizeof(T), RECT_HEIGHT,
258+
{FirstMemcpyEvent, SrcFillEvent, Dst1MemsetEvent, Dst2MemsetEvent})
260259
.wait();
261260
std::vector<T> Results;
262261
Results.resize(SRC_ELEMS);

0 commit comments

Comments
 (0)