Skip to content

Commit e4ff9a4

Browse files
committed
fix unit test to call pipe read/write directly
1 parent a9c58f6 commit e4ff9a4

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

sycl/include/sycl/handler.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ class __copyAcc2Acc;
8686

8787
// For unit testing purposes
8888
class MockHandler;
89-
class PipeTest_Basic_Test;
9089

9190
namespace sycl {
9291
__SYCL_INLINE_VER_NAMESPACE(_V1) {
@@ -2901,7 +2900,6 @@ class __SYCL_EXPORT handler {
29012900
template <class _name, class _dataT, int32_t _min_capacity,
29022901
class _propertiesT, class>
29032902
friend class ext::intel::experimental::pipe;
2904-
friend class ::PipeTest_Basic_Test;
29052903

29062904
/// Read from a host pipe given a host address and
29072905
/// \param Name name of the host pipe to be passed into lower level runtime

sycl/unittests/pipes/host_pipe_registration.cpp

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,26 @@ pi_result redefinedEnqueueWriteHostPipe(pi_queue, pi_program, const char *,
9191
return PI_SUCCESS;
9292
}
9393

94+
pi_result after_piDeviceGetInfo(pi_device device, pi_device_info param_name,
95+
size_t param_value_size, void *param_value,
96+
size_t *param_value_size_ret) {
97+
constexpr char MockSupportedExtensions[] =
98+
"cl_khr_fp64 cl_khr_fp16 cl_khr_il_program cl_intel_program_scope_host_pipe";
99+
switch (param_name) {
100+
case PI_DEVICE_INFO_EXTENSIONS: {
101+
if (param_value) {
102+
assert(param_value_size >= sizeof(MockSupportedExtensions));
103+
std::memcpy(param_value, MockSupportedExtensions,
104+
sizeof(MockSupportedExtensions));
105+
}
106+
if (param_value_size_ret)
107+
*param_value_size_ret = sizeof(MockSupportedExtensions);
108+
return PI_SUCCESS;
109+
}
110+
}
111+
return PI_SUCCESS;
112+
}
113+
94114
void preparePiMock(unittest::PiMock &Mock) {
95115
Mock.redefine<detail::PiApiKind::piextEnqueueReadHostPipe>(
96116
redefinedEnqueueReadHostPipe);
@@ -120,32 +140,20 @@ class PipeTest : public ::testing::Test {
120140
};
121141

122142
TEST_F(PipeTest, Basic) {
143+
// Fake extension
144+
Mock.redefineAfter<sycl::detail::PiApiKind::piDeviceGetInfo>(after_piDeviceGetInfo);
123145

124146
// Device registration
125147
static sycl::unittest::PiImage Img = generateDefaultImage();
126148
static sycl::unittest::PiImageArray<1> ImgArray{&Img};
127149

128-
// Get the hostpipe
129-
const void *HostPipePtr = Pipe::get_host_ptr();
130-
detail::HostPipeMapEntry *HostPipeEntry =
131-
detail::ProgramManager::getInstance().getHostPipeEntry(HostPipePtr);
132-
const std::string PipeName = HostPipeEntry->MUniqueId;
133-
134-
// Testing read
150+
//Testing read
135151
int HostPipeReadData;
136-
void *DataPtrRead = &HostPipeReadData;
137-
event ERead = q.submit([=](handler &CGH) {
138-
CGH.ext_intel_read_host_pipe(PipeName, DataPtrRead, sizeof(int), true /* blocking */);
139-
});
140-
ERead.wait();
152+
HostPipeReadData = Pipe::read(q);
141153
assert(HostPipeReadData == PipeReadVal);
142154

143155
// Testing write
144156
int HostPipeWriteData = 9;
145-
void *DataPtrWrite = &HostPipeWriteData;
146-
event EWrite = q.submit([=](handler &CGH) {
147-
CGH.ext_intel_write_host_pipe(PipeName, DataPtrWrite, sizeof(int), true/* blocking */);
148-
});
149-
EWrite.wait();
157+
Pipe::write(q,HostPipeWriteData);
150158
assert(PipeWriteVal == 9);
151159
}

0 commit comments

Comments
 (0)