Skip to content

Commit 0006149

Browse files
committed
test
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 51c3417 commit 0006149

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

sycl/test/regression/host_tanpi_double_accuracy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl -fno-fast-math %s -o %t.out
1+
// RUN: %clangxx -fsycl -fno-fast-math -ffp-model=precise %s -o %t.out
22
// RUN: %t.out
33
//
44
// Checks that sycl::tanpi with double has the accuracy required by the

sycl/unittests/assert/assert.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ static AssertHappened ExpectedToOutput = {
147147
static constexpr int KernelLaunchCounterBase = 0;
148148
static constexpr int MemoryMapCounterBase = 1000;
149149
static int MemoryMapCounter = MemoryMapCounterBase;
150+
#ifndef _WIN32
151+
static int KernelLaunchCounter = KernelLaunchCounterBase;
152+
static constexpr int PauseWaitOnIdx = KernelLaunchCounterBase + 1;
153+
#endif
150154

151155
// Mock redifinitions
152156
static ur_result_t redefinedKernelGetGroupInfoAfter(void *pParams) {
@@ -165,6 +169,39 @@ static ur_result_t redefinedKernelGetGroupInfoAfter(void *pParams) {
165169
return UR_RESULT_SUCCESS;
166170
}
167171

172+
#ifndef _WIN32
173+
static ur_result_t redefinedEnqueueKernelLaunchAfter(void *pParams) {
174+
auto params = *static_cast<ur_enqueue_kernel_launch_params_t *>(pParams);
175+
static ur_event_handle_t UserKernelEvent = **params.pphEvent;
176+
int Val = KernelLaunchCounter++;
177+
// This output here is to reduce amount of time requried to debug/reproduce a
178+
// failing test upon feature break
179+
printf("Enqueued %i\n", Val);
180+
181+
if (PauseWaitOnIdx == Val) {
182+
// It should be copier kernel. Check if it depends on user's one.
183+
EXPECT_EQ(*params.pnumEventsInWaitList, 1U);
184+
EXPECT_EQ(*params.pphEventWaitList[0], UserKernelEvent);
185+
}
186+
187+
return UR_RESULT_SUCCESS;
188+
}
189+
190+
static ur_result_t redefinedEventWaitPositive(void *pParams) {
191+
auto params = *static_cast<ur_event_wait_params_t *>(pParams);
192+
// there should be two events: one is for memory map and the other is for
193+
// copier kernel
194+
assert(*params.pnumEvents == 2);
195+
196+
int EventIdx1 = reinterpret_cast<int *>((*params.pphEventWaitList)[0])[0];
197+
int EventIdx2 = reinterpret_cast<int *>((*params.pphEventWaitList)[1])[0];
198+
// This output here is to reduce amount of time requried to debug/reproduce
199+
// a failing test upon feature break
200+
printf("Waiting for events %i, %i\n", EventIdx1, EventIdx2);
201+
return UR_RESULT_SUCCESS;
202+
}
203+
#endif
204+
168205
static ur_result_t redefinedEventWaitNegative(void *pParams) {
169206
auto params = *static_cast<ur_enqueue_events_wait_params_t *>(pParams);
170207
// For negative tests we do not expect the copier kernel to be used, so
@@ -190,6 +227,20 @@ static ur_result_t redefinedEnqueueMemBufferMapAfter(void *pParams) {
190227
return UR_RESULT_SUCCESS;
191228
}
192229

230+
#ifndef _WIN32
231+
static void setupMock(sycl::unittest::UrMock<> &Mock) {
232+
using namespace sycl::detail;
233+
mock::getCallbacks().set_after_callback("urKernelGetGroupInfo",
234+
&redefinedKernelGetGroupInfoAfter);
235+
mock::getCallbacks().set_after_callback("urEnqueueKernelLaunch",
236+
&redefinedEnqueueKernelLaunchAfter);
237+
mock::getCallbacks().set_after_callback("urEnqueueMemBufferMap",
238+
&redefinedEnqueueMemBufferMapAfter);
239+
mock::getCallbacks().set_before_callback("urEventWait",
240+
&redefinedEventWaitPositive);
241+
}
242+
#endif
243+
193244
namespace TestInteropKernel {
194245
const sycl::context *Context = nullptr;
195246
const sycl::device *Device = nullptr;

0 commit comments

Comments
 (0)