Skip to content

Latest commit

 

History

History
153 lines (98 loc) · 7.48 KB

kernel_bundle.asciidoc

File metadata and controls

153 lines (98 loc) · 7.48 KB

Test plan for kernel_bundle (cover gaps)

This is a test plan cover kernel_bundle functionality that is not covered by current tests.

1. Testing scope

Tests intend to cover functions from 4.11. Kernel bundles that are not covered in https://github.com/KhronosGroup/SYCL-CTS/tree/main/tests/kernel_bundle

1.1. Device coverage

All of the tests described below are performed only on the default device that is selected on the CTS command line if not stated otherwise.

2. Tests

2.1. Functions is_compatible

2.1.1. Tests for is_compatible(const std::vector<kernel_id> &kernelIds, const device &dev)

Check that result of function is_compatible(const std::vector<kernel_id> &kernelIds, const device &dev):

  • true for zero kernels

  • true for built-in kernel id for the selected device

  • Construct a vector of the built-in kernel ids from every root device other than the selected device. Check that is_compatible returns false for this vector of kernel ids unless the vector is empty.

  • for kernels with no kernel attributes:

    • true for kernel with no optional features and the selected device

    • true for a kernel that uses sycl::half if and only if the selected device has aspect::fp16.

    • true for a kernel that uses double if and only if the selected device has aspect::fp64.

    • true for a kernel that uses 64-bit atomic operations if and only if the selected device has aspect::atomic64.

  • Define kernels with the following values of the [[sycl::reqd_work_group_size()]] attribute. Verify that is_compatible returns true if and only if the work group size is less than or equal to the value reported by info::device::max_work_item_sizes<1> for the selected device.

    • [[sycl::reqd_work_group_size(8)]]

    • [[sycl::reqd_work_group_size(16)]]

    • [[sycl::reqd_work_group_size(4294967295)]]

  • Define kernels with the following values of the [[sycl::reqd_sub_group_size()]] attribute. Verify that is_compatible returns true if and only if the sub group size is one of the values reported by info::device::sub_group_sizes for the selected device.

    • [[sycl::reqd_work_group_size(8)]]

    • [[sycl::reqd_work_group_size(16)]]

    • [[sycl::reqd_work_group_size(4099)]]

  • for kernels with no optional features used and with [[sycl::device_has()]] kernel attribute

    • true for a kernel decorated with [[sycl::device_has(aspect::fp16)]] if and only if the selected device has that aspect.

    • true for a kernel decorated with [[sycl::device_has(aspect::fp64)]] if and only if the selected device has that aspect.

    • true for a kernel decorated with [[sycl::device_has(aspect::atomic64)]] if and only if the selected device has that aspect.

  • for multiple kernels result is equal to AND operation applied to the multiple calls - each one using single kernel id

    • Check with vector with built-in kernel ids and with the selected device - should return true

    • To previous vector add kernel id with large [[sycl::reqd_work_group_size(4294967295)]] attribute and with the selected device - should return false if value reported by info::device::max_work_item_sizes<1> is less than 4294967295.

2.1.2. Tests for template<typename KernelName> bool is_compatible(const device &dev)

Same tests as previous section except no zero, built-in and multiple kernels cases.

2.2. sycl::kernel_bundle API

2.2.1. Deleted default constructor

Check that std::is_default_constructible_v<sycl::kernel_bundle> is false.

2.2.2. Test for get_backend()

Call function kernel_bundle::get_backend() and check that return type is sycl::backend.

2.2.3. Tests for get_devices()

  • Create a 1-element std::vector<device> containing the selected device.

  • Create kernel_bundle via get_kernel_bundle<bundle_state::executable>(const context&, const std::vector<device>&).

  • Call get_devices().

  • Check that return type is std::vector<device>.

  • Check that return vector contains only selected device.

2.2.4. has_kernel(const kernel_id &kernelId, const device &dev)

  • Create a kernel bundle by calling get_kernel_bundle<bundle_state::executable>(const context &).

  • Iterate over all of the kernel ids returned by get_kernel_ids().

  • Verify that has_kernel(kernelId, dev) returns true if and only if is_compatible({kernelId}, const device&) for selected device is true.

2.2.5. template <typename KernelName> bool has_kernel()

  • Define kernel with KernelName.

  • Get a kernel bundle in executable state that contains this kernel via get_kernel_bundle<KernelName, bundle_state::executable>(const context &).

  • Verify that has_kernel<KernelName>() returns true.

2.2.6. template <typename KernelName> bool has_kernel(const device &dev)

  • Define kernel with KernelName.

  • Get a kernel bundle in executable state that contains this kernel via get_kernel_bundle<KernelName, bundle_state::executable>(const context &).

  • Verify that has_kernel<KernelName>(dev) returns true if and only if is_compatible<KernelName>(const device&) for selected device is true.

2.2.7. std::vector<kernel_id> get_kernel_ids()

Define 4 kernels. Get kernel_bundle via get_kernel_bundle<bundle_state::executable>(const context &) Check that result of get_kernel_ids:

  • has type std::vector<kernel_id>

  • has size at least 4

  • has only different kernel ids

2.2.8. get_kernel()

  • Define kernel KernelName.

  • Get a kernel bundle in executable state that contains this kernel via get_kernel_bundle<KernelName, bundle_state::executable>(const context &).

  • Use get_kernel<KernelName>() to get kernel and check that return type is sycl::kernel.

2.3. Tests for working with specialization constants

There are two spec constant defined: SpecName and OtherSpecName. kernel_handler::get_specialization_constant<OtherSpecName>() shouldn’t be used in any kernel in the application.

2.3.1. Empty kernel bundle

  • Get an empty kernel bundle by calling get_kernel_bundle<bundle_state::executable>(const context &, const std::vector<device> &, Selector) where Selector is a function that always returns false.

  • Check that contains_specialization_constants() return false.

  • Check that native_specialization_constant() return false.

  • Check that has_specialization_constant<SpecName>() return false.

2.3.2. Kernel bundle with kernel_handler::get_specialization_constant() call

  • Define a kernel named KernelName that calls kernel_handler::get_specialization_constant<SpecName>().

  • Attempt to get a kernel bundle in input state that contains this kernel by calling get_kernel_bundle<KernelName, bundle_state::input>(const context &, const std::vector<device>& ) with 1-element std::vector<device> containing the selected device.

  • Test if the kernel bundle contains that kernel by calling kernel_bundle::has_kernel<KernelName(). If this returns false, the test is skipped.

  • Set each spec constant to a different value via kernel_bundle::set_specialization_constant().

  • Check that contains_specialization_constants() return true.

  • Check that called native_specialization_constant() without exception.

  • Check that has_specialization_constant<SpecName>() return true.

  • Check that has_specialization_constant<OtherSpecName>() return false.

  • Check that get_specialization_constant<SpecName>() return new value.

  • Call compile() to build the kernel_bundle into object state.

  • Check the same.

  • Call link() to build the kernel_bundle into executable state.

  • Check the same.