Skip to content

Commit

Permalink
[tests] Avoid extra sycl::buffer tests (#1656)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyKopienko authored Jul 2, 2024
1 parent 497ca45 commit b47ff69
Showing 1 changed file with 43 additions and 16 deletions.
59 changes: 43 additions & 16 deletions test/support/utils_sycl.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ sycl::queue get_test_queue()
return my_queue;
}

template <sycl::usm::alloc alloc_type, typename TestValueType, typename TestName>
template <sycl::usm::alloc alloc_type>
constexpr bool
required_test_sycl_buffer()
{
return alloc_type == sycl::usm::alloc::shared;
}

template <sycl::usm::alloc alloc_type, typename TestValueType, typename TestName,
bool TestSyclBuffer = required_test_sycl_buffer<alloc_type>()>
void
test1buffer(float ScaleStep = 1.0f, float ScaleMax = 1.0f)
{
Expand Down Expand Up @@ -140,7 +148,10 @@ test1buffer(float ScaleStep = 1.0f, float ScaleMax = 1.0f)
}
}
#endif
{ // sycl::buffer

if constexpr (TestSyclBuffer)
{
// sycl::buffer
// 1. create buffers
using TestBaseData = test_base_data_buffer<TestValueType>;
TestBaseData test_base_data({ { local_max_n, inout1_offset } });
Expand All @@ -161,7 +172,8 @@ test1buffer(float ScaleStep = 1.0f, float ScaleMax = 1.0f)
}
}

template <sycl::usm::alloc alloc_type, typename TestValueType, typename TestName>
template <sycl::usm::alloc alloc_type, typename TestValueType, typename TestName,
bool TestSyclBuffer = required_test_sycl_buffer<alloc_type>()>
void
test2buffers(float ScaleStep = 1.0f, float ScaleMax = 1.0f)
{
Expand Down Expand Up @@ -194,7 +206,10 @@ test2buffers(float ScaleStep = 1.0f, float ScaleMax = 1.0f)
}
}
#endif
{ // sycl::buffer

if constexpr (TestSyclBuffer)
{
// sycl::buffer
// 1. create buffers
using TestBaseData = test_base_data_buffer<TestValueType>;
TestBaseData test_base_data({ { local_max_n, inout1_offset },
Expand All @@ -218,7 +233,8 @@ test2buffers(float ScaleStep = 1.0f, float ScaleMax = 1.0f)
}
}

template <sycl::usm::alloc alloc_type, typename TestValueType, typename TestName>
template <sycl::usm::alloc alloc_type, typename TestValueType, typename TestName,
bool TestSyclBuffer = required_test_sycl_buffer<alloc_type>()>
void
test3buffers(int mult = kDefaultMultValue, float ScaleStep = 1.0f, float ScaleMax = 1.0f)
{
Expand Down Expand Up @@ -255,7 +271,10 @@ test3buffers(int mult = kDefaultMultValue, float ScaleStep = 1.0f, float ScaleMa
}
}
#endif
{ // sycl::buffer

if constexpr (TestSyclBuffer)
{
// sycl::buffer
// 1. create buffers
using TestBaseData = test_base_data_buffer<TestValueType>;
TestBaseData test_base_data({ { local_max_n, inout1_offset },
Expand All @@ -282,7 +301,8 @@ test3buffers(int mult = kDefaultMultValue, float ScaleStep = 1.0f, float ScaleMa
}
}

template <sycl::usm::alloc alloc_type, typename TestValueType, typename TestName>
template <sycl::usm::alloc alloc_type, typename TestValueType, typename TestName,
bool TestSyclBuffer = required_test_sycl_buffer<alloc_type>()>
void
test4buffers(int mult = kDefaultMultValue, float ScaleStep = 1.0f, float ScaleMax = 1.0f)
{
Expand Down Expand Up @@ -322,7 +342,10 @@ test4buffers(int mult = kDefaultMultValue, float ScaleStep = 1.0f, float ScaleMa
}
}
#endif
{ // sycl::buffer

if constexpr (TestSyclBuffer)
{
// sycl::buffer
// 1. create buffers
using TestBaseData = test_base_data_buffer<TestValueType>;
TestBaseData test_base_data({ { local_max_n, inout1_offset },
Expand Down Expand Up @@ -352,32 +375,36 @@ test4buffers(int mult = kDefaultMultValue, float ScaleStep = 1.0f, float ScaleMa
}
}

template <sycl::usm::alloc alloc_type, typename TestName>
template <sycl::usm::alloc alloc_type, typename TestName,
bool TestSyclBuffer = required_test_sycl_buffer<alloc_type>()>
::std::enable_if_t<::std::is_base_of_v<test_base<typename TestName::UsedValueType>, TestName>>
test1buffer()
{
test1buffer<alloc_type, typename TestName::UsedValueType, TestName>(TestName::ScaleStep, TestName::ScaleMax);
test1buffer<alloc_type, typename TestName::UsedValueType, TestName, TestSyclBuffer>(TestName::ScaleStep, TestName::ScaleMax);
}

template <sycl::usm::alloc alloc_type, typename TestName>
template <sycl::usm::alloc alloc_type, typename TestName,
bool TestSyclBuffer = required_test_sycl_buffer<alloc_type>()>
::std::enable_if_t<::std::is_base_of_v<test_base<typename TestName::UsedValueType>, TestName>>
test2buffers()
{
test2buffers<alloc_type, typename TestName::UsedValueType, TestName>(TestName::ScaleStep, TestName::ScaleMax);
test2buffers<alloc_type, typename TestName::UsedValueType, TestName, TestSyclBuffer>(TestName::ScaleStep, TestName::ScaleMax);
}

template <sycl::usm::alloc alloc_type, typename TestName>
template <sycl::usm::alloc alloc_type, typename TestName,
bool TestSyclBuffer = required_test_sycl_buffer<alloc_type>()>
::std::enable_if_t<::std::is_base_of_v<test_base<typename TestName::UsedValueType>, TestName>>
test3buffers(int mult = kDefaultMultValue)
{
test3buffers<alloc_type, typename TestName::UsedValueType, TestName>(mult, TestName::ScaleStep, TestName::ScaleMax);
test3buffers<alloc_type, typename TestName::UsedValueType, TestName, TestSyclBuffer>(mult, TestName::ScaleStep, TestName::ScaleMax);
}

template <sycl::usm::alloc alloc_type, typename TestName>
template <sycl::usm::alloc alloc_type, typename TestName,
bool TestSyclBuffer = required_test_sycl_buffer<alloc_type>()>
::std::enable_if_t<::std::is_base_of_v<test_base<typename TestName::UsedValueType>, TestName>>
test4buffers(int mult = kDefaultMultValue)
{
test4buffers<alloc_type, typename TestName::UsedValueType, TestName>(mult, TestName::ScaleStep, TestName::ScaleMax);
test4buffers<alloc_type, typename TestName::UsedValueType, TestName, TestSyclBuffer>(mult, TestName::ScaleStep, TestName::ScaleMax);
}

} /* namespace TestUtils */
Expand Down

0 comments on commit b47ff69

Please sign in to comment.