Skip to content

Commit

Permalink
Merge pull request #497 from IntelPython/improve-coverage-test-sycl-q…
Browse files Browse the repository at this point in the history
…ueue-interface

Extend parameterized test in test_sycl_queue_interface
  • Loading branch information
Diptorup Deb authored Jun 24, 2021
2 parents 48a5bb1 + 2f38551 commit 521d277
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
37 changes: 27 additions & 10 deletions dpctl-capi/tests/test_sycl_queue_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,30 @@ namespace
{
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(queue, DPCTLSyclQueueRef);

void error_handler_fn(int /*err*/)
{
return;
}

struct TestDPCTLQueueMemberFunctions
: public ::testing::TestWithParam<const char *>
: public ::testing::TestWithParam<
std::tuple<const char *, DPCTLQueuePropertyType, bool>>
{
protected:
DPCTLSyclQueueRef QRef = nullptr;

TestDPCTLQueueMemberFunctions()
{
auto DS = DPCTLFilterSelector_Create(GetParam());
auto param_tuple = GetParam();
auto DS = DPCTLFilterSelector_Create(std::get<0>(param_tuple));
DPCTLSyclDeviceRef DRef = nullptr;
if (DS) {
EXPECT_NO_FATAL_FAILURE(DRef = DPCTLDevice_CreateFromSelector(DS));
EXPECT_NO_FATAL_FAILURE(QRef = DPCTLQueue_CreateForDevice(
DRef, nullptr, DPCTL_DEFAULT_PROPERTY));
EXPECT_NO_FATAL_FAILURE(
QRef = DPCTLQueue_CreateForDevice(
DRef,
(std::get<2>(param_tuple)) ? &error_handler_fn : nullptr,
std::get<1>(param_tuple)));
}
DPCTLDevice_Delete(DRef);
DPCTLDeviceSelector_Delete(DS);
Expand All @@ -63,8 +73,9 @@ struct TestDPCTLQueueMemberFunctions
void SetUp()
{
if (!QRef) {
auto param_tuple = GetParam();
auto message = "Skipping as no device of type " +
std::string(GetParam()) + ".";
std::string(std::get<0>(param_tuple)) + ".";
GTEST_SKIP_(message.c_str());
}
}
Expand Down Expand Up @@ -284,8 +295,14 @@ TEST_P(TestDPCTLQueueMemberFunctions, CheckGetDevice)
EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(D));
}

INSTANTIATE_TEST_SUITE_P(DPCTLQueueMemberFuncTests,
TestDPCTLQueueMemberFunctions,
::testing::Values("opencl:gpu:0",
"opencl:cpu:0",
"level_zero:gpu:0"));
INSTANTIATE_TEST_SUITE_P(
DPCTLQueueMemberFuncTests,
TestDPCTLQueueMemberFunctions,
::testing::Combine(
::testing::Values("opencl:gpu", "opencl:cpu", "level_zero:gpu"),
::testing::Values(DPCTL_DEFAULT_PROPERTY,
DPCTL_ENABLE_PROFILING,
DPCTL_IN_ORDER,
static_cast<DPCTLQueuePropertyType>(
DPCTL_ENABLE_PROFILING | DPCTL_IN_ORDER)),
::testing::Bool()));
9 changes: 9 additions & 0 deletions dpctl-capi/tests/test_sycl_usm_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ void common_test_body(size_t nbytes,
EXPECT_TRUE(DPCTLDevice_AreEq(Dev, QueueDev));

EXPECT_NO_FATAL_FAILURE(DPCTLQueue_Prefetch(Q, Ptr, nbytes));
EXPECT_NO_FATAL_FAILURE(DPCTLQueue_MemAdvise(Q, Ptr, nbytes, 0));

try {
unsigned short *host_ptr = new unsigned short[nbytes];
EXPECT_NO_FATAL_FAILURE(DPCTLQueue_Memcpy(Q, host_ptr, Ptr, nbytes));
delete[] host_ptr;
} catch (std::bad_alloc const &ba) {
// pass
}

DPCTLDevice_Delete(QueueDev);
DPCTLDevice_Delete(Dev);
Expand Down

0 comments on commit 521d277

Please sign in to comment.