Skip to content

Commit 63eb219

Browse files
Test Local accessor for ndim=1, 2, 3
1 parent 1919fc6 commit 63eb219

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

libsyclinterface/tests/test_sycl_queue_submit_local_accessor_arg.cpp

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,49 @@ void submit_kernel(DPCTLSyclQueueRef QRef,
7575
a_ptr[i] = 0;
7676
}
7777

78-
auto la = MDLocalAccessor{1, kernelArgTy, SIZE / 10, 1, 1};
78+
auto la1 = MDLocalAccessor{1, kernelArgTy, SIZE / 10, 1, 1};
7979

8080
// Create kernel args for vector_add
8181
size_t gRange[] = {SIZE};
8282
size_t lRange[] = {SIZE / 10};
83-
void *args[NARGS] = {unwrap<void>(a), (void *)&la};
83+
void *args_1d[NARGS] = {unwrap<void>(a), (void *)&la1};
8484
DPCTLKernelArgType addKernelArgTypes[] = {DPCTL_VOID_PTR,
8585
DPCTL_LOCAL_ACCESSOR};
8686

87-
auto ERef =
88-
DPCTLQueue_SubmitNDRange(kernel, QRef, args, addKernelArgTypes, NARGS,
89-
gRange, lRange, RANGE_NDIMS, nullptr, 0);
90-
ASSERT_TRUE(ERef != nullptr);
91-
DPCTLQueue_Wait(QRef);
87+
DPCTLSyclEventRef E1Ref = DPCTLQueue_SubmitNDRange(
88+
kernel, QRef, args_1d, addKernelArgTypes, NARGS, gRange, lRange,
89+
RANGE_NDIMS, nullptr, 0);
90+
ASSERT_TRUE(E1Ref != nullptr);
91+
92+
DPCTLSyclEventRef DepEv1[] = {E1Ref};
93+
auto la2 = MDLocalAccessor{2, kernelArgTy, SIZE / 10, 1, 1};
94+
void *args_2d[NARGS] = {unwrap<void>(a), (void *)&la2};
95+
96+
DPCTLSyclEventRef E2Ref =
97+
DPCTLQueue_SubmitNDRange(kernel, QRef, args_2d, addKernelArgTypes,
98+
NARGS, gRange, lRange, RANGE_NDIMS, DepEv1, 1);
99+
ASSERT_TRUE(E2Ref != nullptr);
100+
101+
DPCTLSyclEventRef DepEv2[] = {E1Ref, E2Ref};
102+
auto la3 = MDLocalAccessor{3, kernelArgTy, SIZE / 10, 1, 1};
103+
void *args_3d[NARGS] = {unwrap<void>(a), (void *)&la3};
104+
105+
DPCTLSyclEventRef E3Ref =
106+
DPCTLQueue_SubmitNDRange(kernel, QRef, args_3d, addKernelArgTypes,
107+
NARGS, gRange, lRange, RANGE_NDIMS, DepEv2, 2);
108+
ASSERT_TRUE(E3Ref != nullptr);
109+
110+
DPCTLEvent_Wait(E3Ref);
92111

93112
if (kernelArgTy != DPCTL_FLOAT32_T && kernelArgTy != DPCTL_FLOAT64_T)
94113
ASSERT_TRUE(a_ptr[0] == 20);
95114
else
96115
ASSERT_TRUE(a_ptr[0] == 20.0);
97116

98117
// clean ups
99-
DPCTLEvent_Delete(ERef);
118+
DPCTLEvent_Delete(E1Ref);
119+
DPCTLEvent_Delete(E2Ref);
120+
DPCTLEvent_Delete(E3Ref);
100121
DPCTLKernel_Delete(kernel);
101122
DPCTLfree_with_queue((DPCTLSyclUSMRef)a, QRef);
102123
}

0 commit comments

Comments
 (0)