oneDPL icon indicating copy to clipboard operation
oneDPL copied to clipboard

Simplify `new_kernel_name` implementation in tests

Open SergeyKopienko opened this issue 10 months ago • 4 comments

In this PR we simplify new_kernel_name implementation in tests. The goal - to make generated new Kernel names more short and simple.

Example

Let's take a look to the code (for example):

auto new_policy = make_new_policy<new_kernel_name<Policy, 0>>(exec);
  • before this PR, the type of new_policy is
oneapi::dpl::execution::__dpl::device_policy<TestUtils::unique_kernel_name<oneapi::dpl::execution::__dpl::device_policy<TestUtils::unique_kernel_name<test_binary_search<unsigned long long>,0>>,0>>
  • after this PR, the type of new_policy is
oneapi::dpl::execution::__dpl::device_policy<TestUtils::unique_kernel_name<TestUtils::unique_kernel_name<test_binary_search<unsigned long long>,0>,0>>

SergeyKopienko avatar Mar 13 '25 12:03 SergeyKopienko

Is there a reason there are 2 nested copies of TestUtils::unique_kernel_name here? Are they redundant? If we change the number from 0 to 1, in your code, do both copies of the TestUtils::unique_kernel_name change their number? If so, there is some other issue we can fix I think.

danhoeflinger avatar Mar 13 '25 15:03 danhoeflinger

Is there a reason there are 2 nested copies of TestUtils::unique_kernel_name here? Are they redundant? If we change the number from 0 to 1, in your code, do both copies of the TestUtils::unique_kernel_name change their number? If so, there is some other issue we can fix I think.

In any case now new_kernel_name is implemented in this PR exactly as

template <typename Policy>
using __policy_kernel_name = typename ::std::decay_t<Policy>::kernel_name;

SergeyKopienko avatar Mar 13 '25 16:03 SergeyKopienko

In any case now new_kernel_name is implemented in this PR exactly as

template <typename Policy>
using __policy_kernel_name = typename ::std::decay_t<Policy>::kernel_name;

Yes, but in your "after" result, we still have 2 nested TestUtils::unique_kernel_name. Perhaps that is because of nesting in the test function you are using to generate the "before" and "after", and is required and intentional.

danhoeflinger avatar Mar 13 '25 16:03 danhoeflinger

In any case now new_kernel_name is implemented in this PR exactly as

template <typename Policy>
using __policy_kernel_name = typename ::std::decay_t<Policy>::kernel_name;

Yes, but in your "after" result, we still have 2 nested TestUtils::unique_kernel_name. Perhaps that is because of nesting in the test function you are using to generate the "before" and "after", and is required and intentional.

As example I have used the policy creation at https://github.com/uxlfoundation/oneDPL/blob/f5bd154b25efbe096ecb4d95e938309ebec2637e/test/parallel_api/algorithm/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp#L74 :

auto new_policy = make_new_policy<new_kernel_name<Policy, 0>>(exec);

at this point the type of exec is oneapi::dpl::execution::__dpl::device_policy<TestUtils::unique_kernel_name<test_binary_search<unsigned long long>,0>> & and the type of new_policy is oneapi::dpl::execution::__dpl::device_policy<TestUtils::unique_kernel_name<TestUtils::unique_kernel_name<test_binary_search<unsigned long long>,0>,0>>

So I think it's the question for test environment staff, not for new_kernel_name :

  • this type name starts from
template <::std::size_t CallNumber = 0>
struct invoke_on_all_hetero_policies::operator()(Op op, Args&&... rest)

SergeyKopienko avatar Mar 13 '25 16:03 SergeyKopienko