From 778645c11e707776ed6574e2ed78bdb05a00be72 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Tue, 9 Jul 2024 09:29:17 +0000 Subject: [PATCH] feature: add initial support for Xe2 platforms Related-To: NEO-8188, NEO-10774 Signed-off-by: Mateusz Jablonski --- CMakeLists.txt | 5 +- cmake/fill_core_types.cmake | 4 +- cmake/setup_platform_flags.cmake | 46 + level_zero/core/source/cmdlist/CMakeLists.txt | 6 + .../cmdlist/cmdlist_hw_xe2_hpg_and_later.inl | 64 + .../source/gfx_core_helpers/CMakeLists.txt | 6 + .../l0_gfx_core_helper_xe2_hpg_and_later.inl | 38 + .../core/source/xe2_hpg_core/CMakeLists.txt | 19 + .../source/xe2_hpg_core/bmg/CMakeLists.txt | 17 + .../source/xe2_hpg_core/bmg/cmdlist_bmg.cpp | 21 + .../source/xe2_hpg_core/bmg/cmdqueue_bmg.cpp | 20 + .../source/xe2_hpg_core/bmg/image_bmg.cpp | 23 + .../source/xe2_hpg_core/bmg/kernel_bmg.cpp | 17 + .../source/xe2_hpg_core/bmg/sampler_bmg.cpp | 22 + .../xe2_hpg_core/cmdlist_xe2_hpg_core.cpp | 24 + .../xe2_hpg_core/cmdlist_xe2_hpg_core.h | 24 + .../enable_family_full_l0_xe2_hpg_core.cpp | 24 + .../xe2_hpg_core/image_xe2_hpg_core.inl | 11 + .../l0_gfx_core_helper_xe2_hpg_core.cpp | 211 ++++ .../source/xe2_hpg_core/lnl/CMakeLists.txt | 17 + .../source/xe2_hpg_core/lnl/cmdlist_lnl.cpp | 21 + .../source/xe2_hpg_core/lnl/cmdqueue_lnl.cpp | 20 + .../source/xe2_hpg_core/lnl/image_lnl.cpp | 23 + .../source/xe2_hpg_core/lnl/kernel_lnl.cpp | 17 + .../source/xe2_hpg_core/lnl/sampler_lnl.cpp | 22 + .../unit_tests/sources/cmdlist/CMakeLists.txt | 6 + .../cmdlist/test_cmdlist_xe2_and_later.cpp | 387 ++++++ .../unit_tests/xe2_hpg_core/CMakeLists.txt | 16 + .../test_cmdlist_xe2_hpg_core.cpp | 460 ++++++++ .../test_cmdqueue_xe2_hpg_core.cpp | 84 ++ .../xe2_hpg_core/test_device_xe2_hpg_core.cpp | 293 +++++ .../test_l0_gfx_core_helper_xe2_hpg_core.cpp | 139 +++ .../xe2_hpg_core/test_module_xe2_hpg_core.cpp | 116 ++ .../xe2_hpg_core/CMakeLists.txt | 7 + .../xe2_hpg_core/bmg/CMakeLists.txt | 14 + .../bmg/enable_sysman_product_helper_bmg.cpp | 16 + .../bmg/sysman_product_helper_bmg.cpp | 30 + .../xe2_hpg_core/lnl/CMakeLists.txt | 14 + .../lnl/enable_sysman_product_helper_lnl.cpp | 16 + .../lnl/sysman_product_helper_lnl.cpp | 30 + .../xe2_hpg_core/CMakeLists.txt | 7 + .../xe2_hpg_core/bmg/CMakeLists.txt | 14 + .../bmg/enable_sysman_product_helper_bmg.cpp | 16 + .../bmg/sysman_product_helper_bmg.cpp | 501 ++++++++ .../xe2_hpg_core/lnl/CMakeLists.txt | 14 + .../lnl/enable_sysman_product_helper_lnl.cpp | 16 + .../lnl/sysman_product_helper_lnl.cpp | 18 + .../sources/debug/xe2_hpg_core/CMakeLists.txt | 12 + .../debug_session_tests_xe2_hpg_core.cpp | 94 ++ .../linux/test_metric_ip_sampling_linux.cpp | 4 +- manifests/manifest.yml | 2 +- opencl/source/xe2_hpg_core/CMakeLists.txt | 15 + .../xe2_hpg_core/buffer_xe2_hpg_core.cpp | 20 + .../cl_gfx_core_helper_xe2_hpg_core.cpp | 35 + .../command_queue_xe2_hpg_core.cpp | 42 + .../enable_family_full_ocl_xe2_hpg_core.cpp | 32 + .../gpgpu_walker_xe2_hpg_core.cpp | 31 + .../xe2_hpg_core/gtpin_setup_xe2_hpg_core.cpp | 40 + .../hardware_commands_helper_xe2_hpg_core.cpp | 19 + .../xe2_hpg_core/image_xe2_hpg_core.cpp | 21 + .../xe2_hpg_core/sampler_xe2_hpg_core.cpp | 11 + .../aub_tests/xe2_hpg_core/CMakeLists.txt | 17 + .../aub_mem_dump_tests_xe2_hpg_core.cpp | 17 + .../aub_tests_excludes_xe2_hpg_core.cpp | 13 + .../aub_tests/xe2_hpg_core/bmg/CMakeLists.txt | 12 + .../bmg/aub_tests_excludes_bmg.cpp | 13 + .../copy_engine_aub_tests_xe2_hpg_core.cpp | 85 ++ .../enqueue_kernel_aub_tests_xe2_hpg_core.cpp | 49 + .../aub_tests/xe2_hpg_core/lnl/CMakeLists.txt | 12 + .../lnl/copy_engine_aub_tests_lnl.cpp | 66 ++ ...system_memfence_aub_tests_xe2_hpg_core.cpp | 172 +++ .../unit_test/command_stream/CMakeLists.txt | 6 + ...stream_receiver_hw_tests_xe2_and_later.cpp | 40 + .../unit_test/xe2_hpg_core/CMakeLists.txt | 35 + .../unit_test/xe2_hpg_core/bmg/CMakeLists.txt | 16 + .../bmg/device_info_tests_bmg.cpp | 31 + .../xe2_hpg_core/bmg/linux/CMakeLists.txt | 9 + .../xe2_hpg_core/bmg/linux/dll/CMakeLists.txt | 12 + .../bmg/linux/dll/device_id_tests_bmg.cpp | 22 + .../bmg/test_cl_device_caps_bmg.cpp | 27 + .../cl_gfx_core_helper_tests_xe2_hpg_core.cpp | 34 + .../cmd_parse_tests_xe2_hpg_core.cpp | 61 + ..._stream_receiver_hw_tests_xe2_hpg_core.cpp | 1033 +++++++++++++++++ .../copy_engine_tests_xe2_hpg_core.cpp | 195 ++++ .../dispatch_walker_tests_xe2_hpg_core.cpp | 44 + .../enqueue_tests_xe2_hpg_core.cpp | 172 +++ .../excludes_ocl_xe2_hpg_core.cpp | 23 + .../unit_test/xe2_hpg_core/lnl/CMakeLists.txt | 16 + .../lnl/device_info_tests_lnl.cpp | 31 + .../xe2_hpg_core/lnl/linux/CMakeLists.txt | 9 + .../xe2_hpg_core/lnl/linux/dll/CMakeLists.txt | 11 + .../lnl/linux/dll/device_id_tests_lnl.cpp | 20 + .../lnl/test_cl_device_caps_lnl.cpp | 27 + .../test_cl_device_caps_xe2_hpg_core.cpp | 58 + .../test_cmds_programming_xe2_hpg_core.cpp | 109 ++ .../test_platform_caps_xe2_hpg_core.cpp | 31 + .../test_preamble_xe2_hpg_core.cpp | 45 + .../test_preemption_xe2_hpg_core.cpp | 38 + .../xe2_hpg_core/test_sample_xe2_hpg_core.cpp | 21 + shared/offline_compiler/source/CMakeLists.txt | 1 + .../bmg/ail_configuration_bmg.cpp | 16 + .../bmg/definitions/ail_configuration_bmg.inl | 6 + .../lnl/ail_configuration_lnl.cpp | 16 + .../lnl/definitions/ail_configuration_lnl.inl | 6 + .../aub_mem_dump/definitions/aub_services.h | 4 +- .../source/command_container/CMakeLists.txt | 6 + ...command_encoder_xe2_hpg_core_and_later.inl | 12 + shared/source/command_stream/CMakeLists.txt | 6 + .../preemption_xe2_and_later.inl | 16 + .../debug_settings/debug_variables_base.inl | 4 + shared/source/dll/devices/devices_base.inl | 15 + .../dll/devices/product_config_base.inl | 13 + shared/source/gen_common/aub_mapper_common.h | 5 +- shared/source/helpers/CMakeLists.txt | 8 + ...piler_product_helper_xe2_hpg_and_later.inl | 20 + .../definitions/device_ids_configs_base.h | 9 + shared/source/helpers/definitions/hw_cmds.h | 5 +- .../helpers/gfx_core_helper_xe2_and_later.inl | 48 + .../helpers/preamble_xe2_hpg_and_later.inl | 55 + shared/source/os_interface/CMakeLists.txt | 1 + .../product_helper_xe2_and_later.inl | 138 +++ shared/source/xe2_hpg_core/CMakeLists.txt | 10 + ...b_command_stream_receiver_xe2_hpg_core.cpp | 27 + shared/source/xe2_hpg_core/aub_mapper.h | 31 + .../aub_mem_dump_xe2_hpg_core.cpp | 20 + .../bmg/definitions/device_ids_configs_bmg.h | 14 + .../bmg/os_agnostic_product_helper_bmg.inl | 48 + .../command_encoder_xe2_hpg_core.cpp | 343 ++++++ ...ommand_stream_receiver_hw_xe2_hpg_core.cpp | 325 ++++++ ...eiver_simulated_common_hw_xe2_hpg_core.cpp | 35 + ...e_command_stream_receiver_xe2_hpg_core.cpp | 24 + .../xe2_hpg_core/debugger_xe2_hpg_core.cpp | 25 + ...fx_core_helper_xe2_hpg_core_additional.inl | 6 + .../enable_compiler_product_helper_bmg.cpp | 27 + .../enable_compiler_product_helper_lnl.cpp | 27 + .../enable_family_full_core_xe2_hpg_core.cpp | 34 + .../enable_product_helper_bmg.cpp | 17 + .../enable_product_helper_lnl.cpp | 17 + .../xe2_hpg_core/enable_xe2_hpg_core.cpp | 26 + .../gfx_core_helper_xe2_hpg_core.cpp | 412 +++++++ shared/source/xe2_hpg_core/hw_cmds.h | 18 + shared/source/xe2_hpg_core/hw_cmds_bmg.h | 37 + shared/source/xe2_hpg_core/hw_cmds_lnl.h | 37 + shared/source/xe2_hpg_core/hw_info.h | 16 + shared/source/xe2_hpg_core/hw_info_bmg.cpp | 137 +++ shared/source/xe2_hpg_core/hw_info_bmg.h | 23 + shared/source/xe2_hpg_core/hw_info_lnl.cpp | 134 +++ shared/source/xe2_hpg_core/hw_info_lnl.h | 23 + .../xe2_hpg_core/hw_info_xe2_hpg_core.cpp | 12 + .../xe2_hpg_core/hw_info_xe2_hpg_core.h | 20 + .../xe2_hpg_core/image_core_xe2_hpg_core.cpp | 16 + .../implicit_scaling_xe2_hpg_core.cpp | 29 + .../command_stream_receiver_xe2_hpg_core.cpp | 18 + .../linux/direct_submission_xe2_hpg_core.cpp | 30 + .../xe2_hpg_core/linux/hw_info_extra_bmg.cpp | 17 + .../xe2_hpg_core/linux/hw_info_extra_lnl.cpp | 17 + .../xe2_hpg_core/linux/product_helper_bmg.cpp | 37 + .../xe2_hpg_core/linux/product_helper_lnl.cpp | 39 + .../xe2_hpg_core/lnl/device_ids_configs_lnl.h | 14 + .../lnl/os_agnostic_product_helper_lnl.inl | 117 ++ ...s_agnostic_product_helper_xe2_hpg_core.inl | 42 + .../xe2_hpg_core/preamble_xe2_hpg_core.cpp | 22 + .../xe2_hpg_core/preemption_xe2_hpg_core.cpp | 56 + .../state_base_address_xe2_hpg_core.cpp | 18 + ...x_command_stream_receiver_xe2_hpg_core.cpp | 32 + .../command_stream_receiver_xe2_hpg_core.cpp | 18 + .../direct_submission_xe2_hpg_core.cpp | 30 + .../windows/gmm_callbacks_xe2_hpg_core.cpp | 16 + .../windows/hw_info_extra_bmg.cpp | 15 + .../windows/hw_info_extra_lnl.cpp | 15 + .../windows/product_helper_bmg.cpp | 45 + .../windows/product_helper_lnl.cpp | 54 + .../helpers/includes/test_traits_common.h | 3 +- .../unit_test_helper_xe2_and_later.inl | 67 ++ shared/test/common/libult/CMakeLists.txt | 6 + shared/test/common/libult/xe2_hpg_core.cpp | 34 + .../aub_tests/xe2_hpg_core/CMakeLists.txt | 15 + .../aub_tests_configuration_xe2_hpg_core.cpp | 18 + shared/test/common/test_files/igdrcl.config | 4 + .../test_macros/header/common_matchers.h | 7 + .../header/per_product_test_definitions.h | 27 +- .../header/per_product_test_selector.h | 8 +- .../per_product_test_selector_definitions.h | 9 +- .../test/common/xe2_hpg_core/CMakeLists.txt | 12 + .../common/xe2_hpg_core/bmg/CMakeLists.txt | 12 + .../bmg/mock_product_helper_bmg.cpp | 14 + .../xe2_hpg_core/bmg/product_configs_bmg.h | 14 + .../xe2_hpg_core/cmd_parse_xe2_hpg_core.cpp | 151 +++ .../lnl/mock_product_helper_lnl.cpp | 14 + .../xe2_hpg_core/test_traits_xe2_hpg_core.h | 33 + .../unit_test_helper_xe2_hpg_core.cpp | 22 + shared/test/unit_test/encoders/CMakeLists.txt | 6 +- .../command_encoder_tests_xe2_and_later.cpp | 65 ++ shared/test/unit_test/helpers/CMakeLists.txt | 6 + .../helpers/gfx_core_helper_xe2_and_later.cpp | 123 ++ shared/test/unit_test/preamble/CMakeLists.txt | 8 +- .../preamble/test_preamble_xe2_and_later.cpp | 114 ++ .../test/unit_test/preemption/CMakeLists.txt | 8 +- .../test_preemption_xe2_and_later.cpp | 141 +++ .../unit_test/xe2_hpg_core/CMakeLists.txt | 32 + ...using_aubstream_lib_tests_xe2_hpg_core.cpp | 114 ++ ...d_stream_receiver_2_tests_xe2_hpg_core.cpp | 52 + .../unit_test/xe2_hpg_core/bmg/CMakeLists.txt | 20 + .../bmg/engine_node_helper_tests_bmg.cpp | 46 + .../bmg/excludes_xe2_hpg_core_bmg.cpp | 10 + .../bmg/gfx_core_helper_tests_bmg.cpp | 46 + .../bmg/hw_aot_config_tests_bmg.cpp | 17 + .../xe2_hpg_core/bmg/hw_info_tests_bmg.cpp | 119 ++ .../xe2_hpg_core/bmg/linux/CMakeLists.txt | 9 + .../linux/product_helper_tests_bmg_linux.cpp | 96 ++ .../bmg/product_helper_tests_bmg.cpp | 100 ++ .../xe2_hpg_core/bmg/test_device_caps_bmg.cpp | 31 + .../xe2_hpg_core/bmg/windows/CMakeLists.txt | 9 + .../product_helper_tests_bmg_windows.cpp | 26 + .../compute_mode_tests_xe2_hpg_core.cpp | 326 ++++++ .../xe2_hpg_core/excludes_xe2_hpg_core.cpp | 39 + .../gfx_core_helper_tests_xe2_hpg_core.cpp | 749 ++++++++++++ .../hw_cmds_xe2_hpg_core_tests.cpp | 165 +++ ...image_surface_state_tests_xe2_hpg_core.cpp | 48 + .../unit_test/xe2_hpg_core/lnl/CMakeLists.txt | 19 + .../lnl/engine_node_helper_tests_lnl.cpp | 46 + .../lnl/excludes_xe2_hpg_core_lnl.cpp | 11 + .../lnl/gfx_core_helper_tests_lnl.cpp | 33 + .../xe2_hpg_core/lnl/hw_info_tests_lnl.cpp | 110 ++ .../xe2_hpg_core/lnl/linux/CMakeLists.txt | 9 + .../linux/product_helper_tests_lnl_linux.cpp | 96 ++ .../lnl/product_helper_tests_lnl.cpp | 163 +++ .../xe2_hpg_core/lnl/test_device_caps_lnl.cpp | 32 + .../xe2_hpg_core/lnl/windows/CMakeLists.txt | 9 + .../product_helper_tests_lnl_windows.cpp | 52 + .../simd_helper_tests_xe2_hpg_core.cpp | 20 + ...test_blit_commands_helper_xe2_hpg_core.cpp | 378 ++++++ .../test_device_caps_xe2_hpg_core.cpp | 91 ++ .../test_encode_3dstate_btd_xe2_hpg_core.cpp | 73 ++ .../xe2_hpg_core/test_encode_xe2_hpg_core.cpp | 684 +++++++++++ .../test_preemption_xe2_hpg_core.cpp | 43 + target_unit_tests/xe2_hpg_core/CMakeLists.txt | 9 + .../xe2_hpg_core/bmg/CMakeLists.txt | 10 + .../xe2_hpg_core/lnl/CMakeLists.txt | 11 + 239 files changed, 13854 insertions(+), 18 deletions(-) create mode 100644 level_zero/core/source/cmdlist/cmdlist_hw_xe2_hpg_and_later.inl create mode 100644 level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_xe2_hpg_and_later.inl create mode 100644 level_zero/core/source/xe2_hpg_core/CMakeLists.txt create mode 100644 level_zero/core/source/xe2_hpg_core/bmg/CMakeLists.txt create mode 100644 level_zero/core/source/xe2_hpg_core/bmg/cmdlist_bmg.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/bmg/cmdqueue_bmg.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/bmg/image_bmg.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/bmg/kernel_bmg.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/bmg/sampler_bmg.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/cmdlist_xe2_hpg_core.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/cmdlist_xe2_hpg_core.h create mode 100644 level_zero/core/source/xe2_hpg_core/enable_family_full_l0_xe2_hpg_core.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/image_xe2_hpg_core.inl create mode 100644 level_zero/core/source/xe2_hpg_core/l0_gfx_core_helper_xe2_hpg_core.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/lnl/CMakeLists.txt create mode 100644 level_zero/core/source/xe2_hpg_core/lnl/cmdlist_lnl.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/lnl/cmdqueue_lnl.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/lnl/image_lnl.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/lnl/kernel_lnl.cpp create mode 100644 level_zero/core/source/xe2_hpg_core/lnl/sampler_lnl.cpp create mode 100644 level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xe2_and_later.cpp create mode 100644 level_zero/core/test/unit_tests/xe2_hpg_core/CMakeLists.txt create mode 100644 level_zero/core/test/unit_tests/xe2_hpg_core/test_cmdlist_xe2_hpg_core.cpp create mode 100644 level_zero/core/test/unit_tests/xe2_hpg_core/test_cmdqueue_xe2_hpg_core.cpp create mode 100644 level_zero/core/test/unit_tests/xe2_hpg_core/test_device_xe2_hpg_core.cpp create mode 100644 level_zero/core/test/unit_tests/xe2_hpg_core/test_l0_gfx_core_helper_xe2_hpg_core.cpp create mode 100644 level_zero/core/test/unit_tests/xe2_hpg_core/test_module_xe2_hpg_core.cpp create mode 100644 level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/CMakeLists.txt create mode 100644 level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/CMakeLists.txt create mode 100644 level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/enable_sysman_product_helper_bmg.cpp create mode 100644 level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp create mode 100644 level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/CMakeLists.txt create mode 100644 level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/enable_sysman_product_helper_lnl.cpp create mode 100644 level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/sysman_product_helper_lnl.cpp create mode 100644 level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/CMakeLists.txt create mode 100644 level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/CMakeLists.txt create mode 100644 level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/enable_sysman_product_helper_bmg.cpp create mode 100644 level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp create mode 100644 level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/CMakeLists.txt create mode 100644 level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/enable_sysman_product_helper_lnl.cpp create mode 100644 level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/sysman_product_helper_lnl.cpp create mode 100644 level_zero/tools/test/unit_tests/sources/debug/xe2_hpg_core/CMakeLists.txt create mode 100644 level_zero/tools/test/unit_tests/sources/debug/xe2_hpg_core/debug_session_tests_xe2_hpg_core.cpp create mode 100644 opencl/source/xe2_hpg_core/CMakeLists.txt create mode 100644 opencl/source/xe2_hpg_core/buffer_xe2_hpg_core.cpp create mode 100644 opencl/source/xe2_hpg_core/cl_gfx_core_helper_xe2_hpg_core.cpp create mode 100644 opencl/source/xe2_hpg_core/command_queue_xe2_hpg_core.cpp create mode 100644 opencl/source/xe2_hpg_core/enable_family_full_ocl_xe2_hpg_core.cpp create mode 100644 opencl/source/xe2_hpg_core/gpgpu_walker_xe2_hpg_core.cpp create mode 100644 opencl/source/xe2_hpg_core/gtpin_setup_xe2_hpg_core.cpp create mode 100644 opencl/source/xe2_hpg_core/hardware_commands_helper_xe2_hpg_core.cpp create mode 100644 opencl/source/xe2_hpg_core/image_xe2_hpg_core.cpp create mode 100644 opencl/source/xe2_hpg_core/sampler_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/aub_tests/xe2_hpg_core/CMakeLists.txt create mode 100644 opencl/test/unit_test/aub_tests/xe2_hpg_core/aub_mem_dump_tests_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/aub_tests/xe2_hpg_core/aub_tests_excludes_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/aub_tests/xe2_hpg_core/bmg/CMakeLists.txt create mode 100644 opencl/test/unit_test/aub_tests/xe2_hpg_core/bmg/aub_tests_excludes_bmg.cpp create mode 100644 opencl/test/unit_test/aub_tests/xe2_hpg_core/copy_engine_aub_tests_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/aub_tests/xe2_hpg_core/enqueue_kernel_aub_tests_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/aub_tests/xe2_hpg_core/lnl/CMakeLists.txt create mode 100644 opencl/test/unit_test/aub_tests/xe2_hpg_core/lnl/copy_engine_aub_tests_lnl.cpp create mode 100644 opencl/test/unit_test/aub_tests/xe2_hpg_core/system_memfence_aub_tests_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xe2_and_later.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/CMakeLists.txt create mode 100644 opencl/test/unit_test/xe2_hpg_core/bmg/CMakeLists.txt create mode 100644 opencl/test/unit_test/xe2_hpg_core/bmg/device_info_tests_bmg.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/bmg/linux/CMakeLists.txt create mode 100644 opencl/test/unit_test/xe2_hpg_core/bmg/linux/dll/CMakeLists.txt create mode 100644 opencl/test/unit_test/xe2_hpg_core/bmg/linux/dll/device_id_tests_bmg.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/bmg/test_cl_device_caps_bmg.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/cl_gfx_core_helper_tests_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/cmd_parse_tests_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/command_stream_receiver_hw_tests_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/copy_engine_tests_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/dispatch_walker_tests_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/enqueue_tests_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/excludes_ocl_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/lnl/CMakeLists.txt create mode 100644 opencl/test/unit_test/xe2_hpg_core/lnl/device_info_tests_lnl.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/lnl/linux/CMakeLists.txt create mode 100644 opencl/test/unit_test/xe2_hpg_core/lnl/linux/dll/CMakeLists.txt create mode 100644 opencl/test/unit_test/xe2_hpg_core/lnl/linux/dll/device_id_tests_lnl.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/lnl/test_cl_device_caps_lnl.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/test_cl_device_caps_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/test_cmds_programming_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/test_platform_caps_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/test_preamble_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/test_preemption_xe2_hpg_core.cpp create mode 100644 opencl/test/unit_test/xe2_hpg_core/test_sample_xe2_hpg_core.cpp create mode 100644 shared/source/ail/xe2_hpg_core/bmg/ail_configuration_bmg.cpp create mode 100644 shared/source/ail/xe2_hpg_core/bmg/definitions/ail_configuration_bmg.inl create mode 100644 shared/source/ail/xe2_hpg_core/lnl/ail_configuration_lnl.cpp create mode 100644 shared/source/ail/xe2_hpg_core/lnl/definitions/ail_configuration_lnl.inl create mode 100644 shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl create mode 100644 shared/source/command_stream/preemption_xe2_and_later.inl create mode 100644 shared/source/helpers/compiler_product_helper_xe2_hpg_and_later.inl create mode 100644 shared/source/helpers/gfx_core_helper_xe2_and_later.inl create mode 100644 shared/source/helpers/preamble_xe2_hpg_and_later.inl create mode 100644 shared/source/os_interface/product_helper_xe2_and_later.inl create mode 100644 shared/source/xe2_hpg_core/CMakeLists.txt create mode 100644 shared/source/xe2_hpg_core/aub_command_stream_receiver_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/aub_mapper.h create mode 100644 shared/source/xe2_hpg_core/aub_mem_dump_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/bmg/definitions/device_ids_configs_bmg.h create mode 100644 shared/source/xe2_hpg_core/bmg/os_agnostic_product_helper_bmg.inl create mode 100644 shared/source/xe2_hpg_core/command_encoder_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/command_stream_receiver_hw_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/command_stream_receiver_simulated_common_hw_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/create_device_command_stream_receiver_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/debugger_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/definitions/gfx_core_helper_xe2_hpg_core_additional.inl create mode 100644 shared/source/xe2_hpg_core/enable_compiler_product_helper_bmg.cpp create mode 100644 shared/source/xe2_hpg_core/enable_compiler_product_helper_lnl.cpp create mode 100644 shared/source/xe2_hpg_core/enable_family_full_core_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/enable_product_helper_bmg.cpp create mode 100644 shared/source/xe2_hpg_core/enable_product_helper_lnl.cpp create mode 100644 shared/source/xe2_hpg_core/enable_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/hw_cmds.h create mode 100644 shared/source/xe2_hpg_core/hw_cmds_bmg.h create mode 100644 shared/source/xe2_hpg_core/hw_cmds_lnl.h create mode 100644 shared/source/xe2_hpg_core/hw_info.h create mode 100644 shared/source/xe2_hpg_core/hw_info_bmg.cpp create mode 100644 shared/source/xe2_hpg_core/hw_info_bmg.h create mode 100644 shared/source/xe2_hpg_core/hw_info_lnl.cpp create mode 100644 shared/source/xe2_hpg_core/hw_info_lnl.h create mode 100644 shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h create mode 100644 shared/source/xe2_hpg_core/image_core_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/implicit_scaling_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/linux/command_stream_receiver_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/linux/direct_submission_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/linux/hw_info_extra_bmg.cpp create mode 100644 shared/source/xe2_hpg_core/linux/hw_info_extra_lnl.cpp create mode 100644 shared/source/xe2_hpg_core/linux/product_helper_bmg.cpp create mode 100644 shared/source/xe2_hpg_core/linux/product_helper_lnl.cpp create mode 100644 shared/source/xe2_hpg_core/lnl/device_ids_configs_lnl.h create mode 100644 shared/source/xe2_hpg_core/lnl/os_agnostic_product_helper_lnl.inl create mode 100644 shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl create mode 100644 shared/source/xe2_hpg_core/preamble_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/preemption_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/state_base_address_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/tbx_command_stream_receiver_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/windows/command_stream_receiver_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/windows/direct_submission_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/windows/gmm_callbacks_xe2_hpg_core.cpp create mode 100644 shared/source/xe2_hpg_core/windows/hw_info_extra_bmg.cpp create mode 100644 shared/source/xe2_hpg_core/windows/hw_info_extra_lnl.cpp create mode 100644 shared/source/xe2_hpg_core/windows/product_helper_bmg.cpp create mode 100644 shared/source/xe2_hpg_core/windows/product_helper_lnl.cpp create mode 100644 shared/test/common/helpers/unit_test_helper_xe2_and_later.inl create mode 100644 shared/test/common/libult/xe2_hpg_core.cpp create mode 100644 shared/test/common/test_configuration/aub_tests/xe2_hpg_core/CMakeLists.txt create mode 100644 shared/test/common/test_configuration/aub_tests/xe2_hpg_core/aub_tests_configuration_xe2_hpg_core.cpp create mode 100644 shared/test/common/xe2_hpg_core/CMakeLists.txt create mode 100644 shared/test/common/xe2_hpg_core/bmg/CMakeLists.txt create mode 100644 shared/test/common/xe2_hpg_core/bmg/mock_product_helper_bmg.cpp create mode 100644 shared/test/common/xe2_hpg_core/bmg/product_configs_bmg.h create mode 100644 shared/test/common/xe2_hpg_core/cmd_parse_xe2_hpg_core.cpp create mode 100644 shared/test/common/xe2_hpg_core/lnl/mock_product_helper_lnl.cpp create mode 100644 shared/test/common/xe2_hpg_core/test_traits_xe2_hpg_core.h create mode 100644 shared/test/common/xe2_hpg_core/unit_test_helper_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/encoders/command_encoder_tests_xe2_and_later.cpp create mode 100644 shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp create mode 100644 shared/test/unit_test/preamble/test_preamble_xe2_and_later.cpp create mode 100644 shared/test/unit_test/preemption/test_preemption_xe2_and_later.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/CMakeLists.txt create mode 100644 shared/test/unit_test/xe2_hpg_core/aub_center_using_aubstream_lib_tests_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/aub_command_stream_receiver_2_tests_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/CMakeLists.txt create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/engine_node_helper_tests_bmg.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/excludes_xe2_hpg_core_bmg.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/gfx_core_helper_tests_bmg.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/hw_aot_config_tests_bmg.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/hw_info_tests_bmg.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/linux/CMakeLists.txt create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/linux/product_helper_tests_bmg_linux.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/product_helper_tests_bmg.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/test_device_caps_bmg.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/windows/CMakeLists.txt create mode 100644 shared/test/unit_test/xe2_hpg_core/bmg/windows/product_helper_tests_bmg_windows.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/compute_mode_tests_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/excludes_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/hw_cmds_xe2_hpg_core_tests.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/image_surface_state_tests_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/lnl/CMakeLists.txt create mode 100644 shared/test/unit_test/xe2_hpg_core/lnl/engine_node_helper_tests_lnl.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/lnl/excludes_xe2_hpg_core_lnl.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/lnl/gfx_core_helper_tests_lnl.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/lnl/hw_info_tests_lnl.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/lnl/linux/CMakeLists.txt create mode 100644 shared/test/unit_test/xe2_hpg_core/lnl/linux/product_helper_tests_lnl_linux.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/lnl/test_device_caps_lnl.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/lnl/windows/CMakeLists.txt create mode 100644 shared/test/unit_test/xe2_hpg_core/lnl/windows/product_helper_tests_lnl_windows.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/simd_helper_tests_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/test_blit_commands_helper_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/test_device_caps_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/test_encode_3dstate_btd_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/test_encode_xe2_hpg_core.cpp create mode 100644 shared/test/unit_test/xe2_hpg_core/test_preemption_xe2_hpg_core.cpp create mode 100644 target_unit_tests/xe2_hpg_core/CMakeLists.txt create mode 100644 target_unit_tests/xe2_hpg_core/bmg/CMakeLists.txt create mode 100644 target_unit_tests/xe2_hpg_core/lnl/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index baf0b99eca..20e4a61b08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -921,7 +921,10 @@ include_directories(${NEO_SHARED_DIRECTORY}/sku_info/definitions${BRANCH_DIR_SUF macro(macro_for_each_platform) string(TOLOWER ${PLATFORM_IT} PLATFORM_IT_LOWER) - foreach(PLATFORM_DIRECTORY ${NEO_SHARED_DIRECTORY}/${CORE_TYPE_LOWER}/${PLATFORM_IT_LOWER}/definitions${BRANCH_DIR_SUFFIX}) + foreach(PLATFORM_DIRECTORY + ${NEO_SHARED_DIRECTORY}/${CORE_TYPE_LOWER}/${PLATFORM_IT_LOWER}/definitions${BRANCH_DIR_SUFFIX} + ${NEO_SHARED_DIRECTORY}/ail/${CORE_TYPE_LOWER}/${PLATFORM_IT_LOWER}/definitions${BRANCH_DIR_SUFFIX} + ) if(EXISTS ${PLATFORM_DIRECTORY}) include_directories(${PLATFORM_DIRECTORY}) endif() diff --git a/cmake/fill_core_types.cmake b/cmake/fill_core_types.cmake index cb08490d82..af9ce47226 100644 --- a/cmake/fill_core_types.cmake +++ b/cmake/fill_core_types.cmake @@ -11,7 +11,9 @@ list(APPEND ALL_CORE_TYPES "GEN12LP") list(APPEND ALL_CORE_TYPES "XE_HP_CORE") list(APPEND ALL_CORE_TYPES "XE_HPG_CORE") list(APPEND ALL_CORE_TYPES "XE_HPC_CORE") -list(APPEND PVC_AND_LATER_CORE_TYPES "XE_HPC_CORE") +list(APPEND ALL_CORE_TYPES "XE2_HPG_CORE") +list(APPEND XE2_AND_LATER_CORE_TYPES "XE2_HPG_CORE") +list(APPEND PVC_AND_LATER_CORE_TYPES ${XE2_AND_LATER_CORE_TYPES} "XE_HPC_CORE") list(APPEND DG2_AND_LATER_CORE_TYPES ${PVC_AND_LATER_CORE_TYPES} "XE_HPG_CORE") list(APPEND MTL_AND_LATER_CORE_TYPES ${DG2_AND_LATER_CORE_TYPES}) list(APPEND XEHP_AND_LATER_CORE_TYPES ${MTL_AND_LATER_CORE_TYPES}) diff --git a/cmake/setup_platform_flags.cmake b/cmake/setup_platform_flags.cmake index aa25d496d9..1d1675be81 100644 --- a/cmake/setup_platform_flags.cmake +++ b/cmake/setup_platform_flags.cmake @@ -15,6 +15,7 @@ SET_FLAGS_FOR_LEGACY("GEN11" "ICLLP" "LKF" "EHL") SET_FLAGS_FOR_CURRENT("GEN12LP" "TGLLP" "RKL" "ADLS" "ADLP" "DG1" "ADLN") SET_FLAGS_FOR_CURRENT("XE_HPG_CORE" "DG2" "MTL" "ARL") SET_FLAGS_FOR_CURRENT("XE_HPC_CORE" "PVC") +SET_FLAGS_FOR_CURRENT("XE2_HPG_CORE" "BMG" "LNL") DISABLE_WDDM_LINUX_FOR("XE_HPC_CORE" "PVC") @@ -54,6 +55,15 @@ foreach(CORE_TYPE ${PVC_AND_LATER_CORE_TYPES}) endif() endforeach() +foreach(CORE_TYPE ${XE2_AND_LATER_CORE_TYPES}) + if(TESTS_${CORE_TYPE}) + set(TESTS_XE2_AND_LATER 1) + endif() + if(SUPPORT_${CORE_TYPE}) + set(SUPPORT_XE2_AND_LATER 1) + endif() +endforeach() + if(SUPPORT_ARL) ENABLE_ADDITIONAL_SKU("MTL") if(TESTS_ARL) @@ -376,3 +386,39 @@ if(SUPPORT_XE_HPC_CORE) endif() endif() endif() + +if(SUPPORT_XE2_HPG_CORE) + ADD_AOT_DEFINITION(XE2) + set(XE2_HPG_CORE_TEST_KERNELS_BLOCKLIST "CopyBuffer_simd8.cl") + if(TESTS_XE2_HPG_CORE) + ADD_ITEM_FOR_CORE_TYPE("FAMILY_NAME" "TESTED" "XE2_HPG_CORE" "Xe2HpgCoreFamily") + endif() + + if(SUPPORT_BMG) + ADD_AOT_DEFINITION(XE2_HPG) + ADD_AOT_DEFINITION(BMG) + set(BMG_XE2_HPG_CORE_REVISIONS 4) + set(BMG_XE2_HPG_CORE_RELEASES "20.1.0" "20.1.1" "20.1.4") + ADD_PRODUCT("SUPPORTED" "BMG" "IGFX_BMG") + ADD_PLATFORM_FOR_CORE_TYPE("SUPPORTED" "XE2_HPG_CORE" "BMG") + ADD_PLATFORM_FOR_CORE_TYPE("SUPPORTED_IMAGES" "XE2_HPG_CORE" "BMG") + if(TESTS_BMG) + ADD_ITEM_FOR_CORE_TYPE("PLATFORMS" "TESTED" "XE2_HPG_CORE" "BMG") + ADD_PRODUCT("TESTED" "BMG" "IGFX_BMG") + endif() + endif() + + if(SUPPORT_LNL) + ADD_AOT_DEFINITION(XE2_LPG) + ADD_AOT_DEFINITION(LNL) + set(LNL_XE2_HPG_CORE_REVISIONS 4) + set(LNL_XE2_HPG_CORE_RELEASES "20.4.0" "20.4.1" "20.4.4") + ADD_PRODUCT("SUPPORTED" "LNL" "IGFX_LUNARLAKE") + ADD_PLATFORM_FOR_CORE_TYPE("SUPPORTED" "XE2_HPG_CORE" "LNL") + ADD_PLATFORM_FOR_CORE_TYPE("SUPPORTED_IMAGES" "XE2_HPG_CORE" "LNL") + if(TESTS_LNL) + ADD_ITEM_FOR_CORE_TYPE("PLATFORMS" "TESTED" "XE2_HPG_CORE" "LNL") + ADD_PRODUCT("TESTED" "LNL" "IGFX_LUNARLAKE") + endif() + endif() +endif() diff --git a/level_zero/core/source/cmdlist/CMakeLists.txt b/level_zero/core/source/cmdlist/CMakeLists.txt index e37a931022..39b6dba058 100644 --- a/level_zero/core/source/cmdlist/CMakeLists.txt +++ b/level_zero/core/source/cmdlist/CMakeLists.txt @@ -42,4 +42,10 @@ if(SUPPORT_PVC_AND_LATER) ) endif() +if(SUPPORT_XE2_AND_LATER) + target_sources(${L0_STATIC_LIB_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_hw_xe2_hpg_and_later.inl + ) +endif() + add_subdirectories() diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_xe2_hpg_and_later.inl b/level_zero/core/source/cmdlist/cmdlist_hw_xe2_hpg_and_later.inl new file mode 100644 index 0000000000..194eecc38c --- /dev/null +++ b/level_zero/core/source/cmdlist/cmdlist_hw_xe2_hpg_and_later.inl @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "level_zero/core/source/cmdlist/cmdlist_hw.h" +#include "level_zero/core/source/kernel/kernel.h" + +namespace L0 { + +template +inline NEO::PreemptionMode CommandListCoreFamily::obtainKernelPreemptionMode(Kernel *kernel) { + auto kernelDescriptor = &kernel->getImmutableData()->getDescriptor(); + bool disabledMidThreadPreemptionKernel = kernelDescriptor->kernelAttributes.flags.requiresDisabledMidThreadPreemption || + (kernelDescriptor->kernelAttributes.flags.hasRTCalls && kernel->isMidThreadPreemptionDisallowedForRayTracingKernels()); + bool debuggingEnabled = device->getNEODevice()->getDebugger(); + disabledMidThreadPreemptionKernel |= debuggingEnabled; + disabledMidThreadPreemptionKernel |= device->getNEODevice()->getPreemptionMode() != NEO::PreemptionMode::MidThread; + return disabledMidThreadPreemptionKernel ? NEO::PreemptionMode::ThreadGroup : NEO::PreemptionMode::MidThread; +} + +template +void CommandListCoreFamily::adjustWriteKernelTimestamp(uint64_t globalAddress, uint64_t contextAddress, uint64_t baseAddress, CommandToPatchContainer *outTimeStampSyncCmds, bool maskLsb, uint32_t mask, + bool workloadPartition, bool copyOperation) { + uint64_t globalHighAddress = globalAddress + sizeof(uint32_t); + uint64_t contextHighAddress = contextAddress + sizeof(uint32_t); + + void **globalPostSyncCmdBuffer = nullptr; + void **contextPostSyncCmdBuffer = nullptr; + + void *globalPostSyncCmd = nullptr; + void *contextPostSyncCmd = nullptr; + + if (outTimeStampSyncCmds != nullptr) { + globalPostSyncCmdBuffer = &globalPostSyncCmd; + contextPostSyncCmdBuffer = &contextPostSyncCmd; + } + + if (maskLsb) { + NEO::EncodeMathMMIO::encodeBitwiseAndVal(commandContainer, RegisterOffsets::globalTimestampUn, mask, globalHighAddress, workloadPartition, globalPostSyncCmdBuffer, copyOperation); + NEO::EncodeMathMMIO::encodeBitwiseAndVal(commandContainer, RegisterOffsets::gpThreadTimeRegAddressOffsetHigh, mask, contextHighAddress, workloadPartition, contextPostSyncCmdBuffer, copyOperation); + } else { + NEO::EncodeStoreMMIO::encode(*commandContainer.getCommandStream(), RegisterOffsets::globalTimestampUn, globalHighAddress, workloadPartition, globalPostSyncCmdBuffer); + NEO::EncodeStoreMMIO::encode(*commandContainer.getCommandStream(), RegisterOffsets::gpThreadTimeRegAddressOffsetHigh, contextHighAddress, workloadPartition, contextPostSyncCmdBuffer); + } + + if (outTimeStampSyncCmds != nullptr) { + CommandToPatch ctxCmd; + ctxCmd.type = CommandToPatch::TimestampEventPostSyncStoreRegMem; + + ctxCmd.offset = globalHighAddress - baseAddress; + ctxCmd.pDestination = globalPostSyncCmd; + outTimeStampSyncCmds->push_back(ctxCmd); + + ctxCmd.offset = contextHighAddress - baseAddress; + ctxCmd.pDestination = contextPostSyncCmd; + outTimeStampSyncCmds->push_back(ctxCmd); + } +} + +} // namespace L0 diff --git a/level_zero/core/source/gfx_core_helpers/CMakeLists.txt b/level_zero/core/source/gfx_core_helpers/CMakeLists.txt index 73748408b6..ac9424d160 100644 --- a/level_zero/core/source/gfx_core_helpers/CMakeLists.txt +++ b/level_zero/core/source/gfx_core_helpers/CMakeLists.txt @@ -67,3 +67,9 @@ if(SUPPORT_XE_HP_CORE OR SUPPORT_XE_HPG_CORE OR SUPPORT_XE2_HPG_CORE) ${CMAKE_CURRENT_SOURCE_DIR}/l0_gfx_core_helper_xe_hpg_to_xe2_hpg.inl ) endif() + +if(SUPPORT_XE2_AND_LATER) + target_sources(${L0_STATIC_LIB_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/l0_gfx_core_helper_xe2_hpg_and_later.inl + ) +endif() diff --git a/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_xe2_hpg_and_later.inl b/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_xe2_hpg_and_later.inl new file mode 100644 index 0000000000..36de5cd0f2 --- /dev/null +++ b/level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_xe2_hpg_and_later.inl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/execution_environment/root_device_environment.h" + +#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h" + +namespace L0 { + +template +bool L0GfxCoreHelperHw::imageCompressionSupported(const NEO::HardwareInfo &hwInfo) const { + if (NEO::debugManager.flags.RenderCompressedImagesEnabled.get() != -1) { + return !!NEO::debugManager.flags.RenderCompressedImagesEnabled.get(); + } + + return hwInfo.capabilityTable.ftrRenderCompressedImages; +} + +template +bool L0GfxCoreHelperHw::usmCompressionSupported(const NEO::HardwareInfo &hwInfo) const { + if (NEO::debugManager.flags.RenderCompressedBuffersEnabled.get() != -1) { + return !!NEO::debugManager.flags.RenderCompressedBuffersEnabled.get(); + } + + return hwInfo.capabilityTable.ftrRenderCompressedBuffers; +} + +template +bool L0GfxCoreHelperHw::forceDefaultUsmCompressionSupport() const { + return true; +} + +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/CMakeLists.txt b/level_zero/core/source/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..7e0c5505a8 --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,19 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(SUPPORT_XE2_HPG_CORE) + target_sources(${L0_STATIC_LIB_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_xe2_hpg_core.h + ${CMAKE_CURRENT_SOURCE_DIR}/image_xe2_hpg_core.inl + ${CMAKE_CURRENT_SOURCE_DIR}/enable_family_full_l0_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/l0_gfx_core_helper_xe2_hpg_core.cpp + ) + + add_subdirectories() + +endif() diff --git a/level_zero/core/source/xe2_hpg_core/bmg/CMakeLists.txt b/level_zero/core/source/xe2_hpg_core/bmg/CMakeLists.txt new file mode 100644 index 0000000000..7fede71a91 --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/bmg/CMakeLists.txt @@ -0,0 +1,17 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(SUPPORT_BMG) + target_sources(${L0_STATIC_LIB_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/cmdqueue_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/image_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/kernel_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/sampler_bmg.cpp + ) + add_subdirectories() +endif() diff --git a/level_zero/core/source/xe2_hpg_core/bmg/cmdlist_bmg.cpp b/level_zero/core/source/xe2_hpg_core/bmg/cmdlist_bmg.cpp new file mode 100644 index 0000000000..8787d9dddd --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/bmg/cmdlist_bmg.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info.h" + +#include "level_zero/core/source/xe2_hpg_core/cmdlist_xe2_hpg_core.h" + +namespace L0 { + +static CommandListPopulateFactory> + populateBMG; + +static CommandListImmediatePopulateFactory> + populateBMGImmediate; + +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/bmg/cmdqueue_bmg.cpp b/level_zero/core/source/xe2_hpg_core/bmg/cmdqueue_bmg.cpp new file mode 100644 index 0000000000..c2c695f861 --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/bmg/cmdqueue_bmg.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info.h" + +#include "level_zero/core/source/cmdqueue/cmdqueue_hw.inl" +#include "level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl" + +#include "cmdqueue_extended.inl" +namespace L0 { +template struct CommandQueueHw; +static CommandQueuePopulateFactory> + populateBMG; + +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/bmg/image_bmg.cpp b/level_zero/core/source/xe2_hpg_core/bmg/image_bmg.cpp new file mode 100644 index 0000000000..25e1d1be2d --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/bmg/image_bmg.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/core/source/xe2_hpg_core/image_xe2_hpg_core.inl" + +namespace L0 { + +template <> +struct ImageProductFamily : public ImageCoreFamily { + using ImageCoreFamily::ImageCoreFamily; + + ze_result_t initialize(Device *device, const ze_image_desc_t *desc) override { + return ImageCoreFamily::initialize(device, desc); + }; +}; + +static ImagePopulateFactory> populateBMG; + +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/bmg/kernel_bmg.cpp b/level_zero/core/source/xe2_hpg_core/bmg/kernel_bmg.cpp new file mode 100644 index 0000000000..aaeee77f83 --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/bmg/kernel_bmg.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info.h" + +#include "level_zero/core/source/kernel/kernel_hw.h" + +namespace L0 { + +static KernelPopulateFactory> populateBMG; + +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/bmg/sampler_bmg.cpp b/level_zero/core/source/xe2_hpg_core/bmg/sampler_bmg.cpp new file mode 100644 index 0000000000..921671b352 --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/bmg/sampler_bmg.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info.h" + +#include "level_zero/core/source/sampler/sampler_hw.inl" + +namespace L0 { + +template <> +struct SamplerProductFamily : public SamplerCoreFamily { + using SamplerCoreFamily::SamplerCoreFamily; +}; + +static SamplerPopulateFactory> populateBMG; + +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/cmdlist_xe2_hpg_core.cpp b/level_zero/core/source/xe2_hpg_core/cmdlist_xe2_hpg_core.cpp new file mode 100644 index 0000000000..c79bcf709b --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/cmdlist_xe2_hpg_core.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info.h" + +#include "level_zero/core/source/cmdlist/cmdlist_hw.inl" +#include "level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl" +#include "level_zero/core/source/cmdlist/cmdlist_hw_xe2_hpg_and_later.inl" +#include "level_zero/core/source/cmdlist/cmdlist_hw_xe_hpc_and_later.inl" +#include "level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl" + +#include "cmdlist_extended.inl" + +namespace L0 { + +template struct CommandListCoreFamily; +template struct CommandListCoreFamilyImmediate; + +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/cmdlist_xe2_hpg_core.h b/level_zero/core/source/xe2_hpg_core/cmdlist_xe2_hpg_core.h new file mode 100644 index 0000000000..9e0816e73f --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/cmdlist_xe2_hpg_core.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +#include "level_zero/core/source/cmdlist/cmdlist_hw.h" +#include "level_zero/core/source/cmdlist/cmdlist_hw_immediate.h" + +namespace L0 { +template +struct CommandListProductFamily : public CommandListCoreFamily { + using CommandListCoreFamily::CommandListCoreFamily; +}; + +template +struct CommandListImmediateProductFamily : public CommandListCoreFamilyImmediate { + using CommandListCoreFamilyImmediate::CommandListCoreFamilyImmediate; +}; +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/enable_family_full_l0_xe2_hpg_core.cpp b/level_zero/core/source/xe2_hpg_core/enable_family_full_l0_xe2_hpg_core.cpp new file mode 100644 index 0000000000..d135cb5fee --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/enable_family_full_l0_xe2_hpg_core.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h" +#include "level_zero/core/source/helpers/l0_populate_factory.h" + +namespace NEO { + +using Family = Xe2HpgCoreFamily; + +struct EnableL0Xe2HpgCore { + EnableL0Xe2HpgCore() { + L0::populateFactoryTable>(); + } +}; + +static EnableL0Xe2HpgCore enable; +} // namespace NEO diff --git a/level_zero/core/source/xe2_hpg_core/image_xe2_hpg_core.inl b/level_zero/core/source/xe2_hpg_core/image_xe2_hpg_core.inl new file mode 100644 index 0000000000..3fbf3a9595 --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/image_xe2_hpg_core.inl @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/source/xe2_hpg_core/hw_info.h" + +#include "level_zero/core/source/image/image_hw.inl" diff --git a/level_zero/core/source/xe2_hpg_core/l0_gfx_core_helper_xe2_hpg_core.cpp b/level_zero/core/source/xe2_hpg_core/l0_gfx_core_helper_xe2_hpg_core.cpp new file mode 100644 index 0000000000..fd1b9ccfc4 --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/l0_gfx_core_helper_xe2_hpg_core.cpp @@ -0,0 +1,211 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_base.inl" +#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_pvc_and_later.inl" +#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_xe2_hpg_and_later.inl" +#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_xe_hpg_to_xe2_hpg.inl" +#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper_xehp_and_later.inl" +#include "level_zero/core/source/helpers/l0_populate_factory.h" + +namespace L0 { +using Family = NEO::Xe2HpgCoreFamily; +static auto gfxCore = IGFX_XE2_HPG_CORE; + +template <> +zet_debug_regset_type_intel_gpu_t L0GfxCoreHelperHw::getRegsetTypeForLargeGrfDetection() const { + return ZET_DEBUG_REGSET_TYPE_SR_INTEL_GPU; +} + +/* + * Xe2 stall sample data item format: + * + * Bits Field + * 0 to 28 IP (addr) + * 29 to 36 tdr count + * 37 to 44 other count + * 45 to 52 control count + * 53 to 60 pipestall count + * 61 to 68 send count + * 69 to 76 dist_acc count + * 77 to 84 sbid count + * 85 to 92 sync count + * 93 to 100 inst_fetch count + * 101 to 108 active count + * Exid [109, 111] + * "EndFlag" - is always "1" 112 + * + * bytes at index 48 and 49, subSlice + * bytes at index 50 and 51, flags + * + * total size 64 bytes + */ + +#pragma pack(1) +typedef struct StallSumIpDataXe2 { + uint64_t tdrCount; + uint64_t otherCount; + uint64_t controlCount; + uint64_t pipeStallCount; + uint64_t sendCount; + uint64_t distAccCount; + uint64_t sbidCount; + uint64_t syncCount; + uint64_t instFetchCount; + uint64_t activeCount; +} StallSumIpDataXe2_t; +#pragma pack() + +constexpr uint32_t ipSamplingMetricCountXe2 = 11u; + +template +uint32_t L0GfxCoreHelperHw::getIpSamplingMetricCount() { + return ipSamplingMetricCountXe2; +} + +template +void L0GfxCoreHelperHw::stallIpDataMapDelete(std::map &stallSumIpDataMap) { + for (auto i = stallSumIpDataMap.begin(); i != stallSumIpDataMap.end(); i++) { + StallSumIpDataXe2_t *stallSumData = reinterpret_cast(i->second); + if (stallSumData) { + delete stallSumData; + i->second = nullptr; + } + } +} + +template +bool L0GfxCoreHelperHw::stallIpDataMapUpdate(std::map &stallSumIpDataMap, const uint8_t *pRawIpData) { + const uint8_t *tempAddr = pRawIpData; + uint64_t ip = 0ULL; + memcpy_s(reinterpret_cast(&ip), sizeof(ip), tempAddr, sizeof(ip)); + ip &= 0x1fffffff; + StallSumIpDataXe2_t *stallSumData = nullptr; + if (stallSumIpDataMap.count(ip) == 0) { + stallSumData = new StallSumIpDataXe2_t{}; + stallSumData->tdrCount = 0; + stallSumData->otherCount = 0; + stallSumData->controlCount = 0; + stallSumData->pipeStallCount = 0; + stallSumData->sendCount = 0; + stallSumData->distAccCount = 0; + stallSumData->sbidCount = 0; + stallSumData->syncCount = 0; + stallSumData->instFetchCount = 0; + stallSumData->activeCount = 0; + stallSumIpDataMap[ip] = stallSumData; + } else { + stallSumData = reinterpret_cast(stallSumIpDataMap[ip]); + } + tempAddr += ipStallSamplingOffset; + + auto getCount = [&tempAddr]() { + uint16_t tempCount = 0; + memcpy_s(reinterpret_cast(&tempCount), sizeof(tempCount), tempAddr, sizeof(tempCount)); + tempCount = (tempCount >> ipStallSamplingReportShift) & stallSamplingReportCategoryMask; + tempAddr += 1; + return static_cast(tempCount); + }; + + stallSumData->tdrCount += getCount(); + stallSumData->otherCount += getCount(); + stallSumData->controlCount += getCount(); + stallSumData->pipeStallCount += getCount(); + stallSumData->sendCount += getCount(); + stallSumData->distAccCount += getCount(); + stallSumData->sbidCount += getCount(); + stallSumData->syncCount += getCount(); + stallSumData->instFetchCount += getCount(); + stallSumData->activeCount += getCount(); + +#pragma pack(1) + struct StallCntrInfo { + uint16_t subslice; + uint16_t flags; + } stallCntrInfo = {}; +#pragma pack() + + tempAddr = pRawIpData + stallSamplingReportSubSliceAndFlagsOffset; + memcpy_s(reinterpret_cast(&stallCntrInfo), sizeof(stallCntrInfo), tempAddr, sizeof(stallCntrInfo)); + + constexpr int32_t overflowDropFlag = (1 << 8); + return stallCntrInfo.flags & overflowDropFlag; +} + +// Order of ipDataValues must match stallSamplingReportList +template +void L0GfxCoreHelperHw::stallSumIpDataToTypedValues(uint64_t ip, void *sumIpData, std::vector &ipDataValues) { + StallSumIpDataXe2_t *stallSumData = reinterpret_cast(sumIpData); + zet_typed_value_t tmpValueData; + tmpValueData.type = ZET_VALUE_TYPE_UINT64; + tmpValueData.value.ui64 = ip; + ipDataValues.push_back(tmpValueData); + + tmpValueData.type = ZET_VALUE_TYPE_UINT64; + tmpValueData.value.ui64 = stallSumData->activeCount; + ipDataValues.push_back(tmpValueData); + + tmpValueData.type = ZET_VALUE_TYPE_UINT64; + tmpValueData.value.ui64 = stallSumData->tdrCount; + ipDataValues.push_back(tmpValueData); + + tmpValueData.type = ZET_VALUE_TYPE_UINT64; + tmpValueData.value.ui64 = stallSumData->controlCount; + ipDataValues.push_back(tmpValueData); + + tmpValueData.type = ZET_VALUE_TYPE_UINT64; + tmpValueData.value.ui64 = stallSumData->pipeStallCount; + ipDataValues.push_back(tmpValueData); + + tmpValueData.type = ZET_VALUE_TYPE_UINT64; + tmpValueData.value.ui64 = stallSumData->sendCount; + ipDataValues.push_back(tmpValueData); + + tmpValueData.type = ZET_VALUE_TYPE_UINT64; + tmpValueData.value.ui64 = stallSumData->distAccCount; + ipDataValues.push_back(tmpValueData); + + tmpValueData.type = ZET_VALUE_TYPE_UINT64; + tmpValueData.value.ui64 = stallSumData->sbidCount; + ipDataValues.push_back(tmpValueData); + + tmpValueData.type = ZET_VALUE_TYPE_UINT64; + tmpValueData.value.ui64 = stallSumData->syncCount; + ipDataValues.push_back(tmpValueData); + + tmpValueData.type = ZET_VALUE_TYPE_UINT64; + tmpValueData.value.ui64 = stallSumData->instFetchCount; + ipDataValues.push_back(tmpValueData); + + tmpValueData.type = ZET_VALUE_TYPE_UINT64; + tmpValueData.value.ui64 = stallSumData->otherCount; + ipDataValues.push_back(tmpValueData); +} + +template +std::vector> L0GfxCoreHelperHw::getStallSamplingReportMetrics() const { + std::vector> stallSamplingReportList = { + {"Active", "Active cycles"}, + {"Tdr", "Stall on Timeout Detection and Recovery"}, + {"ControlStall", "Stall on control"}, + {"PipeStall", "Stall on pipe"}, + {"SendStall", "Stall on send"}, + {"DistStall", "Stall on distance"}, + {"SbidStall", "Stall on scoreboard"}, + {"SyncStall", "Stall on sync"}, + {"InstrFetchStall", "Stall on instruction fetch"}, + {"OtherStall", "Stall on other condition"}, + }; + return stallSamplingReportList; +} + +#include "level_zero/core/source/helpers/l0_gfx_core_helper_factory_init.inl" + +template class L0GfxCoreHelperHw; +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/lnl/CMakeLists.txt b/level_zero/core/source/xe2_hpg_core/lnl/CMakeLists.txt new file mode 100644 index 0000000000..b1196040b5 --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/lnl/CMakeLists.txt @@ -0,0 +1,17 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(SUPPORT_LNL) + target_sources(${L0_STATIC_LIB_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/cmdqueue_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/image_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/kernel_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/sampler_lnl.cpp + ) + add_subdirectories() +endif() diff --git a/level_zero/core/source/xe2_hpg_core/lnl/cmdlist_lnl.cpp b/level_zero/core/source/xe2_hpg_core/lnl/cmdlist_lnl.cpp new file mode 100644 index 0000000000..fe7f35a4b9 --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/lnl/cmdlist_lnl.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info.h" + +#include "level_zero/core/source/xe2_hpg_core/cmdlist_xe2_hpg_core.h" + +namespace L0 { + +static CommandListPopulateFactory> + populateLNL; + +static CommandListImmediatePopulateFactory> + populateLNLImmediate; + +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/lnl/cmdqueue_lnl.cpp b/level_zero/core/source/xe2_hpg_core/lnl/cmdqueue_lnl.cpp new file mode 100644 index 0000000000..7d2ebdcc0d --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/lnl/cmdqueue_lnl.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info.h" + +#include "level_zero/core/source/cmdqueue/cmdqueue_hw.inl" +#include "level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl" + +#include "cmdqueue_extended.inl" +namespace L0 { +template struct CommandQueueHw; +static CommandQueuePopulateFactory> + populateLNL; + +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/lnl/image_lnl.cpp b/level_zero/core/source/xe2_hpg_core/lnl/image_lnl.cpp new file mode 100644 index 0000000000..32d1916899 --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/lnl/image_lnl.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/core/source/xe2_hpg_core/image_xe2_hpg_core.inl" + +namespace L0 { + +template <> +struct ImageProductFamily : public ImageCoreFamily { + using ImageCoreFamily::ImageCoreFamily; + + ze_result_t initialize(Device *device, const ze_image_desc_t *desc) override { + return ImageCoreFamily::initialize(device, desc); + }; +}; + +static ImagePopulateFactory> populateLNL; + +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/lnl/kernel_lnl.cpp b/level_zero/core/source/xe2_hpg_core/lnl/kernel_lnl.cpp new file mode 100644 index 0000000000..4d8b9b6253 --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/lnl/kernel_lnl.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info.h" + +#include "level_zero/core/source/kernel/kernel_hw.h" + +namespace L0 { + +static KernelPopulateFactory> populateLNL; + +} // namespace L0 diff --git a/level_zero/core/source/xe2_hpg_core/lnl/sampler_lnl.cpp b/level_zero/core/source/xe2_hpg_core/lnl/sampler_lnl.cpp new file mode 100644 index 0000000000..782b2ec8ca --- /dev/null +++ b/level_zero/core/source/xe2_hpg_core/lnl/sampler_lnl.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info.h" + +#include "level_zero/core/source/sampler/sampler_hw.inl" + +namespace L0 { + +template <> +struct SamplerProductFamily : public SamplerCoreFamily { + using SamplerCoreFamily::SamplerCoreFamily; +}; + +static SamplerPopulateFactory> populateLNL; + +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/CMakeLists.txt b/level_zero/core/test/unit_tests/sources/cmdlist/CMakeLists.txt index cb4e5ce4c5..0317ca4e23 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/sources/cmdlist/CMakeLists.txt @@ -38,4 +38,10 @@ if(TESTS_XEHP_AND_LATER) ) endif() +if(TESTS_XE2_AND_LATER) + target_sources(${TARGET_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_xe2_and_later.cpp + ) +endif() + add_subdirectories() diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xe2_and_later.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xe2_and_later.cpp new file mode 100644 index 0000000000..83aa8bd2bf --- /dev/null +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xe2_and_later.cpp @@ -0,0 +1,387 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/gfx_core_helper.h" +#include "shared/source/helpers/register_offsets.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_graphics_allocation.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "level_zero/core/source/cmdlist/cmdlist_hw.h" +#include "level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" +#include "level_zero/core/test/unit_tests/mocks/mock_event.h" + +namespace L0 { +namespace ult { + +HWTEST_EXCLUDE_PRODUCT(AppendMemoryCopy, givenCopyCommandListWhenTimestampPassedToMemoryCopyRegionBlitThenTimeStampRegistersAreAdded_IsAtLeastSkl, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(AppendMemoryCopy, givenCopyCommandListWhenTimestampPassedToMemoryCopyThenAppendProfilingCalledOnceBeforeAndAfterCommand_IsAtLeastSkl, IGFX_XE2_HPG_CORE); + +using Platforms = IsAtLeastXe2HpgCore; + +struct CommandListXe2AndLaterFixture : public DeviceFixture { + void setUp() { + DeviceFixture::setUp(); + + constexpr ze_event_pool_desc_t eventPoolDesc = {ZE_STRUCTURE_TYPE_EVENT_POOL_DESC, nullptr, ZE_EVENT_POOL_FLAG_HOST_VISIBLE, 4}; + auto hDevice = device->toHandle(); + + ze_result_t result = ZE_RESULT_SUCCESS; + eventPool.reset(static_cast(EventPool::create(device->getDriverHandle(), context, 1, &hDevice, &eventPoolDesc, result))); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + ze_event_handle_t hEvent = 0; + ze_event_desc_t eventDesc = {}; + + eventDesc.index = 0; + + result = eventPool->createEvent(&eventDesc, &hEvent); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + eventObj.reset(L0::Event::fromHandle(hEvent)); + } + + void tearDown() { + eventObj.reset(nullptr); + eventPool.reset(nullptr); + DeviceFixture::tearDown(); + } + + template + std::vector findAllSrmCommands(void *streamStart, size_t size) { + genSrmCommands.clear(); + + EXPECT_TRUE(FamilyType::Parse::parseCommandBuffer(genSrmCommands, streamStart, size)); + + return findAll(genSrmCommands.begin(), genSrmCommands.end()); + } + + template + std::vector findAllLrrCommands(void *streamStart, size_t size) { + genLrrCommands.clear(); + + EXPECT_TRUE(FamilyType::Parse::parseCommandBuffer(genLrrCommands, streamStart, size)); + + return findAll(genLrrCommands.begin(), genLrrCommands.end()); + } + + template + void validateSrmCommand(const typename FamilyType::MI_STORE_REGISTER_MEM *cmd, uint64_t expectedAddress, uint32_t expectedRegisterOffset) { + EXPECT_EQ(expectedRegisterOffset, cmd->getRegisterAddress()); + EXPECT_EQ(expectedAddress, cmd->getMemoryAddress()); + } + + template + void validateLrrCommand(const typename FamilyType::MI_LOAD_REGISTER_REG *cmd, uint32_t expectedRegisterOffset) { + EXPECT_EQ(expectedRegisterOffset, cmd->getSourceRegisterAddress()); + } + + template + void validateCommands(const std::vector &srmCommands, bool beforeWalker, bool useMask) { + using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM; + using MI_LOAD_REGISTER_REG = typename FamilyType::MI_LOAD_REGISTER_REG; + + auto baseAddr = eventObj->getGpuAddress(device); + auto contextOffset = beforeWalker ? eventObj->getContextStartOffset() : eventObj->getContextEndOffset(); + auto globalOffset = beforeWalker ? eventObj->getGlobalStartOffset() : eventObj->getGlobalEndOffset(); + + uint64_t globalAddress = ptrOffset(baseAddr, globalOffset); + uint64_t contextAddress = ptrOffset(baseAddr, contextOffset); + + if (useMask) { + ASSERT_EQ(8u, srmCommands.size()); + + validateSrmCommand(reinterpret_cast(*srmCommands[0]), globalAddress, RegisterOffsets::csGprR12); + validateSrmCommand(reinterpret_cast(*srmCommands[1]), contextAddress, RegisterOffsets::csGprR12); + validateSrmCommand(reinterpret_cast(*srmCommands[2]), globalAddress + sizeof(uint32_t), RegisterOffsets::csGprR12); + validateSrmCommand(reinterpret_cast(*srmCommands[3]), contextAddress + sizeof(uint32_t), RegisterOffsets::csGprR12); + + validateLrrCommand(reinterpret_cast(*srmCommands[4]), RegisterOffsets::globalTimestampLdw); + validateLrrCommand(reinterpret_cast(*srmCommands[5]), RegisterOffsets::gpThreadTimeRegAddressOffsetLow); + validateLrrCommand(reinterpret_cast(*srmCommands[6]), RegisterOffsets::globalTimestampUn); + validateLrrCommand(reinterpret_cast(*srmCommands[7]), RegisterOffsets::gpThreadTimeRegAddressOffsetHigh); + + } else { + ASSERT_EQ(4u, srmCommands.size()); + + validateSrmCommand(reinterpret_cast(*srmCommands[0]), globalAddress, RegisterOffsets::globalTimestampLdw); + validateSrmCommand(reinterpret_cast(*srmCommands[1]), contextAddress, RegisterOffsets::gpThreadTimeRegAddressOffsetLow); + validateSrmCommand(reinterpret_cast(*srmCommands[2]), globalAddress + sizeof(uint32_t), RegisterOffsets::globalTimestampUn); + validateSrmCommand(reinterpret_cast(*srmCommands[3]), contextAddress + sizeof(uint32_t), RegisterOffsets::gpThreadTimeRegAddressOffsetHigh); + } + } + + DebugManagerStateRestore restore; + std::unique_ptr eventPool; + std::unique_ptr eventObj; + GenCmdList genSrmCommands; + GenCmdList genLrrCommands; +}; + +using CommandListXe2AndLaterTests = Test; + +HWTEST2_F(CommandListXe2AndLaterTests, given64bEventWhenTimestampIsWrittenThenAddExtraMmioReads, Platforms) { + auto commandList = std::make_unique>>(); + commandList->initialize(device, NEO::EngineGroupType::compute, 0u); + + NEO::LinearStream *commandStream = commandList->getCmdContainer().getCommandStream(); + + commandList->appendWriteKernelTimestamp(eventObj.get(), nullptr, false, false, false, false); + + size_t streamOffset = commandStream->getUsed(); + + { + auto srmCommands = findAllSrmCommands(commandStream->getCpuBase(), commandStream->getUsed()); + + validateCommands(srmCommands, false, false); + } + + commandList->appendWriteKernelTimestamp(eventObj.get(), nullptr, true, false, false, false); + + { + auto srmCommands = findAllSrmCommands(ptrOffset(commandStream->getCpuBase(), streamOffset), + (commandStream->getUsed() - streamOffset)); + validateCommands(srmCommands, true, false); + } +} + +HWTEST2_F(CommandListXe2AndLaterTests, given64bEventWithLsbMaskingWhenTimestampIsWrittenThenAddExtraMmioReads, Platforms) { + auto commandList = std::make_unique>>(); + commandList->initialize(device, NEO::EngineGroupType::compute, 0u); + + NEO::LinearStream *commandStream = commandList->getCmdContainer().getCommandStream(); + + commandList->appendWriteKernelTimestamp(eventObj.get(), nullptr, false, true, false, false); + + size_t streamOffset = commandStream->getUsed(); + + { + auto commands = findAllSrmCommands(commandStream->getCpuBase(), commandStream->getUsed()); + auto lrrCommands = findAllLrrCommands(commandStream->getCpuBase(), commandStream->getUsed()); + commands.insert(commands.end(), lrrCommands.begin(), lrrCommands.end()); + + validateCommands(commands, false, true); + } + + commandList->appendWriteKernelTimestamp(eventObj.get(), nullptr, true, true, false, false); + + { + auto commands = findAllSrmCommands(ptrOffset(commandStream->getCpuBase(), streamOffset), + (commandStream->getUsed() - streamOffset)); + auto lrrCommands = findAllLrrCommands(ptrOffset(commandStream->getCpuBase(), streamOffset), + (commandStream->getUsed() - streamOffset)); + commands.insert(commands.end(), lrrCommands.begin(), lrrCommands.end()); + + validateCommands(commands, true, true); + } +} + +using CommandListAppendRangesBarrierXe2AndLater = Test; + +HWTEST2_F(CommandListAppendRangesBarrierXe2AndLater, givenCallToAppendRangesBarrierThenPipeControlProgrammed, Platforms) { + using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; + using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL; + auto commandList = std::make_unique>>(); + commandList->initialize(device, NEO::EngineGroupType::copy, 0u); + uint64_t gpuAddress = 0x1200; + void *buffer = reinterpret_cast(gpuAddress); + size_t size = 0x1100; + + NEO::MockGraphicsAllocation mockAllocation(buffer, gpuAddress, size); + NEO::SvmAllocationData allocData(0); + allocData.size = size; + allocData.gpuAllocations.addAllocation(&mockAllocation); + device->getDriverHandle()->getSvmAllocsManager()->insertSVMAlloc(allocData); + const void *ranges[] = {buffer}; + const size_t sizes[] = {size}; + commandList->applyMemoryRangesBarrier(1, sizes, ranges); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, ptrOffset(commandList->getCmdContainer().getCommandStream()->getCpuBase(), 0), commandList->getCmdContainer().getCommandStream()->getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + auto pipeControlCmd = reinterpret_cast(*itor); + EXPECT_TRUE(pipeControlCmd->getDataportFlush()); + EXPECT_TRUE(pipeControlCmd->getUnTypedDataPortCacheFlush()); + auto expectedDcFlushEnable = NEO::MemorySynchronizationCommands::getDcFlushEnable(true, device->getNEODevice()->getRootDeviceEnvironment()); + EXPECT_EQ(expectedDcFlushEnable, pipeControlCmd->getDcFlushEnable()); +} + +using CommandListXe2AndLaterPreemptionTest = Test; +HWTEST2_F(CommandListXe2AndLaterPreemptionTest, givenAppendLaunchKernelWhenKernelFlagRequiresDisablePreemptionThenExpectInterfaceDescriptorDataDisablePreemption, Platforms) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; + + auto &container = commandList->getCmdContainer(); + auto &cmdListStream = *container.getCommandStream(); + + mockKernelImmData->kernelDescriptor->kernelAttributes.flags.requiresDisabledMidThreadPreemption = true; + + ze_group_count_t groupCount{1, 1, 1}; + CmdListKernelLaunchParams launchParams = {}; + size_t sizeBefore = cmdListStream.getUsed(); + auto result = commandList->appendLaunchKernel(kernel->toHandle(), groupCount, nullptr, 0, nullptr, launchParams, false); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + size_t sizeAfter = cmdListStream.getUsed(); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, + ptrOffset(cmdListStream.getCpuBase(), sizeBefore), + sizeAfter - sizeBefore)); + + auto walkerCmds = findAll(cmdList.begin(), cmdList.end()); + ASSERT_EQ(1u, walkerCmds.size()); + + auto walkerCmd = reinterpret_cast(*walkerCmds[0]); + auto &idd = walkerCmd->getInterfaceDescriptor(); + EXPECT_FALSE(idd.getThreadPreemption()); +} + +HWTEST2_F(CommandListXe2AndLaterPreemptionTest, + givenAppendLaunchKernelWhenKernelRequiresDisablePreemptionForRayTracingAndKernelIsUsingRayTracingCallsThenExpectInterfaceDescriptorDataDisablePreemption, + Platforms) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; + + auto &container = commandList->getCmdContainer(); + auto &cmdListStream = *container.getCommandStream(); + + NEO::MockGraphicsAllocation rtMockAllocation; + neoDevice->rtMemoryBackedBuffer = &rtMockAllocation; + mockKernelImmData->kernelDescriptor->kernelAttributes.flags.hasRTCalls = true; + kernel->midThreadPreemptionDisallowedForRayTracingKernels = true; + + ze_group_count_t groupCount{1, 1, 1}; + CmdListKernelLaunchParams launchParams = {}; + size_t sizeBefore = cmdListStream.getUsed(); + auto result = commandList->appendLaunchKernel(kernel->toHandle(), groupCount, nullptr, 0, nullptr, launchParams, false); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + size_t sizeAfter = cmdListStream.getUsed(); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, + ptrOffset(cmdListStream.getCpuBase(), sizeBefore), + sizeAfter - sizeBefore)); + + auto walkerCmds = findAll(cmdList.begin(), cmdList.end()); + ASSERT_EQ(1u, walkerCmds.size()); + + auto walkerCmd = reinterpret_cast(*walkerCmds[0]); + auto &idd = walkerCmd->getInterfaceDescriptor(); + EXPECT_FALSE(idd.getThreadPreemption()); + + neoDevice->rtMemoryBackedBuffer = nullptr; +} + +HWTEST2_F(CommandListXe2AndLaterPreemptionTest, + givenAppendLaunchKernelWhenKernelRequiresDisablePreemptionForRayTracingAndKernelIsNotUsingRayTracingCallsThenExpectInterfaceDescriptorDataEnablePreemption, + Platforms) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; + + auto &container = commandList->getCmdContainer(); + auto &cmdListStream = *container.getCommandStream(); + + mockKernelImmData->kernelDescriptor->kernelAttributes.flags.hasRTCalls = false; + kernel->midThreadPreemptionDisallowedForRayTracingKernels = true; + + ze_group_count_t groupCount{1, 1, 1}; + CmdListKernelLaunchParams launchParams = {}; + size_t sizeBefore = cmdListStream.getUsed(); + auto result = commandList->appendLaunchKernel(kernel->toHandle(), groupCount, nullptr, 0, nullptr, launchParams, false); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + size_t sizeAfter = cmdListStream.getUsed(); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, + ptrOffset(cmdListStream.getCpuBase(), sizeBefore), + sizeAfter - sizeBefore)); + + auto walkerCmds = findAll(cmdList.begin(), cmdList.end()); + ASSERT_EQ(1u, walkerCmds.size()); + + auto walkerCmd = reinterpret_cast(*walkerCmds[0]); + auto &idd = walkerCmd->getInterfaceDescriptor(); + EXPECT_TRUE(idd.getThreadPreemption()); +} + +HWTEST2_F(CommandListXe2AndLaterPreemptionTest, + givenAppendLaunchKernelWhenKernelDoNotRequireDisablePreemptionForRayTracingAndKernelIsUsingRayTracingCallsThenExpectInterfaceDescriptorDataEnablePreemption, + Platforms) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; + + auto &container = commandList->getCmdContainer(); + auto &cmdListStream = *container.getCommandStream(); + + NEO::MockGraphicsAllocation rtMockAllocation; + neoDevice->rtMemoryBackedBuffer = &rtMockAllocation; + mockKernelImmData->kernelDescriptor->kernelAttributes.flags.hasRTCalls = true; + kernel->midThreadPreemptionDisallowedForRayTracingKernels = false; + + ze_group_count_t groupCount{1, 1, 1}; + CmdListKernelLaunchParams launchParams = {}; + size_t sizeBefore = cmdListStream.getUsed(); + auto result = commandList->appendLaunchKernel(kernel->toHandle(), groupCount, nullptr, 0, nullptr, launchParams, false); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + size_t sizeAfter = cmdListStream.getUsed(); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, + ptrOffset(cmdListStream.getCpuBase(), sizeBefore), + sizeAfter - sizeBefore)); + + auto walkerCmds = findAll(cmdList.begin(), cmdList.end()); + ASSERT_EQ(1u, walkerCmds.size()); + + auto walkerCmd = reinterpret_cast(*walkerCmds[0]); + auto &idd = walkerCmd->getInterfaceDescriptor(); + EXPECT_TRUE(idd.getThreadPreemption()); + + neoDevice->rtMemoryBackedBuffer = nullptr; +} + +HWTEST2_F(CommandListXe2AndLaterPreemptionTest, + givenObtainKernelPreemptionModeWhenInDeviceFrocePreemptionModeDifferentThanMidThreadThenThreadGroupPreemptionModeIsReturned, + Platforms) { + + neoDevice->preemptionMode = NEO::PreemptionMode::Disabled; + mockKernelImmData->kernelDescriptor->kernelAttributes.flags.requiresDisabledMidThreadPreemption = false; + mockKernelImmData->kernelDescriptor->kernelAttributes.flags.hasRTCalls = false; + kernel->midThreadPreemptionDisallowedForRayTracingKernels = false; + + auto commandListCore = std::make_unique>>(); + commandListCore->initialize(device, NEO::EngineGroupType::compute, 0u); + + auto result = commandListCore->obtainKernelPreemptionMode(kernel.get()); + EXPECT_EQ(NEO::PreemptionMode::ThreadGroup, result); +} + +HWTEST2_F(CommandListXe2AndLaterPreemptionTest, + givenObtainKernelPreemptionModeWhenInDeviceFrocePreemptionModeMidThreadAndOtherKernelFlagsNotSetThenMidThreadPreemptionModeIsReturned, + Platforms) { + + neoDevice->preemptionMode = NEO::PreemptionMode::MidThread; + mockKernelImmData->kernelDescriptor->kernelAttributes.flags.requiresDisabledMidThreadPreemption = false; + mockKernelImmData->kernelDescriptor->kernelAttributes.flags.hasRTCalls = false; + kernel->midThreadPreemptionDisallowedForRayTracingKernels = false; + + auto commandListCore = std::make_unique>>(); + commandListCore->initialize(device, NEO::EngineGroupType::compute, 0u); + + auto result = commandListCore->obtainKernelPreemptionMode(kernel.get()); + EXPECT_EQ(NEO::PreemptionMode::MidThread, result); +} +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe2_hpg_core/CMakeLists.txt b/level_zero/core/test/unit_tests/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..72e0ee8436 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XE2_HPG_CORE) + target_sources(${TARGET_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdqueue_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_device_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_l0_gfx_core_helper_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_module_xe2_hpg_core.cpp + ) +endif() diff --git a/level_zero/core/test/unit_tests/xe2_hpg_core/test_cmdlist_xe2_hpg_core.cpp b/level_zero/core/test/unit_tests/xe2_hpg_core/test_cmdlist_xe2_hpg_core.cpp new file mode 100644 index 0000000000..7a6e981683 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe2_hpg_core/test_cmdlist_xe2_hpg_core.cpp @@ -0,0 +1,460 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/product_helper.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "level_zero/core/source/event/event.h" +#include "level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.inl" +#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" +#include "level_zero/core/test/unit_tests/mocks/mock_module.h" +#include "level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h" + +namespace L0 { +namespace ult { + +struct LocalMemoryModuleFixture : public ModuleFixture { + void setUp() { + debugManager.flags.EnableLocalMemory.set(1); + ModuleFixture::setUp(); + } + DebugManagerStateRestore restore; +}; + +using CommandListAppendLaunchKernelXe2HpgCore = Test; + +HWTEST2_F(CommandListAppendLaunchKernelXe2HpgCore, givenAppendKernelWhenKernelNotUsingSystemMemoryAllocationsAndEventNotHostSignalScopeThenExpectsNoSystemFenceUsed, IsXe2HpgCore) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + + ze_result_t result = ZE_RESULT_SUCCESS; + + constexpr size_t size = 4096u; + constexpr size_t alignment = 4096u; + void *ptr = nullptr; + + ze_device_mem_alloc_desc_t deviceDesc = {}; + result = context->allocDeviceMem(device->toHandle(), + &deviceDesc, + size, alignment, &ptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_NE(nullptr, ptr); + + Mock<::L0::KernelImp> kernel; + auto mockModule = std::unique_ptr(new Mock(device, nullptr)); + kernel.module = mockModule.get(); + + auto allocData = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr); + ASSERT_NE(nullptr, allocData); + auto kernelAllocation = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); + ASSERT_NE(nullptr, kernelAllocation); + kernel.residencyContainer.push_back(kernelAllocation); + + ze_event_pool_desc_t eventPoolDesc = {}; + eventPoolDesc.count = 1; + auto eventPool = std::unique_ptr(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, result)); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + ze_event_desc_t eventDesc = {}; + eventDesc.index = 0; + eventDesc.signal = ZE_EVENT_SCOPE_FLAG_DEVICE; + eventDesc.wait = 0; + auto event = std::unique_ptr(L0::Event::create(eventPool.get(), &eventDesc, device)); + + kernel.setGroupSize(1, 1, 1); + ze_group_count_t groupCount{8, 1, 1}; + auto commandList = std::make_unique>>(); + result = commandList->initialize(device, NEO::EngineGroupType::compute, 0u); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + CmdListKernelLaunchParams launchParams = {}; + result = commandList->appendLaunchKernelWithParams(&kernel, groupCount, event.get(), launchParams); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + GenCmdList commands; + ASSERT_TRUE(CmdParse::parseCommandBuffer( + commands, + commandList->getCmdContainer().getCommandStream()->getCpuBase(), + commandList->getCmdContainer().getCommandStream()->getUsed())); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); + + result = context->freeMem(ptr); + ASSERT_EQ(result, ZE_RESULT_SUCCESS); +} + +HWTEST2_F(CommandListAppendLaunchKernelXe2HpgCore, + givenAppendKernelWhenKernelUsingUsmHostMemoryAllocationsAndEventNotHostSignalScopeThenExpectsNoSystemFenceUsed, IsXe2HpgCore) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + + ze_result_t result = ZE_RESULT_SUCCESS; + + constexpr size_t size = 4096u; + constexpr size_t alignment = 4096u; + void *ptr = nullptr; + + ze_host_mem_alloc_desc_t hostDesc = {}; + result = context->allocHostMem(&hostDesc, size, alignment, &ptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_NE(nullptr, ptr); + + Mock<::L0::KernelImp> kernel; + auto mockModule = std::unique_ptr(new Mock(device, nullptr)); + kernel.module = mockModule.get(); + + auto allocData = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr); + ASSERT_NE(nullptr, allocData); + auto kernelAllocation = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); + ASSERT_NE(nullptr, kernelAllocation); + kernel.residencyContainer.push_back(kernelAllocation); + + ze_event_pool_desc_t eventPoolDesc = {}; + eventPoolDesc.count = 1; + auto eventPool = std::unique_ptr(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, result)); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + ze_event_desc_t eventDesc = {}; + eventDesc.index = 0; + eventDesc.signal = ZE_EVENT_SCOPE_FLAG_DEVICE; + eventDesc.wait = 0; + auto event = std::unique_ptr(L0::Event::create(eventPool.get(), &eventDesc, device)); + + kernel.setGroupSize(1, 1, 1); + ze_group_count_t groupCount{8, 1, 1}; + auto commandList = std::make_unique>>(); + result = commandList->initialize(device, NEO::EngineGroupType::compute, 0u); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + CmdListKernelLaunchParams launchParams = {}; + result = commandList->appendLaunchKernelWithParams(&kernel, groupCount, event.get(), launchParams); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + GenCmdList commands; + ASSERT_TRUE(CmdParse::parseCommandBuffer( + commands, + commandList->getCmdContainer().getCommandStream()->getCpuBase(), + commandList->getCmdContainer().getCommandStream()->getUsed())); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); + + result = context->freeMem(ptr); + ASSERT_EQ(result, ZE_RESULT_SUCCESS); +} + +HWTEST2_F(CommandListAppendLaunchKernelXe2HpgCore, + givenAppendKernelWhenMigrationOnComputeUsingUsmSharedCpuMemoryAllocationsAndEventNotHostSignalScopeThenExpectsNoSystemFenceUsed, IsXe2HpgCore) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + + ze_result_t result = ZE_RESULT_SUCCESS; + + constexpr size_t size = 4096u; + constexpr size_t alignment = 4096u; + void *ptr = nullptr; + + ze_host_mem_alloc_desc_t hostDesc = {}; + ze_device_mem_alloc_desc_t deviceDesc = {}; + result = context->allocSharedMem(device->toHandle(), &deviceDesc, &hostDesc, size, alignment, &ptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_NE(nullptr, ptr); + + auto allocData = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr); + ASSERT_NE(nullptr, allocData); + auto dstAllocation = allocData->cpuAllocation; + ASSERT_NE(nullptr, dstAllocation); + auto srcAllocation = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); + ASSERT_NE(nullptr, srcAllocation); + + auto commandList = std::make_unique>>(); + result = commandList->initialize(device, NEO::EngineGroupType::compute, 0u); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + result = commandList->appendPageFaultCopy(dstAllocation, srcAllocation, size, false); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_TRUE(commandList->usedKernelLaunchParams.isBuiltInKernel); + EXPECT_FALSE(commandList->usedKernelLaunchParams.isKernelSplitOperation); + EXPECT_TRUE(commandList->usedKernelLaunchParams.isDestinationAllocationInSystemMemory); + + GenCmdList commands; + ASSERT_TRUE(CmdParse::parseCommandBuffer( + commands, + commandList->getCmdContainer().getCommandStream()->getCpuBase(), + commandList->getCmdContainer().getCommandStream()->getUsed())); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); + + result = context->freeMem(ptr); + ASSERT_EQ(result, ZE_RESULT_SUCCESS); +} + +HWTEST2_F(CommandListAppendLaunchKernelXe2HpgCore, + givenAppendKernelWhenKernelUsingIndirectSystemMemoryAllocationsAndEventNotHostSignalScopeThenExpectsNoSystemFenceUsed, IsXe2HpgCore) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + + ze_result_t result = ZE_RESULT_SUCCESS; + + constexpr size_t size = 4096u; + constexpr size_t alignment = 4096u; + void *ptr = nullptr; + + ze_device_mem_alloc_desc_t deviceDesc = {}; + result = context->allocDeviceMem(device->toHandle(), + &deviceDesc, + size, alignment, &ptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_NE(nullptr, ptr); + + Mock<::L0::KernelImp> kernel; + auto mockModule = std::unique_ptr(new Mock(device, nullptr)); + kernel.module = mockModule.get(); + + auto allocData = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr); + ASSERT_NE(nullptr, allocData); + auto kernelAllocation = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); + ASSERT_NE(nullptr, kernelAllocation); + kernel.residencyContainer.push_back(kernelAllocation); + + kernel.unifiedMemoryControls.indirectHostAllocationsAllowed = true; + + ze_event_pool_desc_t eventPoolDesc = {}; + eventPoolDesc.count = 1; + auto eventPool = std::unique_ptr(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, result)); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + ze_event_desc_t eventDesc = {}; + eventDesc.index = 0; + eventDesc.signal = ZE_EVENT_SCOPE_FLAG_DEVICE; + eventDesc.wait = 0; + auto event = std::unique_ptr(L0::Event::create(eventPool.get(), &eventDesc, device)); + + kernel.setGroupSize(1, 1, 1); + ze_group_count_t groupCount{8, 1, 1}; + auto commandList = std::make_unique>>(); + result = commandList->initialize(device, NEO::EngineGroupType::compute, 0u); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + CmdListKernelLaunchParams launchParams = {}; + result = commandList->appendLaunchKernelWithParams(&kernel, groupCount, event.get(), launchParams); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + GenCmdList commands; + ASSERT_TRUE(CmdParse::parseCommandBuffer( + commands, + commandList->getCmdContainer().getCommandStream()->getCpuBase(), + commandList->getCmdContainer().getCommandStream()->getUsed())); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); + + result = context->freeMem(ptr); + ASSERT_EQ(result, ZE_RESULT_SUCCESS); +} + +HWTEST2_F(CommandListAppendLaunchKernelXe2HpgCore, + givenAppendKernelWhenKernelUsingDeviceMemoryAllocationsAndEventHostSignalScopeThenExpectsNoSystemFenceUsed, IsXe2HpgCore) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + + ze_result_t result = ZE_RESULT_SUCCESS; + + constexpr size_t size = 4096u; + constexpr size_t alignment = 4096u; + void *ptr = nullptr; + + ze_device_mem_alloc_desc_t deviceDesc = {}; + result = context->allocDeviceMem(device->toHandle(), + &deviceDesc, + size, alignment, &ptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_NE(nullptr, ptr); + + Mock<::L0::KernelImp> kernel; + auto mockModule = std::unique_ptr(new Mock(device, nullptr)); + kernel.module = mockModule.get(); + + auto allocData = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr); + ASSERT_NE(nullptr, allocData); + auto kernelAllocation = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); + ASSERT_NE(nullptr, kernelAllocation); + kernel.residencyContainer.push_back(kernelAllocation); + + ze_event_pool_desc_t eventPoolDesc = {}; + eventPoolDesc.count = 1; + auto eventPool = std::unique_ptr(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, result)); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + ze_event_desc_t eventDesc = {}; + eventDesc.index = 0; + eventDesc.signal = ZE_EVENT_SCOPE_FLAG_HOST; + eventDesc.wait = 0; + auto event = std::unique_ptr(L0::Event::create(eventPool.get(), &eventDesc, device)); + + kernel.setGroupSize(1, 1, 1); + ze_group_count_t groupCount{8, 1, 1}; + auto commandList = std::make_unique>>(); + result = commandList->initialize(device, NEO::EngineGroupType::compute, 0u); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + CmdListKernelLaunchParams launchParams = {}; + result = commandList->appendLaunchKernelWithParams(&kernel, groupCount, event.get(), launchParams); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + GenCmdList commands; + ASSERT_TRUE(CmdParse::parseCommandBuffer( + commands, + commandList->getCmdContainer().getCommandStream()->getCpuBase(), + commandList->getCmdContainer().getCommandStream()->getUsed())); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); + + result = context->freeMem(ptr); + ASSERT_EQ(result, ZE_RESULT_SUCCESS); +} + +HWTEST2_F(CommandListAppendLaunchKernelXe2HpgCore, + givenAppendKernelWhenKernelUsingUsmHostMemoryAllocationsAndEventHostSignalScopeThenExpectsSystemFenceUsed, IsXe2HpgCore) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + + ze_result_t result = ZE_RESULT_SUCCESS; + + constexpr size_t size = 4096u; + constexpr size_t alignment = 4096u; + void *ptr = nullptr; + + ze_host_mem_alloc_desc_t hostDesc = {}; + result = context->allocHostMem(&hostDesc, size, alignment, &ptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_NE(nullptr, ptr); + + Mock<::L0::KernelImp> kernel; + auto mockModule = std::unique_ptr(new Mock(device, nullptr)); + kernel.module = mockModule.get(); + + auto allocData = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr); + ASSERT_NE(nullptr, allocData); + auto kernelAllocation = allocData->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); + ASSERT_NE(nullptr, kernelAllocation); + kernel.residencyContainer.push_back(kernelAllocation); + + ze_event_pool_desc_t eventPoolDesc = {}; + eventPoolDesc.count = 1; + auto eventPool = std::unique_ptr(L0::EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, result)); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + ze_event_desc_t eventDesc = {}; + eventDesc.index = 0; + eventDesc.signal = ZE_EVENT_SCOPE_FLAG_HOST; + eventDesc.wait = 0; + auto event = std::unique_ptr(L0::Event::create(eventPool.get(), &eventDesc, device)); + + kernel.setGroupSize(1, 1, 1); + ze_group_count_t groupCount{8, 1, 1}; + auto commandList = std::make_unique>>(); + result = commandList->initialize(device, NEO::EngineGroupType::compute, 0u); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + CmdListKernelLaunchParams launchParams = {}; + result = commandList->appendLaunchKernelWithParams(&kernel, groupCount, event.get(), launchParams); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + GenCmdList commands; + ASSERT_TRUE(CmdParse::parseCommandBuffer( + commands, + commandList->getCmdContainer().getCommandStream()->getCpuBase(), + commandList->getCmdContainer().getCommandStream()->getUsed())); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_TRUE(postSyncData.getSystemMemoryFenceRequest()); + + result = context->freeMem(ptr); + ASSERT_EQ(result, ZE_RESULT_SUCCESS); +} + +using CommandListAppendLaunchKernelXe2HpgCoreDebugger = Test; + +HWTEST2_F(CommandListAppendLaunchKernelXe2HpgCoreDebugger, givenDebuggingEnabledWhenKernelAppendedThenIDDDoesNotHaveMidThreadPreemptionEnabled, IsXe2HpgCore) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + + ze_command_queue_desc_t queueDesc = {}; + auto queue = std::make_unique>(device, device->getNEODevice()->getDefaultEngine().commandStreamReceiver, &queueDesc); + + ze_group_count_t groupCount{128, 1, 1}; + auto immediateCmdList = std::make_unique>>(); + immediateCmdList->cmdListType = ::L0::CommandList::CommandListType::typeImmediate; + immediateCmdList->isFlushTaskSubmissionEnabled = false; + immediateCmdList->cmdQImmediate = queue.get(); + auto result = immediateCmdList->initialize(device, NEO::EngineGroupType::compute, 0u); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + auto cmdStream = immediateCmdList->getCmdContainer().getCommandStream(); + + auto sizeBefore = cmdStream->getUsed(); + CmdListKernelLaunchParams launchParams = {}; + Mock<::L0::KernelImp> kernel; + auto mockModule = std::unique_ptr(new Mock(device, nullptr)); + kernel.module = mockModule.get(); + + kernel.setGroupSize(1, 1, 1); + + result = immediateCmdList->appendLaunchKernelWithParams(&kernel, groupCount, nullptr, launchParams); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + auto sizeAfter = cmdStream->getUsed(); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, + ptrOffset(cmdStream->getCpuBase(), sizeBefore), + sizeAfter - sizeBefore)); + + auto itorWalker = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(cmdList.end(), itorWalker); + auto cmdWalker = genCmdCast(*itorWalker); + + EXPECT_EQ(0u, cmdWalker->getInterfaceDescriptor().getThreadPreemption()); +} + +using CmdListThreadArbitrationTestXe2HpgCore = Test; + +using ThreadArbitrationSupport = IsAnyProducts; +HWTEST2_F(CmdListThreadArbitrationTestXe2HpgCore, + givenAppendThreadArbitrationKernelToCommandListWhenExecutingCommandListThenStateComputeModeStateIsTrackedCorrectly, ThreadArbitrationSupport) { + testBody(); +} + +using CmdListLargeGrfTestXe2Hpg = Test; + +using LargeGrfSupport = IsAnyProducts; +HWTEST2_F(CmdListLargeGrfTestXe2Hpg, + givenAppendLargeGrfKernelToCommandListWhenExecutingCommandListThenStateComputeModeStateIsTrackedCorrectly, LargeGrfSupport) { + testBody(); +} + +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe2_hpg_core/test_cmdqueue_xe2_hpg_core.cpp b/level_zero/core/test/unit_tests/xe2_hpg_core/test_cmdqueue_xe2_hpg_core.cpp new file mode 100644 index 0000000000..7b2046fee8 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe2_hpg_core/test_cmdqueue_xe2_hpg_core.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/mocks/mock_command_stream_receiver.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "level_zero/core/source/cmdlist/cmdlist.h" +#include "level_zero/core/source/driver/driver_handle_imp.h" +#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h" + +namespace L0 { +namespace ult { + +using CommandQueueCommandsXe2HpgCore = Test; + +HWTEST2_F(CommandQueueCommandsXe2HpgCore, givenCommandQueueWhenExecutingCommandListsThenStateSystemMemFenceAddressCmdIsGenerated, IsAtLeastXe2HpgCore) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + ze_command_queue_desc_t desc = {}; + auto csr = neoDevice->getDefaultEngine().commandStreamReceiver; + + auto commandQueue = new MockCommandQueueHw(device, csr, &desc); + commandQueue->initialize(false, false, false); + + ze_result_t returnValue; + std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::compute, 0u, returnValue, false)); + auto commandListHandle = commandList->toHandle(); + commandList->close(); + + commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false, nullptr); + + auto globalFence = csr->getGlobalFenceAllocation(); + + auto used = commandQueue->commandStream.getUsed(); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, commandQueue->commandStream.getCpuBase(), used)); + + auto itor = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(cmdList.end(), itor); + + auto systemMemFenceAddressCmd = genCmdCast(*itor); + EXPECT_EQ(globalFence->getGpuAddress(), systemMemFenceAddressCmd->getSystemMemoryFenceAddress()); + + commandQueue->destroy(); +} + +HWTEST2_F(CommandQueueCommandsXe2HpgCore, givenCommandQueueWhenExecutingCommandListsForTheSecondTimeThenStateSystemMemFenceAddressCmdIsNotGenerated, IsAtLeastXe2HpgCore) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + ze_command_queue_desc_t desc = {}; + auto csr = neoDevice->getDefaultEngine().commandStreamReceiver; + + auto commandQueue = new MockCommandQueueHw(device, csr, &desc); + commandQueue->initialize(false, false, false); + + ze_result_t returnValue; + std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::compute, 0u, returnValue, false)); + auto commandListHandle = commandList->toHandle(); + commandList->close(); + + commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false, nullptr); + auto usedSpaceAfter1stExecute = commandQueue->commandStream.getUsed(); + commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false, nullptr); + auto usedSpaceOn2ndExecute = commandQueue->commandStream.getUsed() - usedSpaceAfter1stExecute; + + GenCmdList cmdList; + auto cmdBufferAddress = ptrOffset(commandQueue->commandStream.getCpuBase(), usedSpaceAfter1stExecute); + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer(cmdList, cmdBufferAddress, usedSpaceOn2ndExecute)); + + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_EQ(cmdList.end(), itor); + + commandQueue->destroy(); +} + +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe2_hpg_core/test_device_xe2_hpg_core.cpp b/level_zero/core/test/unit_tests/xe2_hpg_core/test_device_xe2_hpg_core.cpp new file mode 100644 index 0000000000..813662183d --- /dev/null +++ b/level_zero/core/test/unit_tests/xe2_hpg_core/test_device_xe2_hpg_core.cpp @@ -0,0 +1,293 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_device.h" + +namespace L0 { +namespace ult { + +using DeviceXe2HpgCoreTest = Test; + +HWTEST2_F(DeviceXe2HpgCoreTest, whenCallingGetMemoryPropertiesWithNonNullPtrThenPropertiesAreReturned, IsXe2HpgCore) { + uint32_t count = 0; + ze_result_t res = device->getMemoryProperties(&count, nullptr); + EXPECT_EQ(res, ZE_RESULT_SUCCESS); + EXPECT_EQ(1u, count); + + ze_device_memory_properties_t memProperties = {}; + res = device->getMemoryProperties(&count, &memProperties); + EXPECT_EQ(res, ZE_RESULT_SUCCESS); + EXPECT_EQ(1u, count); + + EXPECT_EQ(memProperties.maxClockRate, 0u); + EXPECT_EQ(memProperties.maxBusWidth, this->neoDevice->getDeviceInfo().addressBits); + EXPECT_EQ(memProperties.totalSize, this->neoDevice->getDeviceInfo().globalMemSize); +} + +HWTEST2_F(DeviceXe2HpgCoreTest, GivenTargetXeHpgCoreWhenGettingDpSupportThenReturnsTrue, IsXe2HpgCore) { + ze_device_module_properties_t deviceModProps = {ZE_STRUCTURE_TYPE_DEVICE_MODULE_PROPERTIES}; + ze_intel_device_module_dp_exp_properties_t moduleDpProps = {ZE_STRUCTURE_INTEL_DEVICE_MODULE_DP_EXP_PROPERTIES}; + moduleDpProps.flags = 0u; + deviceModProps.pNext = &moduleDpProps; + + ze_result_t res = device->getKernelProperties(&deviceModProps); + EXPECT_EQ(res, ZE_RESULT_SUCCESS); + + bool dp4a = moduleDpProps.flags & ZE_INTEL_DEVICE_MODULE_EXP_FLAG_DP4A; + bool dpas = moduleDpProps.flags & ZE_INTEL_DEVICE_MODULE_EXP_FLAG_DPAS; + EXPECT_TRUE(dp4a); + EXPECT_TRUE(dpas); +} + +using CommandQueueGroupTest = Test; + +HWTEST2_F(CommandQueueGroupTest, givenNoBlitterSupportAndNoCCSThenOneQueueGroupIsReturned, IsXe2HpgCore) { + const uint32_t rootDeviceIndex = 0u; + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + hwInfo.featureTable.flags.ftrCCSNode = false; + hwInfo.capabilityTable.blitterOperationsSupported = false; + auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, rootDeviceIndex); + MockDeviceImp deviceImp(neoMockDevice, neoMockDevice->getExecutionEnvironment()); + + uint32_t count = 0; + ze_result_t res = deviceImp.getCommandQueueGroupProperties(&count, nullptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + EXPECT_GE(count, 1u); +} + +HWTEST2_F(CommandQueueGroupTest, givenNoBlitterSupportAndCCSThenTwoQueueGroupsAreReturned, IsXe2HpgCore) { + const uint32_t rootDeviceIndex = 0u; + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + hwInfo.featureTable.flags.ftrCCSNode = true; + hwInfo.capabilityTable.blitterOperationsSupported = false; + auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, rootDeviceIndex); + MockDeviceImp deviceImp(neoMockDevice, neoMockDevice->getExecutionEnvironment()); + + uint32_t count = 0; + ze_result_t res = deviceImp.getCommandQueueGroupProperties(&count, nullptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + EXPECT_GE(count, 2u); +} + +HWTEST2_F(CommandQueueGroupTest, givenBlitterSupportAndCCSThenFourQueueGroupsAreReturned, IsXe2HpgCore) { + const uint32_t rootDeviceIndex = 0u; + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + hwInfo.featureTable.flags.ftrCCSNode = true; + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.featureTable.ftrBcsInfo.set(); + auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, rootDeviceIndex); + MockDeviceImp deviceImp(neoMockDevice, neoMockDevice->getExecutionEnvironment()); + + uint32_t count = 0; + ze_result_t res = deviceImp.getCommandQueueGroupProperties(&count, nullptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + EXPECT_GE(count, 4u); + + std::vector properties(count); + res = deviceImp.getCommandQueueGroupProperties(&count, properties.data()); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + + auto &engineGroups = neoMockDevice->getRegularEngineGroups(); + for (uint32_t i = 0; i < count; i++) { + if (engineGroups[i].engineGroupType == NEO::EngineGroupType::renderCompute) { + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS); + EXPECT_EQ(properties[i].numQueues, 1u); + EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits::max()); + } else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::compute) { + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS); + uint32_t numerOfCCSEnabled = hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled; + EXPECT_EQ(properties[i].numQueues, numerOfCCSEnabled); + EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits::max()); + } else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::copy) { + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY); + EXPECT_EQ(properties[i].numQueues, 1u); + EXPECT_EQ(properties[i].maxMemoryFillPatternSize, sizeof(uint8_t)); + } else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::linkedCopy) { + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY); + EXPECT_EQ(properties[i].numQueues, hwInfo.featureTable.ftrBcsInfo.count() - 1u); + EXPECT_EQ(properties[i].maxMemoryFillPatternSize, sizeof(uint8_t)); + } + } +} + +HWTEST2_F(CommandQueueGroupTest, givenBlitterSupportCCSAndLinkedBcsDisabledThenThreeQueueGroupsAreReturned, IsXe2HpgCore) { + const uint32_t rootDeviceIndex = 0u; + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + hwInfo.featureTable.flags.ftrCCSNode = true; + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.featureTable.ftrBcsInfo.set(0); + auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, rootDeviceIndex); + MockDeviceImp deviceImp(neoMockDevice, neoMockDevice->getExecutionEnvironment()); + + uint32_t count = 0; + ze_result_t res = deviceImp.getCommandQueueGroupProperties(&count, nullptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + EXPECT_GE(count, 3u); + + std::vector properties(count); + res = deviceImp.getCommandQueueGroupProperties(&count, properties.data()); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + + auto &engineGroups = neoMockDevice->getRegularEngineGroups(); + for (uint32_t i = 0; i < count; i++) { + if (engineGroups[i].engineGroupType == NEO::EngineGroupType::renderCompute) { + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS); + EXPECT_EQ(properties[i].numQueues, 1u); + EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits::max()); + } else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::compute) { + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS); + uint32_t numerOfCCSEnabled = hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled; + EXPECT_EQ(properties[i].numQueues, numerOfCCSEnabled); + EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits::max()); + } else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::copy) { + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY); + EXPECT_EQ(properties[i].numQueues, 1u); + EXPECT_EQ(properties[i].maxMemoryFillPatternSize, sizeof(uint8_t)); + } + } +} + +HWTEST2_F(CommandQueueGroupTest, givenBlitterDisabledAndAllBcsSetThenTwoQueueGroupsAreReturned, IsXe2HpgCore) { + DebugManagerStateRestore dbgRestorer; + debugManager.flags.EnableBlitterOperationsSupport.set(0); + const uint32_t rootDeviceIndex = 0u; + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + hwInfo.featureTable.flags.ftrCCSNode = true; + hwInfo.featureTable.ftrBcsInfo.set(); + auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, rootDeviceIndex); + MockDeviceImp deviceImp(neoMockDevice, neoMockDevice->getExecutionEnvironment()); + + uint32_t count = 0; + ze_result_t res = deviceImp.getCommandQueueGroupProperties(&count, nullptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + EXPECT_EQ(count, 2u); +} + +class DeviceCopyQueueGroupXe2HpgCoreFixture : public DeviceFixture { + public: + void setUp() { + debugManager.flags.EnableBlitterOperationsSupport.set(0); + DeviceFixture::setUp(); + } + + void tearDown() { + DeviceFixture::tearDown(); + } + DebugManagerStateRestore restorer; +}; + +using DeviceCopyQueueGroupXe2HpgCoreTest = Test; + +HWTEST2_F(DeviceCopyQueueGroupXe2HpgCoreTest, + givenBlitterSupportAndEnableBlitterOperationsSupportSetToZeroThenNoCopyEngineIsReturned, IsXe2HpgCore) { + const uint32_t rootDeviceIndex = 0u; + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + hwInfo.featureTable.flags.ftrCCSNode = false; + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.featureTable.ftrBcsInfo.set(0); + auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, + rootDeviceIndex); + MockDeviceImp deviceImp(neoMockDevice, neoMockDevice->getExecutionEnvironment()); + + uint32_t count = 0; + ze_result_t res = deviceImp.getCommandQueueGroupProperties(&count, nullptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + + std::vector properties(count); + res = deviceImp.getCommandQueueGroupProperties(&count, properties.data()); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + + for (auto &engineGroup : neoMockDevice->getRegularEngineGroups()) { + EXPECT_NE(NEO::EngineGroupType::copy, engineGroup.engineGroupType); + } +} + +class CommandQueueGroupTestXe2HpgCore : public DeviceFixture, public testing::TestWithParam { + public: + void SetUp() override { + DeviceFixture::setUp(); + } + + void TearDown() override { + DeviceFixture::tearDown(); + } +}; + +HWTEST2_P(CommandQueueGroupTestXe2HpgCore, givenVaryingBlitterSupportAndCCSThenBCSGroupContainsCorrectNumberOfEngines, IsXe2HpgCore) { + const uint32_t rootDeviceIndex = 0u; + NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get(); + hwInfo.featureTable.flags.ftrCCSNode = true; + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.featureTable.ftrBcsInfo = maxNBitValue(2); + hwInfo.featureTable.ftrBcsInfo.set(GetParam()); + auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment(&hwInfo, rootDeviceIndex); + MockDeviceImp deviceImp(neoMockDevice, neoMockDevice->getExecutionEnvironment()); + + uint32_t count = 0; + ze_result_t res = deviceImp.getCommandQueueGroupProperties(&count, nullptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + EXPECT_GE(count, 3u); + + std::vector properties(count); + res = deviceImp.getCommandQueueGroupProperties(&count, properties.data()); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + + auto &engineGroups = neoMockDevice->getRegularEngineGroups(); + for (uint32_t i = 0; i < count; i++) { + if (engineGroups[i].engineGroupType == NEO::EngineGroupType::renderCompute) { + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_METRICS); + EXPECT_EQ(properties[i].numQueues, 1u); + EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits::max()); + } else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::compute) { + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY); + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COOPERATIVE_KERNELS); + uint32_t numerOfCCSEnabled = hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled; + EXPECT_EQ(properties[i].numQueues, numerOfCCSEnabled); + EXPECT_EQ(properties[i].maxMemoryFillPatternSize, std::numeric_limits::max()); + } else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::copy) { + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY); + EXPECT_EQ(properties[i].numQueues, 1u); + EXPECT_EQ(properties[i].maxMemoryFillPatternSize, sizeof(uint8_t)); + } else if (engineGroups[i].engineGroupType == NEO::EngineGroupType::linkedCopy) { + EXPECT_TRUE(properties[i].flags & ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COPY); + EXPECT_EQ(properties[i].numQueues, hwInfo.featureTable.ftrBcsInfo.count() - 1u); + EXPECT_EQ(properties[i].maxMemoryFillPatternSize, sizeof(uint8_t)); + } + } +} + +INSTANTIATE_TEST_SUITE_P( + CommandQueueGroupTestXe2HpgCoreValues, + CommandQueueGroupTestXe2HpgCore, + testing::Values(0, 1, 2, 3)); + +HWTEST2_F(DeviceXe2HpgCoreTest, givenReturnedDevicePropertiesThenExpectedPageFaultSupportReturned, IsXe2HpgCore) { + ze_device_properties_t deviceProps = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES}; + + device->getProperties(&deviceProps); + EXPECT_NE(0u, deviceProps.flags & ZE_DEVICE_PROPERTY_FLAG_ONDEMANDPAGING); +} +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe2_hpg_core/test_l0_gfx_core_helper_xe2_hpg_core.cpp b/level_zero/core/test/unit_tests/xe2_hpg_core/test_l0_gfx_core_helper_xe2_hpg_core.cpp new file mode 100644 index 0000000000..119edd8f72 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe2_hpg_core/test_l0_gfx_core_helper_xe2_hpg_core.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/mocks/mock_execution_environment.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +#include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h" +#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" + +namespace L0 { +namespace ult { + +using L0GfxCoreHelperTestXe2Hpg = Test; + +HWTEST_EXCLUDE_PRODUCT(L0GfxCoreHelperTest, givenL0GfxCoreHelperWhenAskingForImageCompressionSupportThenReturnFalse, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(L0GfxCoreHelperTest, givenL0GfxCoreHelperWhenAskingForUsmCompressionSupportThenReturnFalse, IGFX_XE2_HPG_CORE); + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, givenL0GfxCoreHelperWhenGetRegsetTypeForLargeGrfDetectionIsCalledThenSrRegsetTypeIsRetuned) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_EQ(ZET_DEBUG_REGSET_TYPE_SR_INTEL_GPU, l0GfxCoreHelper.getRegsetTypeForLargeGrfDetection()); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, givenL0GfxCoreHelperWhenAskingForImageCompressionSupportThenReturnCorrectValue) { + DebugManagerStateRestore restore; + + auto &l0GfxCoreHelper = getHelper(); + + HardwareInfo hwInfo = *NEO::defaultHwInfo; + + hwInfo.capabilityTable.ftrRenderCompressedImages = true; + EXPECT_TRUE(l0GfxCoreHelper.imageCompressionSupported(hwInfo)); + + hwInfo.capabilityTable.ftrRenderCompressedImages = false; + EXPECT_FALSE(l0GfxCoreHelper.imageCompressionSupported(hwInfo)); + + NEO::debugManager.flags.RenderCompressedImagesEnabled.set(1); + EXPECT_TRUE(l0GfxCoreHelper.imageCompressionSupported(hwInfo)); + + hwInfo.capabilityTable.ftrRenderCompressedImages = true; + NEO::debugManager.flags.RenderCompressedImagesEnabled.set(0); + EXPECT_FALSE(l0GfxCoreHelper.imageCompressionSupported(hwInfo)); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, givenL0GfxCoreHelperWhenAskingForUsmCompressionSupportThenReturnCorrectValue) { + DebugManagerStateRestore restore; + + auto &l0GfxCoreHelper = getHelper(); + + EXPECT_TRUE(l0GfxCoreHelper.forceDefaultUsmCompressionSupport()); + + HardwareInfo hwInfo = *NEO::defaultHwInfo; + + hwInfo.capabilityTable.ftrRenderCompressedBuffers = true; + EXPECT_TRUE(l0GfxCoreHelper.usmCompressionSupported(hwInfo)); + + hwInfo.capabilityTable.ftrRenderCompressedBuffers = false; + EXPECT_FALSE(l0GfxCoreHelper.usmCompressionSupported(hwInfo)); + + NEO::debugManager.flags.RenderCompressedBuffersEnabled.set(1); + EXPECT_TRUE(l0GfxCoreHelper.usmCompressionSupported(hwInfo)); + + hwInfo.capabilityTable.ftrRenderCompressedBuffers = true; + NEO::debugManager.flags.RenderCompressedBuffersEnabled.set(0); + EXPECT_FALSE(l0GfxCoreHelper.usmCompressionSupported(hwInfo)); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenCheckingL0HelperForMultiTileCapablePlatformThenReturnFalse) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_FALSE(l0GfxCoreHelper.multiTileCapablePlatform()); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenCheckingL0HelperForCmdListHeapSharingSupportThenReturnTrue) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_TRUE(l0GfxCoreHelper.platformSupportsCmdListHeapSharing()); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenCheckingL0HelperForStateComputeModeTrackingSupportThenReturnTrue) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_TRUE(l0GfxCoreHelper.platformSupportsStateComputeModeTracking()); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenCheckingL0HelperForFrontEndTrackingSupportThenReturnTrue) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_TRUE(l0GfxCoreHelper.platformSupportsFrontEndTracking()); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenCheckingL0HelperForPipelineSelectTrackingSupportThenReturnTrue) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_TRUE(l0GfxCoreHelper.platformSupportsPipelineSelectTracking()); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenCheckingL0HelperForStateBaseAddressTrackingSupportThenReturnFalse) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_FALSE(l0GfxCoreHelper.platformSupportsStateBaseAddressTracking(device->getNEODevice()->getRootDeviceEnvironment())); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenGettingPlatformDefaultHeapAddressModelThenReturnPrivateHeaps) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_EQ(NEO::HeapAddressModel::privateHeaps, l0GfxCoreHelper.getPlatformHeapAddressModel(device->getNEODevice()->getRootDeviceEnvironment())); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenCheckingL0HelperForCmdlistPrimaryBufferSupportThenReturnTrue) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_TRUE(l0GfxCoreHelper.platformSupportsPrimaryBatchBufferCmdList()); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenCheckingL0HelperForPlatformSupportsImmediateFlushTaskThenReturnTrue) { + auto &l0GfxCoreHelper = getHelper(); + EXPECT_TRUE(l0GfxCoreHelper.platformSupportsImmediateComputeFlushTask()); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenGettingSupportedRTASFormatThenExpectedFormatIsReturned) { + const auto &l0GfxCoreHelper = getHelper(); + EXPECT_EQ(RTASDeviceFormatInternal::version1, static_cast(l0GfxCoreHelper.getSupportedRTASFormat())); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenGettingCmdlistUpdateCapabilityThenReturnCorrectValue) { + const auto &l0GfxCoreHelper = getHelper(); + EXPECT_EQ(63u, l0GfxCoreHelper.getPlatformCmdListUpdateCapabilities()); +} + +XE2_HPG_CORETEST_F(L0GfxCoreHelperTestXe2Hpg, GivenXe2HpgWhenCheckingL0HelperForDeletingIpSamplingEntryWithNullValuesThenMapRemainstheSameSize) { + auto &l0GfxCoreHelper = getHelper(); + std::map stallSumIpDataMap; + stallSumIpDataMap.emplace(std::pair(0ull, nullptr)); + l0GfxCoreHelper.stallIpDataMapDelete(stallSumIpDataMap); + EXPECT_NE(0u, stallSumIpDataMap.size()); +} + +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/xe2_hpg_core/test_module_xe2_hpg_core.cpp b/level_zero/core/test/unit_tests/xe2_hpg_core/test_module_xe2_hpg_core.cpp new file mode 100644 index 0000000000..75784853d5 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe2_hpg_core/test_module_xe2_hpg_core.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/kernel/kernel_properties.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_device.h" +#include "level_zero/core/test/unit_tests/mocks/mock_kernel.h" +#include "level_zero/core/test/unit_tests/mocks/mock_module.h" + +namespace L0 { +namespace ult { + +using KernelPropertyTest = Test; + +HWTEST2_F(KernelPropertyTest, givenKernelExtendedPropertiesStructureWhenKernelPropertiesCalledThenPropertiesAreCorrectlySet, IsXe2HpgCore) { + ze_device_module_properties_t kernelProperties = {}; + ze_float_atomic_ext_properties_t kernelExtendedProperties = {}; + kernelExtendedProperties.stype = ZE_STRUCTURE_TYPE_FLOAT_ATOMIC_EXT_PROPERTIES; + kernelProperties.pNext = &kernelExtendedProperties; + ze_result_t res = device->getKernelProperties(&kernelProperties); + EXPECT_EQ(res, ZE_RESULT_SUCCESS); + + const auto &fp16Properties = kernelExtendedProperties.fp16Flags; + EXPECT_TRUE(fp16Properties & FpAtomicExtFlags::globalLoadStore); + EXPECT_TRUE(fp16Properties & FpAtomicExtFlags::localLoadStore); + EXPECT_TRUE(fp16Properties & FpAtomicExtFlags::globalMinMax); + EXPECT_TRUE(fp16Properties & FpAtomicExtFlags::localMinMax); + + EXPECT_FALSE(fp16Properties & FpAtomicExtFlags::globalAdd); + EXPECT_FALSE(fp16Properties & FpAtomicExtFlags::localAdd); + + const auto &fp32Properties = kernelExtendedProperties.fp32Flags; + EXPECT_TRUE(fp32Properties & FpAtomicExtFlags::globalLoadStore); + EXPECT_TRUE(fp32Properties & FpAtomicExtFlags::localLoadStore); + EXPECT_TRUE(fp32Properties & FpAtomicExtFlags::globalMinMax); + EXPECT_TRUE(fp32Properties & FpAtomicExtFlags::localMinMax); + EXPECT_TRUE(fp32Properties & FpAtomicExtFlags::globalAdd); + EXPECT_TRUE(fp32Properties & FpAtomicExtFlags::localAdd); + + const auto &fp64Properties = kernelExtendedProperties.fp64Flags; + EXPECT_TRUE(fp64Properties & FpAtomicExtFlags::globalLoadStore); + EXPECT_TRUE(fp64Properties & FpAtomicExtFlags::localLoadStore); + EXPECT_TRUE(fp64Properties & FpAtomicExtFlags::globalMinMax); + EXPECT_TRUE(fp64Properties & FpAtomicExtFlags::localMinMax); + EXPECT_TRUE(fp64Properties & FpAtomicExtFlags::globalAdd); + EXPECT_TRUE(fp64Properties & FpAtomicExtFlags::localAdd); +} + +using Xe2KernelSetupTests = ::testing::Test; + +XE2_HPG_CORETEST_F(Xe2KernelSetupTests, givenParamsWhenSetupGroupSizeThenNumThreadsPerThreadGroupAreCorrectly) { + VariableBackup backupHwInfo(defaultHwInfo.get()); + + { + NEO::Device *mockNeoDevice(NEO::MockDevice::createWithNewExecutionEnvironment(NEO::defaultHwInfo.get(), 0)); + MockDeviceImp l0Device(mockNeoDevice, mockNeoDevice->getExecutionEnvironment()); + + Mock kernel; + kernel.descriptor.kernelAttributes.numGrfRequired = GrfConfig::defaultGrfNumber; + kernel.enableForcingOfGenerateLocalIdByHw = true; + Mock module(&l0Device, nullptr); + module.getMaxGroupSizeResult = UINT32_MAX; + kernel.module = &module; + + std::array, 4> values = {{ + {16u, 1u, 64u}, // SIMT Size, HW local-id generation, Max Num of threads + {32u, 1u, 32u}, + {16u, 0u, 64u}, + {32u, 0u, 64u}, + + }}; + + for (auto &[simtSize, isHwLocalIdGeneration, expectedNumThreadsPerThreadGroup] : values) { + kernel.descriptor.kernelAttributes.simdSize = simtSize; + kernel.forceGenerateLocalIdByHw = isHwLocalIdGeneration; + kernel.setGroupSize(1024u, 1024u, 1024u); + EXPECT_EQ(expectedNumThreadsPerThreadGroup, kernel.numThreadsPerThreadGroup); + kernel.groupSize[0] = kernel.groupSize[1] = kernel.groupSize[2] = 0; + } + } + { + NEO::Device *mockNeoDevice(NEO::MockDevice::createWithNewExecutionEnvironment(NEO::defaultHwInfo.get(), 0)); + MockDeviceImp l0Device(mockNeoDevice, mockNeoDevice->getExecutionEnvironment()); + + Mock kernel; + kernel.descriptor.kernelAttributes.numGrfRequired = GrfConfig::largeGrfNumber; + kernel.enableForcingOfGenerateLocalIdByHw = true; + Mock module(&l0Device, nullptr); + module.getMaxGroupSizeResult = UINT32_MAX; + kernel.module = &module; + + std::array, 4> values = {{ + {16u, 0u, 32u}, // SIMT Size, HW local-id generation, Max Num of threads + {16u, 1u, 32u}, + {32u, 0u, 32u}, + {32u, 1u, 32u}, + }}; + + for (auto &[simtSize, isHwLocalIdGeneration, expectedNumThreadsPerThreadGroup] : values) { + kernel.descriptor.kernelAttributes.simdSize = simtSize; + kernel.forceGenerateLocalIdByHw = isHwLocalIdGeneration; + kernel.setGroupSize(1024u, 1024u, 1024u); + EXPECT_EQ(expectedNumThreadsPerThreadGroup, kernel.numThreadsPerThreadGroup); + kernel.groupSize[0] = kernel.groupSize[1] = kernel.groupSize[2] = 0; + } + } +} +} // namespace ult +} // namespace L0 diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/CMakeLists.txt b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..ed573e731e --- /dev/null +++ b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,7 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +add_subdirectories() diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/CMakeLists.txt b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/CMakeLists.txt new file mode 100644 index 0000000000..8a3be2863e --- /dev/null +++ b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/CMakeLists.txt @@ -0,0 +1,14 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(SUPPORT_BMG) + target_sources(${L0_STATIC_LIB_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/enable_sysman_product_helper_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_bmg.cpp + ) +endif() + diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/enable_sysman_product_helper_bmg.cpp b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/enable_sysman_product_helper_bmg.cpp new file mode 100644 index 0000000000..1838b06eb9 --- /dev/null +++ b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/enable_sysman_product_helper_bmg.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h" + +namespace L0 { +namespace Sysman { + +static EnableSysmanProductHelper enableBMG; + +} // namespace Sysman +} // namespace L0 diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp new file mode 100644 index 0000000000..ee4973d2c8 --- /dev/null +++ b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h" +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl" + +namespace L0 { +namespace Sysman { +constexpr static auto gfxProduct = IGFX_BMG; + +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_xe_hp_and_later.inl" + +template <> +RasInterfaceType SysmanProductHelperHw::getGtRasUtilInterface() { + return RasInterfaceType::netlink; +} + +template <> +RasInterfaceType SysmanProductHelperHw::getHbmRasUtilInterface() { + return RasInterfaceType::netlink; +} + +template class SysmanProductHelperHw; + +} // namespace Sysman +} // namespace L0 diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/CMakeLists.txt b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/CMakeLists.txt new file mode 100644 index 0000000000..658f358c0d --- /dev/null +++ b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/CMakeLists.txt @@ -0,0 +1,14 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(SUPPORT_LNL) + target_sources(${L0_STATIC_LIB_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/enable_sysman_product_helper_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_lnl.cpp + ) +endif() + diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/enable_sysman_product_helper_lnl.cpp b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/enable_sysman_product_helper_lnl.cpp new file mode 100644 index 0000000000..d2b4c6b5dc --- /dev/null +++ b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/enable_sysman_product_helper_lnl.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h" + +namespace L0 { +namespace Sysman { + +static EnableSysmanProductHelper enableLNL; + +} // namespace Sysman +} // namespace L0 diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/sysman_product_helper_lnl.cpp b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/sysman_product_helper_lnl.cpp new file mode 100644 index 0000000000..0392280e5c --- /dev/null +++ b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/lnl/sysman_product_helper_lnl.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h" +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.inl" + +namespace L0 { +namespace Sysman { +constexpr static auto gfxProduct = IGFX_LUNARLAKE; + +#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_xe_hp_and_later.inl" + +template <> +RasInterfaceType SysmanProductHelperHw::getGtRasUtilInterface() { + return RasInterfaceType::netlink; +} + +template <> +RasInterfaceType SysmanProductHelperHw::getHbmRasUtilInterface() { + return RasInterfaceType::netlink; +} + +template class SysmanProductHelperHw; + +} // namespace Sysman +} // namespace L0 diff --git a/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/CMakeLists.txt b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..ed573e731e --- /dev/null +++ b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,7 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +add_subdirectories() diff --git a/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/CMakeLists.txt b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/CMakeLists.txt new file mode 100644 index 0000000000..8a3be2863e --- /dev/null +++ b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/CMakeLists.txt @@ -0,0 +1,14 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(SUPPORT_BMG) + target_sources(${L0_STATIC_LIB_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/enable_sysman_product_helper_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_bmg.cpp + ) +endif() + diff --git a/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/enable_sysman_product_helper_bmg.cpp b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/enable_sysman_product_helper_bmg.cpp new file mode 100644 index 0000000000..dc54c98ba9 --- /dev/null +++ b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/enable_sysman_product_helper_bmg.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/sysman/source/shared/windows/product_helper/sysman_product_helper_hw.h" + +namespace L0 { +namespace Sysman { + +static EnableSysmanProductHelper enableBmg; + +} // namespace Sysman +} // namespace L0 diff --git a/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp new file mode 100644 index 0000000000..f9b6b63a31 --- /dev/null +++ b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp @@ -0,0 +1,501 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/debug_helpers.h" + +#include "level_zero/sysman/source/shared/windows/pmt/sysman_pmt.h" +#include "level_zero/sysman/source/shared/windows/product_helper/sysman_product_helper_hw.h" +#include "level_zero/sysman/source/shared/windows/product_helper/sysman_product_helper_hw.inl" +#include "level_zero/sysman/source/sysman_const.h" + +#include +#include + +namespace L0 { +namespace Sysman { + +#define PACK_INTO_64BIT(valueH, valueL) ((static_cast(valueH) << 32) | static_cast(valueL)) + +constexpr static auto gfxProduct = IGFX_BMG; + +static std::map> guidToKeyOffsetMap = { + {0x1e2f8201, // BMG OOBMSM rev 1 + {{"SOC_THERMAL_SENSORS_TEMPERATURE_0_2_0_GTTMMADR[2]", 14}, + {"Package_Temperature_0_0_0_MCHBAR_PCU", 39}, + {"VRAM_TEMPERATURE_0_2_0_GTTMMADR", 43}, + {"REG_RX_BYTECOUNT_LSB", 100}, + {"REG_TX_BYTECOUNT_LSB", 101}, + {"REG_RX_PKTCOUNT_LSB", 102}, + {"REG_TX_PKTCOUNT_LSB", 103}}}, + {0x1e2f8200, // BMG PUNIT rev 1 + {{"VRAM_BANDWIDTH", 14}}}, + {0x5e2f8210, // BMG OOBMSM rev 15 + {{"GDDR_TELEM_CAPTURE_TIMESTAMP_UPPER", 92}, + {"GDDR_TELEM_CAPTURE_TIMESTAMP_LOWER", 93}, + {"GDDR0_CH0_GT_32B_RD_REQ_UPPER", 94}, + {"GDDR0_CH0_GT_32B_RD_REQ_LOWER", 95}, + {"GDDR1_CH0_GT_32B_RD_REQ_UPPER", 134}, + {"GDDR1_CH0_GT_32B_RD_REQ_LOWER", 135}, + {"GDDR2_CH0_GT_32B_RD_REQ_UPPER", 174}, + {"GDDR2_CH0_GT_32B_RD_REQ_LOWER", 175}, + {"GDDR3_CH0_GT_32B_RD_REQ_UPPER", 214}, + {"GDDR3_CH0_GT_32B_RD_REQ_LOWER", 215}, + {"GDDR4_CH0_GT_32B_RD_REQ_UPPER", 254}, + {"GDDR4_CH0_GT_32B_RD_REQ_LOWER", 255}, + {"GDDR5_CH0_GT_32B_RD_REQ_UPPER", 294}, + {"GDDR5_CH0_GT_32B_RD_REQ_LOWER", 295}, + {"GDDR0_CH1_GT_32B_RD_REQ_UPPER", 114}, + {"GDDR0_CH1_GT_32B_RD_REQ_LOWER", 115}, + {"GDDR1_CH1_GT_32B_RD_REQ_UPPER", 154}, + {"GDDR1_CH1_GT_32B_RD_REQ_LOWER", 155}, + {"GDDR2_CH1_GT_32B_RD_REQ_UPPER", 194}, + {"GDDR2_CH1_GT_32B_RD_REQ_LOWER", 195}, + {"GDDR3_CH1_GT_32B_RD_REQ_UPPER", 234}, + {"GDDR3_CH1_GT_32B_RD_REQ_LOWER", 235}, + {"GDDR4_CH1_GT_32B_RD_REQ_UPPER", 274}, + {"GDDR4_CH1_GT_32B_RD_REQ_LOWER", 275}, + {"GDDR5_CH1_GT_32B_RD_REQ_UPPER", 314}, + {"GDDR5_CH1_GT_32B_RD_REQ_LOWER", 315}, + {"GDDR0_CH0_GT_32B_WR_REQ_UPPER", 98}, + {"GDDR0_CH0_GT_32B_WR_REQ_LOWER", 99}, + {"GDDR1_CH0_GT_32B_WR_REQ_UPPER", 138}, + {"GDDR1_CH0_GT_32B_WR_REQ_LOWER", 139}, + {"GDDR2_CH0_GT_32B_WR_REQ_UPPER", 178}, + {"GDDR2_CH0_GT_32B_WR_REQ_LOWER", 179}, + {"GDDR3_CH0_GT_32B_WR_REQ_UPPER", 218}, + {"GDDR3_CH0_GT_32B_WR_REQ_LOWER", 219}, + {"GDDR4_CH0_GT_32B_WR_REQ_UPPER", 258}, + {"GDDR4_CH0_GT_32B_WR_REQ_LOWER", 259}, + {"GDDR5_CH0_GT_32B_WR_REQ_UPPER", 298}, + {"GDDR5_CH0_GT_32B_WR_REQ_LOWER", 299}, + {"GDDR0_CH1_GT_32B_WR_REQ_UPPER", 118}, + {"GDDR0_CH1_GT_32B_WR_REQ_LOWER", 119}, + {"GDDR1_CH1_GT_32B_WR_REQ_UPPER", 158}, + {"GDDR1_CH1_GT_32B_WR_REQ_LOWER", 159}, + {"GDDR2_CH1_GT_32B_WR_REQ_UPPER", 198}, + {"GDDR2_CH1_GT_32B_WR_REQ_LOWER", 199}, + {"GDDR3_CH1_GT_32B_WR_REQ_UPPER", 238}, + {"GDDR3_CH1_GT_32B_WR_REQ_LOWER", 239}, + {"GDDR4_CH1_GT_32B_WR_REQ_UPPER", 278}, + {"GDDR4_CH1_GT_32B_WR_REQ_LOWER", 279}, + {"GDDR5_CH1_GT_32B_WR_REQ_UPPER", 318}, + {"GDDR5_CH1_GT_32B_WR_REQ_LOWER", 319}, + {"GDDR0_CH0_DISPLAYVC0_32B_RD_REQ_UPPER", 102}, + {"GDDR0_CH0_DISPLAYVC0_32B_RD_REQ_LOWER", 103}, + {"GDDR1_CH0_DISPLAYVC0_32B_RD_REQ_UPPER", 142}, + {"GDDR1_CH0_DISPLAYVC0_32B_RD_REQ_LOWER", 143}, + {"GDDR2_CH0_DISPLAYVC0_32B_RD_REQ_UPPER", 182}, + {"GDDR2_CH0_DISPLAYVC0_32B_RD_REQ_LOWER", 183}, + {"GDDR3_CH0_DISPLAYVC0_32B_RD_REQ_UPPER", 222}, + {"GDDR3_CH0_DISPLAYVC0_32B_RD_REQ_LOWER", 223}, + {"GDDR4_CH0_DISPLAYVC0_32B_RD_REQ_UPPER", 262}, + {"GDDR4_CH0_DISPLAYVC0_32B_RD_REQ_LOWER", 263}, + {"GDDR5_CH0_DISPLAYVC0_32B_RD_REQ_UPPER", 302}, + {"GDDR5_CH0_DISPLAYVC0_32B_RD_REQ_LOWER", 303}, + {"GDDR0_CH1_DISPLAYVC0_32B_RD_REQ_UPPER", 122}, + {"GDDR0_CH1_DISPLAYVC0_32B_RD_REQ_LOWER", 123}, + {"GDDR1_CH1_DISPLAYVC0_32B_RD_REQ_UPPER", 162}, + {"GDDR1_CH1_DISPLAYVC0_32B_RD_REQ_LOWER", 163}, + {"GDDR2_CH1_DISPLAYVC0_32B_RD_REQ_UPPER", 202}, + {"GDDR2_CH1_DISPLAYVC0_32B_RD_REQ_LOWER", 203}, + {"GDDR3_CH1_DISPLAYVC0_32B_RD_REQ_UPPER", 242}, + {"GDDR3_CH1_DISPLAYVC0_32B_RD_REQ_LOWER", 243}, + {"GDDR4_CH1_DISPLAYVC0_32B_RD_REQ_UPPER", 282}, + {"GDDR4_CH1_DISPLAYVC0_32B_RD_REQ_LOWER", 283}, + {"GDDR5_CH1_DISPLAYVC0_32B_RD_REQ_UPPER", 322}, + {"GDDR5_CH1_DISPLAYVC0_32B_RD_REQ_LOWER", 323}, + {"GDDR0_CH0_SOC_32B_RD_REQ_UPPER", 106}, + {"GDDR0_CH0_SOC_32B_RD_REQ_LOWER", 107}, + {"GDDR1_CH0_SOC_32B_RD_REQ_UPPER", 146}, + {"GDDR1_CH0_SOC_32B_RD_REQ_LOWER", 147}, + {"GDDR2_CH0_SOC_32B_RD_REQ_UPPER", 186}, + {"GDDR2_CH0_SOC_32B_RD_REQ_LOWER", 187}, + {"GDDR3_CH0_SOC_32B_RD_REQ_UPPER", 226}, + {"GDDR3_CH0_SOC_32B_RD_REQ_LOWER", 227}, + {"GDDR4_CH0_SOC_32B_RD_REQ_UPPER", 266}, + {"GDDR4_CH0_SOC_32B_RD_REQ_LOWER", 267}, + {"GDDR5_CH0_SOC_32B_RD_REQ_UPPER", 306}, + {"GDDR5_CH0_SOC_32B_RD_REQ_LOWER", 307}, + {"GDDR0_CH1_SOC_32B_RD_REQ_UPPER", 126}, + {"GDDR0_CH1_SOC_32B_RD_REQ_LOWER", 127}, + {"GDDR1_CH1_SOC_32B_RD_REQ_UPPER", 166}, + {"GDDR1_CH1_SOC_32B_RD_REQ_LOWER", 167}, + {"GDDR2_CH1_SOC_32B_RD_REQ_UPPER", 206}, + {"GDDR2_CH1_SOC_32B_RD_REQ_LOWER", 207}, + {"GDDR3_CH1_SOC_32B_RD_REQ_UPPER", 246}, + {"GDDR3_CH1_SOC_32B_RD_REQ_LOWER", 247}, + {"GDDR4_CH1_SOC_32B_RD_REQ_UPPER", 286}, + {"GDDR4_CH1_SOC_32B_RD_REQ_LOWER", 287}, + {"GDDR5_CH1_SOC_32B_RD_REQ_UPPER", 326}, + {"GDDR5_CH1_SOC_32B_RD_REQ_LOWER", 327}, + {"GDDR0_CH0_SOC_32B_WR_REQ_UPPER", 110}, + {"GDDR0_CH0_SOC_32B_WR_REQ_LOWER", 111}, + {"GDDR1_CH0_SOC_32B_WR_REQ_UPPER", 150}, + {"GDDR1_CH0_SOC_32B_WR_REQ_LOWER", 151}, + {"GDDR2_CH0_SOC_32B_WR_REQ_UPPER", 190}, + {"GDDR2_CH0_SOC_32B_WR_REQ_LOWER", 191}, + {"GDDR3_CH0_SOC_32B_WR_REQ_UPPER", 230}, + {"GDDR3_CH0_SOC_32B_WR_REQ_LOWER", 231}, + {"GDDR4_CH0_SOC_32B_WR_REQ_UPPER", 270}, + {"GDDR4_CH0_SOC_32B_WR_REQ_LOWER", 271}, + {"GDDR5_CH0_SOC_32B_WR_REQ_UPPER", 310}, + {"GDDR5_CH0_SOC_32B_WR_REQ_LOWER", 311}, + {"GDDR0_CH1_SOC_32B_WR_REQ_UPPER", 130}, + {"GDDR0_CH1_SOC_32B_WR_REQ_LOWER", 131}, + {"GDDR1_CH1_SOC_32B_WR_REQ_UPPER", 170}, + {"GDDR1_CH1_SOC_32B_WR_REQ_LOWER", 171}, + {"GDDR2_CH1_SOC_32B_WR_REQ_UPPER", 210}, + {"GDDR2_CH1_SOC_32B_WR_REQ_LOWER", 211}, + {"GDDR3_CH1_SOC_32B_WR_REQ_UPPER", 250}, + {"GDDR3_CH1_SOC_32B_WR_REQ_LOWER", 251}, + {"GDDR4_CH1_SOC_32B_WR_REQ_UPPER", 290}, + {"GDDR4_CH1_SOC_32B_WR_REQ_LOWER", 291}, + {"GDDR5_CH1_SOC_32B_WR_REQ_UPPER", 330}, + {"GDDR5_CH1_SOC_32B_WR_REQ_LOWER", 331}, + {"MSU_BITMASK", 922}, + {"GDDR0_CH0_GT_64B_RD_REQ_UPPER", 96}, + {"GDDR0_CH0_GT_64B_RD_REQ_LOWER", 97}, + {"GDDR1_CH0_GT_64B_RD_REQ_UPPER", 136}, + {"GDDR1_CH0_GT_64B_RD_REQ_LOWER", 137}, + {"GDDR2_CH0_GT_64B_RD_REQ_UPPER", 176}, + {"GDDR2_CH0_GT_64B_RD_REQ_LOWER", 177}, + {"GDDR3_CH0_GT_64B_RD_REQ_UPPER", 216}, + {"GDDR3_CH0_GT_64B_RD_REQ_LOWER", 217}, + {"GDDR4_CH0_GT_64B_RD_REQ_UPPER", 256}, + {"GDDR4_CH0_GT_64B_RD_REQ_LOWER", 257}, + {"GDDR5_CH0_GT_64B_RD_REQ_UPPER", 296}, + {"GDDR5_CH0_GT_64B_RD_REQ_LOWER", 297}, + {"GDDR0_CH1_GT_64B_RD_REQ_UPPER", 116}, + {"GDDR0_CH1_GT_64B_RD_REQ_LOWER", 117}, + {"GDDR1_CH1_GT_64B_RD_REQ_UPPER", 156}, + {"GDDR1_CH1_GT_64B_RD_REQ_LOWER", 157}, + {"GDDR2_CH1_GT_64B_RD_REQ_UPPER", 196}, + {"GDDR2_CH1_GT_64B_RD_REQ_LOWER", 197}, + {"GDDR3_CH1_GT_64B_RD_REQ_UPPER", 236}, + {"GDDR3_CH1_GT_64B_RD_REQ_LOWER", 237}, + {"GDDR4_CH1_GT_64B_RD_REQ_UPPER", 276}, + {"GDDR4_CH1_GT_64B_RD_REQ_LOWER", 277}, + {"GDDR5_CH1_GT_64B_RD_REQ_UPPER", 316}, + {"GDDR5_CH1_GT_64B_RD_REQ_LOWER", 317}, + {"GDDR0_CH0_DISPLAYVC0_64B_RD_REQ_UPPER", 104}, + {"GDDR0_CH0_DISPLAYVC0_64B_RD_REQ_LOWER", 105}, + {"GDDR1_CH0_DISPLAYVC0_64B_RD_REQ_UPPER", 144}, + {"GDDR1_CH0_DISPLAYVC0_64B_RD_REQ_LOWER", 145}, + {"GDDR2_CH0_DISPLAYVC0_64B_RD_REQ_UPPER", 184}, + {"GDDR2_CH0_DISPLAYVC0_64B_RD_REQ_LOWER", 185}, + {"GDDR3_CH0_DISPLAYVC0_64B_RD_REQ_UPPER", 224}, + {"GDDR3_CH0_DISPLAYVC0_64B_RD_REQ_LOWER", 225}, + {"GDDR4_CH0_DISPLAYVC0_64B_RD_REQ_UPPER", 264}, + {"GDDR4_CH0_DISPLAYVC0_64B_RD_REQ_LOWER", 265}, + {"GDDR5_CH0_DISPLAYVC0_64B_RD_REQ_UPPER", 304}, + {"GDDR5_CH0_DISPLAYVC0_64B_RD_REQ_LOWER", 305}, + {"GDDR0_CH1_DISPLAYVC0_64B_RD_REQ_UPPER", 124}, + {"GDDR0_CH1_DISPLAYVC0_64B_RD_REQ_LOWER", 125}, + {"GDDR1_CH1_DISPLAYVC0_64B_RD_REQ_UPPER", 164}, + {"GDDR1_CH1_DISPLAYVC0_64B_RD_REQ_LOWER", 165}, + {"GDDR2_CH1_DISPLAYVC0_64B_RD_REQ_UPPER", 204}, + {"GDDR2_CH1_DISPLAYVC0_64B_RD_REQ_LOWER", 205}, + {"GDDR3_CH1_DISPLAYVC0_64B_RD_REQ_UPPER", 244}, + {"GDDR3_CH1_DISPLAYVC0_64B_RD_REQ_LOWER", 245}, + {"GDDR4_CH1_DISPLAYVC0_64B_RD_REQ_UPPER", 284}, + {"GDDR4_CH1_DISPLAYVC0_64B_RD_REQ_LOWER", 285}, + {"GDDR5_CH1_DISPLAYVC0_64B_RD_REQ_UPPER", 324}, + {"GDDR5_CH1_DISPLAYVC0_64B_RD_REQ_LOWER", 325}, + {"GDDR0_CH0_SOC_64B_RD_REQ_UPPER", 108}, + {"GDDR0_CH0_SOC_64B_RD_REQ_LOWER", 109}, + {"GDDR1_CH0_SOC_64B_RD_REQ_UPPER", 148}, + {"GDDR1_CH0_SOC_64B_RD_REQ_LOWER", 149}, + {"GDDR2_CH0_SOC_64B_RD_REQ_UPPER", 188}, + {"GDDR2_CH0_SOC_64B_RD_REQ_LOWER", 189}, + {"GDDR3_CH0_SOC_64B_RD_REQ_UPPER", 228}, + {"GDDR3_CH0_SOC_64B_RD_REQ_LOWER", 229}, + {"GDDR4_CH0_SOC_64B_RD_REQ_UPPER", 268}, + {"GDDR4_CH0_SOC_64B_RD_REQ_LOWER", 269}, + {"GDDR5_CH0_SOC_64B_RD_REQ_UPPER", 308}, + {"GDDR5_CH0_SOC_64B_RD_REQ_LOWER", 309}, + {"GDDR0_CH1_SOC_64B_RD_REQ_UPPER", 128}, + {"GDDR0_CH1_SOC_64B_RD_REQ_LOWER", 129}, + {"GDDR1_CH1_SOC_64B_RD_REQ_UPPER", 168}, + {"GDDR1_CH1_SOC_64B_RD_REQ_LOWER", 169}, + {"GDDR2_CH1_SOC_64B_RD_REQ_UPPER", 208}, + {"GDDR2_CH1_SOC_64B_RD_REQ_LOWER", 209}, + {"GDDR3_CH1_SOC_64B_RD_REQ_UPPER", 248}, + {"GDDR3_CH1_SOC_64B_RD_REQ_LOWER", 249}, + {"GDDR4_CH1_SOC_64B_RD_REQ_UPPER", 288}, + {"GDDR4_CH1_SOC_64B_RD_REQ_LOWER", 289}, + {"GDDR5_CH1_SOC_64B_RD_REQ_UPPER", 328}, + {"GDDR5_CH1_SOC_64B_RD_REQ_LOWER", 329}, + {"GDDR0_CH0_SOC_64B_WR_REQ_UPPER", 112}, + {"GDDR0_CH0_SOC_64B_WR_REQ_LOWER", 113}, + {"GDDR1_CH0_SOC_64B_WR_REQ_UPPER", 152}, + {"GDDR1_CH0_SOC_64B_WR_REQ_LOWER", 153}, + {"GDDR2_CH0_SOC_64B_WR_REQ_UPPER", 192}, + {"GDDR2_CH0_SOC_64B_WR_REQ_LOWER", 193}, + {"GDDR3_CH0_SOC_64B_WR_REQ_UPPER", 232}, + {"GDDR3_CH0_SOC_64B_WR_REQ_LOWER", 233}, + {"GDDR4_CH0_SOC_64B_WR_REQ_UPPER", 272}, + {"GDDR4_CH0_SOC_64B_WR_REQ_LOWER", 273}, + {"GDDR5_CH0_SOC_64B_WR_REQ_UPPER", 312}, + {"GDDR5_CH0_SOC_64B_WR_REQ_LOWER", 313}, + {"GDDR0_CH1_SOC_64B_WR_REQ_UPPER", 132}, + {"GDDR0_CH1_SOC_64B_WR_REQ_LOWER", 133}, + {"GDDR1_CH1_SOC_64B_WR_REQ_UPPER", 172}, + {"GDDR1_CH1_SOC_64B_WR_REQ_LOWER", 173}, + {"GDDR2_CH1_SOC_64B_WR_REQ_UPPER", 212}, + {"GDDR2_CH1_SOC_64B_WR_REQ_LOWER", 213}, + {"GDDR3_CH1_SOC_64B_WR_REQ_UPPER", 252}, + {"GDDR3_CH1_SOC_64B_WR_REQ_LOWER", 253}, + {"GDDR4_CH1_SOC_64B_WR_REQ_UPPER", 292}, + {"GDDR4_CH1_SOC_64B_WR_REQ_LOWER", 293}, + {"GDDR5_CH1_SOC_64B_WR_REQ_UPPER", 332}, + {"GDDR5_CH1_SOC_64B_WR_REQ_LOWER", 333}, + {"GDDR0_CH0_GT_64B_WR_REQ_UPPER", 100}, + {"GDDR0_CH0_GT_64B_WR_REQ_LOWER", 101}, + {"GDDR1_CH0_GT_64B_WR_REQ_UPPER", 140}, + {"GDDR1_CH0_GT_64B_WR_REQ_LOWER", 141}, + {"GDDR2_CH0_GT_64B_WR_REQ_UPPER", 180}, + {"GDDR2_CH0_GT_64B_WR_REQ_LOWER", 181}, + {"GDDR3_CH0_GT_64B_WR_REQ_UPPER", 220}, + {"GDDR3_CH0_GT_64B_WR_REQ_LOWER", 221}, + {"GDDR4_CH0_GT_64B_WR_REQ_UPPER", 260}, + {"GDDR4_CH0_GT_64B_WR_REQ_LOWER", 261}, + {"GDDR5_CH0_GT_64B_WR_REQ_UPPER", 300}, + {"GDDR5_CH0_GT_64B_WR_REQ_LOWER", 301}, + {"GDDR0_CH1_GT_64B_WR_REQ_UPPER", 120}, + {"GDDR0_CH1_GT_64B_WR_REQ_LOWER", 121}, + {"GDDR1_CH1_GT_64B_WR_REQ_UPPER", 160}, + {"GDDR1_CH1_GT_64B_WR_REQ_LOWER", 161}, + {"GDDR2_CH1_GT_64B_WR_REQ_UPPER", 200}, + {"GDDR2_CH1_GT_64B_WR_REQ_LOWER", 201}, + {"GDDR3_CH1_GT_64B_WR_REQ_UPPER", 240}, + {"GDDR3_CH1_GT_64B_WR_REQ_LOWER", 241}, + {"GDDR4_CH1_GT_64B_WR_REQ_UPPER", 280}, + {"GDDR4_CH1_GT_64B_WR_REQ_LOWER", 281}, + {"GDDR5_CH1_GT_64B_WR_REQ_UPPER", 320}, + {"GDDR5_CH1_GT_64B_WR_REQ_LOWER", 321}}}}; + +template <> +ze_result_t SysmanProductHelperHw::getSensorTemperature(double *pTemperature, zes_temp_sensors_t type, WddmSysmanImp *pWddmSysmanImp) { + ze_result_t status = ZE_RESULT_SUCCESS; + uint32_t val; + std::string key; + + PlatformMonitoringTech *pPmt = pWddmSysmanImp->getSysmanPmt(); + if (pPmt == nullptr) { + *pTemperature = 0; + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + switch (type) { + case ZES_TEMP_SENSORS_GLOBAL: + key = "Package_Temperature_0_0_0_MCHBAR_PCU"; + break; + case ZES_TEMP_SENSORS_GPU: + key = "SOC_THERMAL_SENSORS_TEMPERATURE_0_2_0_GTTMMADR[2]"; + break; + case ZES_TEMP_SENSORS_MEMORY: + key = "VRAM_TEMPERATURE_0_2_0_GTTMMADR"; + break; + default: + DEBUG_BREAK_IF(true); + *pTemperature = 0; + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + break; + } + status = pPmt->readValue(key, val); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + *pTemperature = static_cast(val); + return status; +} + +template <> +bool SysmanProductHelperHw::isTempModuleSupported(zes_temp_sensors_t type, WddmSysmanImp *pWddmSysmanImp) { + if (type != ZES_TEMP_SENSORS_GLOBAL && type != ZES_TEMP_SENSORS_GPU && type != ZES_TEMP_SENSORS_MEMORY) { + return false; + } + PlatformMonitoringTech *pPmt = pWddmSysmanImp->getSysmanPmt(); + return (pPmt != nullptr); +} + +template <> +ze_result_t SysmanProductHelperHw::getPciStats(zes_pci_stats_t *pStats, WddmSysmanImp *pWddmSysmanImp) { + ze_result_t status = ZE_RESULT_SUCCESS; + pStats->speed.gen = -1; + pStats->speed.width = -1; + pStats->speed.maxBandwidth = -1; + pStats->replayCounter = 0; + + PlatformMonitoringTech *pPmt = pWddmSysmanImp->getSysmanPmt(); + if (pPmt == nullptr) { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + uint64_t rxCounter; + status = pPmt->readValue("REG_RX_BYTECOUNT_LSB", rxCounter); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + uint64_t txCounter; + status = pPmt->readValue("REG_TX_BYTECOUNT_LSB", txCounter); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + uint64_t rxPacketCounter; + status = pPmt->readValue("REG_RX_PKTCOUNT_LSB", rxPacketCounter); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + uint64_t txPacketCounter; + status = pPmt->readValue("REG_TX_PKTCOUNT_LSB", txPacketCounter); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + pStats->txCounter = txCounter; + pStats->rxCounter = rxCounter; + pStats->packetCounter = rxPacketCounter + txPacketCounter; + pStats->timestamp = SysmanDevice::getSysmanTimestamp(); + + return status; +} + +template <> +ze_result_t SysmanProductHelperHw::getMemoryBandWidth(zes_mem_bandwidth_t *pBandwidth, WddmSysmanImp *pWddmSysmanImp) { + ze_result_t status = ZE_RESULT_SUCCESS; + PlatformMonitoringTech *pPmt = pWddmSysmanImp->getSysmanPmt(); + if (pPmt == nullptr) { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + uint32_t supportedMsu = 0; + status = pPmt->readValue("MSU_BITMASK", supportedMsu); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + constexpr uint64_t transactionSize = 32; + constexpr uint64_t maxSupportedMsu = 8; + memset(pBandwidth, 0, sizeof(zes_mem_bandwidth_t)); + + std::vector> readBwRegisterList{{"_CH0_GT_32B_RD_REQ_LOWER", "_CH0_GT_32B_RD_REQ_UPPER"}, + {"_CH0_DISPLAYVC0_32B_RD_REQ_LOWER", "_CH0_DISPLAYVC0_32B_RD_REQ_UPPER"}, + {"_CH0_SOC_32B_RD_REQ_LOWER", "_CH0_SOC_32B_RD_REQ_UPPER"}, + {"_CH1_GT_32B_RD_REQ_LOWER", "_CH1_GT_32B_RD_REQ_UPPER"}, + {"_CH1_DISPLAYVC0_32B_RD_REQ_LOWER", "_CH1_DISPLAYVC0_32B_RD_REQ_UPPER"}, + {"_CH1_SOC_32B_RD_REQ_LOWER", "_CH1_SOC_32B_RD_REQ_UPPER"}, + {"_CH0_GT_64B_RD_REQ_LOWER", "_CH0_GT_64B_RD_REQ_UPPER"}, + {"_CH0_DISPLAYVC0_64B_RD_REQ_LOWER", "_CH0_DISPLAYVC0_64B_RD_REQ_UPPER"}, + {"_CH0_SOC_64B_RD_REQ_LOWER", "_CH0_SOC_64B_RD_REQ_UPPER"}, + {"_CH1_GT_64B_RD_REQ_LOWER", "_CH1_GT_64B_RD_REQ_UPPER"}, + {"_CH1_DISPLAYVC0_64B_RD_REQ_LOWER", "_CH1_DISPLAYVC0_64B_RD_REQ_UPPER"}, + {"_CH1_SOC_64B_RD_REQ_LOWER", "_CH1_SOC_64B_RD_REQ_UPPER"}}; + + std::vector> writeBwRegisterList{{"_CH0_GT_32B_WR_REQ_LOWER", "_CH0_GT_32B_WR_REQ_UPPER"}, + {"_CH0_SOC_32B_WR_REQ_LOWER", "_CH0_SOC_32B_WR_REQ_UPPER"}, + {"_CH1_GT_32B_WR_REQ_LOWER", "_CH1_GT_32B_WR_REQ_UPPER"}, + {"_CH1_SOC_32B_WR_REQ_LOWER", "_CH1_SOC_32B_WR_REQ_UPPER"}, + {"_CH0_GT_64B_WR_REQ_LOWER", "_CH0_GT_64B_WR_REQ_UPPER"}, + {"_CH0_SOC_64B_WR_REQ_LOWER", "_CH0_SOC_64B_WR_REQ_UPPER"}, + {"_CH1_GT_64B_WR_REQ_LOWER", "_CH1_GT_64B_WR_REQ_UPPER"}, + {"_CH1_SOC_64B_WR_REQ_LOWER", "_CH1_SOC_64B_WR_REQ_UPPER"}}; + + for (uint16_t i = 0; i < maxSupportedMsu; i++) { + if (supportedMsu & 1 << i) { + std::string memorySubSystemUnit = "GDDR" + std::to_string(i); + + // Read BW calculation + for (uint32_t j = 0; j < readBwRegisterList.size(); j++) { + uint32_t readRegisterL = 0; + uint32_t readRegisterH = 0; + + std::string readCounterKey = memorySubSystemUnit + readBwRegisterList[j].first; + status = pPmt->readValue(readCounterKey, readRegisterL); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + readCounterKey = memorySubSystemUnit + readBwRegisterList[j].second; + status = pPmt->readValue(readCounterKey, readRegisterH); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + uint64_t readCounter = PACK_INTO_64BIT(readRegisterH, readRegisterL); + + pBandwidth->readCounter += readCounter; + } + + // Write BW calculation + for (uint32_t j = 0; j < writeBwRegisterList.size(); j++) { + uint32_t writeRegisterL = 0; + uint32_t writeRegisterH = 0; + + std::string readCounterKey = memorySubSystemUnit + writeBwRegisterList[j].first; + status = pPmt->readValue(readCounterKey, writeRegisterL); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + readCounterKey = memorySubSystemUnit + writeBwRegisterList[j].second; + status = pPmt->readValue(readCounterKey, writeRegisterH); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + uint64_t writeCounter = PACK_INTO_64BIT(writeRegisterH, writeRegisterL); + + pBandwidth->writeCounter += writeCounter; + } + } + } + + pBandwidth->readCounter = (pBandwidth->readCounter * transactionSize) / microFactor; + pBandwidth->writeCounter = (pBandwidth->writeCounter * transactionSize) / microFactor; + + // Max BW + uint32_t maxBandwidth = 0; + status = pPmt->readValue("VRAM_BANDWIDTH", maxBandwidth); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + maxBandwidth = maxBandwidth >> 16; + pBandwidth->maxBandwidth = static_cast(maxBandwidth) * mbpsToBytesPerSecond; + + // timestamp calcuation + uint32_t timeStampL = 0; + uint32_t timeStampH = 0; + + status = pPmt->readValue("GDDR_TELEM_CAPTURE_TIMESTAMP_UPPER", timeStampH); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + status = pPmt->readValue("GDDR_TELEM_CAPTURE_TIMESTAMP_LOWER", timeStampL); + if (status != ZE_RESULT_SUCCESS) { + return status; + } + + pBandwidth->timestamp = PACK_INTO_64BIT(timeStampH, timeStampL); + + return status; +} + +template <> +std::map> *SysmanProductHelperHw::getGuidToKeyOffsetMap() { + return &guidToKeyOffsetMap; +} + +template class SysmanProductHelperHw; + +} // namespace Sysman +} // namespace L0 diff --git a/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/CMakeLists.txt b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/CMakeLists.txt new file mode 100644 index 0000000000..658f358c0d --- /dev/null +++ b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/CMakeLists.txt @@ -0,0 +1,14 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(SUPPORT_LNL) + target_sources(${L0_STATIC_LIB_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/enable_sysman_product_helper_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_lnl.cpp + ) +endif() + diff --git a/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/enable_sysman_product_helper_lnl.cpp b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/enable_sysman_product_helper_lnl.cpp new file mode 100644 index 0000000000..933a23a547 --- /dev/null +++ b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/enable_sysman_product_helper_lnl.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/sysman/source/shared/windows/product_helper/sysman_product_helper_hw.h" + +namespace L0 { +namespace Sysman { + +static EnableSysmanProductHelper enableLnl; + +} // namespace Sysman +} // namespace L0 diff --git a/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/sysman_product_helper_lnl.cpp b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/sysman_product_helper_lnl.cpp new file mode 100644 index 0000000000..31cddf5cd2 --- /dev/null +++ b/level_zero/sysman/source/shared/windows/product_helper/xe2_hpg_core/lnl/sysman_product_helper_lnl.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/sysman/source/shared/windows/product_helper/sysman_product_helper_hw.h" +#include "level_zero/sysman/source/shared/windows/product_helper/sysman_product_helper_hw.inl" + +namespace L0 { +namespace Sysman { +constexpr static auto gfxProduct = IGFX_LUNARLAKE; + +template class SysmanProductHelperHw; + +} // namespace Sysman +} // namespace L0 diff --git a/level_zero/tools/test/unit_tests/sources/debug/xe2_hpg_core/CMakeLists.txt b/level_zero/tools/test/unit_tests/sources/debug/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..a665feeb54 --- /dev/null +++ b/level_zero/tools/test/unit_tests/sources/debug/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,12 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XE2_HPG_CORE) + target_sources(${TARGET_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/debug_session_tests_xe2_hpg_core.cpp + ) +endif() diff --git a/level_zero/tools/test/unit_tests/sources/debug/xe2_hpg_core/debug_session_tests_xe2_hpg_core.cpp b/level_zero/tools/test/unit_tests/sources/debug/xe2_hpg_core/debug_session_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..b6940aee59 --- /dev/null +++ b/level_zero/tools/test/unit_tests/sources/debug/xe2_hpg_core/debug_session_tests_xe2_hpg_core.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_sip.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h" +#include "level_zero/tools/source/debug/debug_session_imp.h" +#include "level_zero/tools/test/unit_tests/sources/debug/debug_session_common.h" +#include "level_zero/tools/test/unit_tests/sources/debug/debug_session_registers_access.h" +#include "level_zero/tools/test/unit_tests/sources/debug/mock_debug_session.h" + +namespace L0 { +namespace ult { + +using Xe2HpgCoreDebugSessionTest = Test; + +HWTEST2_F(Xe2HpgCoreDebugSessionTest, + givenGetThreadRegisterSetPropertiesCalledWhenLargeGrfIsSetThen256GrfRegisterCountIsReported, IsXe2HpgCore) { + auto mockBuiltins = new L0::ult::MockBuiltins(); + mockBuiltins->stateSaveAreaHeader = NEO::MockSipData::createStateSaveAreaHeader(2, 256); + MockRootDeviceEnvironment::resetBuiltins(neoDevice->executionEnvironment->rootDeviceEnvironments[0].get(), mockBuiltins); + + { + auto pStateSaveAreaHeader = reinterpret_cast(session->stateSaveAreaHeader.data()); + auto size = pStateSaveAreaHeader->versionHeader.size * 8 + + pStateSaveAreaHeader->regHeader.state_area_offset + + pStateSaveAreaHeader->regHeader.state_save_size * 16; + session->stateSaveAreaHeader.resize(size); + } + + ze_device_thread_t thread = stoppedThread; + + auto *regdesc = &(reinterpret_cast(session->stateSaveAreaHeader.data()))->regHeader.sr; + uint32_t sr0[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + sr0[1] = 0x80006000; + session->registersAccessHelper(session->allThreads[stoppedThreadId].get(), regdesc, 0, 1, sr0, true); + + uint32_t threadCount = 0; + EXPECT_EQ(ZE_RESULT_SUCCESS, zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &threadCount, nullptr)); + std::vector threadRegsetProps(threadCount); + ASSERT_EQ(ZE_RESULT_SUCCESS, zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &threadCount, threadRegsetProps.data())); + EXPECT_EQ(256u, threadRegsetProps[0].count); +} + +HWTEST2_F(Xe2HpgCoreDebugSessionTest, + givenGetThreadRegisterSetPropertiesCalledWhenLargeGrfIsNotSetThen128GrfRegisterCountIsReported, IsXe2HpgCore) { + auto mockBuiltins = new L0::ult::MockBuiltins(); + mockBuiltins->stateSaveAreaHeader = NEO::MockSipData::createStateSaveAreaHeader(2, 256); + MockRootDeviceEnvironment::resetBuiltins(neoDevice->executionEnvironment->rootDeviceEnvironments[0].get(), mockBuiltins); + + { + auto pStateSaveAreaHeader = reinterpret_cast(session->stateSaveAreaHeader.data()); + auto size = pStateSaveAreaHeader->versionHeader.size * 8 + + pStateSaveAreaHeader->regHeader.state_area_offset + + pStateSaveAreaHeader->regHeader.state_save_size * 16; + session->stateSaveAreaHeader.resize(size); + } + + ze_device_thread_t thread = stoppedThread; + + auto *regdesc = &(reinterpret_cast(session->stateSaveAreaHeader.data()))->regHeader.sr; + uint32_t sr0[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + sr0[1] = 0x80003000; + session->registersAccessHelper(session->allThreads[stoppedThreadId].get(), regdesc, 0, 1, sr0, true); + + uint32_t threadCount = 0; + EXPECT_EQ(ZE_RESULT_SUCCESS, zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &threadCount, nullptr)); + std::vector threadRegsetProps(threadCount); + ASSERT_EQ(ZE_RESULT_SUCCESS, zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &threadCount, threadRegsetProps.data())); + EXPECT_EQ(128u, threadRegsetProps[0].count); +} + +using DebugApiTest = Test; +using isDebugSupportedProduct = IsAtLeastProduct; +HWTEST2_F(DebugApiTest, givenDeviceWhenDebugAttachIsAvaialbleThenGetPropertiesReturnsCorrectFlag2, isDebugSupportedProduct) { + zet_device_debug_properties_t debugProperties = {}; + debugProperties.flags = ZET_DEVICE_DEBUG_PROPERTY_FLAG_FORCE_UINT32; + + neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new OsInterfaceWithDebugAttach); + + auto result = zetDeviceGetDebugProperties(device->toHandle(), &debugProperties); + + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_EQ(ZET_DEVICE_DEBUG_PROPERTY_FLAG_ATTACH, debugProperties.flags); +} + +} // namespace ult +} // namespace L0 diff --git a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux.cpp b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux.cpp index fcc6b93b63..7d891c02ba 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/linux/test_metric_ip_sampling_linux.cpp @@ -27,9 +27,7 @@ class MetricIpSamplingLinuxTest : public DeviceFixture, std::unique_ptr metricIpSamplingOsInterface = nullptr; }; -using IsNotGen9ThruPVC = IsNotWithinProducts; - -HWTEST2_F(MetricIpSamplingLinuxTest, GivenUnsupportedProductFamilyIsUsedWhenIsDependencyAvailableIsCalledThenReturnFailure, IsNotGen9ThruPVC) { +HWTEST2_F(MetricIpSamplingLinuxTest, GivenUnsupportedProductFamilyIsUsedWhenIsDependencyAvailableIsCalledThenReturnFailure, IsXeHpgCore) { EXPECT_FALSE(metricIpSamplingOsInterface->isDependencyAvailable()); } diff --git a/manifests/manifest.yml b/manifests/manifest.yml index bde2e69c85..193848cd4f 100644 --- a/manifests/manifest.yml +++ b/manifests/manifest.yml @@ -42,7 +42,7 @@ components: dest_dir: kernels_bin type: git branch: kernels_bin - revision: 2925-1969 + revision: 2925-1993 kmdaf: branch: kmdaf dest_dir: kmdaf diff --git a/opencl/source/xe2_hpg_core/CMakeLists.txt b/opencl/source/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..4207cc9e5d --- /dev/null +++ b/opencl/source/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,15 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(SUPPORT_XE2_HPG_CORE) + set(RUNTIME_SRCS_XE2_HPG_CORE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ) + + target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_XE2_HPG_CORE}) + set_property(GLOBAL PROPERTY RUNTIME_SRCS_XE2_HPG_CORE ${RUNTIME_SRCS_XE2_HPG_CORE}) +endif() + diff --git a/opencl/source/xe2_hpg_core/buffer_xe2_hpg_core.cpp b/opencl/source/xe2_hpg_core/buffer_xe2_hpg_core.cpp new file mode 100644 index 0000000000..ca872ae408 --- /dev/null +++ b/opencl/source/xe2_hpg_core/buffer_xe2_hpg_core.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +#include "opencl/source/mem_obj/buffer_base.inl" + +namespace NEO { + +using Family = Xe2HpgCoreFamily; +static auto gfxCore = IGFX_XE2_HPG_CORE; + +template class BufferHw; + +#include "opencl/source/mem_obj/buffer_factory_init.inl" +} // namespace NEO diff --git a/opencl/source/xe2_hpg_core/cl_gfx_core_helper_xe2_hpg_core.cpp b/opencl/source/xe2_hpg_core/cl_gfx_core_helper_xe2_hpg_core.cpp new file mode 100644 index 0000000000..650ab32a82 --- /dev/null +++ b/opencl/source/xe2_hpg_core/cl_gfx_core_helper_xe2_hpg_core.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/populate_factory.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +#include "opencl/source/helpers/cl_gfx_core_helper_base.inl" +#include "opencl/source/helpers/cl_gfx_core_helper_xehp_and_later.inl" + +namespace NEO { + +using Family = Xe2HpgCoreFamily; +static auto gfxCore = IGFX_XE2_HPG_CORE; + +#include "opencl/source/helpers/cl_gfx_core_helper_factory_init.inl" +#include "opencl/source/helpers/cl_gfx_core_helper_pvc_and_later.inl" + +template <> +bool ClGfxCoreHelperHw::requiresAuxResolves(const KernelInfo &kernelInfo) const { + return false; +} + +template <> +bool ClGfxCoreHelperHw::isLimitationForPreemptionNeeded() const { + // mid thread preemption will disable with protected mode + return true; +} + +template class ClGfxCoreHelperHw; + +} // namespace NEO diff --git a/opencl/source/xe2_hpg_core/command_queue_xe2_hpg_core.cpp b/opencl/source/xe2_hpg_core/command_queue_xe2_hpg_core.cpp new file mode 100644 index 0000000000..3a21425188 --- /dev/null +++ b/opencl/source/xe2_hpg_core/command_queue_xe2_hpg_core.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/populate_factory.h" +#include "shared/source/memory_manager/unified_memory_manager.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +#include "opencl/source/command_queue/command_queue_hw.h" +#include "opencl/source/command_queue/enqueue_resource_barrier.h" + +namespace NEO { +using Family = Xe2HpgCoreFamily; +static auto gfxCore = IGFX_XE2_HPG_CORE; +} // namespace NEO + +#include "opencl/source/command_queue/command_queue_hw_xehp_and_later.inl" + +namespace NEO { + +template <> +void populateFactoryTable>() { + extern CommandQueueCreateFunc commandQueueFactory[IGFX_MAX_CORE]; + commandQueueFactory[gfxCore] = CommandQueueHw::create; +} + +template <> +bool CommandQueueHw::isCacheFlushForBcsRequired() const { + if (debugManager.flags.ForceCacheFlushForBcs.get() != -1) { + return !!debugManager.flags.ForceCacheFlushForBcs.get(); + } + + const auto &productHelper = this->device->getProductHelper(); + return productHelper.isDcFlushAllowed(); +} + +} // namespace NEO + +template class NEO::CommandQueueHw; diff --git a/opencl/source/xe2_hpg_core/enable_family_full_ocl_xe2_hpg_core.cpp b/opencl/source/xe2_hpg_core/enable_family_full_ocl_xe2_hpg_core.cpp new file mode 100644 index 0000000000..0b1c6310fb --- /dev/null +++ b/opencl/source/xe2_hpg_core/enable_family_full_ocl_xe2_hpg_core.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/populate_factory.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +#include "opencl/source/command_queue/command_queue_hw.h" +#include "opencl/source/helpers/cl_gfx_core_helper.h" +#include "opencl/source/mem_obj/buffer.h" +#include "opencl/source/mem_obj/image.h" +#include "opencl/source/sampler/sampler.h" + +namespace NEO { + +using Family = Xe2HpgCoreFamily; + +struct EnableOCLXe2HpgCore { + EnableOCLXe2HpgCore() { + populateFactoryTable>(); + populateFactoryTable>(); + populateFactoryTable>(); + populateFactoryTable>(); + populateFactoryTable>(); + } +}; + +static EnableOCLXe2HpgCore enable; +} // namespace NEO diff --git a/opencl/source/xe2_hpg_core/gpgpu_walker_xe2_hpg_core.cpp b/opencl/source/xe2_hpg_core/gpgpu_walker_xe2_hpg_core.cpp new file mode 100644 index 0000000000..a57d5bff1b --- /dev/null +++ b/opencl/source/xe2_hpg_core/gpgpu_walker_xe2_hpg_core.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +#include "opencl/source/command_queue/gpgpu_walker_xehp_and_later.inl" +#include "opencl/source/command_queue/hardware_interface_xehp_and_later.inl" + +namespace NEO { + +using Family = Xe2HpgCoreFamily; + +template class GpgpuWalkerHelper; +template void GpgpuWalkerHelper::setupTimestampPacket(LinearStream *cmdStream, Family::DefaultWalkerType *walkerCmd, TagNodeBase *timestampPacketNode, const RootDeviceEnvironment &rootDeviceEnvironment); +template size_t GpgpuWalkerHelper::setGpgpuWalkerThreadData(Family::DefaultWalkerType *walkerCmd, const KernelDescriptor &kernelDescriptor, const size_t globalOffsets[3], const size_t startWorkGroups[3], + const size_t numWorkGroups[3], const size_t localWorkSizesIn[3], uint32_t simd, uint32_t workDim, bool localIdsGenerationByRuntime, bool inlineDataProgrammingRequired, uint32_t requiredWorkGroupOrder); + +template class HardwareInterface; + +template void HardwareInterface::dispatchWalker(CommandQueue &commandQueue, const MultiDispatchInfo &multiDispatchInfo, const CsrDependencies &csrDependencies, HardwareInterfaceWalkerArgs &walkerArgs); +template void HardwareInterface::programWalker(LinearStream &commandStream, Kernel &kernel, CommandQueue &commandQueue, IndirectHeap &dsh, IndirectHeap &ioh, IndirectHeap &ssh, const DispatchInfo &dispatchInfo, HardwareInterfaceWalkerArgs &walkerArgs); +template void HardwareInterface::dispatchKernelCommands(CommandQueue &commandQueue, const DispatchInfo &dispatchInfo, LinearStream &commandStream, IndirectHeap &dsh, IndirectHeap &ioh, IndirectHeap &ssh, HardwareInterfaceWalkerArgs &walkerArgs); +template Family::DefaultWalkerType *HardwareInterface::allocateWalkerSpace(LinearStream &commandStream, const Kernel &kernel); + +template struct EnqueueOperation; + +} // namespace NEO diff --git a/opencl/source/xe2_hpg_core/gtpin_setup_xe2_hpg_core.cpp b/opencl/source/xe2_hpg_core/gtpin_setup_xe2_hpg_core.cpp new file mode 100644 index 0000000000..c668f6bb5c --- /dev/null +++ b/opencl/source/xe2_hpg_core/gtpin_setup_xe2_hpg_core.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/compiler_interface/external_functions.h" +#include "shared/source/kernel/implicit_args_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +#include "opencl/source/gtpin/gtpin_gfx_core_helper.h" +#include "opencl/source/gtpin/gtpin_gfx_core_helper.inl" +#include "opencl/source/gtpin/gtpin_gfx_core_helper_xehp_and_later.inl" + +#include "ocl_igc_shared/gtpin/gtpin_ocl_interface.h" + +namespace NEO { + +extern GTPinGfxCoreHelperCreateFunctionType gtpinGfxCoreHelperFactory[IGFX_MAX_CORE]; + +using Family = Xe2HpgCoreFamily; +static const auto gfxFamily = IGFX_XE2_HPG_CORE; + +template <> +uint32_t GTPinGfxCoreHelperHw::getGenVersion() const { + return gtpin::GTPIN_XE_HPG_CORE; +} + +template class GTPinGfxCoreHelperHw; + +struct GTPinEnableXe2HpgCore { + GTPinEnableXe2HpgCore() { + gtpinGfxCoreHelperFactory[gfxFamily] = GTPinGfxCoreHelperHw::create; + } +}; + +static GTPinEnableXe2HpgCore gtpinEnable; + +} // namespace NEO diff --git a/opencl/source/xe2_hpg_core/hardware_commands_helper_xe2_hpg_core.cpp b/opencl/source/xe2_hpg_core/hardware_commands_helper_xe2_hpg_core.cpp new file mode 100644 index 0000000000..7855dff5fb --- /dev/null +++ b/opencl/source/xe2_hpg_core/hardware_commands_helper_xe2_hpg_core.cpp @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/cache_flush_xehp_and_later.inl" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +#include "opencl/source/helpers/hardware_commands_helper.h" +#include "opencl/source/helpers/hardware_commands_helper_base.inl" +#include "opencl/source/helpers/hardware_commands_helper_xehp_and_later.inl" + +namespace NEO { +using FamilyType = Xe2HpgCoreFamily; +} // namespace NEO + +#include "opencl/source/helpers/enable_hardware_commands_helper_cw.inl" diff --git a/opencl/source/xe2_hpg_core/image_xe2_hpg_core.cpp b/opencl/source/xe2_hpg_core/image_xe2_hpg_core.cpp new file mode 100644 index 0000000000..9d27d5125b --- /dev/null +++ b/opencl/source/xe2_hpg_core/image_xe2_hpg_core.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +#include "opencl/source/mem_obj/image.inl" + +namespace NEO { + +using Family = Xe2HpgCoreFamily; +static auto gfxCore = IGFX_XE2_HPG_CORE; + +} // namespace NEO +#include "opencl/source/mem_obj/image_tgllp_and_later.inl" + +// factory initializer +#include "opencl/source/mem_obj/image_factory_init.inl" diff --git a/opencl/source/xe2_hpg_core/sampler_xe2_hpg_core.cpp b/opencl/source/xe2_hpg_core/sampler_xe2_hpg_core.cpp new file mode 100644 index 0000000000..bbc42fad3b --- /dev/null +++ b/opencl/source/xe2_hpg_core/sampler_xe2_hpg_core.cpp @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +using Family = NEO::Xe2HpgCoreFamily; +constexpr static auto gfxCore = IGFX_XE2_HPG_CORE; +#include "opencl/source/sampler/sampler_tgllp_and_later.inl" diff --git a/opencl/test/unit_test/aub_tests/xe2_hpg_core/CMakeLists.txt b/opencl/test/unit_test/aub_tests/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..938d1d5433 --- /dev/null +++ b/opencl/test/unit_test/aub_tests/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,17 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XE2_HPG_CORE) + target_sources(igdrcl_aub_tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/aub_mem_dump_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/aub_tests_excludes_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/copy_engine_aub_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/enqueue_kernel_aub_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/system_memfence_aub_tests_xe2_hpg_core.cpp + ) + add_subdirectories() +endif() diff --git a/opencl/test/unit_test/aub_tests/xe2_hpg_core/aub_mem_dump_tests_xe2_hpg_core.cpp b/opencl/test/unit_test/aub_tests/xe2_hpg_core/aub_mem_dump_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..52c168d427 --- /dev/null +++ b/opencl/test/unit_test/aub_tests/xe2_hpg_core/aub_mem_dump_tests_xe2_hpg_core.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/mocks/mock_device.h" + +#include "opencl/test/unit_test/aub_tests/command_stream/aub_mem_dump_tests.h" +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" + +using Xe2HpgCoreAubMemDumpTests = Test; + +XE2_HPG_CORETEST_F(Xe2HpgCoreAubMemDumpTests, GivenCcsThenExpectationsAreMet) { + setupAUB(pDevice, aub_stream::ENGINE_CCS); +} diff --git a/opencl/test/unit_test/aub_tests/xe2_hpg_core/aub_tests_excludes_xe2_hpg_core.cpp b/opencl/test/unit_test/aub_tests/xe2_hpg_core/aub_tests_excludes_xe2_hpg_core.cpp new file mode 100644 index 0000000000..c61ea3dcab --- /dev/null +++ b/opencl/test/unit_test/aub_tests/xe2_hpg_core/aub_tests_excludes_xe2_hpg_core.cpp @@ -0,0 +1,13 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/test_macros/hw_test_base.h" + +using namespace NEO; + +HWTEST_EXCLUDE_PRODUCT(MultiContextLargeGrfKernelAubTest, givenLargeAndSmallGrfWhenParallelRunOnCcsAndRcsThenResultsAreOk, IGFX_XE2_HPG_CORE); diff --git a/opencl/test/unit_test/aub_tests/xe2_hpg_core/bmg/CMakeLists.txt b/opencl/test/unit_test/aub_tests/xe2_hpg_core/bmg/CMakeLists.txt new file mode 100644 index 0000000000..cdc8c0ef2d --- /dev/null +++ b/opencl/test/unit_test/aub_tests/xe2_hpg_core/bmg/CMakeLists.txt @@ -0,0 +1,12 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_BMG) + target_sources(igdrcl_aub_tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/aub_tests_excludes_bmg.cpp + ) +endif() diff --git a/opencl/test/unit_test/aub_tests/xe2_hpg_core/bmg/aub_tests_excludes_bmg.cpp b/opencl/test/unit_test/aub_tests/xe2_hpg_core/bmg/aub_tests_excludes_bmg.cpp new file mode 100644 index 0000000000..d0a03c69c9 --- /dev/null +++ b/opencl/test/unit_test/aub_tests/xe2_hpg_core/bmg/aub_tests_excludes_bmg.cpp @@ -0,0 +1,13 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/test/common/test_macros/hw_test_base.h" + +HWTEST_EXCLUDE_PRODUCT(CompressionSystemXeHPAndLater, givenCompressedBuffersWhenWritingAndCopyingThenResultsAreCorrect, IGFX_BMG); +HWTEST_EXCLUDE_PRODUCT(CompressionSystemXeHPAndLater, givenCompressedImage2DFromBufferWhenItIsUsedThenDataIsCorrect, IGFX_BMG); +HWTEST_EXCLUDE_PRODUCT(CompressionSystemXeHPAndLater, givenCompressedImageWhenReadingThenResultsAreCorrect, IGFX_BMG); diff --git a/opencl/test/unit_test/aub_tests/xe2_hpg_core/copy_engine_aub_tests_xe2_hpg_core.cpp b/opencl/test/unit_test/aub_tests/xe2_hpg_core/copy_engine_aub_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..4c5ed1e633 --- /dev/null +++ b/opencl/test/unit_test/aub_tests/xe2_hpg_core/copy_engine_aub_tests_xe2_hpg_core.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +#include "opencl/source/helpers/hardware_commands_helper.h" +#include "opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h" + +using namespace NEO; + +template +struct CopyEnginesXe2HpgCoreFixture : public CopyEngineXeHPAndLater { + using MEM_COPY = typename FamilyType::MEM_COPY; + + void SetUp() override { + this->bcsEngineType = aub_stream::EngineType::ENGINE_BCS; + CopyEngineXeHPAndLater::SetUp(); + } +}; + +using SingleTileXe2HpgCoreTests = CopyEnginesXe2HpgCoreFixture<1, Xe2HpgCoreFamily, true>; + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenNotCompressedBufferWhenBltExecutedThenCompressDataAndResolve) { + givenNotCompressedBufferWhenBltExecutedThenCompressDataAndResolveImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenHostPtrWhenBlitCommandToCompressedBufferIsDispatchedThenCopiedDataIsValid) { + givenHostPtrWhenBlitCommandToCompressedBufferIsDispatchedThenCopiedDataIsValidImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenDstHostPtrWhenBlitCommandFromCompressedBufferIsDispatchedThenCopiedDataIsValid) { + givenDstHostPtrWhenBlitCommandFromCompressedBufferIsDispatchedThenCopiedDataIsValidImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenDstHostPtrWhenBlitCommandFromNotCompressedBufferIsDispatchedThenCopiedDataIsValid) { + givenDstHostPtrWhenBlitCommandFromNotCompressedBufferIsDispatchedThenCopiedDataIsValidImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenSrcHostPtrWhenBlitCommandToNotCompressedBufferIsDispatchedThenCopiedDataIsValid) { + givenSrcHostPtrWhenBlitCommandToNotCompressedBufferIsDispatchedThenCopiedDataIsValidImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenBufferWithOffsetWhenHostPtrBlitCommandIsDispatchedFromHostPtrThenDataIsCorrectlyCopied) { + givenBufferWithOffsetWhenHostPtrBlitCommandIsDispatchedFromHostPtrThenDataIsCorrectlyCopiedImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenBufferWithOffsetWhenHostPtrBlitCommandIsDispatchedToHostPtrThenDataIsCorrectlyCopied) { + givenBufferWithOffsetWhenHostPtrBlitCommandIsDispatchedToHostPtrThenDataIsCorrectlyCopiedImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenOffsetsWhenBltExecutedThenCopiedDataIsValid) { + givenOffsetsWhenBltExecutedThenCopiedDataIsValidImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenSrcCompressedBufferWhenBlitCommandToDstCompressedBufferIsDispatchedThenCopiedDataIsValid) { + givenSrcCompressedBufferWhenBlitCommandToDstCompressedBufferIsDispatchedThenCopiedDataIsValidImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenCompressedBufferWhenAuxTranslationCalledThenResolveAndCompress) { + givenCompressedBufferWhenAuxTranslationCalledThenResolveAndCompressImpl(); +} + +using SingleTileSystemMemoryXe2HpgCoreTests = CopyEnginesXe2HpgCoreFixture<1, Xe2HpgCoreFamily, false>; + +XE2_HPG_CORETEST_F(SingleTileSystemMemoryXe2HpgCoreTests, givenSrcSystemBufferWhenBlitCommandToDstSystemBufferIsDispatchedThenCopiedDataIsValid) { + givenSrcSystemBufferWhenBlitCommandToDstSystemBufferIsDispatchedThenCopiedDataIsValidImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenReadBufferRectWithOffsetWhenHostPtrBlitCommandIsDispatchedToHostPtrThenDataIsCorrectlyCopied) { + givenReadBufferRectWithOffsetWhenHostPtrBlitCommandIsDispatchedToHostPtrThenDataIsCorrectlyCopiedImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenWriteBufferRectWithOffsetWhenHostPtrBlitCommandIsDispatchedToHostPtrThenDataIsCorrectlyCopied) { + givenWriteBufferRectWithOffsetWhenHostPtrBlitCommandIsDispatchedToHostPtrThenDataIsCorrectlyCopiedImpl(); +} + +XE2_HPG_CORETEST_F(SingleTileXe2HpgCoreTests, givenCopyBufferRectWithOffsetWhenHostPtrBlitCommandIsDispatchedToHostPtrThenDataIsCorrectlyCopied) { + givenCopyBufferRectWithOffsetWhenHostPtrBlitCommandIsDispatchedToHostPtrThenDataIsCorrectlyCopiedImpl(); +} diff --git a/opencl/test/unit_test/aub_tests/xe2_hpg_core/enqueue_kernel_aub_tests_xe2_hpg_core.cpp b/opencl/test/unit_test/aub_tests/xe2_hpg_core/enqueue_kernel_aub_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..012ea59510 --- /dev/null +++ b/opencl/test/unit_test/aub_tests/xe2_hpg_core/enqueue_kernel_aub_tests_xe2_hpg_core.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "opencl/source/command_queue/command_queue.h" +#include "opencl/source/mem_obj/buffer.h" +#include "opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h" +#include "opencl/test/unit_test/fixtures/simple_arg_fixture.h" + +using namespace NEO; + +extern const HardwareInfo *defaultHwInfo; + +using AUBSimpleKernelStatelessTestXe2HpgCore = Test>; + +HWTEST2_F(AUBSimpleKernelStatelessTestXe2HpgCore, givenPrefetchEnabledWhenEnqueuedKernelThenDataIsCorrect, IsXe2HpgCore) { + DebugManagerStateRestore restore; + debugManager.flags.EnableMemoryPrefetch.set(1); + + constexpr size_t bufferSize = MemoryConstants::pageSize; + + cl_uint workDim = 1; + size_t globalWorkOffset[3] = {0, 0, 0}; + size_t globalWorkSize[3] = {bufferSize, 1, 1}; + size_t localWorkSize[3] = {1, 1, 1}; + + uint8_t bufferData[bufferSize] = {}; + uint8_t bufferExpected[bufferSize]; + memset(bufferExpected, 0xCD, bufferSize); + + auto buffer = std::unique_ptr(Buffer::create(context, CL_MEM_USE_HOST_PTR | CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL, + bufferSize, bufferData, retVal)); + ASSERT_NE(nullptr, buffer); + + kernel->setArg(0, buffer.get()); + + retVal = this->pCmdQ->enqueueKernel(kernel.get(), workDim, globalWorkOffset, globalWorkSize, + localWorkSize, 0, nullptr, nullptr); + + this->pCmdQ->flush(); + expectMemory(addrToPtr(ptrOffset(buffer->getGraphicsAllocation(rootDeviceIndex)->getGpuAddress(), buffer->getOffset())), + bufferExpected, bufferSize); +} diff --git a/opencl/test/unit_test/aub_tests/xe2_hpg_core/lnl/CMakeLists.txt b/opencl/test/unit_test/aub_tests/xe2_hpg_core/lnl/CMakeLists.txt new file mode 100644 index 0000000000..bd6edf25bc --- /dev/null +++ b/opencl/test/unit_test/aub_tests/xe2_hpg_core/lnl/CMakeLists.txt @@ -0,0 +1,12 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_LNL) + target_sources(igdrcl_aub_tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/copy_engine_aub_tests_lnl.cpp + ) +endif() diff --git a/opencl/test/unit_test/aub_tests/xe2_hpg_core/lnl/copy_engine_aub_tests_lnl.cpp b/opencl/test/unit_test/aub_tests/xe2_hpg_core/lnl/copy_engine_aub_tests_lnl.cpp new file mode 100644 index 0000000000..22f59b1a0f --- /dev/null +++ b/opencl/test/unit_test/aub_tests/xe2_hpg_core/lnl/copy_engine_aub_tests_lnl.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +#include "opencl/source/helpers/hardware_commands_helper.h" +#include "opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and_later.h" + +using namespace NEO; + +template +struct CopyEnginesLnlFixture : public CopyEngineXeHPAndLater { + + bool compressionSupported() const override { + auto &ftrTable = MulticontextOclAubFixture::rootDevice->getHardwareInfo().featureTable; + return (ftrTable.flags.ftrFlatPhysCCS); + } +}; + +using SingleTileSystemMemLnlCoreTests = CopyEnginesLnlFixture<1, Xe2HpgCoreFamily, false>; + +LNLTEST_F(SingleTileSystemMemLnlCoreTests, givenNotCompressedBufferWhenBltExecutedThenCompressDataAndResolve) { + givenNotCompressedBufferWhenBltExecutedThenCompressDataAndResolveImpl(); +} + +LNLTEST_F(SingleTileSystemMemLnlCoreTests, givenHostPtrWhenBlitCommandToCompressedBufferIsDispatchedThenCopiedDataIsValid) { + givenHostPtrWhenBlitCommandToCompressedBufferIsDispatchedThenCopiedDataIsValidImpl(); +} + +LNLTEST_F(SingleTileSystemMemLnlCoreTests, givenDstHostPtrWhenBlitCommandFromCompressedBufferIsDispatchedThenCopiedDataIsValid) { + givenDstHostPtrWhenBlitCommandFromCompressedBufferIsDispatchedThenCopiedDataIsValidImpl(); +} + +LNLTEST_F(SingleTileSystemMemLnlCoreTests, givenDstHostPtrWhenBlitCommandFromNotCompressedBufferIsDispatchedThenCopiedDataIsValid) { + givenDstHostPtrWhenBlitCommandFromNotCompressedBufferIsDispatchedThenCopiedDataIsValidImpl(); +} + +LNLTEST_F(SingleTileSystemMemLnlCoreTests, givenSrcHostPtrWhenBlitCommandToNotCompressedBufferIsDispatchedThenCopiedDataIsValid) { + givenSrcHostPtrWhenBlitCommandToNotCompressedBufferIsDispatchedThenCopiedDataIsValidImpl(); +} + +LNLTEST_F(SingleTileSystemMemLnlCoreTests, givenBufferWithOffsetWhenHostPtrBlitCommandIsDispatchedFromHostPtrThenDataIsCorrectlyCopied) { + givenBufferWithOffsetWhenHostPtrBlitCommandIsDispatchedFromHostPtrThenDataIsCorrectlyCopiedImpl(); +} + +LNLTEST_F(SingleTileSystemMemLnlCoreTests, givenBufferWithOffsetWhenHostPtrBlitCommandIsDispatchedToHostPtrThenDataIsCorrectlyCopied) { + givenBufferWithOffsetWhenHostPtrBlitCommandIsDispatchedToHostPtrThenDataIsCorrectlyCopiedImpl(); +} + +LNLTEST_F(SingleTileSystemMemLnlCoreTests, givenOffsetsWhenBltExecutedThenCopiedDataIsValid) { + givenOffsetsWhenBltExecutedThenCopiedDataIsValidImpl(); +} + +LNLTEST_F(SingleTileSystemMemLnlCoreTests, givenSrcCompressedBufferWhenBlitCommandToDstCompressedBufferIsDispatchedThenCopiedDataIsValid) { + givenSrcCompressedBufferWhenBlitCommandToDstCompressedBufferIsDispatchedThenCopiedDataIsValidImpl(); +} + +LNLTEST_F(SingleTileSystemMemLnlCoreTests, givenCompressedBufferWhenAuxTranslationCalledThenResolveAndCompress) { + givenCompressedBufferWhenAuxTranslationCalledThenResolveAndCompressImpl(); +} diff --git a/opencl/test/unit_test/aub_tests/xe2_hpg_core/system_memfence_aub_tests_xe2_hpg_core.cpp b/opencl/test/unit_test/aub_tests/xe2_hpg_core/system_memfence_aub_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..322e62cb8a --- /dev/null +++ b/opencl/test/unit_test/aub_tests/xe2_hpg_core/system_memfence_aub_tests_xe2_hpg_core.cpp @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_execution_environment.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" +#include "shared/test/common/utilities/base_object_utils.h" + +#include "opencl/source/api/api.h" +#include "opencl/test/unit_test/aub_tests/fixtures/aub_fixture.h" +#include "opencl/test/unit_test/aub_tests/fixtures/multicontext_ocl_aub_fixture.h" +#include "opencl/test/unit_test/mocks/mock_kernel.h" + +using namespace NEO; + +class SystemMemFenceViaMiMemFence : public AUBFixture, + public ::testing::Test { + public: + void SetUp() override { + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(1); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0); + AUBFixture::setUp(defaultHwInfo.get()); + } + void TearDown() override { + AUBFixture::tearDown(); + } + + DebugManagerStateRestore debugRestorer; + cl_int retVal = CL_SUCCESS; +}; + +using SystemMemFenceViaMiMemFenceXe2HpgCore = SystemMemFenceViaMiMemFence; + +XE2_HPG_CORETEST_F(SystemMemFenceViaMiMemFenceXe2HpgCore, WhenGeneratedAsMiMemFenceCommandInCommandStreamThenWritesToSystemMemoryAreGloballyObservable) { + const size_t bufferSize = MemoryConstants::kiloByte; + std::vector buffer(bufferSize, 0x11); + + auto deviceMemAlloc = clDeviceMemAllocINTEL(this->context, this->device.get(), nullptr, bufferSize, 0, &retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + ASSERT_NE(nullptr, deviceMemAlloc); + + retVal = clEnqueueMemcpyINTEL(this->pCmdQ, true, deviceMemAlloc, buffer.data(), bufferSize, 0, nullptr, nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + + expectMemory(deviceMemAlloc, buffer.data(), bufferSize); + + auto hostMemAlloc = clHostMemAllocINTEL(this->context, nullptr, bufferSize, 0, &retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + ASSERT_NE(nullptr, hostMemAlloc); + + retVal = clEnqueueMemcpyINTEL(this->pCmdQ, true, hostMemAlloc, deviceMemAlloc, bufferSize, 0, nullptr, nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + + expectMemory(hostMemAlloc, buffer.data(), bufferSize); + + retVal = clMemFreeINTEL(this->context, deviceMemAlloc); + EXPECT_EQ(CL_SUCCESS, retVal); + + retVal = clMemFreeINTEL(this->context, hostMemAlloc); + EXPECT_EQ(CL_SUCCESS, retVal); +} + +class SystemMemFenceViaComputeWalker : public AUBFixture, + public ::testing::Test { + public: + void SetUp() override { + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(1); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0); + AUBFixture::setUp(defaultHwInfo.get()); + } + void TearDown() override { + AUBFixture::tearDown(); + } + + DebugManagerStateRestore debugRestorer; + cl_int retVal = CL_SUCCESS; +}; + +using SystemMemFenceViaComputeWalkerXe2HpgCore = SystemMemFenceViaComputeWalker; + +XE2_HPG_CORETEST_F(SystemMemFenceViaComputeWalkerXe2HpgCore, WhenGeneratedAsPostSyncOperationInWalkerThenWritesToSystemMemoryAreGloballyObservable) { + const size_t bufferSize = MemoryConstants::kiloByte; + std::vector buffer(bufferSize, 0x11); + + auto deviceMemAlloc = clDeviceMemAllocINTEL(this->context, this->device.get(), nullptr, bufferSize, 0, &retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + ASSERT_NE(nullptr, deviceMemAlloc); + + retVal = clEnqueueMemcpyINTEL(this->pCmdQ, true, deviceMemAlloc, buffer.data(), bufferSize, 0, nullptr, nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + + expectMemory(deviceMemAlloc, buffer.data(), bufferSize); + + auto hostMemAlloc = clHostMemAllocINTEL(this->context, nullptr, bufferSize, 0, &retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + ASSERT_NE(nullptr, hostMemAlloc); + + retVal = clEnqueueMemcpyINTEL(this->pCmdQ, true, hostMemAlloc, deviceMemAlloc, bufferSize, 0, nullptr, nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + + expectMemory(hostMemAlloc, buffer.data(), bufferSize); + + retVal = clMemFreeINTEL(this->context, deviceMemAlloc); + EXPECT_EQ(CL_SUCCESS, retVal); + + retVal = clMemFreeINTEL(this->context, hostMemAlloc); + EXPECT_EQ(CL_SUCCESS, retVal); +} + +class SystemMemFenceWithBlitterXe2HpgCore : public MulticontextOclAubFixture, + public ::testing::Test { + public: + void SetUp() override { + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(1); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0); + + debugManager.flags.EnableBlitterOperationsSupport.set(1); + debugManager.flags.EnableBlitterForEnqueueOperations.set(1); + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); + if (!productHelper.obtainBlitterPreference(*defaultHwInfo.get())) { + GTEST_SKIP(); + } + + MulticontextOclAubFixture::setUp(1, EnabledCommandStreamers::single, false); + } + void TearDown() override { + MulticontextOclAubFixture::tearDown(); + } + + DebugManagerStateRestore debugRestorer; + cl_int retVal = CL_SUCCESS; +}; + +XE2_HPG_CORETEST_F(SystemMemFenceWithBlitterXe2HpgCore, givenSystemMemFenceWhenGeneratedAsMiMemFenceCmdInBCSThenWritesToSystemMemoryAreGloballyObservable) { + const size_t bufferSize = MemoryConstants::kiloByte; + std::vector buffer(bufferSize, 0x11); + + auto deviceMemAlloc = clDeviceMemAllocINTEL(context.get(), tileDevices[0], nullptr, bufferSize, 0, &retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + ASSERT_NE(nullptr, deviceMemAlloc); + + retVal = clEnqueueMemcpyINTEL(commandQueues[0][0].get(), true, deviceMemAlloc, buffer.data(), bufferSize, 0, nullptr, nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + + expectMemory(deviceMemAlloc, buffer.data(), bufferSize, 0, 0); + + auto hostMemAlloc = clHostMemAllocINTEL(context.get(), nullptr, bufferSize, 0, &retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + ASSERT_NE(nullptr, hostMemAlloc); + + retVal = clEnqueueMemcpyINTEL(commandQueues[0][0].get(), true, hostMemAlloc, deviceMemAlloc, bufferSize, 0, nullptr, nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + + expectMemory(hostMemAlloc, buffer.data(), bufferSize, 0, 0); + + retVal = clMemFreeINTEL(context.get(), deviceMemAlloc); + EXPECT_EQ(CL_SUCCESS, retVal); + + retVal = clMemFreeINTEL(context.get(), hostMemAlloc); + EXPECT_EQ(CL_SUCCESS, retVal); +} diff --git a/opencl/test/unit_test/command_stream/CMakeLists.txt b/opencl/test/unit_test/command_stream/CMakeLists.txt index 9490c425bd..a44a137b85 100644 --- a/opencl/test/unit_test/command_stream/CMakeLists.txt +++ b/opencl/test/unit_test/command_stream/CMakeLists.txt @@ -42,5 +42,11 @@ if(TESTS_DG2_AND_LATER) ) endif() +if(TESTS_XE2_AND_LATER) + list(APPEND IGDRCL_SRCS_tests_command_stream + ${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_hw_tests_xe2_and_later.cpp + ) +endif() + target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_command_stream}) add_subdirectories() diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xe2_and_later.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xe2_and_later.cpp new file mode 100644 index 0000000000..80a94d03b9 --- /dev/null +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_tests_xe2_and_later.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/libult/ult_command_stream_receiver.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h" + +#include "gtest/gtest.h" + +using CommandStreamReceiverXe2AndLater = UltCommandStreamReceiverTest; + +HWTEST2_F(CommandStreamReceiverXe2AndLater, GivenPreambleNotSentAndDebugFlagEnabledWhenFlushingTaskThenPipelineSelectIsSent, IsAtLeastXe2HpgCore) { + DebugManagerStateRestore restorer{}; + debugManager.flags.PipelinedPipelineSelect.set(true); + + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + commandStreamReceiver.isPreambleSent = false; + + flushTask(commandStreamReceiver); + parseCommands(commandStreamReceiver.commandStream, 0); + EXPECT_NE(nullptr, getCommand()); +} + +HWTEST2_F(CommandStreamReceiverXe2AndLater, GivenPreambleNotSentAndDebugFlagDisabledWhenFlushingTaskThenPipelineSelectIsNotSent, IsAtLeastXe2HpgCore) { + DebugManagerStateRestore restorer{}; + debugManager.flags.PipelinedPipelineSelect.set(false); + + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + commandStreamReceiver.isPreambleSent = false; + + flushTask(commandStreamReceiver); + parseCommands(commandStreamReceiver.commandStream, 0); + EXPECT_EQ(nullptr, getCommand()); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/CMakeLists.txt b/opencl/test/unit_test/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..6ac7864f56 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,35 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XE2_HPG_CORE) + set(IGDRCL_SRCS_tests_xe2_hpg_core_excludes + ${CMAKE_CURRENT_SOURCE_DIR}/excludes_ocl_xe2_hpg_core.cpp + ) + set_property(GLOBAL APPEND PROPERTY IGDRCL_SRCS_tests_excludes ${IGDRCL_SRCS_tests_xe2_hpg_core_excludes}) + + set(IGDRCL_SRCS_tests_xe2_hpg_core + ${IGDRCL_SRCS_tests_xe2_hpg_core_excludes} + ${CMAKE_CURRENT_SOURCE_DIR}/cl_gfx_core_helper_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_hw_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/copy_engine_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dispatch_walker_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/enqueue_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_cmds_programming_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_cl_device_caps_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_platform_caps_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_sample_xe2_hpg_core.cpp + ) + + get_property(NEO_CORE_TESTS_XE2_HPG_CORE GLOBAL PROPERTY NEO_CORE_TESTS_XE2_HPG_CORE) + list(APPEND IGDRCL_SRCS_tests_xe2_hpg_core ${NEO_CORE_TESTS_XE2_HPG_CORE}) + + target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_xe2_hpg_core}) + add_subdirectories() +endif() diff --git a/opencl/test/unit_test/xe2_hpg_core/bmg/CMakeLists.txt b/opencl/test/unit_test/xe2_hpg_core/bmg/CMakeLists.txt new file mode 100644 index 0000000000..d7adfef738 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/bmg/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_BMG) + set(IGDRCL_SRCS_tests_xe2_hpg_core_bmg + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/device_info_tests_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_cl_device_caps_bmg.cpp + ) + + target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_xe2_hpg_core_bmg}) + add_subdirectories() +endif() diff --git a/opencl/test/unit_test/xe2_hpg_core/bmg/device_info_tests_bmg.cpp b/opencl/test/unit_test/xe2_hpg_core/bmg/device_info_tests_bmg.cpp new file mode 100644 index 0000000000..45a45d94b3 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/bmg/device_info_tests_bmg.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_bmg.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +#include "opencl/test/unit_test/fixtures/device_info_fixture.h" + +using GetDeviceInfoMemCapabilitiesTestBmgLinux = NEO::GetDeviceInfoMemCapabilitiesTest; + +BMGTEST_F(GetDeviceInfoMemCapabilitiesTestBmgLinux, GivenValidParametersWhenGetDeviceInfoIsCalledForBmgLinuxThenClSuccessIsReturned) { + std::vector params = { + {CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL, + (CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL | CL_UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS_INTEL)}, + {CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL, + (CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL | CL_UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS_INTEL)}, + {CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, + (CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL | CL_UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS_INTEL)}, + {CL_DEVICE_CROSS_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, + (CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL | CL_UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS_INTEL)}, + {CL_DEVICE_SHARED_SYSTEM_MEM_CAPABILITIES_INTEL, + 0}}; + + check(params); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/bmg/linux/CMakeLists.txt b/opencl/test/unit_test/xe2_hpg_core/bmg/linux/CMakeLists.txt new file mode 100644 index 0000000000..97db1686a2 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/bmg/linux/CMakeLists.txt @@ -0,0 +1,9 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(UNIX) + add_subdirectories() +endif() diff --git a/opencl/test/unit_test/xe2_hpg_core/bmg/linux/dll/CMakeLists.txt b/opencl/test/unit_test/xe2_hpg_core/bmg/linux/dll/CMakeLists.txt new file mode 100644 index 0000000000..c37256b225 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/bmg/linux/dll/CMakeLists.txt @@ -0,0 +1,12 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +set(IGDRCL_SRCS_linux_dll_tests_xe2_hpg_core_bmg + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/device_id_tests_bmg.cpp +) +target_sources(igdrcl_linux_dll_tests PRIVATE ${IGDRCL_SRCS_linux_dll_tests_xe2_hpg_core_bmg}) +add_subdirectories() diff --git a/opencl/test/unit_test/xe2_hpg_core/bmg/linux/dll/device_id_tests_bmg.cpp b/opencl/test/unit_test/xe2_hpg_core/bmg/linux/dll/device_id_tests_bmg.cpp new file mode 100644 index 0000000000..1127585163 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/bmg/linux/dll/device_id_tests_bmg.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/fixtures/linux/device_id_fixture.h" + +using namespace NEO; + +TEST_F(DeviceIdTests, GivenBmgSupportedDeviceIdThenDeviceDescriptorTableExists) { + std::array expectedDescriptors = {{ + {0xE202, &BmgHwConfig::hwInfo, &BmgHwConfig::setupHardwareInfo}, + {0xE20B, &BmgHwConfig::hwInfo, &BmgHwConfig::setupHardwareInfo}, + {0xE20C, &BmgHwConfig::hwInfo, &BmgHwConfig::setupHardwareInfo}, + {0xE20D, &BmgHwConfig::hwInfo, &BmgHwConfig::setupHardwareInfo}, + {0xE212, &BmgHwConfig::hwInfo, &BmgHwConfig::setupHardwareInfo}, + }}; + + testImpl(expectedDescriptors); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/bmg/test_cl_device_caps_bmg.cpp b/opencl/test/unit_test/xe2_hpg_core/bmg/test_cl_device_caps_bmg.cpp new file mode 100644 index 0000000000..1e5a1ced14 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/bmg/test_cl_device_caps_bmg.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_bmg.h" +#include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" + +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" +#include "opencl/test/unit_test/mocks/mock_cl_device.h" + +using namespace NEO; + +using BmgClDeviceIdTest = Test; + +BMGTEST_F(BmgClDeviceIdTest, givenDeviceExtensionsWhenDeviceCapsInitializedThenAddProperExtensions) { + const auto &dInfo = pClDevice->getDeviceInfo(); + EXPECT_TRUE(hasSubstr(dInfo.deviceExtensions, std::string("cl_intel_create_buffer_with_properties"))); + EXPECT_TRUE(hasSubstr(dInfo.deviceExtensions, std::string("cl_intel_subgroup_local_block_io"))); + EXPECT_TRUE(hasSubstr(dInfo.deviceExtensions, std::string("cl_intel_subgroup_matrix_multiply_accumulate"))); + EXPECT_TRUE(hasSubstr(dInfo.deviceExtensions, std::string("cl_khr_subgroup_named_barrier"))); + EXPECT_TRUE(hasSubstr(dInfo.deviceExtensions, std::string("cl_intel_subgroup_extended_block_read"))); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/cl_gfx_core_helper_tests_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/cl_gfx_core_helper_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..cd85d48ccc --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/cl_gfx_core_helper_tests_xe2_hpg_core.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/program/kernel_info.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/helpers/gfx_core_helper_tests.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" + +#include "opencl/source/helpers/cl_gfx_core_helper.h" +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" + +using ClGfxCoreHelperTestsXe2HpgCore = Test; + +XE2_HPG_CORETEST_F(ClGfxCoreHelperTestsXe2HpgCore, givenXe2HpgCoreThenAuxTranslationIsNotRequired) { + auto &clGfxCoreHelper = getHelper(); + KernelInfo kernelInfo{}; + + EXPECT_FALSE(clGfxCoreHelper.requiresAuxResolves(kernelInfo)); +} +XE2_HPG_CORETEST_F(ClGfxCoreHelperTestsXe2HpgCore, WhenCheckingPreferenceForBlitterForLocalToLocalTransfersThenReturnFalse) { + auto &clGfxCoreHelper = getHelper(); + + EXPECT_FALSE(clGfxCoreHelper.preferBlitterForLocalToLocalTransfers()); +} +XE2_HPG_CORETEST_F(ClGfxCoreHelperTestsXe2HpgCore, WhenCheckingIsLimitationForPreemptionNeededThenReturnTrue) { + auto &clGfxCoreHelper = getHelper(); + + EXPECT_TRUE(clGfxCoreHelper.isLimitationForPreemptionNeeded()); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/cmd_parse_tests_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/cmd_parse_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..e48d49256c --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/cmd_parse_tests_xe2_hpg_core.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/cmd_parse/hw_parse.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" + +using namespace NEO; + +using CmdParseTestsXe2HpgCore = ::testing::Test; + +XE2_HPG_CORETEST_F(CmdParseTestsXe2HpgCore, givenMiMemFenceCmdWhenParsingThenFindCommandAndsItsName) { + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + uint32_t buffer[64] = {}; + LinearStream cmdStream(buffer, sizeof(buffer)); + + auto miMemFenceCmd = cmdStream.getSpaceForCmd(); + miMemFenceCmd->init(); + + EXPECT_NE(nullptr, genCmdCast(buffer)); + + auto commandName = CmdParse::getCommandName(buffer); + EXPECT_EQ(0, strcmp(commandName, "MI_MEM_FENCE")); + + HardwareParse hwParser; + + hwParser.parseCommands(cmdStream, 0); + + EXPECT_EQ(1u, hwParser.cmdList.size()); +} + +XE2_HPG_CORETEST_F(CmdParseTestsXe2HpgCore, givenStateSystemMemFenceAddrCmdWhenParsingThenFindCommandAndsItsName) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + + uint32_t buffer[64] = {}; + LinearStream cmdStream(buffer, sizeof(buffer)); + + auto stateSystemMemFenceCmd = cmdStream.getSpaceForCmd(); + stateSystemMemFenceCmd->init(); + + EXPECT_NE(nullptr, genCmdCast(buffer)); + + auto commandName = CmdParse::getCommandName(buffer); + EXPECT_EQ(0, strcmp(commandName, "STATE_SYSTEM_MEM_FENCE_ADDRESS")); + + HardwareParse hwParser; + + hwParser.parseCommands(cmdStream, 0); + + EXPECT_EQ(1u, hwParser.cmdList.size()); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/command_stream_receiver_hw_tests_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/command_stream_receiver_hw_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..540314a8b4 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/command_stream_receiver_hw_tests_xe2_hpg_core.cpp @@ -0,0 +1,1033 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/linear_stream.h" +#include "shared/source/gmm_helper/client_context/gmm_client_context.h" +#include "shared/source/gmm_helper/resource_info.h" +#include "shared/source/helpers/blit_commands_helper.h" +#include "shared/source/os_interface/device_factory.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/engine_descriptor_helper.h" +#include "shared/test/common/libult/ult_aub_command_stream_receiver.h" +#include "shared/test/common/mocks/mock_timestamp_container.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" +#include "shared/test/common/utilities/base_object_utils.h" + +#include "opencl/source/command_queue/gpgpu_walker.h" +#include "opencl/source/command_queue/hardware_interface.h" +#include "opencl/source/event/event.h" +#include "opencl/source/helpers/cl_memory_properties_helpers.h" +#include "opencl/test/unit_test/command_queue/hardware_interface_helper.h" +#include "opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h" +#include "opencl/test/unit_test/mocks/mock_cl_device.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" +#include "opencl/test/unit_test/mocks/mock_kernel.h" +#include "opencl/test/unit_test/mocks/mock_mdi.h" +#include "opencl/test/unit_test/mocks/mock_platform.h" + +#include + +using namespace NEO; + +struct MemorySynchronizationViaMiSemaphoreWaitTest : public UltCommandStreamReceiverTest { + void SetUp() override { + debugManager.flags.EnableLocalMemory.set(1); + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0); + UltCommandStreamReceiverTest::SetUp(); + } + DebugManagerStateRestore restore; +}; + +using CommandStreamReceiverXe2HpgCoreTests = UltCommandStreamReceiverTest; + +XE2_HPG_CORETEST_F(CommandStreamReceiverXe2HpgCoreTests, givenProfilingEnabledWhenBlitBufferThenCommandBufferIsConstructedProperly) { + using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM; + + auto bcsOsContext = std::unique_ptr(OsContext::create(nullptr, pDevice->getRootDeviceIndex(), 0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::regular}, pDevice->getDeviceBitfield()))); + auto bcsCsr = std::make_unique>(*pDevice->getExecutionEnvironment(), pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); + bcsCsr->setupContext(*bcsOsContext); + bcsCsr->initializeTagAllocation(); + + auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); + + auto timestampPacketAllocator = new MockTagAllocator>(0, pDevice->getMemoryManager(), bcsCsr->getPreferredTagPoolSize(), gfxCoreHelper.getTimestampPacketAllocatorAlignment(), + sizeof(TimestampPackets), false, bcsOsContext->getDeviceBitfield()); + + bcsCsr->timestampPacketAllocator.reset(timestampPacketAllocator); + + auto context = std::make_unique(pClDevice); + + cl_int retVal = CL_SUCCESS; + auto buffer = clUniquePtr(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal)); + void *hostPtr = reinterpret_cast(0x12340000); + auto graphicsAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex()); + + auto blitProperties = BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::hostPtrToBuffer, + *bcsCsr, graphicsAllocation, nullptr, hostPtr, + graphicsAllocation->getGpuAddress(), 0, + 0, 0, {1, 1, 1}, 0, 0, 0, 0); + + MockTimestampPacketContainer timestamp(*bcsCsr->getTimestampPacketAllocator(), 1u); + blitProperties.outputTimestampPacket = timestamp.getNode(0); + + auto timestampContextStartGpuAddress = TimestampPacketHelper::getContextStartGpuAddress(*blitProperties.outputTimestampPacket); + auto timestampGlobalStartAddress = TimestampPacketHelper::getGlobalStartGpuAddress(*blitProperties.outputTimestampPacket); + + auto timestampContextEndGpuAddress = TimestampPacketHelper::getContextEndGpuAddress(*blitProperties.outputTimestampPacket); + auto timestampGlobalEndAddress = TimestampPacketHelper::getGlobalEndGpuAddress(*blitProperties.outputTimestampPacket); + + BlitPropertiesContainer blitPropertiesContainer; + blitPropertiesContainer.push_back(blitProperties); + + bcsCsr->flushBcsTask(blitPropertiesContainer, false, true, *pDevice); + + HardwareParse hwParser; + hwParser.parseCommands(bcsCsr->commandStream); + auto &cmdList = hwParser.cmdList; + + auto cmdIterator = cmdList.begin(); + + auto verifyLri = [&](const GenCmdList::iterator &itBegin, uint32_t expectRegister, uint64_t expectedAddress) { + cmdIterator = find(itBegin, cmdList.end()); + ASSERT_NE(cmdList.end(), cmdIterator); + + auto lriCmd = genCmdCast(*cmdIterator); + + EXPECT_EQ(expectRegister, lriCmd->getRegisterAddress()); + EXPECT_EQ(expectedAddress, lriCmd->getMemoryAddress()); + }; + + { + verifyLri(cmdIterator, RegisterOffsets::gpThreadTimeRegAddressOffsetHigh, timestampContextStartGpuAddress + sizeof(uint32_t)); + + verifyLri(++cmdIterator, RegisterOffsets::globalTimestampUn, timestampGlobalStartAddress + sizeof(uint32_t)); + + verifyLri(++cmdIterator, RegisterOffsets::gpThreadTimeRegAddressOffsetLow, timestampContextStartGpuAddress); + + verifyLri(++cmdIterator, RegisterOffsets::globalTimestampLdw, timestampGlobalStartAddress); + } + + cmdIterator = find(++cmdIterator, cmdList.end()); + ASSERT_NE(cmdList.end(), cmdIterator); + + cmdIterator = find(++cmdIterator, cmdList.end()); + ASSERT_NE(cmdList.end(), cmdIterator); + + { + + verifyLri(++cmdIterator, RegisterOffsets::gpThreadTimeRegAddressOffsetHigh, timestampContextEndGpuAddress + sizeof(uint32_t)); + + verifyLri(++cmdIterator, RegisterOffsets::globalTimestampUn, timestampGlobalEndAddress + sizeof(uint32_t)); + + verifyLri(++cmdIterator, RegisterOffsets::gpThreadTimeRegAddressOffsetLow, timestampContextEndGpuAddress); + + verifyLri(++cmdIterator, RegisterOffsets::globalTimestampLdw, timestampGlobalEndAddress); + } +} + +using MemorySynchronizationViaMiSemaphoreWaitTestXe2HpgCore = MemorySynchronizationViaMiSemaphoreWaitTest; + +XE2_HPG_CORETEST_F(MemorySynchronizationViaMiSemaphoreWaitTestXe2HpgCore, givenMemorySynchronizationViaMiSemaphoreWaitWhenProgramEnginePrologueIsCalledThenNoCommandIsProgrammed) { + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + EXPECT_FALSE(commandStreamReceiver.isEnginePrologueSent); + + auto requiredSize = commandStreamReceiver.getCmdSizeForPrologue(); + EXPECT_EQ(0u, requiredSize); + + StackVec buffer(requiredSize); + LinearStream cmdStream(buffer.begin(), buffer.size()); + + commandStreamReceiver.programEnginePrologue(cmdStream); + EXPECT_TRUE(commandStreamReceiver.isEnginePrologueSent); + + HardwareParse hwParser; + hwParser.parseCommands(cmdStream); + EXPECT_EQ(0u, hwParser.cmdList.size()); +} + +struct SystemMemoryFenceInDisabledConfigurationTest : public UltCommandStreamReceiverTest { + void SetUp() override { + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0); + UltCommandStreamReceiverTest::SetUp(); + } + DebugManagerStateRestore restore; +}; + +using SystemMemoryFenceInDisabledConfigurationTestXe2HpgCore = SystemMemoryFenceInDisabledConfigurationTest; + +XE2_HPG_CORETEST_F(SystemMemoryFenceInDisabledConfigurationTestXe2HpgCore, givenNoSystemMemoryFenceWhenEnqueueKernelIsCalledThenDontGenerateFenceCommands) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + MockKernelWithInternals kernel(*pClDevice); + MockContext context(pClDevice); + MockCommandQueueHw commandQueue(&context, pClDevice, nullptr); + + size_t globalWorkSize[3] = {1, 1, 1}; + commandQueue.enqueueKernel(kernel, 1, nullptr, globalWorkSize, nullptr, 0, nullptr, nullptr); + + ClHardwareParse hwParser; + hwParser.parseCommands(commandQueue); + + auto itorSystemMemFenceAddress = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + EXPECT_EQ(hwParser.cmdList.end(), itorSystemMemFenceAddress); + + auto itorComputeWalker = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorComputeWalker); + auto walkerCmd = genCmdCast(*itorComputeWalker); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); + + auto itorMiMemFence = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + EXPECT_EQ(hwParser.cmdList.end(), itorMiMemFence); +} + +struct SystemMemoryFenceViaMiMemFenceTest : public UltCommandStreamReceiverTest { + void SetUp() override { + debugManager.flags.EnableLocalMemory.set(1); + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(1); + UltCommandStreamReceiverTest::SetUp(); + } + DebugManagerStateRestore restore; +}; + +using SystemMemoryFenceViaMiMemFenceTestXe2HpgCore = SystemMemoryFenceViaMiMemFenceTest; + +XE2_HPG_CORETEST_F(SystemMemoryFenceViaMiMemFenceTestXe2HpgCore, givenCommadStreamReceiverWhenProgramEnginePrologueIsCalledThenIsEnginePrologueSentIsSetToTrue) { + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + EXPECT_FALSE(commandStreamReceiver.isEnginePrologueSent); + + auto requiredSize = commandStreamReceiver.getCmdSizeForPrologue(); + StackVec buffer(requiredSize); + LinearStream cmdStream(buffer.begin(), buffer.size()); + + commandStreamReceiver.programEnginePrologue(cmdStream); + EXPECT_TRUE(commandStreamReceiver.isEnginePrologueSent); +} + +XE2_HPG_CORETEST_F(SystemMemoryFenceViaMiMemFenceTestXe2HpgCore, givenIsEnginePrologueSentIsSetToTrueWhenGetRequiredCmdStreamSizeIsCalledThenSizeForEnginePrologueIsNotIncluded) { + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + auto dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags(); + + EXPECT_FALSE(commandStreamReceiver.isEnginePrologueSent); + auto sizeForEnginePrologue = commandStreamReceiver.getCmdSizeForPrologue(); + + auto sizeWhenEnginePrologueIsNotSent = commandStreamReceiver.getRequiredCmdStreamSize(dispatchFlags, *pDevice); + + commandStreamReceiver.isEnginePrologueSent = true; + auto sizeWhenEnginePrologueIsSent = commandStreamReceiver.getRequiredCmdStreamSize(dispatchFlags, *pDevice); + + EXPECT_EQ(sizeForEnginePrologue, sizeWhenEnginePrologueIsNotSent - sizeWhenEnginePrologueIsSent); +} + +XE2_HPG_CORETEST_F(SystemMemoryFenceViaMiMemFenceTestXe2HpgCore, givenSystemMemoryFenceGeneratedAsMiFenceCommandInCommandStreamWhenBlitBufferIsCalledThenSystemMemFenceAddressIsProgrammed) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + auto &cmdStream = commandStreamReceiver.getCS(0); + + EXPECT_FALSE(commandStreamReceiver.isEnginePrologueSent); + + BlitPropertiesContainer blitPropertiesContainer; + commandStreamReceiver.flushBcsTask(blitPropertiesContainer, false, false, *pDevice); + EXPECT_TRUE(commandStreamReceiver.isEnginePrologueSent); + + HardwareParse hwParser; + hwParser.parseCommands(cmdStream); + auto itorSystemMemFenceAddress = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorSystemMemFenceAddress); + + auto systemMemFenceAddressCmd = genCmdCast(*itorSystemMemFenceAddress); + EXPECT_EQ(commandStreamReceiver.globalFenceAllocation->getGpuAddress(), systemMemFenceAddressCmd->getSystemMemoryFenceAddress()); +} + +struct SystemMemoryFenceViaComputeWalkerTest : public UltCommandStreamReceiverTest { + void SetUp() override { + debugManager.flags.EnableLocalMemory.set(1); + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(1); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0); + UltCommandStreamReceiverTest::SetUp(); + } + DebugManagerStateRestore restore; +}; + +using SystemMemoryFenceViaComputeWalkerTestXe2HpgCore = SystemMemoryFenceViaComputeWalkerTest; + +XE2_HPG_CORETEST_F(SystemMemoryFenceViaComputeWalkerTestXe2HpgCore, givenSystemMemoryFenceGeneratedAsPostSyncOperationInComputeWalkerWhenProgramEnginePrologueIsCalledThenSystemMemFenceAddressIsProgrammed) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + EXPECT_FALSE(commandStreamReceiver.isEnginePrologueSent); + + auto requiredSize = commandStreamReceiver.getCmdSizeForPrologue(); + StackVec buffer(requiredSize); + LinearStream cmdStream(buffer.begin(), buffer.size()); + + commandStreamReceiver.programEnginePrologue(cmdStream); + EXPECT_TRUE(commandStreamReceiver.isEnginePrologueSent); + + HardwareParse hwParser; + hwParser.parseCommands(cmdStream); + auto itorSystemMemFenceAddress = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorSystemMemFenceAddress); + + auto systemMemFenceAddressCmd = genCmdCast(*itorSystemMemFenceAddress); + EXPECT_EQ(commandStreamReceiver.globalFenceAllocation->getGpuAddress(), systemMemFenceAddressCmd->getSystemMemoryFenceAddress()); +} + +XE2_HPG_CORETEST_F(SystemMemoryFenceViaComputeWalkerTestXe2HpgCore, givenSystemMemoryFenceGeneratedAsPostSyncOperationInComputeWalkerWhenDispatchWalkerIsCalledThenSystemMemoryFenceRequestInPostSyncDataIsProgrammed) { + using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; + + MockKernelWithInternals kernel(*pClDevice); + MockMultiDispatchInfo multiDispatchInfo(pClDevice, kernel.mockKernel); + MockContext context(pClDevice); + MockCommandQueue commandQueue(&context, pClDevice, nullptr, false); + auto &cmdStream = commandQueue.getCS(0); + MockTimestampPacketContainer timestampPacket(*pClDevice->getGpgpuCommandStreamReceiver().getTimestampPacketAllocator(), 1); + + HardwareInterfaceWalkerArgs walkerArgs = createHardwareInterfaceWalkerArgs(CL_COMMAND_NDRANGE_KERNEL); + walkerArgs.currentTimestampPacketNodes = ×tampPacket; + HardwareInterface::template dispatchWalker( + commandQueue, + multiDispatchInfo, + CsrDependencies(), + walkerArgs); + + HardwareParse hwParser; + hwParser.parseCommands(cmdStream); + auto itorComputeWalker = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorComputeWalker); + + auto walkerCmd = genCmdCast(*itorComputeWalker); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_TRUE(postSyncData.getSystemMemoryFenceRequest()); +} + +struct SystemMemoryFenceViaKernelInstructionTest : public UltCommandStreamReceiverTest { + void SetUp() override { + debugManager.flags.EnableLocalMemory.set(1); + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(1); + UltCommandStreamReceiverTest::SetUp(); + } + DebugManagerStateRestore restore; +}; + +using SystemMemoryFenceViaKernelInstructionTestXe2HpgCore = SystemMemoryFenceViaKernelInstructionTest; + +XE2_HPG_CORETEST_F(SystemMemoryFenceViaKernelInstructionTestXe2HpgCore, givenSystemMemoryFenceGeneratedAsKernelInstructionInKernelCodeWhenProgramEnginePrologueIsCalledThenSystemMemFenceAddressIsProgrammed) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + EXPECT_FALSE(commandStreamReceiver.isEnginePrologueSent); + + auto requiredSize = commandStreamReceiver.getCmdSizeForPrologue(); + StackVec buffer(requiredSize); + LinearStream cmdStream(buffer.begin(), buffer.size()); + + commandStreamReceiver.programEnginePrologue(cmdStream); + EXPECT_TRUE(commandStreamReceiver.isEnginePrologueSent); + + HardwareParse hwParser; + hwParser.parseCommands(cmdStream); + auto itorSystemMemFenceAddress = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorSystemMemFenceAddress); + + auto systemMemFenceAddressCmd = genCmdCast(*itorSystemMemFenceAddress); + EXPECT_EQ(commandStreamReceiver.globalFenceAllocation->getGpuAddress(), systemMemFenceAddressCmd->getSystemMemoryFenceAddress()); +} + +struct SystemMemoryFenceInDefaultConfigurationTest : public UltCommandStreamReceiverTest { + void SetUp() override { + debugManager.flags.EnableLocalMemory.set(1); + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(-1); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(-1); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(-1); + UltCommandStreamReceiverTest::SetUp(); + } + DebugManagerStateRestore restore; +}; + +using SystemMemoryFenceInDefaultConfigurationTestXe2HpgCore = SystemMemoryFenceInDefaultConfigurationTest; + +XE2_HPG_CORETEST_F(SystemMemoryFenceInDefaultConfigurationTestXe2HpgCore, + givenNoEventProvidedWhenEnqueueKernelNotUsingSystemMemoryThenNoPostSyncFenceRequestDispatched) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + MockKernelWithInternals kernel(*pClDevice); + MockContext context(pClDevice); + MockCommandQueueHw commandQueue(&context, pClDevice, nullptr); + auto &commandStreamReceiver = pClDevice->getUltCommandStreamReceiver(); + + size_t globalWorkSize[3] = {1, 1, 1}; + commandQueue.enqueueKernel(kernel, 1, nullptr, globalWorkSize, nullptr, 0, nullptr, nullptr); + + ClHardwareParse hwParser; + hwParser.parseCommands(commandQueue); + + auto itorSystemMemFenceAddress = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorSystemMemFenceAddress); + auto systemMemFenceAddressCmd = genCmdCast(*itorSystemMemFenceAddress); + EXPECT_EQ(commandStreamReceiver.globalFenceAllocation->getGpuAddress(), systemMemFenceAddressCmd->getSystemMemoryFenceAddress()); + + auto itorComputeWalker = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorComputeWalker); + auto walkerCmd = genCmdCast(*itorComputeWalker); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); + + auto itorMiMemFence = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorMiMemFence); + auto fenceCmd = genCmdCast(*itorMiMemFence); + ASSERT_NE(nullptr, fenceCmd); + EXPECT_EQ(MI_MEM_FENCE::FENCE_TYPE::FENCE_TYPE_RELEASE, fenceCmd->getFenceType()); +} + +XE2_HPG_CORETEST_F(SystemMemoryFenceInDefaultConfigurationTestXe2HpgCore, + givenNoEventProvidedWhenEnqueueKernelUsingSystemMemoryThenPostSyncFenceRequestNotDispatched) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + MockKernelWithInternals kernel(*pClDevice); + MockContext context(pClDevice); + MockCommandQueueHw commandQueue(&context, pClDevice, nullptr); + auto &commandStreamReceiver = pClDevice->getUltCommandStreamReceiver(); + + size_t globalWorkSize[3] = {1, 1, 1}; + kernel.mockKernel->anyKernelArgumentUsingSystemMemory = true; + commandQueue.enqueueKernel(kernel, 1, nullptr, globalWorkSize, nullptr, 0, nullptr, nullptr); + + ClHardwareParse hwParser; + hwParser.parseCommands(commandQueue); + + auto itorSystemMemFenceAddress = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorSystemMemFenceAddress); + auto systemMemFenceAddressCmd = genCmdCast(*itorSystemMemFenceAddress); + EXPECT_EQ(commandStreamReceiver.globalFenceAllocation->getGpuAddress(), systemMemFenceAddressCmd->getSystemMemoryFenceAddress()); + + auto itorComputeWalker = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorComputeWalker); + auto walkerCmd = genCmdCast(*itorComputeWalker); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); + + auto itorMiMemFence = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorMiMemFence); + auto fenceCmd = genCmdCast(*itorMiMemFence); + ASSERT_NE(nullptr, fenceCmd); + EXPECT_EQ(MI_MEM_FENCE::FENCE_TYPE::FENCE_TYPE_RELEASE, fenceCmd->getFenceType()); +} + +XE2_HPG_CORETEST_F(SystemMemoryFenceInDefaultConfigurationTestXe2HpgCore, + givenEventProvidedWhenEnqueueKernelNotUsingSystemMemoryThenPostSyncFenceRequestNotDispatched) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + MockKernelWithInternals kernel(*pClDevice); + MockContext context(pClDevice); + MockCommandQueueHw commandQueue(&context, pClDevice, nullptr); + auto &commandStreamReceiver = pClDevice->getUltCommandStreamReceiver(); + + size_t globalWorkSize[3] = {1, 1, 1}; + cl_event kernelEvent{}; + commandQueue.enqueueKernel(kernel, 1, nullptr, globalWorkSize, nullptr, 0, nullptr, &kernelEvent); + + ClHardwareParse hwParser; + hwParser.parseCommands(commandQueue); + + auto itorSystemMemFenceAddress = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorSystemMemFenceAddress); + auto systemMemFenceAddressCmd = genCmdCast(*itorSystemMemFenceAddress); + EXPECT_EQ(commandStreamReceiver.globalFenceAllocation->getGpuAddress(), systemMemFenceAddressCmd->getSystemMemoryFenceAddress()); + + auto itorComputeWalker = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorComputeWalker); + auto walkerCmd = genCmdCast(*itorComputeWalker); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); + + auto itorMiMemFence = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorMiMemFence); + auto fenceCmd = genCmdCast(*itorMiMemFence); + ASSERT_NE(nullptr, fenceCmd); + EXPECT_EQ(MI_MEM_FENCE::FENCE_TYPE::FENCE_TYPE_RELEASE, fenceCmd->getFenceType()); + + auto event = castToObject(kernelEvent); + event->release(); +} + +XE2_HPG_CORETEST_F(SystemMemoryFenceInDefaultConfigurationTestXe2HpgCore, + givenEventProvidedWhenEnqueueKernelUsingSystemMemoryThenPostSyncFenceRequestDispatched) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + MockKernelWithInternals kernel(*pClDevice); + MockContext context(pClDevice); + MockCommandQueueHw commandQueue(&context, pClDevice, nullptr); + auto &commandStreamReceiver = pClDevice->getUltCommandStreamReceiver(); + + size_t globalWorkSize[3] = {1, 1, 1}; + cl_event kernelEvent{}; + kernel.mockKernel->anyKernelArgumentUsingSystemMemory = true; + commandQueue.enqueueKernel(kernel, 1, nullptr, globalWorkSize, nullptr, 0, nullptr, &kernelEvent); + + ClHardwareParse hwParser; + hwParser.parseCommands(commandQueue); + + auto itorSystemMemFenceAddress = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorSystemMemFenceAddress); + auto systemMemFenceAddressCmd = genCmdCast(*itorSystemMemFenceAddress); + EXPECT_EQ(commandStreamReceiver.globalFenceAllocation->getGpuAddress(), systemMemFenceAddressCmd->getSystemMemoryFenceAddress()); + + auto itorComputeWalker = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorComputeWalker); + auto walkerCmd = genCmdCast(*itorComputeWalker); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_TRUE(postSyncData.getSystemMemoryFenceRequest()); + + auto itorMiMemFence = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorMiMemFence); + auto fenceCmd = genCmdCast(*itorMiMemFence); + ASSERT_NE(nullptr, fenceCmd); + EXPECT_EQ(MI_MEM_FENCE::FENCE_TYPE::FENCE_TYPE_RELEASE, fenceCmd->getFenceType()); + + auto event = castToObject(kernelEvent); + event->release(); +} + +XE2_HPG_CORETEST_F(SystemMemoryFenceInDefaultConfigurationTestXe2HpgCore, + givenEventProvidedWhenEnqueueBuiltinKernelUsingSystemMemoryInDestinationArgumentThenPostSyncFenceRequestDispatched) { + using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS; + using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + MockKernelWithInternals kernel(*pClDevice); + MockContext context(pClDevice); + MockCommandQueueHw commandQueue(&context, pClDevice, nullptr); + auto &commandStreamReceiver = pClDevice->getUltCommandStreamReceiver(); + + size_t globalWorkSize[3] = {1, 1, 1}; + cl_event kernelEvent{}; + kernel.mockKernel->isBuiltIn = true; + kernel.mockKernel->setDestinationAllocationInSystemMemory(true); + commandQueue.enqueueKernel(kernel, 1, nullptr, globalWorkSize, nullptr, 0, nullptr, &kernelEvent); + + ClHardwareParse hwParser; + hwParser.parseCommands(commandQueue); + + auto itorSystemMemFenceAddress = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorSystemMemFenceAddress); + auto systemMemFenceAddressCmd = genCmdCast(*itorSystemMemFenceAddress); + EXPECT_EQ(commandStreamReceiver.globalFenceAllocation->getGpuAddress(), systemMemFenceAddressCmd->getSystemMemoryFenceAddress()); + + auto itorComputeWalker = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorComputeWalker); + auto walkerCmd = genCmdCast(*itorComputeWalker); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_TRUE(postSyncData.getSystemMemoryFenceRequest()); + + auto itorMiMemFence = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorMiMemFence); + auto fenceCmd = genCmdCast(*itorMiMemFence); + ASSERT_NE(nullptr, fenceCmd); + EXPECT_EQ(MI_MEM_FENCE::FENCE_TYPE::FENCE_TYPE_RELEASE, fenceCmd->getFenceType()); + + auto event = castToObject(kernelEvent); + event->release(); +} + +struct Xe2MidThreadCommandStreamReceiverTest : public UltCommandStreamReceiverTest { + void SetUp() override { + debugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::MidThread)); + + UltCommandStreamReceiverTest::SetUp(); + } + DebugManagerStateRestore restore; +}; + +XE2_HPG_CORETEST_F(Xe2MidThreadCommandStreamReceiverTest, givenMidThreadPreemptionWhenCreatingPreemptionAllocationThenExpectProperAlignment) { + using STATE_CONTEXT_DATA_BASE_ADDRESS = typename FamilyType::STATE_CONTEXT_DATA_BASE_ADDRESS; + constexpr size_t expectedMask = STATE_CONTEXT_DATA_BASE_ADDRESS::CONTEXTDATABASEADDRESS::CONTEXTDATABASEADDRESS_ALIGN_SIZE - 1; + + auto &csr = pDevice->getUltCommandStreamReceiver(); + GraphicsAllocation *preemptionAllocation = csr.getPreemptionAllocation(); + ASSERT_NE(nullptr, preemptionAllocation); + + size_t addressValue = reinterpret_cast(preemptionAllocation->getUnderlyingBuffer()); + EXPECT_EQ(0u, expectedMask & addressValue); +} + +using Xe2CommandStreamReceiverFlushTaskTests = UltCommandStreamReceiverTest; +XE2_HPG_CORETEST_F(Xe2CommandStreamReceiverFlushTaskTests, givenOverrideThreadArbitrationPolicyDebugVariableSetWhenFlushingThenRequestRequiredMode) { + using STATE_COMPUTE_MODE = typename Xe2HpgCoreFamily::STATE_COMPUTE_MODE; + DebugManagerStateRestore restore; + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + debugManager.flags.OverrideThreadArbitrationPolicy.set(ThreadArbitrationPolicy::RoundRobin); + + EXPECT_EQ(-1, commandStreamReceiver.streamProperties.stateComputeMode.threadArbitrationPolicy.value); + + flushTask(commandStreamReceiver); + EXPECT_EQ(ThreadArbitrationPolicy::RoundRobin, + commandStreamReceiver.streamProperties.stateComputeMode.threadArbitrationPolicy.value); +} + +XE2_HPG_CORETEST_F(Xe2CommandStreamReceiverFlushTaskTests, givenNotExistPolicyWhenFlushingThenDefaultPolicyIsProgrammed) { + using STATE_COMPUTE_MODE = typename Xe2HpgCoreFamily::STATE_COMPUTE_MODE; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags(); + int32_t notExistPolicy = -2; + flushTaskFlags.threadArbitrationPolicy = notExistPolicy; + + flushTask(commandStreamReceiver); + + EXPECT_EQ(notExistPolicy, commandStreamReceiver.streamProperties.stateComputeMode.threadArbitrationPolicy.value); +} + +XE2_HPG_CORETEST_F(Xe2CommandStreamReceiverFlushTaskTests, givenLastSystolicPipelineSelectModeWhenFlushTaskIsCalledThenDontReprogramPipelineSelect) { + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + commandStreamReceiver.isPreambleSent = true; + commandStreamReceiver.lastMediaSamplerConfig = false; + flushTaskFlags.pipelineSelectArgs.mediaSamplerRequired = false; + flushTaskFlags.pipelineSelectArgs.systolicPipelineSelectMode = true; + + flushTask(commandStreamReceiver); + EXPECT_FALSE(commandStreamReceiver.lastSystolicPipelineSelectMode); +} + +struct Xe2BcsTests : public UltCommandStreamReceiverTest { + void SetUp() override { + debugManager.flags.EnableLocalMemory.set(true); + UltCommandStreamReceiverTest::SetUp(); + context = std::make_unique(pClDevice); + } + + void TearDown() override { + context.reset(); + UltCommandStreamReceiverTest::TearDown(); + } + + DebugManagerStateRestore restore; + std::unique_ptr context; + cl_int retVal = CL_SUCCESS; +}; + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenBufferInDeviceMemoryWhenStatelessCompressionIsEnabledThenBlitterForBufferUsesStatelessCompressedSettings) { + using MEM_COPY = typename Xe2HpgCoreFamily::MEM_COPY; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto buffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + EXPECT_TRUE(!MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool())); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, + 0, 0, {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = Xe2HpgCoreFamily::cmdInitXyCopyBlt; + + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(true); + platformsImpl->clear(); + EXPECT_EQ(platform(), nullptr); + + BlitCommandsHelper::appendBlitCommandsForBuffer(blitProperties, *bltCmd, context->getDevice(0)->getRootDeviceEnvironment()); + + EXPECT_EQ(static_cast(debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()), bltCmd->getCompressionFormat()); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenDstBufferInDeviceAndSrcInSystemMemoryWhenStatelessCompressionIsEnabledThenBlitterForBufferUsesStatelessCompressedSettings) { + using MEM_COPY = typename Xe2HpgCoreFamily::MEM_COPY; + + debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.set(0x1); + + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto bufferDst = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + auto bufferSrc = clUniquePtr(Buffer::create(context.get(), CL_MEM_FORCE_HOST_MEMORY_INTEL, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto allocationDst = bufferDst->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + auto allocationSrc = bufferSrc->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(allocationDst->getMemoryPool())); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(allocationSrc->getMemoryPool())); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(allocationDst, allocationSrc, + 0, 0, {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = Xe2HpgCoreFamily::cmdInitXyCopyBlt; + + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(true); + + BlitCommandsHelper::appendBlitCommandsForBuffer(blitProperties, *bltCmd, context->getDevice(0)->getRootDeviceEnvironment()); + + EXPECT_EQ(static_cast(debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()), bltCmd->getCompressionFormat()); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenBufferInSystemMemoryWhenStatelessCompressionIsEnabledThenBlitterForBufferDoesntUseStatelessCompressedSettings) { + using MEM_COPY = typename Xe2HpgCoreFamily::MEM_COPY; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto buffer = clUniquePtr(Buffer::create(context.get(), CL_MEM_FORCE_HOST_MEMORY_INTEL, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool())); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, + 0, 0, {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = Xe2HpgCoreFamily::cmdInitXyCopyBlt; + + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(true); + platformsImpl->clear(); + EXPECT_EQ(platform(), nullptr); + + BlitCommandsHelper::appendBlitCommandsForBuffer(blitProperties, *bltCmd, context->getDevice(0)->getRootDeviceEnvironment()); + + EXPECT_EQ(0u, bltCmd->getCompressionFormat()); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenCompressibleDstBuffersWhenAppendBlitCommandsForBufferCalledThenSetCompressionFormat) { + debugManager.flags.RenderCompressedBuffersEnabled.set(1); + + using MEM_COPY = typename FamilyType::MEM_COPY; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto srcBuffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto dstBuffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto srcAllocation = srcBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + srcAllocation->getDefaultGmm()->setCompressionEnabled(false); + + auto dstAllocation = dstBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + EXPECT_TRUE(dstAllocation->getDefaultGmm()->isCompressionEnabled()); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(dstAllocation, srcAllocation, 0, 0, + {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = FamilyType::cmdInitXyCopyBlt; + + const auto &rootDeviceEnvironment = context->getDevice(0)->getRootDeviceEnvironment(); + BlitCommandsHelper::appendBlitCommandsForBuffer(blitProperties, *bltCmd, rootDeviceEnvironment); + + auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); + auto compressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); + + EXPECT_EQ(compressionFormat, bltCmd->getCompressionFormat()); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenCompressibleSrcBuffersWhenAppendBlitCommandsForBufferCalledThenSetCompressionFormat) { + debugManager.flags.RenderCompressedBuffersEnabled.set(1); + + using MEM_COPY = typename FamilyType::MEM_COPY; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto srcBuffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto dstBuffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto srcAllocation = srcBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + EXPECT_TRUE(srcAllocation->getDefaultGmm()->isCompressionEnabled()); + + auto dstAllocation = dstBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + dstAllocation->getDefaultGmm()->setCompressionEnabled(false); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(dstAllocation, srcAllocation, 0, 0, + {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = FamilyType::cmdInitXyCopyBlt; + + const auto &rootDeviceEnvironment = context->getDevice(0)->getRootDeviceEnvironment(); + BlitCommandsHelper::appendBlitCommandsForBuffer(blitProperties, *bltCmd, rootDeviceEnvironment); + + auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); + auto compressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); + + EXPECT_EQ(compressionFormat, bltCmd->getCompressionFormat()); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenCompressibleSrcBuffersWhenAppendBlitCommandsBlockCopyIsCalledThenSetCompressionFormat) { + debugManager.flags.RenderCompressedBuffersEnabled.set(1); + + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto srcBuffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto dstBuffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto srcAllocation = srcBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + EXPECT_TRUE(srcAllocation->getDefaultGmm()->isCompressionEnabled()); + + auto dstAllocation = dstBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + dstAllocation->getDefaultGmm()->setCompressionEnabled(false); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(dstAllocation, srcAllocation, 0, 0, + {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + bltCmd->setDestinationX2CoordinateRight(1); + bltCmd->setDestinationY2CoordinateBottom(1); + + const auto &rootDeviceEnvironment = context->getDevice(0)->getRootDeviceEnvironment(); + BlitCommandsHelper::appendBlitCommandsBlockCopy(blitProperties, *bltCmd, rootDeviceEnvironment); + + auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); + auto compressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); + + EXPECT_EQ(compressionFormat, bltCmd->getSourceCompressionFormat()); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenCompressibleDstBuffersWhenAppendBlitCommandsBlockCopyIsCalledThenSetCompressionFormat) { + debugManager.flags.RenderCompressedBuffersEnabled.set(1); + + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto srcBuffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto dstBuffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto srcAllocation = srcBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + srcAllocation->getDefaultGmm()->setCompressionEnabled(false); + + auto dstAllocation = dstBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + EXPECT_TRUE(dstAllocation->getDefaultGmm()->isCompressionEnabled()); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(dstAllocation, srcAllocation, 0, 0, + {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + bltCmd->setDestinationX2CoordinateRight(1); + bltCmd->setDestinationY2CoordinateBottom(1); + + const auto &rootDeviceEnvironment = context->getDevice(0)->getRootDeviceEnvironment(); + BlitCommandsHelper::appendBlitCommandsBlockCopy(blitProperties, *bltCmd, rootDeviceEnvironment); + + auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); + auto compressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); + + EXPECT_EQ(compressionFormat, bltCmd->getDestinationCompressionFormat()); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenCompressibleBuffersWhenBufferCompressionFormatIsForcedThenCompressionFormatIsSet) { + debugManager.flags.RenderCompressedBuffersEnabled.set(1); + + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto buffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + EXPECT_TRUE(allocation->getDefaultGmm()->isCompressionEnabled()); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, 0, 0, + {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + bltCmd->setDestinationX2CoordinateRight(1); + bltCmd->setDestinationY2CoordinateBottom(1); + + uint32_t forcedCompressionFormat = 1; + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(forcedCompressionFormat)); + + const auto &rootDeviceEnvironment = context->getDevice(0)->getRootDeviceEnvironment(); + BlitCommandsHelper::appendBlitCommandsBlockCopy(blitProperties, *bltCmd, rootDeviceEnvironment); + + EXPECT_EQ(forcedCompressionFormat, bltCmd->getDestinationCompressionFormat()); + EXPECT_EQ(forcedCompressionFormat, bltCmd->getSourceCompressionFormat()); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenNotCompressibleBuffersWhenBufferCompressionFormatIsForcedThenCompressionFormatIsNotSet) { + debugManager.flags.RenderCompressedBuffersEnabled.set(1); + + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto buffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + allocation->getDefaultGmm()->setCompressionEnabled(false); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, 0, 0, + {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + bltCmd->setDestinationX2CoordinateRight(1); + bltCmd->setDestinationY2CoordinateBottom(1); + + uint32_t forcedCompressionFormat = 1; + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(forcedCompressionFormat)); + + const auto &rootDeviceEnvironment = context->getDevice(0)->getRootDeviceEnvironment(); + BlitCommandsHelper::appendBlitCommandsBlockCopy(blitProperties, *bltCmd, rootDeviceEnvironment); + + EXPECT_EQ(0u, bltCmd->getDestinationCompressionFormat()); + EXPECT_EQ(0u, bltCmd->getSourceCompressionFormat()); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenOverriddenBlitterTargetToZeroWhenAppendBlitCommandsBlockCopyThenUseSystemMem) { + debugManager.flags.OverrideBlitterTargetMemory.set(0); + + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto buffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, 0, 0, + {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + bltCmd->setDestinationX2CoordinateRight(1); + bltCmd->setDestinationY2CoordinateBottom(1); + + const auto &rootDeviceEnvironment = context->getDevice(0)->getRootDeviceEnvironment(); + BlitCommandsHelper::appendBlitCommandsBlockCopy(blitProperties, *bltCmd, rootDeviceEnvironment); + + EXPECT_EQ(bltCmd->getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); + EXPECT_EQ(bltCmd->getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenOverriddenBlitterTargetToOneWhenAppendBlitCommandsBlockCopyThenUseLocalMem) { + debugManager.flags.OverrideBlitterTargetMemory.set(1); + + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto buffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, 0, 0, + {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + bltCmd->setDestinationX2CoordinateRight(1); + bltCmd->setDestinationY2CoordinateBottom(1); + + const auto &rootDeviceEnvironment = context->getDevice(0)->getRootDeviceEnvironment(); + BlitCommandsHelper::appendBlitCommandsBlockCopy(blitProperties, *bltCmd, rootDeviceEnvironment); + + EXPECT_EQ(bltCmd->getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM); + EXPECT_EQ(bltCmd->getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenOverriddenBlitterTargetToTwoWhenAppendBlitCommandsBlockCopyThenUseDefaultMem) { + debugManager.flags.OverrideBlitterTargetMemory.set(2); + + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto buffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, 0, 0, + {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + bltCmd->setDestinationX2CoordinateRight(1); + bltCmd->setDestinationY2CoordinateBottom(1); + + const auto &rootDeviceEnvironment = context->getDevice(0)->getRootDeviceEnvironment(); + BlitCommandsHelper::appendBlitCommandsBlockCopy(blitProperties, *bltCmd, rootDeviceEnvironment); + + EXPECT_EQ(bltCmd->getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM); + EXPECT_EQ(bltCmd->getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM); +} + +XE2_HPG_CORETEST_F(Xe2BcsTests, givenOverriddenMocksValueWhenAppendBlitCommandsBlockCopyThenDebugMocksValueIsSet) { + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + MockGraphicsAllocation clearColorAlloc; + + auto buffer = clUniquePtr(Buffer::create(context.get(), {}, MemoryConstants::pageSize64k, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()); + + auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, 0, 0, + {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + auto bltCmd = stream.getSpaceForCmd(); + *bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + bltCmd->setDestinationX2CoordinateRight(1); + bltCmd->setDestinationY2CoordinateBottom(1); + + uint32_t mockValue = context->getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + uint32_t newValue = mockValue + 1; + debugManager.flags.OverrideBlitterMocs.set(newValue); + + const auto &rootDeviceEnvironment = context->getDevice(0)->getRootDeviceEnvironment(); + BlitCommandsHelper::appendBlitCommandsBlockCopy(blitProperties, *bltCmd, rootDeviceEnvironment); + + EXPECT_EQ(bltCmd->getDestinationMOCS(), newValue); + EXPECT_EQ(bltCmd->getSourceMOCS(), newValue); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/copy_engine_tests_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/copy_engine_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..ebd8a91396 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/copy_engine_tests_xe2_hpg_core.cpp @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/cmd_parse/hw_parse.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/libult/ult_command_stream_receiver.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_graphics_allocation.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" +#include "shared/test/common/utilities/base_object_utils.h" + +#include "opencl/source/command_queue/command_queue_hw.h" +#include "opencl/source/mem_obj/buffer.h" +#include "opencl/test/unit_test/mocks/mock_cl_device.h" +#include "opencl/test/unit_test/mocks/mock_context.h" + +using namespace NEO; + +struct BlitXe2HpgCoreTests : public ::testing::Test { + void SetUp() override { + if (is32bit) { + GTEST_SKIP(); + } + debugManager.flags.RenderCompressedBuffersEnabled.set(true); + debugManager.flags.EnableLocalMemory.set(true); + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.capabilityTable.blitterOperationsSupported = true; + + clDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); + } + + std::optional flushBcsTask(CommandStreamReceiver *csr, const BlitProperties &blitProperties, bool blocking, Device &device) { + BlitPropertiesContainer blitPropertiesContainer; + blitPropertiesContainer.push_back(blitProperties); + + return csr->flushBcsTask(blitPropertiesContainer, blocking, false, device); + } + + std::unique_ptr clDevice; + TimestampPacketContainer timestampPacketContainer; + CsrDependencies csrDependencies; + DebugManagerStateRestore debugRestorer; +}; + +XE2_HPG_CORETEST_F(BlitXe2HpgCoreTests, givenBufferWhenProgrammingBltCommandThenSetMocs) { + using MEM_COPY = typename FamilyType::MEM_COPY; + + auto &bcsEngine = clDevice->getEngine(aub_stream::EngineType::ENGINE_BCS, EngineUsage::regular); + auto csr = static_cast *>(bcsEngine.commandStreamReceiver); + MockContext context(clDevice.get()); + MockGraphicsAllocation clearColorAlloc; + + cl_int retVal = CL_SUCCESS; + auto buffer = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); + auto blitProperties = BlitProperties::constructPropertiesForCopy(buffer->getGraphicsAllocation(clDevice->getRootDeviceIndex()), + buffer->getGraphicsAllocation(clDevice->getRootDeviceIndex()), + 0, 0, {1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + + flushBcsTask(csr, blitProperties, true, clDevice->getDevice()); + + HardwareParse hwParser; + hwParser.parseCommands(csr->commandStream); + + auto itorBltCmd = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorBltCmd); + MEM_COPY *bltCmd = (MEM_COPY *)*itorBltCmd; + + if (clDevice->getGmmHelper()->deferMOCSToPatIndex()) { + EXPECT_EQ(0u, bltCmd->getDestinationMOCS()); + EXPECT_EQ(0u, bltCmd->getSourceMOCS()); + } else { + auto mocsL3Enabled = 0x10u; + EXPECT_EQ(mocsL3Enabled, bltCmd->getDestinationMOCS()); + EXPECT_EQ(mocsL3Enabled, bltCmd->getSourceMOCS()); + } +} + +XE2_HPG_CORETEST_F(BlitXe2HpgCoreTests, givenBufferWhenProgrammingBltCommandThenSetMocsToValueOfDebugKey) { + uint32_t expectedMocs = 0; + + DebugManagerStateRestore restorer; + debugManager.flags.OverrideBlitterMocs.set(expectedMocs); + using MEM_COPY = typename FamilyType::MEM_COPY; + + auto &bcsEngine = clDevice->getEngine(aub_stream::EngineType::ENGINE_BCS, EngineUsage::regular); + auto csr = static_cast *>(bcsEngine.commandStreamReceiver); + MockContext context(clDevice.get()); + MockGraphicsAllocation clearColorAlloc; + + cl_int retVal = CL_SUCCESS; + auto buffer = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); + auto blitProperties = BlitProperties::constructPropertiesForCopy(buffer->getGraphicsAllocation(clDevice->getRootDeviceIndex()), + buffer->getGraphicsAllocation(clDevice->getRootDeviceIndex()), + 0, 0, {1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + + flushBcsTask(csr, blitProperties, true, clDevice->getDevice()); + + HardwareParse hwParser; + hwParser.parseCommands(csr->commandStream); + + auto itorBltCmd = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), itorBltCmd); + MEM_COPY *bltCmd = (MEM_COPY *)*itorBltCmd; + + EXPECT_EQ(expectedMocs, bltCmd->getDestinationMOCS()); + EXPECT_EQ(expectedMocs, bltCmd->getSourceMOCS()); +} + +XE2_HPG_CORETEST_F(BlitXe2HpgCoreTests, given2dBlitCommandWhenDispatchingThenSetValidSurfaceType) { + using MEM_COPY = typename FamilyType::MEM_COPY; + + auto &bcsEngine = clDevice->getEngine(aub_stream::EngineType::ENGINE_BCS, EngineUsage::regular); + auto csr = static_cast *>(bcsEngine.commandStreamReceiver); + MockContext context(clDevice.get()); + + cl_int retVal = CL_SUCCESS; + auto buffer = clUniquePtr(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); + auto allocation = buffer->getGraphicsAllocation(clDevice->getRootDeviceIndex()); + MockGraphicsAllocation clearColorAlloc; + + size_t offset = 0; + { + // 1D + auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, + 0, 0, {BlitterConstants::maxBlitWidth - 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + flushBcsTask(csr, blitProperties, false, clDevice->getDevice()); + + HardwareParse hwParser; + hwParser.parseCommands(csr->commandStream); + + auto cmdIterator = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), cmdIterator); + + auto bltCmd = genCmdCast(*cmdIterator); + EXPECT_NE(nullptr, bltCmd); + + EXPECT_EQ(MEM_COPY::COPY_TYPE::COPY_TYPE_LINEAR_COPY, bltCmd->getCopyType()); + + offset = csr->commandStream.getUsed(); + } + + { + // 2D + auto blitProperties = BlitProperties::constructPropertiesForCopy(allocation, allocation, + 0, 0, {(2 * BlitterConstants::maxBlitWidth) + 1, 1, 1}, 0, 0, 0, 0, &clearColorAlloc); + flushBcsTask(csr, blitProperties, false, clDevice->getDevice()); + + HardwareParse hwParser; + hwParser.parseCommands(csr->commandStream, offset); + + auto cmdIterator = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + ASSERT_NE(hwParser.cmdList.end(), cmdIterator); + + auto bltCmd = genCmdCast(*cmdIterator); + EXPECT_NE(nullptr, bltCmd); + + EXPECT_EQ(MEM_COPY::COPY_TYPE::COPY_TYPE_MATRIX_COPY, bltCmd->getCopyType()); + } +} + +using Xe2HpgCoreCopyEngineTests = ::testing::Test; +XE2_HPG_CORETEST_F(Xe2HpgCoreCopyEngineTests, givenCommandQueueWhenAskingForCacheFlushOnBcsThenReturnCorrectValue) { + auto clDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); + MockContext context(clDevice.get()); + + cl_int retVal = CL_SUCCESS; + auto commandQueue = std::unique_ptr(CommandQueue::create(&context, clDevice.get(), nullptr, false, retVal)); + auto commandQueueHw = static_cast *>(commandQueue.get()); + + const auto &productHelper = clDevice->getProductHelper(); + EXPECT_EQ(productHelper.isDcFlushAllowed(), commandQueueHw->isCacheFlushForBcsRequired()); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreCopyEngineTests, givenDebugFlagSetWhenCheckingBcsCacheFlushRequirementThenReturnCorrectValue) { + DebugManagerStateRestore restorer; + auto clDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); + MockContext context(clDevice.get()); + + cl_int retVal = CL_SUCCESS; + auto commandQueue = std::unique_ptr(CommandQueue::create(&context, clDevice.get(), nullptr, false, retVal)); + auto commandQueueHw = static_cast *>(commandQueue.get()); + + debugManager.flags.ForceCacheFlushForBcs.set(0); + EXPECT_FALSE(commandQueueHw->isCacheFlushForBcsRequired()); + + debugManager.flags.ForceCacheFlushForBcs.set(1); + EXPECT_TRUE(commandQueueHw->isCacheFlushForBcsRequired()); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/dispatch_walker_tests_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/dispatch_walker_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..eb946e0a0c --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/dispatch_walker_tests_xe2_hpg_core.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/command_encoder.h" +#include "shared/source/kernel/kernel_descriptor.h" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/mocks/mock_execution_environment.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +using namespace NEO; + +using WalkerDispatchTestsXe2HpGCore = ::testing::Test; + +XE2_HPG_CORETEST_F(WalkerDispatchTestsXe2HpGCore, whenEncodeAdditionalWalkerFieldsIsCalledThenComputeDispatchAllIsCorrectlySet) { + using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; + + DebugManagerStateRestore debugRestorer; + auto walkerCmd = FamilyType::cmdInitGpgpuWalker; + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; + + KernelDescriptor kernelDescriptor; + EncodeWalkerArgs walkerArgs{KernelExecutionType::concurrent, true, kernelDescriptor, NEO::RequiredDispatchWalkOrder::none, 0, 0}; + { + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, walkerArgs); + EXPECT_TRUE(walkerCmd.getComputeDispatchAllWalkerEnable()); + } + + { + walkerArgs.kernelExecutionType = KernelExecutionType::defaultType; + debugManager.flags.ComputeDispatchAllWalkerEnableInComputeWalker.set(1); + EncodeDispatchKernel::encodeAdditionalWalkerFields(rootDeviceEnvironment, walkerCmd, walkerArgs); + + EXPECT_TRUE(walkerCmd.getComputeDispatchAllWalkerEnable()); + } +} diff --git a/opencl/test/unit_test/xe2_hpg_core/enqueue_tests_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/enqueue_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..63a457a201 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/enqueue_tests_xe2_hpg_core.cpp @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/command_encoder.h" +#include "shared/source/helpers/gfx_core_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/cmd_parse/hw_parse.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_graphics_allocation.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +#include "opencl/source/command_queue/hardware_interface.h" +#include "opencl/test/unit_test/command_queue/hardware_interface_helper.h" +#include "opencl/test/unit_test/mocks/mock_cl_device.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" +#include "opencl/test/unit_test/mocks/mock_context.h" +#include "opencl/test/unit_test/mocks/mock_kernel.h" + +using namespace NEO; + +struct EnqueueFixtureXe2HpgCore : public ::testing::Test { + void SetUp() override { + debugManager.flags.EnableMemoryPrefetch.set(1); + + clDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get(), mockRootDeviceIndex)); + context = std::make_unique(clDevice.get()); + + mockKernel = std::make_unique(*clDevice, context.get()); + mockKernel->kernelInfo.createKernelAllocation(clDevice->getDevice(), false); + + dispatchInfo = {clDevice.get(), mockKernel->mockKernel, 1, 0, 0, 0}; + } + + void TearDown() override { + clDevice->getMemoryManager()->freeGraphicsMemory(mockKernel->kernelInfo.getGraphicsAllocation()); + } + + template + std::unique_ptr> createCommandQueue() { + return std::make_unique>(context.get(), clDevice.get(), nullptr); + } + + DebugManagerStateRestore restore; + std::unique_ptr clDevice; + std::unique_ptr context; + std::unique_ptr mockKernel; + DispatchInfo dispatchInfo; +}; + +using MemoryPrefetchTestsXe2HpgCore = EnqueueFixtureXe2HpgCore; + +XE2_HPG_CORETEST_F(MemoryPrefetchTestsXe2HpgCore, givenKernelWhenWalkerIsProgrammedThenPrefetchIsaBeforeWalker) { + using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; + using STATE_PREFETCH = typename FamilyType::STATE_PREFETCH; + + auto commandQueue = createCommandQueue(); + auto &commandStream = commandQueue->getCS(1024); + + auto &heap = commandQueue->getIndirectHeap(IndirectHeap::Type::dynamicState, 1); + size_t workSize[] = {1, 1, 1}; + Vec3 wgInfo = {1, 1, 1}; + + mockKernel->kernelInfo.heapInfo.kernelHeapSize = 1; + + HardwareInterfaceWalkerArgs walkerArgs = createHardwareInterfaceWalkerArgs(workSize, wgInfo, PreemptionMode::Disabled); + + HardwareInterface::template programWalker(commandStream, *mockKernel->mockKernel, *commandQueue, heap, heap, heap, dispatchInfo, walkerArgs); + + HardwareParse hwParse; + hwParse.parseCommands(commandStream, 0); + auto itorWalker = find(hwParse.cmdList.begin(), hwParse.cmdList.end()); + EXPECT_NE(hwParse.cmdList.end(), itorWalker); + + auto itorStatePrefetch = find(hwParse.cmdList.begin(), itorWalker); + EXPECT_NE(itorWalker, itorStatePrefetch); + + auto statePrefetchCmd = genCmdCast(*itorStatePrefetch); + EXPECT_NE(nullptr, statePrefetchCmd); + + EXPECT_EQ(mockKernel->kernelInfo.getGraphicsAllocation()->getGpuAddress(), statePrefetchCmd->getAddress()); + EXPECT_TRUE(statePrefetchCmd->getKernelInstructionPrefetch()); +} + +XE2_HPG_CORETEST_F(MemoryPrefetchTestsXe2HpgCore, givenPrefetchEnabledWhenEstimatingCommandsSizeThenAddStatePrefetch) { + auto commandQueue = createCommandQueue(); + + size_t numPipeControls = MemorySynchronizationCommands::isBarrierWaRequired(clDevice->getRootDeviceEnvironment()) ? 2 : 1; + + size_t expected = sizeof(typename FamilyType::COMPUTE_WALKER) + + (sizeof(typename FamilyType::PIPE_CONTROL) * numPipeControls) + + HardwareCommandsHelper::getSizeRequiredCS() + + EncodeMemoryPrefetch::getSizeForMemoryPrefetch(mockKernel->kernelInfo.heapInfo.kernelHeapSize, clDevice->getRootDeviceEnvironment()); + + EXPECT_EQ(expected, EnqueueOperation::getSizeRequiredCS(CL_COMMAND_NDRANGE_KERNEL, false, false, *commandQueue, mockKernel->mockKernel, {})); +} + +using ProgramWalkerTestsXe2HpgCore = EnqueueFixtureXe2HpgCore; + +XE2_HPG_CORETEST_F(ProgramWalkerTestsXe2HpgCore, givenDebugVariableSetWhenProgrammingWalkerThenSetL3Prefetch) { + using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; + + auto commandQueue = createCommandQueue(); + auto &commandStream = commandQueue->getCS(1024); + + auto &heap = commandQueue->getIndirectHeap(IndirectHeap::Type::dynamicState, 1); + size_t workSize[] = {1, 1, 1}; + Vec3 wgInfo = {1, 1, 1}; + + size_t commandsOffset = 0; + + HardwareInterfaceWalkerArgs walkerArgs = createHardwareInterfaceWalkerArgs(workSize, wgInfo, PreemptionMode::Disabled); + + { + // default + HardwareInterface::template programWalker(commandStream, *mockKernel->mockKernel, *commandQueue, + heap, heap, heap, dispatchInfo, walkerArgs); + + HardwareParse hwParse; + hwParse.parseCommands(commandStream, 0); + auto itorWalker = find(hwParse.cmdList.begin(), hwParse.cmdList.end()); + EXPECT_NE(hwParse.cmdList.end(), itorWalker); + auto walkerCmd = genCmdCast(*itorWalker); + EXPECT_NE(nullptr, walkerCmd); + + EXPECT_FALSE(walkerCmd->getL3PrefetchDisable()); + } + + { + // debug flag == 1 + + commandsOffset = commandStream.getUsed(); + debugManager.flags.ForceL3PrefetchForComputeWalker.set(1); + + HardwareInterface::template programWalker(commandStream, *mockKernel->mockKernel, *commandQueue, + heap, heap, heap, dispatchInfo, walkerArgs); + + HardwareParse hwParse; + hwParse.parseCommands(commandStream, commandsOffset); + auto itorWalker = find(hwParse.cmdList.begin(), hwParse.cmdList.end()); + EXPECT_NE(hwParse.cmdList.end(), itorWalker); + auto walkerCmd = genCmdCast(*itorWalker); + EXPECT_NE(nullptr, walkerCmd); + + EXPECT_FALSE(walkerCmd->getL3PrefetchDisable()); + } + + { + // debug flag == 0 + + commandsOffset = commandStream.getUsed(); + debugManager.flags.ForceL3PrefetchForComputeWalker.set(0); + + HardwareInterface::template programWalker(commandStream, *mockKernel->mockKernel, *commandQueue, + heap, heap, heap, dispatchInfo, walkerArgs); + + HardwareParse hwParse; + hwParse.parseCommands(commandStream, commandsOffset); + auto itorWalker = find(hwParse.cmdList.begin(), hwParse.cmdList.end()); + EXPECT_NE(hwParse.cmdList.end(), itorWalker); + auto walkerCmd = genCmdCast(*itorWalker); + EXPECT_NE(nullptr, walkerCmd); + + EXPECT_TRUE(walkerCmd->getL3PrefetchDisable()); + } +} diff --git a/opencl/test/unit_test/xe2_hpg_core/excludes_ocl_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/excludes_ocl_xe2_hpg_core.cpp new file mode 100644 index 0000000000..ccaa35b75d --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/excludes_ocl_xe2_hpg_core.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/test_macros/hw_test_base.h" + +HWTEST_EXCLUDE_PRODUCT(BufferSetSurfaceTests, givenAlignedCacheableReadOnlyBufferThenChoseOclBufferPolicy, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(BufferSetSurfaceTests, givenBufferSetSurfaceThatMemoryIsUnalignedToCachelineButReadOnlyThenL3CacheShouldBeStillOn, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapabilityThenProgramAuxFieldsForCcs, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(ImageSetArgTest, givenCompressedResourceWhenSettingImgArgThenSetCorrectAuxParams, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(XeHPAndLaterImageTests, givenCompressionEnabledWhenAppendingSurfaceStateParamsThenProgramCompressionFormat, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(QueueFamilyNameTest, givenRcsWhenGettingQueueFamilyNameThenReturnProperValue, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(DeviceGetCapsTest, givenDeviceWhenAskingForSubGroupSizesThenReturnCorrectValues, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(DeviceGetCapsTest, givenDisabledFtrPooledEuWhenCalculatingMaxEuPerSSThenIgnoreEuCountPerPoolMin, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(DeviceGetCapsTest, givenEnabledFtrPooledEuWhenCalculatingMaxEuPerSSThenDontIgnoreEuCountPerPoolMin, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(CommandQueueHwTest, givenCommandQueueWhenAskingForCacheFlushOnBcsThenReturnTrue, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(CommandStreamReceiverFlushTaskTests, givenOverrideThreadArbitrationPolicyDebugVariableSetWhenFlushingThenRequestRequiredMode, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(ClGfxCoreHelperTest, givenKernelInfoWhenCheckingRequiresAuxResolvesThenCorrectValuesAreReturned, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(MidThreadPreemptionTests, GivenValueArgWhenOverrideMidThreadPreemptionSupportThenNothingChange, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(ClGfxCoreHelperTest, WhenCheckingIsLimitationForPreemptionNeededThenReturnFalse, IGFX_XE2_HPG_CORE); diff --git a/opencl/test/unit_test/xe2_hpg_core/lnl/CMakeLists.txt b/opencl/test/unit_test/xe2_hpg_core/lnl/CMakeLists.txt new file mode 100644 index 0000000000..d0d7dd08d9 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/lnl/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_LNL) + set(IGDRCL_SRCS_tests_xe2_hpg_core_lnl + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/device_info_tests_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_cl_device_caps_lnl.cpp + ) + + target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_xe2_hpg_core_lnl}) + add_subdirectories() +endif() diff --git a/opencl/test/unit_test/xe2_hpg_core/lnl/device_info_tests_lnl.cpp b/opencl/test/unit_test/xe2_hpg_core/lnl/device_info_tests_lnl.cpp new file mode 100644 index 0000000000..9b9e20e0e1 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/lnl/device_info_tests_lnl.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_lnl.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +#include "opencl/test/unit_test/fixtures/device_info_fixture.h" + +using GetDeviceInfoMemCapabilitiesTestLnlLinux = NEO::GetDeviceInfoMemCapabilitiesTest; + +LNLTEST_F(GetDeviceInfoMemCapabilitiesTestLnlLinux, GivenValidParametersWhenGetDeviceInfoIsCalledForLnlLinuxThenClSuccessIsReturned) { + std::vector params = { + {CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL, + (CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL | CL_UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS_INTEL)}, + {CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL, + (CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL | CL_UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS_INTEL)}, + {CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, + (CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL | CL_UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS_INTEL)}, + {CL_DEVICE_CROSS_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, + (CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL | CL_UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS_INTEL)}, + {CL_DEVICE_SHARED_SYSTEM_MEM_CAPABILITIES_INTEL, + 0}}; + + check(params); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/lnl/linux/CMakeLists.txt b/opencl/test/unit_test/xe2_hpg_core/lnl/linux/CMakeLists.txt new file mode 100644 index 0000000000..97db1686a2 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/lnl/linux/CMakeLists.txt @@ -0,0 +1,9 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(UNIX) + add_subdirectories() +endif() diff --git a/opencl/test/unit_test/xe2_hpg_core/lnl/linux/dll/CMakeLists.txt b/opencl/test/unit_test/xe2_hpg_core/lnl/linux/dll/CMakeLists.txt new file mode 100644 index 0000000000..2aeba9e222 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/lnl/linux/dll/CMakeLists.txt @@ -0,0 +1,11 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +set(IGDRCL_SRCS_linux_dll_tests_xe2_hpg_core_lnl + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/device_id_tests_lnl.cpp +) +target_sources(igdrcl_linux_dll_tests PRIVATE ${IGDRCL_SRCS_linux_dll_tests_xe2_hpg_core_lnl}) diff --git a/opencl/test/unit_test/xe2_hpg_core/lnl/linux/dll/device_id_tests_lnl.cpp b/opencl/test/unit_test/xe2_hpg_core/lnl/linux/dll/device_id_tests_lnl.cpp new file mode 100644 index 0000000000..fdaba61b98 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/lnl/linux/dll/device_id_tests_lnl.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/fixtures/linux/device_id_fixture.h" + +using namespace NEO; + +TEST_F(DeviceIdTests, GivenLnlSupportedDeviceIdThenDeviceDescriptorTableExists) { + std::array expectedDescriptors = {{ + {0x6420, &LnlHwConfig::hwInfo, &LnlHwConfig::setupHardwareInfo}, + {0x64A0, &LnlHwConfig::hwInfo, &LnlHwConfig::setupHardwareInfo}, + {0x64B0, &LnlHwConfig::hwInfo, &LnlHwConfig::setupHardwareInfo}, + }}; + + testImpl(expectedDescriptors); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/lnl/test_cl_device_caps_lnl.cpp b/opencl/test/unit_test/xe2_hpg_core/lnl/test_cl_device_caps_lnl.cpp new file mode 100644 index 0000000000..c47735258c --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/lnl/test_cl_device_caps_lnl.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_lnl.h" +#include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" + +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" +#include "opencl/test/unit_test/mocks/mock_cl_device.h" + +using namespace NEO; + +using LnlClDeviceIdTest = Test; + +LNLTEST_F(LnlClDeviceIdTest, givenDeviceExtensionsWhenDeviceCapsInitializedThenAddProperExtensions) { + const auto &dInfo = pClDevice->getDeviceInfo(); + EXPECT_TRUE(hasSubstr(dInfo.deviceExtensions, std::string("cl_intel_create_buffer_with_properties"))); + EXPECT_TRUE(hasSubstr(dInfo.deviceExtensions, std::string("cl_intel_subgroup_local_block_io"))); + EXPECT_TRUE(hasSubstr(dInfo.deviceExtensions, std::string("cl_intel_subgroup_matrix_multiply_accumulate"))); + EXPECT_TRUE(hasSubstr(dInfo.deviceExtensions, std::string("cl_khr_subgroup_named_barrier"))); + EXPECT_TRUE(hasSubstr(dInfo.deviceExtensions, std::string("cl_intel_subgroup_extended_block_read"))); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/test_cl_device_caps_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/test_cl_device_caps_xe2_hpg_core.cpp new file mode 100644 index 0000000000..8730783e29 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/test_cl_device_caps_xe2_hpg_core.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/basic_math.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" + +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" +#include "opencl/test/unit_test/fixtures/device_info_fixture.h" + +using namespace NEO; + +using Xe2HpgCoreClDeviceCaps = Test; + +XE2_HPG_CORETEST_F(Xe2HpgCoreClDeviceCaps, givenXe2HpgCoreWhenCheckExtensionsThenDeviceDoesNotReportClKhrSubgroupsExtension) { + const auto &caps = pClDevice->getDeviceInfo(); + + EXPECT_TRUE(hasSubstr(caps.deviceExtensions, std::string("cl_khr_subgroups"))); + EXPECT_TRUE(hasSubstr(caps.deviceExtensions, std::string("cl_intel_bfloat16_conversions"))); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreClDeviceCaps, givenXe2HpgCoreWhenCheckingCapsThenDeviceDoesNotSupportIndependentForwardProgress) { + const auto &caps = pClDevice->getDeviceInfo(); + + EXPECT_TRUE(caps.independentForwardProgress); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreClDeviceCaps, givenXe2HpgCoreWhenCalculatingMaxEuPerSSThenDontIgnoreEuCountPerPoolMin) { + HardwareInfo myHwInfo = *defaultHwInfo; + GT_SYSTEM_INFO &mySysInfo = myHwInfo.gtSystemInfo; + FeatureTable &mySkuTable = myHwInfo.featureTable; + + mySysInfo.EUCount = 20; + mySysInfo.EuCountPerPoolMin = 99999; + mySkuTable.flags.ftrPooledEuEnabled = 1; + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&myHwInfo)); + + auto expectedMaxWGS = mySysInfo.EuCountPerPoolMin * (mySysInfo.ThreadCount / mySysInfo.EUCount) * 8; + expectedMaxWGS = std::min(Math::prevPowerOfTwo(expectedMaxWGS), 2048u); + + EXPECT_EQ(expectedMaxWGS, device->getDeviceInfo().maxWorkGroupSize); +} + +using QueueFamilyNameTestXe2HpgCore = QueueFamilyNameTest; + +XE2_HPG_CORETEST_F(QueueFamilyNameTestXe2HpgCore, givenCccsWhenGettingQueueFamilyNameThenReturnProperValue) { + verify(EngineGroupType::renderCompute, "cccs"); +} + +XE2_HPG_CORETEST_F(QueueFamilyNameTestXe2HpgCore, givenLinkedBcsWhenGettingQueueFamilyNameThenReturnProperValue) { + verify(EngineGroupType::linkedCopy, "linked bcs"); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/test_cmds_programming_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/test_cmds_programming_xe2_hpg_core.cpp new file mode 100644 index 0000000000..ee969a0083 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/test_cmds_programming_xe2_hpg_core.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/encode_surface_state.h" +#include "shared/source/gmm_helper/client_context/gmm_client_context.h" +#include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/helpers/state_base_address.h" +#include "shared/source/memory_manager/allocation_properties.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/libult/ult_command_stream_receiver.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +#include "opencl/source/mem_obj/buffer.h" +#include "opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h" +#include "opencl/test/unit_test/mocks/mock_cl_device.h" +#include "opencl/test/unit_test/mocks/mock_context.h" + +#include "encode_surface_state_args.h" + +using namespace NEO; +using CmdsProgrammingTestsXe2HpgCore = UltCommandStreamReceiverTest; + +XE2_HPG_CORETEST_F(CmdsProgrammingTestsXe2HpgCore, givenL3ToL1DebugFlagWhenStatelessMocsIsProgrammedThenItHasL1CachingOn) { + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + + DebugManagerStateRestore restore; + debugManager.flags.ForceL1Caching.set(1u); + + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + flushTask(commandStreamReceiver); + + HardwareParse hwParserCsr; + hwParserCsr.parseCommands(commandStreamReceiver.commandStream, 0); + hwParserCsr.findHardwareCommands(); + ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress); + + auto stateBaseAddress = static_cast(hwParserCsr.cmdStateBaseAddress); + + auto actualL1CachePolocy = static_cast(stateBaseAddress->getL1CachePolicyL1CacheControl()); + + const uint8_t expectedL1CachePolicy = 0; + EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolocy); +} + +XE2_HPG_CORETEST_F(CmdsProgrammingTestsXe2HpgCore, whenAppendingRssThenProgramWtL1CachePolicy) { + auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get(); + size_t allocationSize = MemoryConstants::pageSize; + AllocationProperties properties(pDevice->getRootDeviceIndex(), allocationSize, AllocationType::buffer, pDevice->getDeviceBitfield()); + auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties); + + auto rssCmd = FamilyType::cmdInitRenderSurfaceState; + + MockContext context(pClDevice); + auto multiGraphicsAllocation = MultiGraphicsAllocation(pClDevice->getRootDeviceIndex()); + multiGraphicsAllocation.addAllocation(allocation); + + std::unique_ptr> buffer(static_cast *>( + BufferHw::create(&context, {}, 0, 0, allocationSize, nullptr, nullptr, std::move(multiGraphicsAllocation), false, false, false))); + + NEO::EncodeSurfaceStateArgs args; + args.outMemory = &rssCmd; + args.graphicsAddress = allocation->getGpuAddress(); + args.size = allocation->getUnderlyingBufferSize(); + args.mocs = buffer->getMocsValue(false, false, pClDevice->getRootDeviceIndex()); + args.numAvailableDevices = pClDevice->getNumGenericSubDevices(); + args.allocation = allocation; + args.gmmHelper = pClDevice->getGmmHelper(); + args.areMultipleSubDevicesInContext = true; + + EncodeSurfaceState::encodeBuffer(args); + + EXPECT_EQ(FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WBP, rssCmd.getL1CachePolicyL1CacheControl()); +} + +XE2_HPG_CORETEST_F(CmdsProgrammingTestsXe2HpgCore, givenAlignedCacheableReadOnlyBufferThenChoseOclBufferConstPolicy) { + MockContext context; + const auto size = MemoryConstants::pageSize; + const auto ptr = (void *)alignedMalloc(size * 2, MemoryConstants::pageSize); + const auto flags = CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY; + + auto retVal = CL_SUCCESS; + auto buffer = std::unique_ptr(Buffer::create( + &context, + flags, + size, + ptr, + retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + typename FamilyType::RENDER_SURFACE_STATE surfaceState = {}; + buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false); + + const auto expectedMocs = context.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST); + const auto actualMocs = surfaceState.getMemoryObjectControlState(); + EXPECT_EQ(expectedMocs, actualMocs); + + auto actualL1CachePolocy = static_cast(surfaceState.getL1CachePolicyL1CacheControl()); + + const uint8_t expectedL1CachePolicy = 0; + EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolocy); + + alignedFree(ptr); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/test_platform_caps_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/test_platform_caps_xe2_hpg_core.cpp new file mode 100644 index 0000000000..8e6be49830 --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/test_platform_caps_xe2_hpg_core.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +#include "opencl/source/platform/platform_info.h" +#include "opencl/test/unit_test/fixtures/platform_fixture.h" + +using namespace NEO; + +struct Xe2HpgCorePlatformCaps : public PlatformFixture, public ::testing::Test { + void SetUp() override { + PlatformFixture::setUp(); + } + + void TearDown() override { + PlatformFixture::tearDown(); + } +}; + +XE2_HPG_CORETEST_F(Xe2HpgCorePlatformCaps, givenXe2HpgCoreSkusThenItSupportFP64) { + const auto &caps = pPlatform->getPlatformInfo(); + + EXPECT_NE(std::string::npos, caps.extensions.find(std::string("cl_khr_fp64"))); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/test_preamble_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/test_preamble_xe2_hpg_core.cpp new file mode 100644 index 0000000000..56073b397f --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/test_preamble_xe2_hpg_core.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/stream_properties.h" +#include "shared/source/helpers/gfx_core_helper.h" +#include "shared/test/common/fixtures/preamble_fixture.h" + +using namespace NEO; + +using PreambleCfeState = PreambleFixture; +XE2_HPG_CORETEST_F(PreambleCfeState, givenXe2HpgCoreAndConcurrentKernelExecutionTypeWhenCallingProgramVFEStateThenSingleSpliceDispatchCcsModeIsEnabled) { + using CFE_STATE = typename FamilyType::CFE_STATE; + + auto pVfeCmd = PreambleHelper::getSpaceForVfeState(&linearStream, *defaultHwInfo, EngineGroupType::renderCompute); + StreamProperties streamProperties{}; + streamProperties.initSupport(pDevice->getRootDeviceEnvironment()); + streamProperties.frontEndState.setPropertiesAll(true, false, false, false); + PreambleHelper::programVfeState(pVfeCmd, pDevice->getRootDeviceEnvironment(), 0u, 0, 0, streamProperties); + parseCommands(linearStream); + auto cfeStateIt = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(cmdList.end(), cfeStateIt); + auto cfeState = reinterpret_cast(*cfeStateIt); + EXPECT_FALSE(cfeState->getComputeOverdispatchDisable()); + EXPECT_FALSE(cfeState->getSingleSliceDispatchCcsMode()); +} + +XE2_HPG_CORETEST_F(PreambleCfeState, givenXe2HpgCoreAndDefaultKernelExecutionTypeWhenCallingProgramVFEStateThenSingleSpliceDispatchCcsModeIsDisabled) { + using CFE_STATE = typename FamilyType::CFE_STATE; + + auto pVfeCmd = PreambleHelper::getSpaceForVfeState(&linearStream, *defaultHwInfo, EngineGroupType::renderCompute); + StreamProperties streamProperties{}; + streamProperties.initSupport(pDevice->getRootDeviceEnvironment()); + streamProperties.frontEndState.setPropertiesAll(false, false, false, false); + PreambleHelper::programVfeState(pVfeCmd, pDevice->getRootDeviceEnvironment(), 0u, 0, 0, streamProperties); + parseCommands(linearStream); + auto cfeStateIt = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(cmdList.end(), cfeStateIt); + auto cfeState = reinterpret_cast(*cfeStateIt); + EXPECT_FALSE(cfeState->getComputeOverdispatchDisable()); + EXPECT_FALSE(cfeState->getSingleSliceDispatchCcsMode()); +} diff --git a/opencl/test/unit_test/xe2_hpg_core/test_preemption_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/test_preemption_xe2_hpg_core.cpp new file mode 100644 index 0000000000..beee93cead --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/test_preemption_xe2_hpg_core.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/test_macros/test.h" + +#include "opencl/source/helpers/cl_preemption_helper.h" +#include "opencl/test/unit_test/fixtures/cl_preemption_fixture.h" + +using Xe2HpgMidThreadPreemptionTests = DevicePreemptionTests; + +XE2_HPG_CORETEST_F(Xe2HpgMidThreadPreemptionTests, GivenValueArgSetWhenOverrideMidThreadPreemptionSupportThenPreemptionModeDisabled) { + device->setPreemptionMode(PreemptionMode::MidThread); + bool value = true; + ClPreemptionHelper::overrideMidThreadPreemptionSupport(*context.get(), value); + EXPECT_EQ(PreemptionMode::Disabled, device->getPreemptionMode()); +} + +XE2_HPG_CORETEST_F(Xe2HpgMidThreadPreemptionTests, GivenValueArgNotSetWhenOverrideMidThreadPreemptionSupportThenMidThreadPreemptionMode) { + device->setPreemptionMode(PreemptionMode::MidThread); + bool value = false; + ClPreemptionHelper::overrideMidThreadPreemptionSupport(*context.get(), value); + EXPECT_EQ(PreemptionMode::MidThread, device->getPreemptionMode()); +} + +XE2_HPG_CORETEST_F(Xe2HpgMidThreadPreemptionTests, GivenFlagForcePreemptionModeSetAsDisabledWhenOverrideMidThreadPreemptionSupportThenNothingChanged) { + device->setPreemptionMode(PreemptionMode::Disabled); + debugManager.flags.ForcePreemptionMode.set(PreemptionMode::Disabled); + bool value = true; + ClPreemptionHelper::overrideMidThreadPreemptionSupport(*context.get(), value); + EXPECT_EQ(PreemptionMode::Disabled, device->getPreemptionMode()); + value = false; + ClPreemptionHelper::overrideMidThreadPreemptionSupport(*context.get(), value); + EXPECT_EQ(PreemptionMode::Disabled, device->getPreemptionMode()); +} \ No newline at end of file diff --git a/opencl/test/unit_test/xe2_hpg_core/test_sample_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/test_sample_xe2_hpg_core.cpp new file mode 100644 index 0000000000..6eb9b6157b --- /dev/null +++ b/opencl/test/unit_test/xe2_hpg_core/test_sample_xe2_hpg_core.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +#include "opencl/test/unit_test/fixtures/cl_device_fixture.h" + +using namespace NEO; + +using Xe2HpgCoreOnlyTest = Test; + +XE2_HPG_CORETEST_F(Xe2HpgCoreOnlyTest, WhenGettingRenderCoreFamilyThenOnlyHpgCoreIsReturned) { + EXPECT_EQ(IGFX_XE2_HPG_CORE, pDevice->getRenderCoreFamily()); +} diff --git a/shared/offline_compiler/source/CMakeLists.txt b/shared/offline_compiler/source/CMakeLists.txt index 64e5969ceb..d5d6cbd6f9 100644 --- a/shared/offline_compiler/source/CMakeLists.txt +++ b/shared/offline_compiler/source/CMakeLists.txt @@ -62,6 +62,7 @@ set(CLOC_LIB_SRCS_LIB ${NEO_SHARED_DIRECTORY}/helpers/compiler_product_helper_bdw_and_later.inl ${NEO_SHARED_DIRECTORY}/helpers/compiler_product_helper_before_xe_hpc.inl ${NEO_SHARED_DIRECTORY}/helpers/compiler_product_helper_xe_hpc_and_later.inl + ${NEO_SHARED_DIRECTORY}/helpers/compiler_product_helper_xe2_hpg_and_later.inl ${NEO_SHARED_DIRECTORY}/helpers/compiler_options_parser.cpp ${NEO_SHARED_DIRECTORY}/helpers/compiler_options_parser.h ${NEO_SHARED_DIRECTORY}/helpers/cache_policy.h diff --git a/shared/source/ail/xe2_hpg_core/bmg/ail_configuration_bmg.cpp b/shared/source/ail/xe2_hpg_core/bmg/ail_configuration_bmg.cpp new file mode 100644 index 0000000000..4c62eb7457 --- /dev/null +++ b/shared/source/ail/xe2_hpg_core/bmg/ail_configuration_bmg.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "ail_configuration_bmg.inl" + +#include "shared/source/ail/ail_configuration_base.inl" + +namespace NEO { +static EnableAIL enableAILBMG; + +template class AILConfigurationHw; +} // namespace NEO diff --git a/shared/source/ail/xe2_hpg_core/bmg/definitions/ail_configuration_bmg.inl b/shared/source/ail/xe2_hpg_core/bmg/definitions/ail_configuration_bmg.inl new file mode 100644 index 0000000000..4fa4901f25 --- /dev/null +++ b/shared/source/ail/xe2_hpg_core/bmg/definitions/ail_configuration_bmg.inl @@ -0,0 +1,6 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ diff --git a/shared/source/ail/xe2_hpg_core/lnl/ail_configuration_lnl.cpp b/shared/source/ail/xe2_hpg_core/lnl/ail_configuration_lnl.cpp new file mode 100644 index 0000000000..94856c97ea --- /dev/null +++ b/shared/source/ail/xe2_hpg_core/lnl/ail_configuration_lnl.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "ail_configuration_lnl.inl" + +#include "shared/source/ail/ail_configuration_base.inl" + +namespace NEO { +static EnableAIL enableAILLNL; + +template class AILConfigurationHw; +} // namespace NEO diff --git a/shared/source/ail/xe2_hpg_core/lnl/definitions/ail_configuration_lnl.inl b/shared/source/ail/xe2_hpg_core/lnl/definitions/ail_configuration_lnl.inl new file mode 100644 index 0000000000..4fa4901f25 --- /dev/null +++ b/shared/source/ail/xe2_hpg_core/lnl/definitions/ail_configuration_lnl.inl @@ -0,0 +1,6 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ diff --git a/shared/source/aub_mem_dump/definitions/aub_services.h b/shared/source/aub_mem_dump/definitions/aub_services.h index 98179e937b..3e70f84463 100644 --- a/shared/source/aub_mem_dump/definitions/aub_services.h +++ b/shared/source/aub_mem_dump/definitions/aub_services.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -108,6 +108,8 @@ struct CmdServicesMemTraceVersion { Dg2 = 36, Pvc = 39, Mtl = 42, + Bmg = 43, + Lnl = 45, Arl = 46, }; }; diff --git a/shared/source/command_container/CMakeLists.txt b/shared/source/command_container/CMakeLists.txt index 4c7b09521c..6042009316 100644 --- a/shared/source/command_container/CMakeLists.txt +++ b/shared/source/command_container/CMakeLists.txt @@ -48,6 +48,12 @@ if(SUPPORT_PVC_AND_LATER) ) endif() +if(SUPPORT_XE2_AND_LATER) + list(APPEND NEO_CORE_COMMAND_CONTAINER + ${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_xe2_hpg_core_and_later.inl + ) +endif() + set_property(GLOBAL PROPERTY NEO_CORE_COMMAND_CONTAINER ${NEO_CORE_COMMAND_CONTAINER}) add_subdirectories() diff --git a/shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl b/shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl new file mode 100644 index 0000000000..6a711598dc --- /dev/null +++ b/shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +namespace NEO { +template <> +void EncodeSurfaceState::setCoherencyType(Family::RENDER_SURFACE_STATE *surfaceState, Family::RENDER_SURFACE_STATE::COHERENCY_TYPE coherencyType) { +} +} // namespace NEO \ No newline at end of file diff --git a/shared/source/command_stream/CMakeLists.txt b/shared/source/command_stream/CMakeLists.txt index ff0837dae1..2ceda1744b 100644 --- a/shared/source/command_stream/CMakeLists.txt +++ b/shared/source/command_stream/CMakeLists.txt @@ -92,5 +92,11 @@ if(NOT SUPPORTED_HEAPLESS) ) endif() +if(SUPPORT_XE2_AND_LATER) + list(APPEND NEO_CORE_COMMAND_STREAM + ${CMAKE_CURRENT_SOURCE_DIR}/preemption_xe2_and_later.inl + ) +endif() + set_property(GLOBAL PROPERTY NEO_CORE_COMMAND_STREAM ${NEO_CORE_COMMAND_STREAM}) add_subdirectories() diff --git a/shared/source/command_stream/preemption_xe2_and_later.inl b/shared/source/command_stream/preemption_xe2_and_later.inl new file mode 100644 index 0000000000..dd2d97826b --- /dev/null +++ b/shared/source/command_stream/preemption_xe2_and_later.inl @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +template <> +void PreemptionHelper::programCmdStream(LinearStream &cmdStream, PreemptionMode newPreemptionMode, + PreemptionMode oldPreemptionMode, GraphicsAllocation *preemptionCsr) { +} + +template <> +size_t PreemptionHelper::getRequiredCmdStreamSize(PreemptionMode newPreemptionMode, PreemptionMode oldPreemptionMode) { + return 0u; +} diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index eaddcc0999..f889dc8498 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -87,6 +87,7 @@ DECLARE_DEBUG_VARIABLE(bool, WaitForMemoryRelease, false, "Wait for memory relea DECLARE_DEBUG_VARIABLE(bool, RemoveRestrictionsOnNumberOfThreadsInGpgpuThreadGroup, 0, "0 - default disabled, 1- remove restrictions on NumberOfThreadsInGpgpuThreadGroup in INTERFACE_DESCRIPTOR_DATA") DECLARE_DEBUG_VARIABLE(bool, DisableGemCreateExtSetPat, false, "Do not use I915_GEM_CREATE_EXT_SET_PAT extension when gem create ext is called") DECLARE_DEBUG_VARIABLE(bool, SkipInOrderNonWalkerSignalingAllowed, false, "Allows for skipping non walker signalling in InOrder command lists, default: false") +DECLARE_DEBUG_VARIABLE(bool, PipelinedPipelineSelect, false, "Restore usage of default pipeline select command") DECLARE_DEBUG_VARIABLE(std::string, ForceDeviceId, std::string("unk"), "Override device id in AUB/TBX mode") DECLARE_DEBUG_VARIABLE(std::string, FilterDeviceId, std::string("unk"), "Device id filter, adapter matching device id will be opened; ignored when unk") DECLARE_DEBUG_VARIABLE(std::string, FilterBdfPath, std::string("unk"), "Linux-only, BDF path filter, only matching paths will be opened; ignored when unk") @@ -287,6 +288,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideCmdListUpdateCapability, -1, "-1: defaul DECLARE_DEBUG_VARIABLE(int32_t, ForceSynchronizedDispatchMode, -1, "-1: default, 0: disabled, 1: enable full synchronization mode") DECLARE_DEBUG_VARIABLE(int32_t, ForceSipClass, -1, "-1: default, otherwise based on values from enum class SipClassType (init, builtins, rawBinaryFromFile, hexadecimalHeaderFile)") DECLARE_DEBUG_VARIABLE(int32_t, ForceScratchAndMTPBufferSizeMode, -1, "-1: default, 0: Full, 1: Min. BMG+: Reduce required memory for Scrach and MTP buffers on CCS context") +DECLARE_DEBUG_VARIABLE(int32_t, CFEStackIDControl, -1, "Set Stack ID Control in CFE_STATE on Xe2+, -1 - do not set") /*LOGGING FLAGS*/ DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level") @@ -524,6 +526,8 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableBcsSwControlWa, -1, "Enable BCS WA via BCS DECLARE_DEBUG_VARIABLE(bool, EnableHostAllocationMemPolicy, false, "Enables Memory Policy for host allocation") DECLARE_DEBUG_VARIABLE(int32_t, OverrideHostAllocationMemPolicyMode, -1, "Override Memory Policy mode for host allocation -1: default (use the system configuration), 0: MPOL_DEFAULT, 1: MPOL_PREFERRED, 2: MPOL_BIND, 3: MPOL_INTERLEAVED, 4: MPOL_LOCAL, 5: MPOL_PREFERRED_MANY") DECLARE_DEBUG_VARIABLE(int32_t, EnableFtrTile64Optimization, 0, "Control feature Tile64 Optimization flag passed to gmmlib. -1: pass as-is, 0: disable flag(default due to NEO-10623), 1: enable flag"); +DECLARE_DEBUG_VARIABLE(int32_t, ForceTheMaximumNumberOfOutstandingRayqueriesPerSs, -1, "Set the maximum number of outstanding RayQueries per SS, -1: default, 0: 128, 1: 256, 2: 512, 3: 1024") +DECLARE_DEBUG_VARIABLE(int32_t, ForceDispatchTimeoutCounter, -1, "Set timeout for Synchronous Ray Tracing, -1: default, 0: 64, 1: 128, 2: 192, 3: 256, 4: 512, 5: 1024, 6: 2048, 7: 4096") /* IMPLICIT SCALING */ DECLARE_DEBUG_VARIABLE(int32_t, EnableWalkerPartition, -1, "-1: default, 0: disable, 1: enable, Enables Walker Partitioning via WPARID.") diff --git a/shared/source/dll/devices/devices_base.inl b/shared/source/dll/devices/devices_base.inl index 5d33bb9282..154be594ae 100644 --- a/shared/source/dll/devices/devices_base.inl +++ b/shared/source/dll/devices/devices_base.inl @@ -5,6 +5,21 @@ * */ +#if SUPPORT_XE2_HPG_CORE +#ifdef SUPPORT_BMG +DEVICE(0xE202, BmgHwConfig) +DEVICE(0xE20B, BmgHwConfig) +DEVICE(0xE20C, BmgHwConfig) +DEVICE(0xE20D, BmgHwConfig) +DEVICE(0xE212, BmgHwConfig) +#endif +#ifdef SUPPORT_LNL +DEVICE(0x6420, LnlHwConfig) +DEVICE(0x64A0, LnlHwConfig) +DEVICE(0x64B0, LnlHwConfig) +#endif +#endif + #if SUPPORT_XE_HPC_CORE #ifdef SUPPORT_PVC DEVICE(0x0BD0, PvcHwConfig) diff --git a/shared/source/dll/devices/product_config_base.inl b/shared/source/dll/devices/product_config_base.inl index 599095df43..6bf9029c52 100644 --- a/shared/source/dll/devices/product_config_base.inl +++ b/shared/source/dll/devices/product_config_base.inl @@ -5,6 +5,19 @@ * */ +#if SUPPORT_XE2_HPG_CORE +#ifdef SUPPORT_BMG +DEVICE_CONFIG(BMG_G21_A0, BmgHwConfig, bmgG21DeviceIds, XE2_FAMILY, XE2_HPG_RELEASE) +DEVICE_CONFIG(BMG_G21_A1, BmgHwConfig, bmgG21DeviceIds, XE2_FAMILY, XE2_HPG_RELEASE) +DEVICE_CONFIG(BMG_G21_B0, BmgHwConfig, bmgG21DeviceIds, XE2_FAMILY, XE2_HPG_RELEASE) +#endif +#ifdef SUPPORT_LNL +DEVICE_CONFIG(LNL_A0, LnlHwConfig, lnlDeviceIds, XE2_FAMILY, XE2_LPG_RELEASE) +DEVICE_CONFIG(LNL_A1, LnlHwConfig, lnlDeviceIds, XE2_FAMILY, XE2_LPG_RELEASE) +DEVICE_CONFIG(LNL_B0, LnlHwConfig, lnlDeviceIds, XE2_FAMILY, XE2_LPG_RELEASE) +#endif +#endif + #if SUPPORT_XE_HPC_CORE #ifdef SUPPORT_PVC DEVICE_CONFIG(PVC_XL_A0, PvcHwConfig, pvcXlDeviceIds, XE_FAMILY, XE_HPC_RELEASE) diff --git a/shared/source/gen_common/aub_mapper_common.h b/shared/source/gen_common/aub_mapper_common.h index 1ea761d7f2..6159e6fda2 100644 --- a/shared/source/gen_common/aub_mapper_common.h +++ b/shared/source/gen_common/aub_mapper_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -27,3 +27,6 @@ #ifdef SUPPORT_XE_HPC_CORE #include "shared/source/xe_hpc_core/aub_mapper.h" #endif +#ifdef SUPPORT_XE2_HPG_CORE +#include "shared/source/xe2_hpg_core/aub_mapper.h" +#endif diff --git a/shared/source/helpers/CMakeLists.txt b/shared/source/helpers/CMakeLists.txt index 40bba98f61..b7abcbdfe6 100644 --- a/shared/source/helpers/CMakeLists.txt +++ b/shared/source/helpers/CMakeLists.txt @@ -203,6 +203,14 @@ if(SUPPORT_PVC_AND_LATER) ) endif() +if(SUPPORT_XE2_AND_LATER) + list(APPEND NEO_CORE_HELPERS + ${CMAKE_CURRENT_SOURCE_DIR}/gfx_core_helper_xe2_and_later.inl + ${CMAKE_CURRENT_SOURCE_DIR}/compiler_product_helper_xe2_hpg_and_later.inl + ${CMAKE_CURRENT_SOURCE_DIR}/preamble_xe2_hpg_and_later.inl + ) +endif() + set(NEO_CORE_HELPERS_GMM_CALLBACKS_WINDOWS ${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.cpp ${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.h diff --git a/shared/source/helpers/compiler_product_helper_xe2_hpg_and_later.inl b/shared/source/helpers/compiler_product_helper_xe2_hpg_and_later.inl new file mode 100644 index 0000000000..a6c0a45dea --- /dev/null +++ b/shared/source/helpers/compiler_product_helper_xe2_hpg_and_later.inl @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include "shared/source/helpers/compiler_product_helper.h" +#include "shared/source/helpers/hw_info.h" + +namespace NEO { + +template +bool CompilerProductHelperHw::isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) const { + return hwInfo.featureTable.flags.ftrWalkerMTP; +} + +} // namespace NEO diff --git a/shared/source/helpers/definitions/device_ids_configs_base.h b/shared/source/helpers/definitions/device_ids_configs_base.h index d331a7a45b..a27e40b14f 100644 --- a/shared/source/helpers/definitions/device_ids_configs_base.h +++ b/shared/source/helpers/definitions/device_ids_configs_base.h @@ -7,6 +7,15 @@ #pragma once +#if SUPPORT_XE2_HPG_CORE +#ifdef SUPPORT_BMG +#include "device_ids_configs_bmg.h" +#endif +#ifdef SUPPORT_LNL +#include "shared/source/xe2_hpg_core/lnl/device_ids_configs_lnl.h" +#endif +#endif + #ifdef SUPPORT_XE_HPG_CORE #ifdef SUPPORT_MTL #include "shared/source/xe_hpg_core/xe_lpg/device_ids_configs_xe_lpg.h" diff --git a/shared/source/helpers/definitions/hw_cmds.h b/shared/source/helpers/definitions/hw_cmds.h index 3fa087102d..93e598afce 100644 --- a/shared/source/helpers/definitions/hw_cmds.h +++ b/shared/source/helpers/definitions/hw_cmds.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 Intel Corporation + * Copyright (C) 2019-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -27,3 +27,6 @@ #ifdef SUPPORT_XE_HPC_CORE #include "shared/source/xe_hpc_core/hw_cmds.h" #endif +#ifdef SUPPORT_XE2_HPG_CORE +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#endif diff --git a/shared/source/helpers/gfx_core_helper_xe2_and_later.inl b/shared/source/helpers/gfx_core_helper_xe2_and_later.inl new file mode 100644 index 0000000000..36167b8827 --- /dev/null +++ b/shared/source/helpers/gfx_core_helper_xe2_and_later.inl @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/gmm_helper/gmm.h" +#include "shared/source/helpers/gfx_core_helper.h" + +namespace NEO { + +template <> +void GfxCoreHelperHw::applyAdditionalCompressionSettings(Gmm &gmm, bool isNotCompressed) const { + gmm.resourceParams.Flags.Info.NotCompressed = isNotCompressed; + if (!isNotCompressed) { + gmm.resourceParams.Flags.Info.Cacheable = 0; + } + + if (debugManager.flags.PrintGmmCompressionParams.get()) { + printf("\n\tFlags.Info.NotCompressed: %u", gmm.resourceParams.Flags.Info.NotCompressed); + } +} + +template <> +size_t GfxCoreHelperHw::getIOHAlignment() const { + size_t alignment = 256; + if (debugManager.flags.ForceIOHAlignment.get() != -1) { + alignment = static_cast(debugManager.flags.ForceIOHAlignment.get()); + } + return alignment; +} + +template <> +void GfxCoreHelperHw::applyRenderCompressionFlag(Gmm &gmm, uint32_t isCompressed) const {} + +template <> +bool GfxCoreHelperHw::isTimestampShiftRequired() const { + return false; +} + +template <> +void MemorySynchronizationCommands::encodeAdditionalTimestampOffsets(LinearStream &commandStream, uint64_t contextAddress, uint64_t globalAddress) { + EncodeStoreMMIO::encode(commandStream, RegisterOffsets::gpThreadTimeRegAddressOffsetHigh, contextAddress + sizeof(uint32_t), false, nullptr); + EncodeStoreMMIO::encode(commandStream, RegisterOffsets::globalTimestampUn, globalAddress + sizeof(uint32_t), false, nullptr); +} + +} // namespace NEO diff --git a/shared/source/helpers/preamble_xe2_hpg_and_later.inl b/shared/source/helpers/preamble_xe2_hpg_and_later.inl new file mode 100644 index 0000000000..9031797182 --- /dev/null +++ b/shared/source/helpers/preamble_xe2_hpg_and_later.inl @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/linear_stream.h" +#include "shared/source/command_stream/stream_properties.h" +#include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/helpers/pipeline_select_helper.h" +#include "shared/source/helpers/preamble.h" + +namespace NEO { + +template +size_t PreambleHelper::getCmdSizeForPipelineSelect(const RootDeviceEnvironment &rootDeviceEnvironment) { + if (debugManager.flags.PipelinedPipelineSelect.get()) { + return sizeof(typename Family::PIPELINE_SELECT); + } + + return 0; +} + +template +void PreambleHelper::programPipelineSelect(LinearStream *pCommandStream, + const PipelineSelectArgs &pipelineSelectArgs, + const RootDeviceEnvironment &rootDeviceEnvironment) { + if (debugManager.flags.PipelinedPipelineSelect.get()) { + using PIPELINE_SELECT = typename Family::PIPELINE_SELECT; + + auto cmdBuffer = pCommandStream->getSpaceForCmd(); + auto pipelineSelectCmd = Family::cmdInitPipelineSelect; + + auto mask = pipelineSelectEnablePipelineSelectMaskBits; + pipelineSelectCmd.setMaskBits(mask); + + pipelineSelectCmd.setPipelineSelection(PIPELINE_SELECT::PIPELINE_SELECTION_GPGPU); + + *cmdBuffer = pipelineSelectCmd; + } +} + +template +void PreambleHelper::appendProgramVFEState(const RootDeviceEnvironment &rootDeviceEnvironment, const StreamProperties &streamProperties, void *cmd) { + using CFE_STATE = typename Family::CFE_STATE; + using STACK_ID_CONTROL = typename CFE_STATE::STACK_ID_CONTROL; + auto command = static_cast(cmd); + + if (debugManager.flags.CFEStackIDControl.get() != -1) { + command->setStackIdControl(static_cast(debugManager.flags.CFEStackIDControl.get())); + } +} + +} // namespace NEO diff --git a/shared/source/os_interface/CMakeLists.txt b/shared/source/os_interface/CMakeLists.txt index 0a4eb47504..5caf1a3c99 100644 --- a/shared/source/os_interface/CMakeLists.txt +++ b/shared/source/os_interface/CMakeLists.txt @@ -26,6 +26,7 @@ set(NEO_CORE_OS_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/product_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/product_helper.inl ${CMAKE_CURRENT_SOURCE_DIR}/product_helper_bdw_and_later.inl + ${CMAKE_CURRENT_SOURCE_DIR}/product_helper_xe2_and_later.inl ${CMAKE_CURRENT_SOURCE_DIR}/metrics_library.cpp ${CMAKE_CURRENT_SOURCE_DIR}/os_context.cpp ${CMAKE_CURRENT_SOURCE_DIR}/os_context.h diff --git a/shared/source/os_interface/product_helper_xe2_and_later.inl b/shared/source/os_interface/product_helper_xe2_and_later.inl new file mode 100644 index 0000000000..71c7942a34 --- /dev/null +++ b/shared/source/os_interface/product_helper_xe2_and_later.inl @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/os_interface/product_helper_hw.h" +#include "shared/source/unified_memory/usm_memory_support.h" + +#include + +namespace NEO { + +template +uint64_t ProductHelperHw::getHostMemCapabilitiesValue() const { + return (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess); +} + +template +uint64_t ProductHelperHw::getCrossDeviceSharedMemCapabilities() const { + uint64_t capabilities = UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess; + + if (getConcurrentAccessMemCapabilitiesSupported(UsmAccessCapabilities::sharedCrossDevice)) { + capabilities |= UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess; + } + + return capabilities; +} + +template +void ProductHelperHw::enableCompression(HardwareInfo *hwInfo) const { + const bool isCompressionEnabled = hwInfo->featureTable.flags.ftrE2ECompression && hwInfo->featureTable.flags.ftrXe2Compression; + hwInfo->capabilityTable.ftrRenderCompressedImages = isCompressionEnabled; + hwInfo->capabilityTable.ftrRenderCompressedBuffers = isCompressionEnabled; +} + +template +uint32_t ProductHelperHw::getMaxThreadsForWorkgroupInDSSOrSS(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice, uint32_t maxNumEUsPerDualSubSlice) const { + return getMaxThreadsForWorkgroup(hwInfo, maxNumEUsPerDualSubSlice); +} + +template +bool ProductHelperHw::obtainBlitterPreference(const HardwareInfo &hwInfo) const { + return true; +} + +template +bool ProductHelperHw::useGemCreateExtInAllocateMemoryByKMD() const { + return true; +} + +template +bool ProductHelperHw::isBlitterFullySupported(const HardwareInfo &hwInfo) const { + return hwInfo.capabilityTable.blitterOperationsSupported; +} + +template +bool ProductHelperHw::isNewResidencyModelSupported() const { + return true; +} + +template +bool ProductHelperHw::deferMOCSToPatIndex() const { + return true; +} + +template +bool ProductHelperHw::heapInLocalMem(const HardwareInfo &hwInfo) const { + return true; +} + +template +bool ProductHelperHw::isInitBuiltinAsyncSupported(const HardwareInfo &hwInfo) const { + return false; +} + +template +bool ProductHelperHw::isTimestampWaitSupportedForEvents() const { + return true; +} + +template +uint32_t ProductHelperHw::getCommandBuffersPreallocatedPerCommandQueue() const { + return 2u; +} + +template +uint32_t ProductHelperHw::getInternalHeapsPreallocated() const { + if (debugManager.flags.SetAmountOfInternalHeapsToPreallocate.get() != -1) { + return debugManager.flags.SetAmountOfInternalHeapsToPreallocate.get(); + } + return 1u; +} + +template +void ProductHelperHw::setCapabilityCoherencyFlag(const HardwareInfo &hwInfo, bool &coherencyFlag) { + coherencyFlag = false; +} + +template +bool ProductHelperHw::isTile64With3DSurfaceOnBCSSupported(const HardwareInfo &hwInfo) const { + return true; +} + +template +bool ProductHelperHw::isBufferPoolAllocatorSupported() const { + return true; +} + +template +bool ProductHelperHw::isUsmPoolAllocatorSupported() const { + return true; +} + +template +bool ProductHelperHw::useLocalPreferredForCacheableBuffers() const { + return false; +} + +template +std::optional ProductHelperHw::isCoherentAllocation(uint64_t patIndex) const { + std::array listOfCoherentPatIndexes = {1, 2, 4, 5, 7, 22, 23, 26, 27, 30, 31}; + if (std::find(listOfCoherentPatIndexes.begin(), listOfCoherentPatIndexes.end(), patIndex) != listOfCoherentPatIndexes.end()) { + return true; + } + return false; +} + +template +bool ProductHelperHw::isDeviceUsmAllocationReuseSupported() const { + return true; +} + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/CMakeLists.txt b/shared/source/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..aa7d61db0f --- /dev/null +++ b/shared/source/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,10 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(SUPPORT_XE2_HPG_CORE) + add_subdirectories() +endif() + diff --git a/shared/source/xe2_hpg_core/aub_command_stream_receiver_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/aub_command_stream_receiver_xe2_hpg_core.cpp new file mode 100644 index 0000000000..14c17a46e6 --- /dev/null +++ b/shared/source/xe2_hpg_core/aub_command_stream_receiver_xe2_hpg_core.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/aub_command_stream_receiver.h" +#include "shared/source/command_stream/aub_command_stream_receiver_hw_xehp_and_later.inl" +#include "shared/source/helpers/array_count.h" +#include "shared/source/helpers/populate_factory.h" + +namespace NEO { +struct Xe2HpgCoreFamily; + +using Family = Xe2HpgCoreFamily; +static auto gfxCore = IGFX_XE2_HPG_CORE; + +template <> +void populateFactoryTable>() { + extern AubCommandStreamReceiverCreateFunc aubCommandStreamReceiverFactory[IGFX_MAX_CORE]; + UNRECOVERABLE_IF(!isInRange(gfxCore, aubCommandStreamReceiverFactory)); + aubCommandStreamReceiverFactory[gfxCore] = AUBCommandStreamReceiverHw::create; +} + +template class AUBCommandStreamReceiverHw; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/aub_mapper.h b/shared/source/xe2_hpg_core/aub_mapper.h new file mode 100644 index 0000000000..b4b2805b91 --- /dev/null +++ b/shared/source/xe2_hpg_core/aub_mapper.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "shared/source/aub/aub_mapper_base.h" +#include "shared/source/helpers/constants.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +#include "aubstream/engine_node.h" + +namespace NEO { +struct Xe2HpgCoreFamily; + +template <> +struct AUBFamilyMapper { + enum { device = AubMemDump::DeviceValues::Bmg }; + + using AubTraits = AubMemDump::Traits; + + static const AubMemDump::LrcaHelper *const csTraits[aub_stream::NUM_ENGINES]; + + static const MMIOList globalMMIO; + static const MMIOList *perEngineMMIO[aub_stream::NUM_ENGINES]; + + using AUB = AubMemDump::AubDump; +}; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/aub_mem_dump_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/aub_mem_dump_xe2_hpg_core.cpp new file mode 100644 index 0000000000..30f55099f9 --- /dev/null +++ b/shared/source/xe2_hpg_core/aub_mem_dump_xe2_hpg_core.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/aub/aub_helper_xehp_and_later.inl" +#include "shared/source/aub_mem_dump/aub_mem_dump.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +namespace NEO { +struct Xe2HpgCoreFamily; +using Family = NEO::Xe2HpgCoreFamily; +constexpr static auto deviceValue = AubMemDump::DeviceValues::Bmg; + +template class AubHelperHw; +} // namespace NEO + +#include "shared/source/aub_mem_dump/aub_mem_dump_pvc_and_later.inl" diff --git a/shared/source/xe2_hpg_core/bmg/definitions/device_ids_configs_bmg.h b/shared/source/xe2_hpg_core/bmg/definitions/device_ids_configs_bmg.h new file mode 100644 index 0000000000..c48d4081a3 --- /dev/null +++ b/shared/source/xe2_hpg_core/bmg/definitions/device_ids_configs_bmg.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include + +namespace NEO { +const std::vector bmgG21DeviceIds{0xE202, 0xE20B, 0xE20C, 0xE20D, 0xE212}; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/bmg/os_agnostic_product_helper_bmg.inl b/shared/source/xe2_hpg_core/bmg/os_agnostic_product_helper_bmg.inl new file mode 100644 index 0000000000..46f4471689 --- /dev/null +++ b/shared/source/xe2_hpg_core/bmg/os_agnostic_product_helper_bmg.inl @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/command_stream_receiver.h" + +#include "aubstream/product_family.h" + +namespace NEO { + +template <> +bool ProductHelperHw::isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const { + const bool enabled = false; + if (debugManager.flags.ResolveDependenciesViaPipeControls.get() != -1) { + return debugManager.flags.ResolveDependenciesViaPipeControls.get() == 1; + } + return enabled; +} + +template <> +bool ProductHelperHw::isEvictionIfNecessaryFlagSupported() const { + return true; +} + +template <> +bool ProductHelperHw::isMidThreadPreemptionDisallowedForRayTracingKernels() const { + return true; +} + +template <> +bool ProductHelperHw::isBufferPoolAllocatorSupported() const { + return true; +} + +template <> +std::optional ProductHelperHw::getAubStreamProductFamily() const { + return aub_stream::ProductFamily::Bmg; +}; + +template <> +void ProductHelperHw::adjustNumberOfCcs(HardwareInfo &hwInfo) const { + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1; +} + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/command_encoder_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/command_encoder_xe2_hpg_core.cpp new file mode 100644 index 0000000000..432b1250cd --- /dev/null +++ b/shared/source/xe2_hpg_core/command_encoder_xe2_hpg_core.cpp @@ -0,0 +1,343 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/command_encoder.h" +#include "shared/source/command_container/command_encoder.inl" +#include "shared/source/command_container/command_encoder_heap_addressing.inl" +#include "shared/source/command_container/command_encoder_xehp_and_later.inl" +#include "shared/source/command_container/encode_compute_mode_tgllp_and_later.inl" +#include "shared/source/command_stream/stream_properties.h" +#include "shared/source/helpers/constants.h" +#include "shared/source/kernel/grf_config.h" +#include "shared/source/release_helper/release_helper.h" +#include "shared/source/utilities/lookup_array.h" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +using Family = NEO::Xe2HpgCoreFamily; + +#include "shared/source/command_container/command_encoder_tgllp_and_later.inl" +#include "shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl" +#include "shared/source/command_container/command_encoder_xe_hpc_core_and_later.inl" +#include "shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl" +#include "shared/source/command_container/image_surface_state/compression_params_xehp_and_later.inl" + +namespace NEO { + +template <> +void EncodeEnableRayTracing::append3dStateBtd(void *ptr3dStateBtd) { + using _3DSTATE_BTD = typename Family::_3DSTATE_BTD; + using DISPATCH_TIMEOUT_COUNTER = typename Family::_3DSTATE_BTD_BODY::DISPATCH_TIMEOUT_COUNTER; + using CONTROLS_THE_MAXIMUM_NUMBER_OF_OUTSTANDING_RAYQUERIES_PER_SS = typename Family::_3DSTATE_BTD_BODY::CONTROLS_THE_MAXIMUM_NUMBER_OF_OUTSTANDING_RAYQUERIES_PER_SS; + auto cmd = static_cast<_3DSTATE_BTD *>(ptr3dStateBtd); + if (debugManager.flags.ForceTheMaximumNumberOfOutstandingRayqueriesPerSs.get() != -1) { + auto value = static_cast(debugManager.flags.ForceTheMaximumNumberOfOutstandingRayqueriesPerSs.get()); + DEBUG_BREAK_IF(value > 3); + cmd->getBtdStateBody().setControlsTheMaximumNumberOfOutstandingRayqueriesPerSs(value); + } + if (debugManager.flags.ForceDispatchTimeoutCounter.get() != -1) { + auto value = static_cast(debugManager.flags.ForceDispatchTimeoutCounter.get()); + DEBUG_BREAK_IF(value > 7); + cmd->getBtdStateBody().setDispatchTimeoutCounter(value); + } +} + +template <> +template +void EncodeDispatchKernel::adjustInterfaceDescriptorData(InterfaceDescriptorType &interfaceDescriptor, const Device &device, const HardwareInfo &hwInfo, const uint32_t threadGroupCount, const uint32_t grfCount, WalkerType &walkerCmd) { + EncodeDispatchKernel::adjustInterfaceDescriptorDataForOverdispatch(interfaceDescriptor, device, hwInfo, threadGroupCount, grfCount, walkerCmd); +} + +template <> +inline void EncodeAtomic::setMiAtomicAddress(MI_ATOMIC &atomic, uint64_t writeAddress) { + atomic.setMemoryAddress(writeAddress); +} + +template <> +void EncodeComputeMode::programComputeModeCommand(LinearStream &csr, StateComputeModeProperties &properties, const RootDeviceEnvironment &rootDeviceEnvironment) { + using STATE_COMPUTE_MODE = typename Family::STATE_COMPUTE_MODE; + + STATE_COMPUTE_MODE stateComputeMode = Family::cmdInitStateComputeMode; + auto maskBits = stateComputeMode.getMask1(); + auto maskBits2 = stateComputeMode.getMask2(); + + if (properties.memoryAllocationForScratchAndMidthreadPreemptionBuffers.isDirty) { + stateComputeMode.setMemoryAllocationForScratchAndMidthreadPreemptionBuffers(properties.memoryAllocationForScratchAndMidthreadPreemptionBuffers.value); + maskBits2 |= Family::stateComputeModeMemoryAllocationForScratchAndMidthreadPreemptionBuffersMask; + } + + if (properties.threadArbitrationPolicy.isDirty) { + switch (properties.threadArbitrationPolicy.value) { + case ThreadArbitrationPolicy::RoundRobin: + stateComputeMode.setEuThreadSchedulingModeOverride(STATE_COMPUTE_MODE::EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_ROUND_ROBIN); + break; + case ThreadArbitrationPolicy::AgeBased: + stateComputeMode.setEuThreadSchedulingModeOverride(STATE_COMPUTE_MODE::EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_OLDEST_FIRST); + break; + case ThreadArbitrationPolicy::RoundRobinAfterDependency: + stateComputeMode.setEuThreadSchedulingModeOverride(STATE_COMPUTE_MODE::EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_STALL_BASED_ROUND_ROBIN); + break; + default: + stateComputeMode.setEuThreadSchedulingModeOverride(STATE_COMPUTE_MODE::EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_HW_DEFAULT); + } + maskBits |= Family::stateComputeModeEuThreadSchedulingModeOverrideMask; + } + + if (properties.largeGrfMode.isDirty) { + stateComputeMode.setLargeGrfMode(properties.largeGrfMode.value); + maskBits |= Family::stateComputeModeLargeGrfModeMask; + } + + stateComputeMode.setMask1(maskBits); + stateComputeMode.setMask2(maskBits2); + + auto buffer = csr.getSpaceForCmd(); + *buffer = stateComputeMode; +} + +template <> +void EncodeWA::adjustCompressionFormatForPlanarImage(uint32_t &compressionFormat, int plane) { +} + +template <> +void EncodeMemoryPrefetch::programMemoryPrefetch(LinearStream &commandStream, const GraphicsAllocation &graphicsAllocation, uint32_t size, size_t offset, const RootDeviceEnvironment &rootDeviceEnvironment) { + using STATE_PREFETCH = typename Family::STATE_PREFETCH; + constexpr uint32_t mocsIndexForL3 = (1 << 1); + + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + auto &productHelper = rootDeviceEnvironment.getHelper(); + bool prefetch = productHelper.allowMemoryPrefetch(hwInfo); + + if (!prefetch) { + return; + } + + uint64_t gpuVa = graphicsAllocation.getGpuAddress() + offset; + + while (size > 0) { + uint32_t sizeInBytesToPrefetch = std::min(alignUp(size, MemoryConstants::cacheLineSize), + static_cast(MemoryConstants::pageSize64k)); + + uint32_t prefetchSize = sizeInBytesToPrefetch / MemoryConstants::cacheLineSize; + + auto statePrefetch = commandStream.getSpaceForCmd(); + STATE_PREFETCH cmd = Family::cmdInitStatePrefetch; + + cmd.setAddress(gpuVa); + cmd.setPrefetchSize(prefetchSize); + cmd.setMemoryObjectControlState(mocsIndexForL3); + cmd.setKernelInstructionPrefetch(GraphicsAllocation::isIsaAllocationType(graphicsAllocation.getAllocationType())); + + if (debugManager.flags.ForceCsStallForStatePrefetch.get() == 1) { + cmd.setParserStall(true); + } + + *statePrefetch = cmd; + + if (sizeInBytesToPrefetch > size) { + break; + } + + gpuVa += sizeInBytesToPrefetch; + size -= sizeInBytesToPrefetch; + } +} + +template <> +size_t EncodeMemoryPrefetch::getSizeForMemoryPrefetch(size_t size, const RootDeviceEnvironment &rootDeviceEnvironment) { + auto &productHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + if (!productHelper.allowMemoryPrefetch(hwInfo)) { + return 0; + } + + size = alignUp(size, MemoryConstants::pageSize64k); + + size_t count = size / MemoryConstants::pageSize64k; + + return (count * sizeof(typename Family::STATE_PREFETCH)); +} + +template <> +inline void EncodeMiFlushDW::adjust(MI_FLUSH_DW *miFlushDwCmd, const ProductHelper &productHelper) { + miFlushDwCmd->setFlushLlc(1); + + if (productHelper.isDcFlushAllowed()) { + miFlushDwCmd->setFlushCcs(1); + } +} + +template <> +template <> +void EncodeDispatchKernel::programBarrierEnable(INTERFACE_DESCRIPTOR_DATA &interfaceDescriptor, + uint32_t value, + const HardwareInfo &hwInfo) { + using BARRIERS = INTERFACE_DESCRIPTOR_DATA::NUMBER_OF_BARRIERS; + static const LookupArray barrierLookupArray({{{0, BARRIERS::NUMBER_OF_BARRIERS_NONE}, + {1, BARRIERS::NUMBER_OF_BARRIERS_B1}, + {2, BARRIERS::NUMBER_OF_BARRIERS_B2}, + {4, BARRIERS::NUMBER_OF_BARRIERS_B4}, + {8, BARRIERS::NUMBER_OF_BARRIERS_B8}, + {16, BARRIERS::NUMBER_OF_BARRIERS_B16}, + {24, BARRIERS::NUMBER_OF_BARRIERS_B24}, + {32, BARRIERS::NUMBER_OF_BARRIERS_B32}}}); + BARRIERS numBarriers = barrierLookupArray.lookUp(value); + interfaceDescriptor.setNumberOfBarriers(numBarriers); +} + +template <> +void EncodeSurfaceState::setImageAuxParamsForCCS(R_SURFACE_STATE *surfaceState, Gmm *gmm) { +} + +template <> +void EncodeSurfaceState::setBufferAuxParamsForCCS(R_SURFACE_STATE *surfaceState) { +} + +template <> +bool EncodeSurfaceState::isAuxModeEnabled(R_SURFACE_STATE *surfaceState, Gmm *gmm) { + return gmm && gmm->isCompressionEnabled(); +} + +template <> +void EncodeSurfaceState::appendImageCompressionParams(R_SURFACE_STATE *surfaceState, GraphicsAllocation *allocation, + GmmHelper *gmmHelper, bool imageFromBuffer, GMM_YUV_PLANE_ENUM plane) { + if (!allocation->isCompressionEnabled()) { + return; + } + + using COMPRESSION_FORMAT = typename R_SURFACE_STATE::COMPRESSION_FORMAT; + + auto gmmResourceInfo = allocation->getDefaultGmm()->gmmResourceInfo.get(); + + auto compressionFormat = gmmHelper->getClientContext()->getSurfaceStateCompressionFormat(gmmResourceInfo->getResourceFormat()); + + surfaceState->setCompressionFormat(static_cast(compressionFormat)); +} + +template <> +void EncodeSurfaceState::setAuxParamsForMCSCCS(R_SURFACE_STATE *surfaceState, const ReleaseHelper *releaseHelper) { + if (releaseHelper && releaseHelper->isAuxSurfaceModeOverrideRequired()) + surfaceState->setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_MCS); +} + +template <> +void EncodeSurfaceState::setClearColorParams(R_SURFACE_STATE *surfaceState, Gmm *gmm) { +} + +template <> +inline void EncodeSurfaceState::setFlagsForMediaCompression(R_SURFACE_STATE *surfaceState, Gmm *gmm) { +} + +template <> +void EncodeSurfaceState::disableCompressionFlags(R_SURFACE_STATE *surfaceState) { +} + +template <> +template +void EncodeDispatchKernel::encodeAdditionalWalkerFields(const RootDeviceEnvironment &rootDeviceEnvironment, WalkerType &walkerCmd, const EncodeWalkerArgs &walkerArgs) { + auto programGlobalFenceAsPostSyncOperationInComputeWalker = walkerArgs.requiredSystemFence; + int32_t overrideProgramSystemMemoryFence = debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.get(); + if (overrideProgramSystemMemoryFence != -1) { + programGlobalFenceAsPostSyncOperationInComputeWalker = !!overrideProgramSystemMemoryFence; + } + auto &postSyncData = walkerCmd.getPostSync(); + postSyncData.setSystemMemoryFenceRequest(programGlobalFenceAsPostSyncOperationInComputeWalker); + + int32_t forceL3PrefetchForComputeWalker = debugManager.flags.ForceL3PrefetchForComputeWalker.get(); + if (forceL3PrefetchForComputeWalker != -1) { + walkerCmd.setL3PrefetchDisable(!forceL3PrefetchForComputeWalker); + } + + bool computeDispatchAllWalkerEnable = walkerArgs.kernelExecutionType == KernelExecutionType::concurrent; + int32_t overrideComputeDispatchAllWalkerEnable = debugManager.flags.ComputeDispatchAllWalkerEnableInComputeWalker.get(); + if (overrideComputeDispatchAllWalkerEnable != -1) { + computeDispatchAllWalkerEnable = !!overrideComputeDispatchAllWalkerEnable; + } + walkerCmd.setComputeDispatchAllWalkerEnable(computeDispatchAllWalkerEnable); +} + +template <> +template +void EncodeDispatchKernel::appendAdditionalIDDFields(InterfaceDescriptorType *pInterfaceDescriptor, const RootDeviceEnvironment &rootDeviceEnvironment, const uint32_t threadsPerThreadGroup, uint32_t slmTotalSize, SlmPolicy slmPolicy) { + using PREFERRED_SLM_ALLOCATION_SIZE = typename InterfaceDescriptorType::PREFERRED_SLM_ALLOCATION_SIZE; + + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + uint32_t threadsPerDssCount = hwInfo.gtSystemInfo.ThreadCount / + hwInfo.gtSystemInfo.SubSliceCount; + uint32_t workGroupCountPerDss = static_cast(Math::divideAndRoundUp(threadsPerDssCount, threadsPerThreadGroup)); + + uint32_t slmSize = 0u; + + switch (slmPolicy) { + case SlmPolicy::slmPolicyLargeData: + slmSize = slmTotalSize; + break; + case SlmPolicy::slmPolicyLargeSlm: + default: + slmSize = slmTotalSize * workGroupCountPerDss; + break; + } + + struct SizeToPreferredSlmValue { + uint32_t upperLimit; + PREFERRED_SLM_ALLOCATION_SIZE valueToProgram; + }; + const std::array ranges = {{ + // upper limit, retVal + {0, PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_0K}, + {16 * MemoryConstants::kiloByte, PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_16K}, + {32 * MemoryConstants::kiloByte, PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_32K}, + {64 * MemoryConstants::kiloByte, PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_64K}, + {96 * MemoryConstants::kiloByte, PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_96K}, + {128 * MemoryConstants::kiloByte, PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_128K}, + }}; + + auto programmableIdPreferredSlmSize = PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_160K; + + auto *releaseHelper = rootDeviceEnvironment.getReleaseHelper(); + programmableIdPreferredSlmSize = static_cast( + releaseHelper->getProductMaxPreferredSlmSize(programmableIdPreferredSlmSize)); + + for (auto &range : ranges) { + if (slmSize <= range.upperLimit) { + programmableIdPreferredSlmSize = range.valueToProgram; + break; + } + } + + pInterfaceDescriptor->setPreferredSlmAllocationSize(programmableIdPreferredSlmSize); + + if (debugManager.flags.OverridePreferredSlmAllocationSizePerDss.get() != -1) { + auto toProgram = + static_cast(debugManager.flags.OverridePreferredSlmAllocationSizePerDss.get()); + pInterfaceDescriptor->setPreferredSlmAllocationSize(toProgram); + } +} + +template <> +template +void EncodeDispatchKernel::setGrfInfo(InterfaceDescriptorType *pInterfaceDescriptor, uint32_t grfCount, + const size_t &sizeCrossThreadData, const size_t &sizePerThreadData, + const RootDeviceEnvironment &rootDeviceEnvironment) {} + +template <> +template +void EncodeDispatchKernel::adjustWalkOrder(WalkerType &walkerCmd, uint32_t requiredWorkGroupOrder, const RootDeviceEnvironment &rootDeviceEnvironment) { + if (HwWalkOrderHelper::compatibleDimensionOrders[requiredWorkGroupOrder] == HwWalkOrderHelper::linearWalk) { + walkerCmd.setDispatchWalkOrder(WalkerType::DISPATCH_WALK_ORDER::LINERAR_WALKER); + } else if (HwWalkOrderHelper::compatibleDimensionOrders[requiredWorkGroupOrder] == HwWalkOrderHelper::yOrderWalk) { + walkerCmd.setDispatchWalkOrder(WalkerType::DISPATCH_WALK_ORDER::Y_ORDER_WALKER); + } +} + +} // namespace NEO + +#include "shared/source/command_container/command_encoder_enablers.inl" + +namespace NEO { +template void InOrderPatchCommandHelpers::PatchCmd::patchComputeWalker(uint64_t appendCounterValue); + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/command_stream_receiver_hw_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/command_stream_receiver_hw_xe2_hpg_core.cpp new file mode 100644 index 0000000000..09d7ef6199 --- /dev/null +++ b/shared/source/xe2_hpg_core/command_stream_receiver_hw_xe2_hpg_core.cpp @@ -0,0 +1,325 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/gmm_helper/client_context/gmm_client_context.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/source/xe2_hpg_core/hw_info.h" + +using Family = NEO::Xe2HpgCoreFamily; + +#include "shared/source/command_stream/command_stream_receiver_hw_dg2_and_later.inl" +#include "shared/source/command_stream/command_stream_receiver_hw_heap_addressing.inl" +#include "shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl" +#include "shared/source/gmm_helper/gmm.h" +#include "shared/source/helpers/blit_commands_helper_xehp_and_later.inl" +#include "shared/source/helpers/blit_properties.h" +#include "shared/source/helpers/populate_factory.h" +#include "shared/source/helpers/register_offsets.h" +#include "shared/source/helpers/state_base_address_xehp_and_later.inl" + +namespace NEO { +static auto gfxCore = IGFX_XE2_HPG_CORE; + +template <> +bool ImplicitFlushSettings::defaultSettingForNewResource = false; +template <> +bool ImplicitFlushSettings::defaultSettingForGpuIdle = false; +template class ImplicitFlushSettings; + +template <> +void populateFactoryTable>() { + extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE]; + commandStreamReceiverFactory[gfxCore] = DeviceCommandStreamReceiver::create; +} + +template <> +void CommandStreamReceiverHw::programEnginePrologue(LinearStream &csr) { + if (!this->isEnginePrologueSent) { + if (globalFenceAllocation) { + EncodeMemoryFence::encodeSystemMemoryFence(csr, globalFenceAllocation); + } + this->isEnginePrologueSent = true; + } +} + +template <> +size_t CommandStreamReceiverHw::getCmdSizeForPrologue() const { + if (!this->isEnginePrologueSent) { + if (globalFenceAllocation) { + return EncodeMemoryFence::getSystemMemoryFenceSize(); + } + } + return 0u; +} + +template <> +void BlitCommandsHelper::appendBlitCommandsBlockCopy(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) { + using XY_BLOCK_COPY_BLT = typename Family::XY_BLOCK_COPY_BLT; + + uint8_t srcCompressionFormat = 0; + uint8_t dstCompressionFormat = 0; + auto dstAllocation = blitProperties.dstAllocation; + auto srcAllocation = blitProperties.srcAllocation; + + if (srcAllocation->isCompressionEnabled()) { + auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); + srcCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); + } + + if (dstAllocation->isCompressionEnabled()) { + auto resourceFormat = dstAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); + dstCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); + } + + if (debugManager.flags.ForceBufferCompressionFormat.get() != -1) { + if (srcAllocation->isCompressionEnabled()) { + srcCompressionFormat = static_cast(debugManager.flags.ForceBufferCompressionFormat.get()); + } + if (dstAllocation->isCompressionEnabled()) { + dstCompressionFormat = static_cast(debugManager.flags.ForceBufferCompressionFormat.get()); + } + } + + DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) && + (blitProperties.dstAllocation != blitProperties.srcAllocation || !blitProperties.dstAllocation->isCompressionEnabled())); + + blitCmd.setSourceCompressionFormat(static_cast(srcCompressionFormat)); + blitCmd.setDestinationCompressionFormat(static_cast(dstCompressionFormat)); + + if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.dstAllocation->getMemoryPool())) { + blitCmd.setDestinationTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); + } + if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.srcAllocation->getMemoryPool())) { + blitCmd.setSourceTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); + } + + if (debugManager.flags.OverrideBlitterTargetMemory.get() != -1) { + if (debugManager.flags.OverrideBlitterTargetMemory.get() == 0u) { + blitCmd.setDestinationTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); + blitCmd.setSourceTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); + } else if (debugManager.flags.OverrideBlitterTargetMemory.get() == 1u) { + blitCmd.setDestinationTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM); + blitCmd.setSourceTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM); + } + } + + appendExtraMemoryProperties(blitCmd, rootDeviceEnvironment); + + blitCmd.setSourceSurfaceWidth(blitCmd.getDestinationX2CoordinateRight()); + blitCmd.setSourceSurfaceHeight(blitCmd.getDestinationY2CoordinateBottom()); + + blitCmd.setDestinationSurfaceWidth(blitCmd.getDestinationX2CoordinateRight()); + blitCmd.setDestinationSurfaceHeight(blitCmd.getDestinationY2CoordinateBottom()); + + if (blitCmd.getDestinationY2CoordinateBottom() > 1) { + blitCmd.setDestinationSurfaceType(XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_2D); + blitCmd.setSourceSurfaceType(XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_2D); + } else { + blitCmd.setDestinationSurfaceType(XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_1D); + blitCmd.setSourceSurfaceType(XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_1D); + } + + auto mocs = rootDeviceEnvironment.getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + if (debugManager.flags.OverrideBlitterMocs.get() != -1) { + mocs = static_cast(debugManager.flags.OverrideBlitterMocs.get()); + } + + blitCmd.setDestinationMOCS(mocs); + blitCmd.setSourceMOCS(mocs); +} + +template <> +template +void BlitCommandsHelper::appendBlitCommandsForBuffer(const BlitProperties &blitProperties, T &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) { + appendBlitCommandsMemCopy(blitProperties, blitCmd, rootDeviceEnvironment); +} + +template <> +uint32_t BlitCommandsHelper::getAvailableBytesPerPixel(size_t copySize, uint32_t srcOrigin, uint32_t dstOrigin, size_t srcSize, size_t dstSize) { + return 1; +} + +template <> +void BlitCommandsHelper::appendBlitCommandsMemCopy(const BlitProperties &blitProperites, typename Family::XY_COPY_BLT &blitCmd, + const RootDeviceEnvironment &rootDeviceEnvironment) { + using MEM_COPY = typename Family::MEM_COPY; + using COMPRESSION_FORMAT30 = typename MEM_COPY::COMPRESSION_FORMAT30; + + auto dstAllocation = blitProperites.dstAllocation; + auto srcAllocation = blitProperites.srcAllocation; + + if (blitCmd.getDestinationY2CoordinateBottom() > 1) { + blitCmd.setCopyType(MEM_COPY::COPY_TYPE::COPY_TYPE_MATRIX_COPY); + } else { + blitCmd.setCopyType(MEM_COPY::COPY_TYPE::COPY_TYPE_LINEAR_COPY); + } + + auto mocs = rootDeviceEnvironment.getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + if (debugManager.flags.OverrideBlitterMocs.get() != -1) { + mocs = static_cast(debugManager.flags.OverrideBlitterMocs.get()); + } + blitCmd.setDestinationMOCS(mocs); + blitCmd.setSourceMOCS(mocs); + + uint8_t compressionFormat = 0; + + if (dstAllocation->isCompressionEnabled()) { + auto resourceFormat = dstAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); + compressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); + } else if (srcAllocation->isCompressionEnabled()) { + auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); + compressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); + } + + if (debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.get()) { + if (!MemoryPoolHelper::isSystemMemoryPool(srcAllocation->getMemoryPool()) || !MemoryPoolHelper::isSystemMemoryPool(dstAllocation->getMemoryPool())) { + compressionFormat = static_cast(debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()); + } + } + + blitCmd.setCompressionFormat(static_cast(compressionFormat)); + + DEBUG_BREAK_IF(AuxTranslationDirection::none != blitProperites.auxTranslationDirection); +} + +template <> +template <> +void BlitCommandsHelper::dispatchBlitMemoryFill<1>(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth) { + using MEM_SET = typename Family::MEM_SET; + using COMPRESSION_FORMAT30 = typename MEM_SET::COMPRESSION_FORMAT30; + auto blitCmd = Family::cmdInitMemSet; + + auto mocs = rootDeviceEnvironment.getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + if (debugManager.flags.OverrideBlitterMocs.get() != -1) { + mocs = static_cast(debugManager.flags.OverrideBlitterMocs.get()); + } + blitCmd.setDestinationMOCS(mocs); + + if (dstAlloc->isCompressionEnabled()) { + auto resourceFormat = dstAlloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); + auto compressionFormat = static_cast(rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat)); + blitCmd.setCompressionFormat(compressionFormat); + } + + if (debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.get()) { + if (!MemoryPoolHelper::isSystemMemoryPool(dstAlloc->getMemoryPool())) { + blitCmd.setCompressionFormat(debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()); + } + } + + blitCmd.setFillData(*pattern); + + auto sizeToFill = size; + while (sizeToFill != 0) { + auto tmpCmd = blitCmd; + tmpCmd.setDestinationStartAddress(ptrOffset(dstAlloc->getGpuAddress(), static_cast(offset))); + size_t height = 0; + size_t width = 0; + if (sizeToFill <= BlitterConstants::maxBlitSetWidth) { + width = sizeToFill; + height = 1; + } else { + width = BlitterConstants::maxBlitSetWidth; + height = std::min((sizeToFill / width), BlitterConstants::maxBlitSetHeight); + if (height > 1) { + tmpCmd.setFillType(MEM_SET::FILL_TYPE::FILL_TYPE_MATRIX_FILL); + } + } + tmpCmd.setFillWidth(static_cast(width)); + tmpCmd.setFillHeight(static_cast(height)); + tmpCmd.setDestinationPitch(static_cast(width)); + + auto cmd = linearStream.getSpaceForCmd(); + *cmd = tmpCmd; + + auto blitSize = width * height; + offset += blitSize; + sizeToFill -= blitSize; + } +} + +template <> +void BlitCommandsHelper::encodeProfilingStartMmios(LinearStream &cmdStream, const TagNodeBase ×tampPacketNode) { + auto timestampContextStartGpuAddress = TimestampPacketHelper::getContextStartGpuAddress(timestampPacketNode); + auto timestampGlobalStartAddress = TimestampPacketHelper::getGlobalStartGpuAddress(timestampPacketNode); + + EncodeStoreMMIO::encode(cmdStream, RegisterOffsets::gpThreadTimeRegAddressOffsetHigh, timestampContextStartGpuAddress + sizeof(uint32_t), false, nullptr); + EncodeStoreMMIO::encode(cmdStream, RegisterOffsets::globalTimestampUn, timestampGlobalStartAddress + sizeof(uint32_t), false, nullptr); + + EncodeStoreMMIO::encode(cmdStream, RegisterOffsets::gpThreadTimeRegAddressOffsetLow, timestampContextStartGpuAddress, false, nullptr); + EncodeStoreMMIO::encode(cmdStream, RegisterOffsets::globalTimestampLdw, timestampGlobalStartAddress, false, nullptr); +} + +template <> +void BlitCommandsHelper::encodeProfilingEndMmios(LinearStream &cmdStream, const TagNodeBase ×tampPacketNode) { + auto timestampContextEndGpuAddress = TimestampPacketHelper::getContextEndGpuAddress(timestampPacketNode); + auto timestampGlobalEndAddress = TimestampPacketHelper::getGlobalEndGpuAddress(timestampPacketNode); + + EncodeStoreMMIO::encode(cmdStream, RegisterOffsets::gpThreadTimeRegAddressOffsetHigh, timestampContextEndGpuAddress + sizeof(uint32_t), false, nullptr); + EncodeStoreMMIO::encode(cmdStream, RegisterOffsets::globalTimestampUn, timestampGlobalEndAddress + sizeof(uint32_t), false, nullptr); + + EncodeStoreMMIO::encode(cmdStream, RegisterOffsets::gpThreadTimeRegAddressOffsetLow, timestampContextEndGpuAddress, false, nullptr); + EncodeStoreMMIO::encode(cmdStream, RegisterOffsets::globalTimestampLdw, timestampGlobalEndAddress, false, nullptr); +} + +template <> +size_t BlitCommandsHelper::getProfilingMmioCmdsSize() { + return 8 * sizeof(typename Family::MI_STORE_REGISTER_MEM); +} + +template <> +void setCompressionParamsForFillOperation(typename Family::XY_COLOR_BLT &xyColorBlt) { +} + +template class CommandStreamReceiverHw; +template struct BlitCommandsHelper; +template void BlitCommandsHelper::appendColorDepth(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd); +template void BlitCommandsHelper::appendColorDepth(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd); +template void BlitCommandsHelper::appendBlitCommandsForBuffer(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment); + +const Family::COMPUTE_WALKER Family::cmdInitGpgpuWalker = Family::COMPUTE_WALKER::sInit(); +const Family::CFE_STATE Family::cmdInitCfeState = Family::CFE_STATE::sInit(); +const Family::INTERFACE_DESCRIPTOR_DATA Family::cmdInitInterfaceDescriptorData = Family::INTERFACE_DESCRIPTOR_DATA::sInit(); +const Family::MI_BATCH_BUFFER_START Family::cmdInitBatchBufferStart = Family::MI_BATCH_BUFFER_START::sInit(); +const Family::MI_BATCH_BUFFER_END Family::cmdInitBatchBufferEnd = Family::MI_BATCH_BUFFER_END::sInit(); +const Family::PIPE_CONTROL Family::cmdInitPipeControl = Family::PIPE_CONTROL::sInit(); +const Family::STATE_COMPUTE_MODE Family::cmdInitStateComputeMode = Family::STATE_COMPUTE_MODE::sInit(); +const Family::_3DSTATE_BINDING_TABLE_POOL_ALLOC Family::cmdInitStateBindingTablePoolAlloc = + Family::_3DSTATE_BINDING_TABLE_POOL_ALLOC::sInit(); +const Family::MI_SEMAPHORE_WAIT Family::cmdInitMiSemaphoreWait = Family::MI_SEMAPHORE_WAIT::sInit(); +const Family::RENDER_SURFACE_STATE Family::cmdInitRenderSurfaceState = Family::RENDER_SURFACE_STATE::sInit(); +const Family::POSTSYNC_DATA Family::cmdInitPostSyncData = Family::POSTSYNC_DATA::sInit(); +const Family::MI_SET_PREDICATE Family::cmdInitSetPredicate = Family::MI_SET_PREDICATE::sInit(); +const Family::MI_LOAD_REGISTER_IMM Family::cmdInitLoadRegisterImm = Family::MI_LOAD_REGISTER_IMM::sInit(); +const Family::MI_LOAD_REGISTER_REG Family::cmdInitLoadRegisterReg = Family::MI_LOAD_REGISTER_REG::sInit(); +const Family::MI_LOAD_REGISTER_MEM Family::cmdInitLoadRegisterMem = Family::MI_LOAD_REGISTER_MEM::sInit(); +const Family::MI_STORE_DATA_IMM Family::cmdInitStoreDataImm = Family::MI_STORE_DATA_IMM::sInit(); +const Family::MI_STORE_REGISTER_MEM Family::cmdInitStoreRegisterMem = Family::MI_STORE_REGISTER_MEM::sInit(); +const Family::MI_NOOP Family::cmdInitNoop = Family::MI_NOOP::sInit(); +const Family::MI_REPORT_PERF_COUNT Family::cmdInitReportPerfCount = Family::MI_REPORT_PERF_COUNT::sInit(); +const Family::MI_ATOMIC Family::cmdInitAtomic = Family::MI_ATOMIC::sInit(); +const Family::PIPELINE_SELECT Family::cmdInitPipelineSelect = Family::PIPELINE_SELECT::sInit(); +const Family::MI_ARB_CHECK Family::cmdInitArbCheck = Family::MI_ARB_CHECK::sInit(); +const Family::STATE_BASE_ADDRESS Family::cmdInitStateBaseAddress = Family::STATE_BASE_ADDRESS::sInit(); +const Family::MEDIA_SURFACE_STATE Family::cmdInitMediaSurfaceState = Family::MEDIA_SURFACE_STATE::sInit(); +const Family::SAMPLER_STATE Family::cmdInitSamplerState = Family::SAMPLER_STATE::sInit(); +const Family::BINDING_TABLE_STATE Family::cmdInitBindingTableState = Family::BINDING_TABLE_STATE::sInit(); +const Family::MI_USER_INTERRUPT Family::cmdInitUserInterrupt = Family::MI_USER_INTERRUPT::sInit(); +const Family::MI_CONDITIONAL_BATCH_BUFFER_END cmdInitConditionalBatchBufferEnd = Family::MI_CONDITIONAL_BATCH_BUFFER_END::sInit(); +const Family::MI_FLUSH_DW Family::cmdInitMiFlushDw = Family::MI_FLUSH_DW::sInit(); +const Family::XY_BLOCK_COPY_BLT Family::cmdInitXyBlockCopyBlt = Family::XY_BLOCK_COPY_BLT::sInit(); +const Family::MEM_COPY Family::cmdInitXyCopyBlt = Family::MEM_COPY::sInit(); +const Family::XY_FAST_COLOR_BLT Family::cmdInitXyColorBlt = Family::XY_FAST_COLOR_BLT::sInit(); +const Family::STATE_PREFETCH Family::cmdInitStatePrefetch = Family::STATE_PREFETCH::sInit(); +const Family::_3DSTATE_BTD Family::cmd3dStateBtd = Family::_3DSTATE_BTD::sInit(); +const Family::_3DSTATE_BTD_BODY Family::cmd3dStateBtdBody = Family::_3DSTATE_BTD_BODY::sInit(); +const Family::MI_MEM_FENCE Family::cmdInitMemFence = Family::MI_MEM_FENCE::sInit(); +const Family::MEM_SET Family::cmdInitMemSet = Family::MEM_SET::sInit(); +const Family::STATE_SIP Family::cmdInitStateSip = Family::STATE_SIP::sInit(); +const Family::STATE_CONTEXT_DATA_BASE_ADDRESS Family::cmdInitStateContextDataBaseAddress = Family::STATE_CONTEXT_DATA_BASE_ADDRESS::sInit(); +const Family::STATE_SYSTEM_MEM_FENCE_ADDRESS Family::cmdInitStateSystemMemFenceAddress = Family::STATE_SYSTEM_MEM_FENCE_ADDRESS::sInit(); +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/command_stream_receiver_simulated_common_hw_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/command_stream_receiver_simulated_common_hw_xe2_hpg_core.cpp new file mode 100644 index 0000000000..b8931f540a --- /dev/null +++ b/shared/source/xe2_hpg_core/command_stream_receiver_simulated_common_hw_xe2_hpg_core.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/command_stream_receiver_simulated_common_hw_xehp_and_later.inl" +#include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/helpers/ptr_math.h" + +namespace NEO { +using Family = Xe2HpgCoreFamily; + +template <> +bool CommandStreamReceiverSimulatedCommonHw::expectMemoryEqual(void *gfxAddress, const void *srcAddress, size_t length) { + auto gpuAddress = peekGmmHelper()->decanonize(castToUint64(gfxAddress)); + return this->expectMemory(reinterpret_cast(gpuAddress), srcAddress, length, + AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual); +} +template <> +bool CommandStreamReceiverSimulatedCommonHw::expectMemoryNotEqual(void *gfxAddress, const void *srcAddress, size_t length) { + auto gpuAddress = peekGmmHelper()->decanonize(castToUint64(gfxAddress)); + return this->expectMemory(reinterpret_cast(gpuAddress), srcAddress, length, + AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual); +} +template <> +bool CommandStreamReceiverSimulatedCommonHw::expectMemoryCompressed(void *gfxAddress, const void *srcAddress, size_t length) { + auto gpuAddress = peekGmmHelper()->decanonize(castToUint64(gfxAddress)); + return this->expectMemory(reinterpret_cast(gpuAddress), srcAddress, length, + AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual); +} + +template class CommandStreamReceiverSimulatedCommonHw; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/create_device_command_stream_receiver_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/create_device_command_stream_receiver_xe2_hpg_core.cpp new file mode 100644 index 0000000000..04def9161f --- /dev/null +++ b/shared/source/xe2_hpg_core/create_device_command_stream_receiver_xe2_hpg_core.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/device_command_stream.h" +#include "shared/source/execution_environment/execution_environment.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +#include "create_command_stream_receiver.inl" + +namespace NEO { + +template <> +CommandStreamReceiver *createDeviceCommandStreamReceiver(bool withAubDump, + ExecutionEnvironment &executionEnvironment, + uint32_t rootDeviceIndex, + const DeviceBitfield deviceBitfield) { + return createCommandStreamReceiver(withAubDump, executionEnvironment, rootDeviceIndex, deviceBitfield); +} + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/debugger_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/debugger_xe2_hpg_core.cpp new file mode 100644 index 0000000000..344c22c260 --- /dev/null +++ b/shared/source/xe2_hpg_core/debugger_xe2_hpg_core.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/debugger/debugger_l0.inl" +#include "shared/source/debugger/debugger_l0_tgllp_and_later.inl" +#include "shared/source/helpers/populate_factory.h" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +namespace NEO { + +using GfxFamily = NEO::Xe2HpgCoreFamily; +static auto coreFamily = IGFX_XE2_HPG_CORE; + +template <> +void populateFactoryTable>() { + extern DebugerL0CreateFn debuggerL0Factory[IGFX_MAX_CORE]; + debuggerL0Factory[coreFamily] = DebuggerL0Hw::allocate; +} +template class DebuggerL0Hw; + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/definitions/gfx_core_helper_xe2_hpg_core_additional.inl b/shared/source/xe2_hpg_core/definitions/gfx_core_helper_xe2_hpg_core_additional.inl new file mode 100644 index 0000000000..4fa4901f25 --- /dev/null +++ b/shared/source/xe2_hpg_core/definitions/gfx_core_helper_xe2_hpg_core_additional.inl @@ -0,0 +1,6 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ diff --git a/shared/source/xe2_hpg_core/enable_compiler_product_helper_bmg.cpp b/shared/source/xe2_hpg_core/enable_compiler_product_helper_bmg.cpp new file mode 100644 index 0000000000..3d962c3abc --- /dev/null +++ b/shared/source/xe2_hpg_core/enable_compiler_product_helper_bmg.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/compiler_product_helper.h" +#include "shared/source/helpers/compiler_product_helper_base.inl" +#include "shared/source/helpers/compiler_product_helper_enable_subgroup_local_block_io.inl" +#include "shared/source/helpers/compiler_product_helper_mtl_and_later.inl" +#include "shared/source/helpers/compiler_product_helper_tgllp_and_later.inl" +#include "shared/source/helpers/compiler_product_helper_xe2_hpg_and_later.inl" +#include "shared/source/helpers/compiler_product_helper_xe_hp_and_later.inl" +#include "shared/source/helpers/compiler_product_helper_xe_hpc_and_later.inl" + +#include "platforms.h" + +namespace NEO { +template <> +uint32_t CompilerProductHelperHw::getDefaultHwIpVersion() const { + return AOT::BMG_G21_B0; +} + +static EnableCompilerProductHelper enableCompilerProductHelperBMG; + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/enable_compiler_product_helper_lnl.cpp b/shared/source/xe2_hpg_core/enable_compiler_product_helper_lnl.cpp new file mode 100644 index 0000000000..a2863dbaf3 --- /dev/null +++ b/shared/source/xe2_hpg_core/enable_compiler_product_helper_lnl.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/compiler_product_helper.h" +#include "shared/source/helpers/compiler_product_helper_base.inl" +#include "shared/source/helpers/compiler_product_helper_enable_subgroup_local_block_io.inl" +#include "shared/source/helpers/compiler_product_helper_mtl_and_later.inl" +#include "shared/source/helpers/compiler_product_helper_tgllp_and_later.inl" +#include "shared/source/helpers/compiler_product_helper_xe2_hpg_and_later.inl" +#include "shared/source/helpers/compiler_product_helper_xe_hp_and_later.inl" +#include "shared/source/helpers/compiler_product_helper_xe_hpc_and_later.inl" + +#include "platforms.h" + +namespace NEO { +template <> +uint32_t CompilerProductHelperHw::getDefaultHwIpVersion() const { + return AOT::LNL_B0; +} + +static EnableCompilerProductHelper enableCompilerProductHelperLNL; + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/enable_family_full_core_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/enable_family_full_core_xe2_hpg_core.cpp new file mode 100644 index 0000000000..bafc8ba078 --- /dev/null +++ b/shared/source/xe2_hpg_core/enable_family_full_core_xe2_hpg_core.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/aub_command_stream_receiver_hw.h" +#include "shared/source/command_stream/command_stream_receiver_hw.h" +#include "shared/source/command_stream/tbx_command_stream_receiver_hw.h" +#include "shared/source/debugger/debugger_l0.h" +#include "shared/source/helpers/gfx_core_helper.h" +#include "shared/source/helpers/populate_factory.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +namespace NEO { + +extern GfxCoreHelperCreateFunctionType gfxCoreHelperFactory[IGFX_MAX_CORE]; + +using Family = Xe2HpgCoreFamily; +static auto gfxFamily = IGFX_XE2_HPG_CORE; + +struct EnableCoreXe2HpgCore { + EnableCoreXe2HpgCore() { + gfxCoreHelperFactory[gfxFamily] = GfxCoreHelperHw::create; + populateFactoryTable>(); + populateFactoryTable>(); + populateFactoryTable>(); + populateFactoryTable>(); + } +}; + +static EnableCoreXe2HpgCore enable; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/enable_product_helper_bmg.cpp b/shared/source/xe2_hpg_core/enable_product_helper_bmg.cpp new file mode 100644 index 0000000000..0323fc87c2 --- /dev/null +++ b/shared/source/xe2_hpg_core/enable_product_helper_bmg.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/os_interface/product_helper_hw.h" +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_bmg.h" + +namespace NEO { + +static EnableProductHelper enableBMG; + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/enable_product_helper_lnl.cpp b/shared/source/xe2_hpg_core/enable_product_helper_lnl.cpp new file mode 100644 index 0000000000..6e056e9d2b --- /dev/null +++ b/shared/source/xe2_hpg_core/enable_product_helper_lnl.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/os_interface/product_helper_hw.h" +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_lnl.h" + +namespace NEO { + +static EnableProductHelper enableLNL; + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/enable_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/enable_xe2_hpg_core.cpp new file mode 100644 index 0000000000..7df51efb5e --- /dev/null +++ b/shared/source/xe2_hpg_core/enable_xe2_hpg_core.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/cache_policy_dg2_and_later.inl" +#include "shared/source/helpers/enable_product.inl" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +namespace NEO { + +#ifdef SUPPORT_BMG +template struct L1CachePolicyHelper; +static EnableGfxProductHw enableGfxProductHwBMG; + +#endif + +#ifdef SUPPORT_LNL +template struct L1CachePolicyHelper; +static EnableGfxProductHw enableGfxProductHwLNL; +#endif + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp new file mode 100644 index 0000000000..213ff349ba --- /dev/null +++ b/shared/source/xe2_hpg_core/gfx_core_helper_xe2_hpg_core.cpp @@ -0,0 +1,412 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/aub_mapper.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +using Family = NEO::Xe2HpgCoreFamily; + +#include "shared/source/command_container/command_encoder.h" +#include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/gmm_helper/client_context/gmm_client_context.h" +#include "shared/source/helpers/flat_batch_buffer_helper_hw.inl" +#include "shared/source/helpers/gfx_core_helper_base.inl" +#include "shared/source/helpers/gfx_core_helper_dg2_and_later.inl" +#include "shared/source/helpers/gfx_core_helper_pvc_and_later.inl" +#include "shared/source/helpers/gfx_core_helper_tgllp_and_later.inl" +#include "shared/source/helpers/gfx_core_helper_xe2_and_later.inl" +#include "shared/source/helpers/gfx_core_helper_xehp_and_later.inl" +#include "shared/source/helpers/local_id_gen.h" +#include "shared/source/helpers/simd_helper.h" +#include "shared/source/release_helper/release_helper.h" + +#include "gfx_core_helper_xe2_hpg_core_additional.inl" + +namespace NEO { + +template <> +const AuxTranslationMode GfxCoreHelperHw::defaultAuxTranslationMode = AuxTranslationMode::none; + +template <> +uint8_t GfxCoreHelperHw::getBarriersCountFromHasBarriers(uint8_t hasBarriers) const { + static constexpr uint8_t possibleBarriersCounts[] = { + 0u, // 0 + 1u, // 1 + 2u, // 2 + 4u, // 3 + 8u, // 4 + 16u, // 5 + 24u, // 6 + 32u, // 7 + }; + return possibleBarriersCounts[hasBarriers]; +} + +template <> +const EngineInstancesContainer GfxCoreHelperHw::getGpgpuEngineInstances(const RootDeviceEnvironment &rootDeviceEnvironment) const { + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + auto defaultEngine = getChosenEngineType(hwInfo); + EngineInstancesContainer engines; + + if (hwInfo.featureTable.flags.ftrCCSNode) { + for (uint32_t i = 0; i < hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled; i++) { + engines.push_back({static_cast(i + aub_stream::ENGINE_CCS), EngineUsage::regular}); + } + } + + engines.push_back({aub_stream::ENGINE_CCCS, EngineUsage::regular}); + engines.push_back({defaultEngine, EngineUsage::lowPriority}); + engines.push_back({defaultEngine, EngineUsage::internal}); + + if (hwInfo.capabilityTable.blitterOperationsSupported) { + if (hwInfo.featureTable.ftrBcsInfo.test(0)) { + engines.push_back({aub_stream::EngineType::ENGINE_BCS, EngineUsage::regular}); // Main copy engine + engines.push_back({aub_stream::EngineType::ENGINE_BCS, EngineUsage::internal}); // Internal usage + } + + for (uint32_t i = 1; i < hwInfo.featureTable.ftrBcsInfo.size(); i++) { + if (hwInfo.featureTable.ftrBcsInfo.test(i)) { + auto engineType = static_cast((i - 1) + aub_stream::ENGINE_BCS1); // Link copy engine + engines.push_back({engineType, EngineUsage::regular}); + uint32_t internalIndex = 3; + if (debugManager.flags.ForceBCSForInternalCopyEngine.get() != -1) { + internalIndex = debugManager.flags.ForceBCSForInternalCopyEngine.get(); + } + if (i == internalIndex) { + engines.push_back({engineType, EngineUsage::internal}); // BCS3 for internal usage + } + } + } + } + + return engines; +}; + +template <> +EngineGroupType GfxCoreHelperHw::getEngineGroupType(aub_stream::EngineType engineType, EngineUsage engineUsage, const HardwareInfo &hwInfo) const { + if (engineType == aub_stream::ENGINE_CCCS) { + return EngineGroupType::renderCompute; + } + if (engineType >= aub_stream::ENGINE_CCS && engineType < (aub_stream::ENGINE_CCS + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled)) { + if (engineUsage == EngineUsage::cooperative) { + return EngineGroupType::cooperativeCompute; + } + return EngineGroupType::compute; + } + if (engineType == aub_stream::ENGINE_BCS) { + return EngineGroupType::copy; + } + if (engineType >= aub_stream::ENGINE_BCS1 && engineType < aub_stream::ENGINE_BCS1 + hwInfo.featureTable.ftrBcsInfo.size() - 1) { + return EngineGroupType::linkedCopy; + } + UNRECOVERABLE_IF(true); +} + +template <> +void GfxCoreHelperHw::adjustDefaultEngineType(HardwareInfo *pHwInfo, const ProductHelper &productHelper, AILConfiguration *ailConfiguration) { + if (!pHwInfo->featureTable.flags.ftrCCSNode) { + pHwInfo->capabilityTable.defaultEngineType = aub_stream::EngineType::ENGINE_CCCS; + } +} + +template <> +uint32_t GfxCoreHelperHw::getMinimalSIMDSize() const { + return 16u; +} + +template <> +uint32_t GfxCoreHelperHw::getMocsIndex(const GmmHelper &gmmHelper, bool l3enabled, bool l1enabled) const { + if (l3enabled) { + return gmmHelper.getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) >> 1; + } + return gmmHelper.getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED) >> 1; +} + +template <> +bool GfxCoreHelperHw::isTimestampWaitSupportedForQueues() const { + return false; +} + +template <> +const StackVec GfxCoreHelperHw::getDeviceSubGroupSizes() const { + return {16, 32}; +} + +template <> +aub_stream::MMIOList GfxCoreHelperHw::getExtraMmioList(const HardwareInfo &hwInfo, const GmmHelper &gmmHelper) const { + aub_stream::MMIOList mmioList; + + if (compressedBuffersSupported(hwInfo) || compressedImagesSupported(hwInfo)) { + uint32_t format = gmmHelper.getClientContext()->getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT::GMM_FORMAT_GENERIC_8BIT); + + if (debugManager.flags.ForceBufferCompressionFormat.get() != -1) { + format = static_cast(debugManager.flags.ForceBufferCompressionFormat.get()); + } + + UNRECOVERABLE_IF(format > 0xF); + + mmioList.push_back({0x4148, format}); // [0:3] compression format + } + + return mmioList; +} + +template <> +size_t MemorySynchronizationCommands::getSizeForSingleAdditionalSynchronization(const RootDeviceEnvironment &rootDeviceEnvironment) { + auto programGlobalFenceAsMiMemFenceCommandInCommandStream = true; + if (debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.get() != -1) { + programGlobalFenceAsMiMemFenceCommandInCommandStream = !!debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.get(); + } + + if (programGlobalFenceAsMiMemFenceCommandInCommandStream) { + return sizeof(Family::MI_MEM_FENCE); + } else { + return EncodeSemaphore::getSizeMiSemaphoreWait(); + } +} + +template <> +void MemorySynchronizationCommands::setAdditionalSynchronization(void *&commandsBuffer, uint64_t gpuAddress, bool acquire, const RootDeviceEnvironment &rootDeviceEnvironment) { + using MI_MEM_FENCE = typename Family::MI_MEM_FENCE; + using MI_SEMAPHORE_WAIT = typename Family::MI_SEMAPHORE_WAIT; + auto programGlobalFenceAsMiMemFenceCommandInCommandStream = true; + if (debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.get() != -1) { + programGlobalFenceAsMiMemFenceCommandInCommandStream = !!debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.get(); + } + if (programGlobalFenceAsMiMemFenceCommandInCommandStream) { + MI_MEM_FENCE miMemFence = Family::cmdInitMemFence; + if (acquire) { + miMemFence.setFenceType(Family::MI_MEM_FENCE::FENCE_TYPE::FENCE_TYPE_ACQUIRE); + } else { + miMemFence.setFenceType(Family::MI_MEM_FENCE::FENCE_TYPE::FENCE_TYPE_RELEASE); + } + *reinterpret_cast(commandsBuffer) = miMemFence; + commandsBuffer = ptrOffset(commandsBuffer, sizeof(MI_MEM_FENCE)); + } else { + EncodeSemaphore::programMiSemaphoreWait(reinterpret_cast(commandsBuffer), + gpuAddress, + EncodeSemaphore::invalidHardwareTag, + MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD, + false, true, false, false, false); + commandsBuffer = ptrOffset(commandsBuffer, EncodeSemaphore::getSizeMiSemaphoreWait()); + } +} + +template <> +bool MemorySynchronizationCommands::isBarrierWaRequired(const RootDeviceEnvironment &rootDeviceEnvironment) { + if (debugManager.flags.DisablePipeControlPrecedingPostSyncCommand.get() == 1) { + return true; + } + return false; +} + +template <> +size_t MemorySynchronizationCommands::getSizeForAdditonalSynchronization(const RootDeviceEnvironment &rootDeviceEnvironment) { + return (debugManager.flags.DisablePipeControlPrecedingPostSyncCommand.get() == 1 ? 2 : 1) * getSizeForSingleAdditionalSynchronization(rootDeviceEnvironment); +} + +template <> +void MemorySynchronizationCommands::setBarrierWaFlags(void *barrierCmd) { + auto &pipeControl = *reinterpret_cast(barrierCmd); + + pipeControl.setCommandStreamerStallEnable(true); + pipeControl.setDataportFlush(true); + pipeControl.setUnTypedDataPortCacheFlush(true); +} + +template <> +inline void MemorySynchronizationCommands::setBarrierExtraProperties(void *barrierCmd, PipeControlArgs &args) { + auto &pipeControl = *reinterpret_cast(barrierCmd); + + pipeControl.setDataportFlush(args.hdcPipelineFlush); + pipeControl.setUnTypedDataPortCacheFlush(args.unTypedDataPortCacheFlush); + pipeControl.setCompressionControlSurfaceCcsFlush(args.compressionControlSurfaceCcsFlush); + pipeControl.setWorkloadPartitionIdOffsetEnable(args.workloadPartitionOffset); + pipeControl.setAmfsFlushEnable(args.amfsFlushEnable); + + if (debugManager.flags.FlushAllCaches.get()) { + pipeControl.setDataportFlush(true); + pipeControl.setUnTypedDataPortCacheFlush(true); + pipeControl.setCompressionControlSurfaceCcsFlush(true); + } + if (debugManager.flags.DoNotFlushCaches.get()) { + pipeControl.setDataportFlush(false); + pipeControl.setUnTypedDataPortCacheFlush(false); + pipeControl.setCompressionControlSurfaceCcsFlush(false); + } +} + +template <> +void GfxCoreHelperHw::setL1CachePolicy(bool useL1Cache, typename Family::RENDER_SURFACE_STATE *surfaceState, const HardwareInfo *hwInfo) const { + if (useL1Cache) { + surfaceState->setL1CachePolicyL1CacheControl(Family::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB); + if (debugManager.flags.OverrideL1CacheControlInSurfaceStateForScratchSpace.get() != -1) { + surfaceState->setL1CachePolicyL1CacheControl(static_cast(debugManager.flags.OverrideL1CacheControlInSurfaceStateForScratchSpace.get())); + } + } +} + +template <> +void GfxCoreHelperHw::setExtraAllocationData(AllocationData &allocationData, const AllocationProperties &properties, const RootDeviceEnvironment &rootDeviceEnvironment) const { + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + + if (hwInfo.featureTable.flags.ftrLocalMemory) { + if (properties.allocationType == AllocationType::timestampPacketTagBuffer) { + allocationData.flags.useSystemMemory = false; + } + + if (properties.allocationType == AllocationType::commandBuffer || + properties.allocationType == AllocationType::ringBuffer || + properties.allocationType == AllocationType::semaphoreBuffer) { + allocationData.flags.useSystemMemory = false; + allocationData.flags.requiresCpuAccess = true; + } + } +} + +template <> +uint32_t GfxCoreHelperHw::alignSlmSize(uint32_t slmSize) const { + const uint32_t alignedSlmSizes[] = { + 0u, + 1u * MemoryConstants::kiloByte, + 2u * MemoryConstants::kiloByte, + 4u * MemoryConstants::kiloByte, + 8u * MemoryConstants::kiloByte, + 16u * MemoryConstants::kiloByte, + 24u * MemoryConstants::kiloByte, + 32u * MemoryConstants::kiloByte, + 48u * MemoryConstants::kiloByte, + 64u * MemoryConstants::kiloByte, + 96u * MemoryConstants::kiloByte, + 128u * MemoryConstants::kiloByte, + }; + + for (auto &alignedSlmSize : alignedSlmSizes) { + if (slmSize <= alignedSlmSize) { + return alignedSlmSize; + } + } + + UNRECOVERABLE_IF(true); + return 0; +} + +template <> +uint32_t GfxCoreHelperHw::computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) const { + using SHARED_LOCAL_MEMORY_SIZE = typename Family::INTERFACE_DESCRIPTOR_DATA::SHARED_LOCAL_MEMORY_SIZE; + auto alignedSlmSize = alignSlmSize(slmSize); + + if (alignedSlmSize == 0u) { + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_0K; + } + + UNRECOVERABLE_IF(slmSize > 128u * MemoryConstants::kiloByte); + + if (alignedSlmSize > 96u * MemoryConstants::kiloByte) { + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_128K; + } + if (alignedSlmSize > 64u * MemoryConstants::kiloByte) { + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_96K; + } + if (alignedSlmSize > 48u * MemoryConstants::kiloByte) { + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_64K; + } + if (alignedSlmSize > 32u * MemoryConstants::kiloByte) { + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_48K; + } + if (alignedSlmSize > 24u * MemoryConstants::kiloByte) { + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_32K; + } + if (alignedSlmSize > 16u * MemoryConstants::kiloByte) { + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_24K; + } + if (alignedSlmSize > 8u * MemoryConstants::kiloByte) { + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_16K; + } + if (alignedSlmSize > 4u * MemoryConstants::kiloByte) { + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_8K; + } + if (alignedSlmSize > 2u * MemoryConstants::kiloByte) { + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_4K; + } + if (alignedSlmSize > 1u * MemoryConstants::kiloByte) { + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_2K; + } + return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_1K; +} + +template <> +int32_t GfxCoreHelperHw::getDefaultThreadArbitrationPolicy() const { + return ThreadArbitrationPolicy::RoundRobinAfterDependency; +} + +template <> +size_t GfxCoreHelperHw::getTimestampPacketAllocatorAlignment() const { + return MemoryConstants::cacheLineSize; +} + +template <> +size_t GfxCoreHelperHw::getPreemptionAllocationAlignment() const { + using STATE_CONTEXT_DATA_BASE_ADDRESS = Family::STATE_CONTEXT_DATA_BASE_ADDRESS; + return STATE_CONTEXT_DATA_BASE_ADDRESS::CONTEXTDATABASEADDRESS::CONTEXTDATABASEADDRESS_ALIGN_SIZE; +} + +template <> +uint32_t GfxCoreHelperHw::overrideMaxWorkGroupSize(uint32_t maxWG) const { + return std::min(maxWG, 2048u); +} + +template <> +bool GfxCoreHelperHw::isRunaloneModeRequired(DebuggingMode debuggingMode) const { + return (debuggingMode == DebuggingMode::online); +} + +template <> +uint32_t GfxCoreHelperHw::calculateNumThreadsPerThreadGroup(uint32_t simd, uint32_t totalWorkItems, uint32_t grfCount, bool isHwLocalIdGeneration, const RootDeviceEnvironment &rootDeviceEnvironment) const { + uint32_t numThreadsPerThreadGroup = getThreadsPerWG(simd, totalWorkItems); + if (debugManager.flags.RemoveRestrictionsOnNumberOfThreadsInGpgpuThreadGroup.get() == 1) { + return numThreadsPerThreadGroup; + } + auto simt = isSimd1(simd) ? 32u : simd; + uint32_t maxThreadsPerThreadGroup = 32u; + if (grfCount != GrfConfig::largeGrfNumber && ((simt == 16u) || (simt == 32u && !isHwLocalIdGeneration))) { + maxThreadsPerThreadGroup = 64u; + } + return std::min(numThreadsPerThreadGroup, maxThreadsPerThreadGroup); +} + +template <> +uint32_t GfxCoreHelperHw::adjustMaxWorkGroupSize(const uint32_t grfCount, const uint32_t simd, bool isHwLocalGeneration, const uint32_t defaultMaxGroupSize, const RootDeviceEnvironment &rootDeviceEnvironment) const { + const uint32_t threadsPerThreadGroup = calculateNumThreadsPerThreadGroup(simd, defaultMaxGroupSize, grfCount, isHwLocalGeneration, rootDeviceEnvironment); + return (threadsPerThreadGroup * simd); +} + +template <> +uint32_t GfxCoreHelperHw::getAmountOfAllocationsToFill() const { + if (debugManager.flags.SetAmountOfReusableAllocations.get() != -1) { + return debugManager.flags.SetAmountOfReusableAllocations.get(); + } + return 1u; +} + +template <> +bool GfxCoreHelperHw::usmCompressionSupported(const NEO::HardwareInfo &hwInfo) const { + if (NEO::debugManager.flags.RenderCompressedBuffersEnabled.get() != -1) { + return !!NEO::debugManager.flags.RenderCompressedBuffersEnabled.get(); + } + + return hwInfo.capabilityTable.ftrRenderCompressedBuffers; +} + +} // namespace NEO + +namespace NEO { +template class GfxCoreHelperHw; +template class FlatBatchBufferHelperHw; +template struct MemorySynchronizationCommands; +template struct LriHelper; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/hw_cmds.h b/shared/source/xe2_hpg_core/hw_cmds.h new file mode 100644 index 0000000000..2c4d7eaee4 --- /dev/null +++ b/shared/source/xe2_hpg_core/hw_cmds.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#ifdef SUPPORT_BMG +#include "hw_cmds_bmg.h" +#include "hw_info_bmg.h" +#endif + +#ifdef SUPPORT_LNL +#include "hw_cmds_lnl.h" +#include "hw_info_lnl.h" +#endif diff --git a/shared/source/xe2_hpg_core/hw_cmds_bmg.h b/shared/source/xe2_hpg_core/hw_cmds_bmg.h new file mode 100644 index 0000000000..b94cdb29fd --- /dev/null +++ b/shared/source/xe2_hpg_core/hw_cmds_bmg.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "shared/source/helpers/hw_info.h" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +namespace NEO { + +struct BMG : public Xe2HpgCoreFamily { + static const PLATFORM platform; + static const HardwareInfo hwInfo; + static FeatureTable featureTable; + static WorkaroundTable workaroundTable; + static const RuntimeCapabilityTable capabilityTable; + static void (*setupHardwareInfo)(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, uint64_t hwInfoConfig, const ReleaseHelper *releaseHelper); + static void setupFeatureAndWorkaroundTable(HardwareInfo *hwInfo); + static void setupHardwareInfoBase(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, const ReleaseHelper *releaseHelper); + static void adjustHardwareInfo(HardwareInfo *hwInfo); + + static constexpr bool isDcFlushAllowed = false; +}; + +class BmgHwConfig : public BMG { + public: + static const HardwareInfo hwInfo; + static void setupHardwareInfo(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, const ReleaseHelper *releaseHelper); + + private: + static GT_SYSTEM_INFO gtSystemInfo; +}; + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/hw_cmds_lnl.h b/shared/source/xe2_hpg_core/hw_cmds_lnl.h new file mode 100644 index 0000000000..16396424e6 --- /dev/null +++ b/shared/source/xe2_hpg_core/hw_cmds_lnl.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "shared/source/helpers/hw_info.h" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +namespace NEO { + +struct LNL : public Xe2HpgCoreFamily { + static const PLATFORM platform; + static const HardwareInfo hwInfo; + static FeatureTable featureTable; + static WorkaroundTable workaroundTable; + static const RuntimeCapabilityTable capabilityTable; + static void (*setupHardwareInfo)(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, uint64_t hwInfoConfig, const ReleaseHelper *releaseHelper); + static void setupFeatureAndWorkaroundTable(HardwareInfo *hwInfo); + static void setupHardwareInfoBase(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, const ReleaseHelper *releaseHelper); + static void adjustHardwareInfo(HardwareInfo *hwInfo); + + static constexpr bool isDcFlushAllowed = true; +}; + +class LnlHwConfig : public LNL { + public: + static void setupHardwareInfo(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, const ReleaseHelper *releaseHelper); + static const HardwareInfo hwInfo; + + private: + static GT_SYSTEM_INFO gtSystemInfo; +}; + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/hw_info.h b/shared/source/xe2_hpg_core/hw_info.h new file mode 100644 index 0000000000..a9b103716b --- /dev/null +++ b/shared/source/xe2_hpg_core/hw_info.h @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#ifdef SUPPORT_BMG +#include "hw_info_bmg.h" +#endif + +#ifdef SUPPORT_LNL +#include "hw_info_lnl.h" +#endif diff --git a/shared/source/xe2_hpg_core/hw_info_bmg.cpp b/shared/source/xe2_hpg_core/hw_info_bmg.cpp new file mode 100644 index 0000000000..1e843bdbab --- /dev/null +++ b/shared/source/xe2_hpg_core/hw_info_bmg.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_info_bmg.h" + +#include "shared/source/aub_mem_dump/definitions/aub_services.h" +#include "shared/source/command_stream/preemption_mode.h" +#include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/helpers/constants.h" +#include "shared/source/release_helper/release_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" + +#include "aubstream/engine_node.h" +namespace NEO { + +const char *HwMapper::abbreviation = "bmg"; + +const PLATFORM BMG::platform = { + IGFX_BMG, + PCH_UNKNOWN, + IGFX_XE2_HPG_CORE, + IGFX_XE2_HPG_CORE, + PLATFORM_NONE, // default init + 0, // usDeviceID + 0, // usRevId. 0 sets the stepping to A0 + 0, // usDeviceID_PCH + 0, // usRevId_PCH + GTTYPE_UNDEFINED}; + +const RuntimeCapabilityTable BMG::capabilityTable{ + EngineDirectSubmissionInitVec{ + {aub_stream::ENGINE_CCS, {true, false, false, true}}, + {aub_stream::ENGINE_CCS1, {true, false, true, true}}}, // directSubmissionEngines + {0, 0, 0, 0, false, false, false, false}, // kmdNotifyProperties + MemoryConstants::max48BitAddress, // gpuAddressSpace + 0, // sharedSystemMemCapabilities + 83.333, // defaultProfilingTimerResolution + MemoryConstants::pageSize, // requiredPreemptionSurfaceSize + "", // deviceName + nullptr, // preferredPlatformName + PreemptionMode::MidThread, // defaultPreemptionMode + aub_stream::ENGINE_CCS, // defaultEngineType + 0, // maxRenderFrequency + 30, // clVersionSupport + CmdServicesMemTraceVersion::DeviceValues::Bmg, // aubDeviceId + 0, // extraQuantityThreadsPerEU + 128, // slmSize + sizeof(BMG::GRF), // grfSize + 64, // timestampValidBits + 64, // kernelTimestampValidBits + false, // blitterOperationsSupported + true, // ftrSupportsInteger64BitAtomics + true, // ftrSupportsFP64 + false, // ftrSupportsFP64Emulation + true, // ftrSupports64BitMath + true, // ftrSvm + false, // ftrSupportsCoherency + false, // ftrSupportsVmeAvcTextureSampler + false, // ftrSupportsVmeAvcPreemption + false, // ftrRenderCompressedBuffers + false, // ftrRenderCompressedImages + true, // ftr64KBpages + true, // instrumentationEnabled + false, // supportsVme + false, // supportCacheFlushAfterWalker + true, // supportsImages + false, // supportsDeviceEnqueue + false, // supportsPipes + true, // supportsOcl21Features + true, // supportsOnDemandPageFaults + true, // supportsIndependentForwardProgress + false, // hostPtrTrackingEnabled + true, // levelZeroSupported + false, // isIntegratedDevice + false, // supportsMediaBlock + false, // p2pAccessSupported + false, // p2pAtomicAccessSupported + false, // fusedEuEnabled + true, // l0DebuggerSupported; + true, // supportsFloatAtomics + 0 // cxlType +}; + +void BMG::setupFeatureAndWorkaroundTable(HardwareInfo *hwInfo) { + setupDefaultFeatureTableAndWorkaroundTable(hwInfo); + FeatureTable *featureTable = &hwInfo->featureTable; + + featureTable->flags.ftrLocalMemory = true; + featureTable->flags.ftrFlatPhysCCS = true; + featureTable->flags.ftrE2ECompression = true; + featureTable->flags.ftrTile64Optimization = true; + featureTable->flags.ftrWalkerMTP = true; + featureTable->flags.ftrXe2Compression = true; + featureTable->flags.ftrXe2PlusTiling = true; + featureTable->flags.ftrL3TransientDataFlush = true; + featureTable->flags.ftrPml5Support = true; + + featureTable->ftrBcsInfo = 1; +} + +FeatureTable BMG::featureTable{}; +WorkaroundTable BMG::workaroundTable{}; + +const HardwareInfo BmgHwConfig::hwInfo = { + &BMG::platform, + &BMG::featureTable, + &BMG::workaroundTable, + &BmgHwConfig::gtSystemInfo, + BMG::capabilityTable}; + +GT_SYSTEM_INFO BmgHwConfig::gtSystemInfo = {}; + +const HardwareInfo BMG::hwInfo = BmgHwConfig::hwInfo; + +void BMG::setupHardwareInfoBase(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, const ReleaseHelper *releaseHelper) { + setupDefaultGtSysInfo(hwInfo, releaseHelper); + + BMG::adjustHardwareInfo(hwInfo); + if (setupFeatureTableAndWorkaroundTable) { + BMG::setupFeatureAndWorkaroundTable(hwInfo); + } +} + +void BmgHwConfig::setupHardwareInfo(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, const ReleaseHelper *releaseHelper) { + BMG::setupHardwareInfoBase(hwInfo, setupFeatureTableAndWorkaroundTable, releaseHelper); +} + +void setupBMGHardwareInfoImpl(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, uint64_t hwInfoConfig, const ReleaseHelper *releaseHelper) { + BmgHwConfig::setupHardwareInfo(hwInfo, setupFeatureTableAndWorkaroundTable, releaseHelper); +} + +void (*BMG::setupHardwareInfo)(HardwareInfo *, bool, uint64_t, const ReleaseHelper *) = setupBMGHardwareInfoImpl; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/hw_info_bmg.h b/shared/source/xe2_hpg_core/hw_info_bmg.h new file mode 100644 index 0000000000..bc95f8b2c5 --- /dev/null +++ b/shared/source/xe2_hpg_core/hw_info_bmg.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "hw_info_xe2_hpg_core.h" + +namespace NEO { + +struct BMG; + +template <> +struct HwMapper { + enum { gfxFamily = IGFX_XE2_HPG_CORE }; + + static const char *abbreviation; + using GfxFamily = GfxFamilyMapper(gfxFamily)>::GfxFamily; + using GfxProduct = BMG; +}; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/hw_info_lnl.cpp b/shared/source/xe2_hpg_core/hw_info_lnl.cpp new file mode 100644 index 0000000000..5fe99a3d7c --- /dev/null +++ b/shared/source/xe2_hpg_core/hw_info_lnl.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_info_lnl.h" + +#include "shared/source/aub_mem_dump/definitions/aub_services.h" +#include "shared/source/command_stream/preemption_mode.h" +#include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/helpers/constants.h" +#include "shared/source/release_helper/release_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" + +#include "aubstream/engine_node.h" + +namespace NEO { + +const char *HwMapper::abbreviation = "lnl"; + +const PLATFORM LNL::platform = { + IGFX_LUNARLAKE, + PCH_UNKNOWN, + IGFX_XE2_HPG_CORE, + IGFX_XE2_HPG_CORE, + PLATFORM_NONE, // default init + 0, // usDeviceID + 0, // usRevId. 0 sets the stepping to A0 + 0, // usDeviceID_PCH + 0, // usRevId_PCH + GTTYPE_UNDEFINED}; + +const RuntimeCapabilityTable LNL::capabilityTable{ + EngineDirectSubmissionInitVec{ + {aub_stream::ENGINE_CCS, {true, false, false, true}}}, // directSubmissionEngines + {0, 0, 0, 0, false, false, false, false}, // kmdNotifyProperties + MemoryConstants::max48BitAddress, // gpuAddressSpace + 0, // sharedSystemMemCapabilities + 83.333, // defaultProfilingTimerResolution + MemoryConstants::pageSize, // requiredPreemptionSurfaceSize + "", // deviceName + nullptr, // preferredPlatformName + PreemptionMode::MidThread, // defaultPreemptionMode + aub_stream::ENGINE_CCS, // defaultEngineType + 0, // maxRenderFrequency + 30, // clVersionSupport + CmdServicesMemTraceVersion::DeviceValues::Lnl, // aubDeviceId + 0, // extraQuantityThreadsPerEU + 128, // slmSize + sizeof(LNL::GRF), // grfSize + 64, // timestampValidBits + 64, // kernelTimestampValidBits + false, // blitterOperationsSupported + true, // ftrSupportsInteger64BitAtomics + true, // ftrSupportsFP64 + false, // ftrSupportsFP64Emulation + true, // ftrSupports64BitMath + true, // ftrSvm + false, // ftrSupportsCoherency + false, // ftrSupportsVmeAvcTextureSampler + false, // ftrSupportsVmeAvcPreemption + false, // ftrRenderCompressedBuffers + false, // ftrRenderCompressedImages + true, // ftr64KBpages + true, // instrumentationEnabled + false, // supportsVme + false, // supportCacheFlushAfterWalker + true, // supportsImages + false, // supportsDeviceEnqueue + false, // supportsPipes + true, // supportsOcl21Features + true, // supportsOnDemandPageFaults + true, // supportsIndependentForwardProgress + false, // hostPtrTrackingEnabled + true, // levelZeroSupported + true, // isIntegratedDevice + false, // supportsMediaBlock + false, // p2pAccessSupported + false, // p2pAtomicAccessSupported + false, // fusedEuEnabled + true, // l0DebuggerSupported; + true, // supportsFloatAtomics + 0 // cxlType +}; + +void LNL::setupFeatureAndWorkaroundTable(HardwareInfo *hwInfo) { + setupDefaultFeatureTableAndWorkaroundTable(hwInfo); + FeatureTable *featureTable = &hwInfo->featureTable; + + featureTable->flags.ftrFlatPhysCCS = true; + featureTable->flags.ftrE2ECompression = true; + featureTable->flags.ftrTile64Optimization = true; + featureTable->flags.ftrWalkerMTP = true; + featureTable->flags.ftrXe2Compression = true; + featureTable->flags.ftrXe2PlusTiling = true; + featureTable->flags.ftrPml5Support = true; + + featureTable->ftrBcsInfo = 1; +} + +FeatureTable LNL::featureTable{}; +WorkaroundTable LNL::workaroundTable{}; + +const HardwareInfo LnlHwConfig::hwInfo = { + &LNL::platform, + &LNL::featureTable, + &LNL::workaroundTable, + &LnlHwConfig::gtSystemInfo, + LNL::capabilityTable}; + +GT_SYSTEM_INFO LnlHwConfig::gtSystemInfo = {}; + +const HardwareInfo LNL::hwInfo = LnlHwConfig::hwInfo; + +void LNL::setupHardwareInfoBase(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, const ReleaseHelper *releaseHelper) { + setupDefaultGtSysInfo(hwInfo, releaseHelper); + + LNL::adjustHardwareInfo(hwInfo); + if (setupFeatureTableAndWorkaroundTable) { + LNL::setupFeatureAndWorkaroundTable(hwInfo); + } +} +void LnlHwConfig::setupHardwareInfo(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, const ReleaseHelper *releaseHelper) { + LNL::setupHardwareInfoBase(hwInfo, setupFeatureTableAndWorkaroundTable, releaseHelper); +} + +void setupLNLHardwareInfoImpl(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, uint64_t hwInfoConfig, const ReleaseHelper *releaseHelper) { + LnlHwConfig::setupHardwareInfo(hwInfo, setupFeatureTableAndWorkaroundTable, releaseHelper); +} + +void (*LNL::setupHardwareInfo)(HardwareInfo *, bool, uint64_t, const ReleaseHelper *) = setupLNLHardwareInfoImpl; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/hw_info_lnl.h b/shared/source/xe2_hpg_core/hw_info_lnl.h new file mode 100644 index 0000000000..0f05772bf3 --- /dev/null +++ b/shared/source/xe2_hpg_core/hw_info_lnl.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "hw_info_xe2_hpg_core.h" + +namespace NEO { + +struct LNL; + +template <> +struct HwMapper { + enum { gfxFamily = IGFX_XE2_HPG_CORE }; + + static const char *abbreviation; + using GfxFamily = GfxFamilyMapper(gfxFamily)>::GfxFamily; + using GfxProduct = LNL; +}; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.cpp new file mode 100644 index 0000000000..eac219aec9 --- /dev/null +++ b/shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.cpp @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h" + +namespace NEO { +const char *GfxFamilyMapper::name = "XE2_HPG_CORE"; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h b/shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h new file mode 100644 index 0000000000..ee0f3ede5a --- /dev/null +++ b/shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "shared/source/helpers/hw_mapper.h" + +namespace NEO { + +struct Xe2HpgCoreFamily; + +template <> +struct GfxFamilyMapper { + using GfxFamily = Xe2HpgCoreFamily; + static const char *name; +}; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/image_core_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/image_core_xe2_hpg_core.cpp new file mode 100644 index 0000000000..05ed448515 --- /dev/null +++ b/shared/source/xe2_hpg_core/image_core_xe2_hpg_core.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/image/image_surface_state.h" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +namespace NEO { + +using Family = Xe2HpgCoreFamily; + +#include "shared/source/image/image_skl_and_later.inl" +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/implicit_scaling_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/implicit_scaling_xe2_hpg_core.cpp new file mode 100644 index 0000000000..e32725fe5c --- /dev/null +++ b/shared/source/xe2_hpg_core/implicit_scaling_xe2_hpg_core.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/implicit_scaling.h" +#include "shared/source/command_container/implicit_scaling_xehp_and_later.inl" +#include "shared/source/command_container/walker_partition_xehp_and_later.inl" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +namespace NEO { + +using Family = Xe2HpgCoreFamily; +using DefaultWalkerType = Family::DefaultWalkerType; + +template <> +bool ImplicitScalingDispatch::pipeControlStallRequired = false; + +template struct ImplicitScalingDispatch; +template void ImplicitScalingDispatch::dispatchCommands(LinearStream &commandStream, DefaultWalkerType &walkerCmd, void **outWalkerPtr, + const DeviceBitfield &devices, RequiredPartitionDim requiredPartitionDim, uint32_t &partitionCount, + bool useSecondaryBatchBuffer, bool apiSelfCleanup, bool dcFlush, bool forceExecutionOnSingleTile, + uint64_t workPartitionAllocationGpuVa, const HardwareInfo &hwInfo); +template size_t ImplicitScalingDispatch::getSize(bool apiSelfCleanup, bool preferStaticPartitioning, const DeviceBitfield &devices, const Vec3 &groupStart, const Vec3 &groupCount); +} // namespace NEO + +template void WalkerPartition::appendWalkerFields(NEO::DefaultWalkerType &walkerCmd, uint32_t tileCount); diff --git a/shared/source/xe2_hpg_core/linux/command_stream_receiver_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/linux/command_stream_receiver_xe2_hpg_core.cpp new file mode 100644 index 0000000000..dd7fcebb7b --- /dev/null +++ b/shared/source/xe2_hpg_core/linux/command_stream_receiver_xe2_hpg_core.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/command_stream_receiver_with_aub_dump.inl" +#include "shared/source/os_interface/linux/device_command_stream.inl" +#include "shared/source/os_interface/linux/drm_command_stream.inl" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +namespace NEO { + +template class DeviceCommandStreamReceiver; +template class DrmCommandStreamReceiver; +template class CommandStreamReceiverWithAUBDump>; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/linux/direct_submission_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/linux/direct_submission_xe2_hpg_core.cpp new file mode 100644 index 0000000000..089e268a47 --- /dev/null +++ b/shared/source/xe2_hpg_core/linux/direct_submission_xe2_hpg_core.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/direct_submission/direct_submission_hw.inl" +#include "shared/source/direct_submission/direct_submission_prefetch_mitigation_xe_hp_core_and_later.inl" +#include "shared/source/direct_submission/direct_submission_prefetcher_pvc_and_later.inl" +#include "shared/source/direct_submission/direct_submission_xe_hp_core_and_later.inl" +#include "shared/source/direct_submission/dispatchers/blitter_dispatcher.inl" +#include "shared/source/direct_submission/dispatchers/dispatcher.inl" +#include "shared/source/direct_submission/dispatchers/render_dispatcher.inl" +#include "shared/source/direct_submission/linux/drm_direct_submission.inl" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +namespace NEO { +using GfxFamily = Xe2HpgCoreFamily; + +template class Dispatcher; +template class BlitterDispatcher; +template class RenderDispatcher; + +template class DirectSubmissionHw>; +template class DirectSubmissionHw>; + +template class DrmDirectSubmission>; +template class DrmDirectSubmission>; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/linux/hw_info_extra_bmg.cpp b/shared/source/xe2_hpg_core/linux/hw_info_extra_bmg.cpp new file mode 100644 index 0000000000..f7ce62b57a --- /dev/null +++ b/shared/source/xe2_hpg_core/linux/hw_info_extra_bmg.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/unified_memory/usm_memory_support.h" +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" + +namespace NEO { + +void BMG::adjustHardwareInfo(HardwareInfo *hwInfo) { + hwInfo->capabilityTable.sharedSystemMemCapabilities = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess); +} + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/linux/hw_info_extra_lnl.cpp b/shared/source/xe2_hpg_core/linux/hw_info_extra_lnl.cpp new file mode 100644 index 0000000000..06e9d0c0ef --- /dev/null +++ b/shared/source/xe2_hpg_core/linux/hw_info_extra_lnl.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/unified_memory/usm_memory_support.h" +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" + +namespace NEO { + +void LNL::adjustHardwareInfo(HardwareInfo *hwInfo) { + hwInfo->capabilityTable.sharedSystemMemCapabilities = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess); +} + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/linux/product_helper_bmg.cpp b/shared/source/xe2_hpg_core/linux/product_helper_bmg.cpp new file mode 100644 index 0000000000..a28586f30c --- /dev/null +++ b/shared/source/xe2_hpg_core/linux/product_helper_bmg.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/constants.h" +#include "shared/source/helpers/hw_info.h" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/os_interface/product_helper.inl" +#include "shared/source/os_interface/product_helper_xe2_and_later.inl" +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_bmg.h" + +constexpr static auto gfxProduct = IGFX_BMG; + +#include "shared/source/os_interface/linux/product_helper_mtl_and_later.inl" +#include "shared/source/xe2_hpg_core/bmg/os_agnostic_product_helper_bmg.inl" +#include "shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl" + +namespace NEO { +#include "shared/source/os_interface/linux/product_helper_xe_hpc_and_later.inl" + +template <> +int ProductHelperHw::configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) const { + enableCompression(hwInfo); + + hwInfo->featureTable.flags.ftr57bGPUAddressing = (hwInfo->capabilityTable.gpuAddressSpace == maxNBitValue(57)); + + enableBlitterOperationsSupport(hwInfo); + + return 0; +} + +template class ProductHelperHw; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/linux/product_helper_lnl.cpp b/shared/source/xe2_hpg_core/linux/product_helper_lnl.cpp new file mode 100644 index 0000000000..97d86a83a5 --- /dev/null +++ b/shared/source/xe2_hpg_core/linux/product_helper_lnl.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/constants.h" +#include "shared/source/helpers/hw_info.h" +#include "shared/source/kernel/kernel_properties.h" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/os_interface/product_helper.inl" +#include "shared/source/os_interface/product_helper_xe2_and_later.inl" +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_lnl.h" + +constexpr static auto gfxProduct = IGFX_LUNARLAKE; + +#include "shared/source/os_interface/linux/product_helper_mtl_and_later.inl" +#include "shared/source/xe2_hpg_core/lnl/os_agnostic_product_helper_lnl.inl" +#include "shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl" + +namespace NEO { + +#include "shared/source/os_interface/linux/product_helper_xe_hpc_and_later.inl" + +template <> +int ProductHelperHw::configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) const { + enableCompression(hwInfo); + + hwInfo->featureTable.flags.ftr57bGPUAddressing = (hwInfo->capabilityTable.gpuAddressSpace == maxNBitValue(57)); + + enableBlitterOperationsSupport(hwInfo); + + return 0; +} + +template class ProductHelperHw; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/lnl/device_ids_configs_lnl.h b/shared/source/xe2_hpg_core/lnl/device_ids_configs_lnl.h new file mode 100644 index 0000000000..8bfd774f69 --- /dev/null +++ b/shared/source/xe2_hpg_core/lnl/device_ids_configs_lnl.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include + +namespace NEO { +const std::vector lnlDeviceIds{0x6420, 0x64A0, 0x64B0}; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/lnl/os_agnostic_product_helper_lnl.inl b/shared/source/xe2_hpg_core/lnl/os_agnostic_product_helper_lnl.inl new file mode 100644 index 0000000000..b9983bb4ec --- /dev/null +++ b/shared/source/xe2_hpg_core/lnl/os_agnostic_product_helper_lnl.inl @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/command_stream_receiver.h" + +#include "aubstream/product_family.h" + +namespace NEO { + +template <> +bool ProductHelperHw::overrideAllocationCacheable(const AllocationData &allocationData) const { + return allocationData.type == AllocationType::commandBuffer || this->overrideCacheableForDcFlushMitigation(allocationData.type); +} + +template <> +bool ProductHelperHw::isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const { + const bool enabled = !isOOQ && queueTaskCount == queueCsr.peekTaskCount() && !queueCsr.directSubmissionRelaxedOrderingEnabled(); + if (debugManager.flags.ResolveDependenciesViaPipeControls.get() != -1) { + return debugManager.flags.ResolveDependenciesViaPipeControls.get() == 1; + } + return enabled; +} + +template <> +bool ProductHelperHw::isEvictionIfNecessaryFlagSupported() const { + return true; +} + +template <> +bool ProductHelperHw::isMidThreadPreemptionDisallowedForRayTracingKernels() const { + return true; +} + +template <> +std::optional ProductHelperHw::getAubStreamProductFamily() const { + return aub_stream::ProductFamily::Lnl; +} + +template <> +std::optional ProductHelperHw::getPreferredAllocationMethod(AllocationType allocationType) const { + switch (allocationType) { + case AllocationType::tagBuffer: + case AllocationType::timestampPacketTagBuffer: + return this->isDcFlushMitigated() ? std::optional(GfxMemoryAllocationMethod::allocateByKmd) : std::nullopt; + default: + return GfxMemoryAllocationMethod::allocateByKmd; + } +} + +template <> +bool ProductHelperHw::blitEnqueueAllowed(bool isWriteToImageFromBuffer) const { + return isWriteToImageFromBuffer; +} + +template <> +bool ProductHelperHw::isCachingOnCpuAvailable() const { + return false; +} + +template <> +bool ProductHelperHw::isAdjustDirectSubmissionTimeoutOnThrottleAndAcLineStatusEnabled() const { + return true; +} + +template <> +TimeoutParams ProductHelperHw::getDirectSubmissionControllerTimeoutParams(bool acLineConnected, QueueThrottle queueThrottle) const { + TimeoutParams params{}; + if (acLineConnected) { + switch (queueThrottle) { + case NEO::LOW: + params.maxTimeout = std::chrono::microseconds{500}; + params.timeout = std::chrono::microseconds{500}; + break; + case NEO::MEDIUM: + params.maxTimeout = std::chrono::microseconds{4'500}; + params.timeout = std::chrono::microseconds{4'500}; + break; + case NEO::HIGH: + params.maxTimeout = std::chrono::microseconds{DirectSubmissionController::defaultTimeout}; + params.timeout = std::chrono::microseconds{DirectSubmissionController::defaultTimeout}; + break; + default: + break; + } + } else { + switch (queueThrottle) { + case NEO::LOW: + params.maxTimeout = std::chrono::microseconds{500}; + params.timeout = std::chrono::microseconds{500}; + break; + case NEO::MEDIUM: + params.maxTimeout = std::chrono::microseconds{2'000}; + params.timeout = std::chrono::microseconds{2'000}; + break; + case NEO::HIGH: + params.maxTimeout = std::chrono::microseconds{3'000}; + params.timeout = std::chrono::microseconds{3'000}; + break; + default: + break; + } + } + params.timeoutDivisor = 1; + params.directSubmissionEnabled = true; + return params; +} + +template <> +bool ProductHelperHw::isDeviceUsmAllocationReuseSupported() const { + return true; +} + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl b/shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl new file mode 100644 index 0000000000..79d8288549 --- /dev/null +++ b/shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +namespace NEO { + +template <> +bool ProductHelperHw::isBlitterForImagesSupported() const { + return true; +} + +template <> +bool ProductHelperHw::isGlobalFenceInCommandStreamRequired(const HardwareInfo &hwInfo) const { + return true; +} + +template <> +bool ProductHelperHw::isCooperativeEngineSupported(const HardwareInfo &hwInfo) const { + return true; +} + +template <> +bool ProductHelperHw::isIpSamplingSupported(const HardwareInfo &hwInfo) const { + return true; +} + +template <> +void ProductHelperHw::fillScmPropertiesSupportStructure(StateComputeModePropertiesSupport &propertiesSupport) const { + using GfxProduct = typename HwMapper::GfxProduct; + + fillScmPropertiesSupportStructureBase(propertiesSupport); + propertiesSupport.allocationForScratchAndMidthreadPreemption = GfxProduct::StateComputeModeStateSupport::allocationForScratchAndMidthreadPreemption; +} + +template <> +bool ProductHelperHw::isNewCoherencyModelSupported() const { + return true; +} +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/preamble_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/preamble_xe2_hpg_core.cpp new file mode 100644 index 0000000000..b507cb5f96 --- /dev/null +++ b/shared/source/xe2_hpg_core/preamble_xe2_hpg_core.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +namespace NEO { +struct Xe2HpgCoreFamily; +using Family = Xe2HpgCoreFamily; +} // namespace NEO + +#include "shared/source/helpers/preamble_xe2_hpg_and_later.inl" +#include "shared/source/helpers/preamble_xehp_and_later.inl" + +namespace NEO { + +template struct PreambleHelper; + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/preemption_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/preemption_xe2_hpg_core.cpp new file mode 100644 index 0000000000..82ef4c72db --- /dev/null +++ b/shared/source/xe2_hpg_core/preemption_xe2_hpg_core.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/linear_stream.h" +#include "shared/source/command_stream/preemption.h" +#include "shared/source/command_stream/preemption.inl" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +namespace NEO { + +using GfxFamily = Xe2HpgCoreFamily; + +template <> +void PreemptionHelper::programInterfaceDescriptorDataPreemption(INTERFACE_DESCRIPTOR_DATA *idd, PreemptionMode preemptionMode) { + using INTERFACE_DESCRIPTOR_DATA = typename GfxFamily::INTERFACE_DESCRIPTOR_DATA; + if (preemptionMode == PreemptionMode::MidThread) { + idd->setThreadPreemption(true); + } else { + idd->setThreadPreemption(false); + } +} + +template <> +void PreemptionHelper::programCsrBaseAddressCmd(LinearStream &preambleCmdStream, const GraphicsAllocation *preemptionCsr) { + using STATE_CONTEXT_DATA_BASE_ADDRESS = typename GfxFamily::STATE_CONTEXT_DATA_BASE_ADDRESS; + + auto stateContextBaseAddressCmd = preambleCmdStream.getSpaceForCmd(); + STATE_CONTEXT_DATA_BASE_ADDRESS cmd = GfxFamily::cmdInitStateContextDataBaseAddress; + cmd.setContextDataBaseAddress(preemptionCsr->getGpuAddressToPatch()); + *stateContextBaseAddressCmd = cmd; +} + +template <> +size_t PreemptionHelper::getRequiredPreambleSize(const Device &device) { + using STATE_CONTEXT_DATA_BASE_ADDRESS = typename GfxFamily::STATE_CONTEXT_DATA_BASE_ADDRESS; + bool debuggingEnabled = device.getDebugger() != nullptr; + if ((device.getPreemptionMode() == PreemptionMode::MidThread) || debuggingEnabled) { + return sizeof(STATE_CONTEXT_DATA_BASE_ADDRESS); + } + return 0u; +} + +#include "shared/source/command_stream/preemption_xe2_and_later.inl" + +template size_t PreemptionHelper::getPreemptionWaCsSize(const Device &device); +template void PreemptionHelper::applyPreemptionWaCmdsBegin(LinearStream *pCommandStream, const Device &device); +template void PreemptionHelper::applyPreemptionWaCmdsEnd(LinearStream *pCommandStream, const Device &device); +template void PreemptionHelper::programStateSip(LinearStream &preambleCmdStream, Device &device, OsContext *context); +template void PreemptionHelper::programStateSipCmd(LinearStream &preambleCmdStream, GraphicsAllocation *sipAllocation, bool useFullAddress); +template size_t PreemptionHelper::getRequiredStateSipCmdSize(Device &device, bool isRcs); +template void PreemptionHelper::programCsrBaseAddress(LinearStream &cmdStream, Device &device, const GraphicsAllocation *preemptionCsr); +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/state_base_address_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/state_base_address_xe2_hpg_core.cpp new file mode 100644 index 0000000000..3e56b91d53 --- /dev/null +++ b/shared/source/xe2_hpg_core/state_base_address_xe2_hpg_core.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/state_base_address_xehp_and_later.inl" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +namespace NEO { + +template <> +void setSbaStatelessCompressionParams(typename Xe2HpgCoreFamily::STATE_BASE_ADDRESS *stateBaseAddress, MemoryCompressionState memoryCompressionState) { +} + +template struct StateBaseAddressHelper; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/tbx_command_stream_receiver_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/tbx_command_stream_receiver_xe2_hpg_core.cpp new file mode 100644 index 0000000000..91e6bdda6d --- /dev/null +++ b/shared/source/xe2_hpg_core/tbx_command_stream_receiver_xe2_hpg_core.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/command_stream_receiver_with_aub_dump.inl" +#include "shared/source/command_stream/tbx_command_stream_receiver_hw.h" +#include "shared/source/command_stream/tbx_command_stream_receiver_hw.inl" +#include "shared/source/helpers/array_count.h" +#include "shared/source/helpers/populate_factory.h" +#include "shared/source/memory_manager/memory_banks.h" +#include "shared/source/memory_manager/memory_pool.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +namespace NEO { +using Family = Xe2HpgCoreFamily; +static auto gfxCore = IGFX_XE2_HPG_CORE; + +template <> +void populateFactoryTable>() { + extern TbxCommandStreamReceiverCreateFunc tbxCommandStreamReceiverFactory[IGFX_MAX_CORE]; + UNRECOVERABLE_IF(!isInRange(gfxCore, tbxCommandStreamReceiverFactory)); + tbxCommandStreamReceiverFactory[gfxCore] = TbxCommandStreamReceiverHw::create; +} + +#include "shared/source/command_stream/tbx_command_stream_receiver_xehp_and_later.inl" + +template class TbxCommandStreamReceiverHw; +template class CommandStreamReceiverWithAUBDump>; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/windows/command_stream_receiver_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/windows/command_stream_receiver_xe2_hpg_core.cpp new file mode 100644 index 0000000000..79e67497e9 --- /dev/null +++ b/shared/source/xe2_hpg_core/windows/command_stream_receiver_xe2_hpg_core.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/command_stream_receiver_with_aub_dump.inl" +#include "shared/source/os_interface/windows/device_command_stream.inl" +#include "shared/source/os_interface/windows/wddm_device_command_stream.inl" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" + +namespace NEO { + +template class DeviceCommandStreamReceiver; +template class WddmCommandStreamReceiver; +template class CommandStreamReceiverWithAUBDump>; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/windows/direct_submission_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/windows/direct_submission_xe2_hpg_core.cpp new file mode 100644 index 0000000000..d15ced7635 --- /dev/null +++ b/shared/source/xe2_hpg_core/windows/direct_submission_xe2_hpg_core.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/direct_submission/direct_submission_hw.inl" +#include "shared/source/direct_submission/direct_submission_prefetch_mitigation_xe_hp_core_and_later.inl" +#include "shared/source/direct_submission/direct_submission_prefetcher_pvc_and_later.inl" +#include "shared/source/direct_submission/direct_submission_xe_hp_core_and_later.inl" +#include "shared/source/direct_submission/dispatchers/blitter_dispatcher.inl" +#include "shared/source/direct_submission/dispatchers/dispatcher.inl" +#include "shared/source/direct_submission/dispatchers/render_dispatcher.inl" +#include "shared/source/direct_submission/windows/wddm_direct_submission.inl" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +namespace NEO { +using GfxFamily = Xe2HpgCoreFamily; + +template class Dispatcher; +template class BlitterDispatcher; +template class RenderDispatcher; + +template class DirectSubmissionHw>; +template class DirectSubmissionHw>; + +template class WddmDirectSubmission>; +template class WddmDirectSubmission>; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/windows/gmm_callbacks_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/windows/gmm_callbacks_xe2_hpg_core.cpp new file mode 100644 index 0000000000..578b232524 --- /dev/null +++ b/shared/source/xe2_hpg_core/windows/gmm_callbacks_xe2_hpg_core.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/windows/gmm_callbacks_tgllp_and_later.inl" +#include "shared/source/xe2_hpg_core/hw_cmds.h" + +namespace NEO { + +template struct DeviceCallbacks; +template struct TTCallbacks; + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/windows/hw_info_extra_bmg.cpp b/shared/source/xe2_hpg_core/windows/hw_info_extra_bmg.cpp new file mode 100644 index 0000000000..a3f22d3270 --- /dev/null +++ b/shared/source/xe2_hpg_core/windows/hw_info_extra_bmg.cpp @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" + +namespace NEO { + +void BMG::adjustHardwareInfo(HardwareInfo *hwInfo) { +} + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/windows/hw_info_extra_lnl.cpp b/shared/source/xe2_hpg_core/windows/hw_info_extra_lnl.cpp new file mode 100644 index 0000000000..0446ae1299 --- /dev/null +++ b/shared/source/xe2_hpg_core/windows/hw_info_extra_lnl.cpp @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" + +namespace NEO { + +void LNL::adjustHardwareInfo(HardwareInfo *hwInfo) { +} + +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/windows/product_helper_bmg.cpp b/shared/source/xe2_hpg_core/windows/product_helper_bmg.cpp new file mode 100644 index 0000000000..ed98ef3fe1 --- /dev/null +++ b/shared/source/xe2_hpg_core/windows/product_helper_bmg.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/os_interface/product_helper.inl" +#include "shared/source/os_interface/product_helper_xe2_and_later.inl" +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_bmg.h" + +constexpr static auto gfxProduct = IGFX_BMG; + +#include "shared/source/xe2_hpg_core/bmg/os_agnostic_product_helper_bmg.inl" +#include "shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl" + +namespace NEO { + +template <> +int ProductHelperHw::configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) const { + enableCompression(hwInfo); + enableBlitterOperationsSupport(hwInfo); + + return 0; +} + +template <> +bool ProductHelperHw::isDirectSubmissionSupported(ReleaseHelper *releaseHelper) const { + return true; +} + +template <> +bool ProductHelperHw::restartDirectSubmissionForHostptrFree() const { + return true; +} + +template <> +bool ProductHelperHw::isStagingBuffersEnabled() const { + return true; +} + +template class ProductHelperHw; +} // namespace NEO diff --git a/shared/source/xe2_hpg_core/windows/product_helper_lnl.cpp b/shared/source/xe2_hpg_core/windows/product_helper_lnl.cpp new file mode 100644 index 0000000000..c332e8919b --- /dev/null +++ b/shared/source/xe2_hpg_core/windows/product_helper_lnl.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/os_interface/product_helper.inl" +#include "shared/source/os_interface/product_helper_xe2_and_later.inl" +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_lnl.h" + +constexpr static auto gfxProduct = IGFX_LUNARLAKE; + +#include "shared/source/xe2_hpg_core/lnl/os_agnostic_product_helper_lnl.inl" +#include "shared/source/xe2_hpg_core/os_agnostic_product_helper_xe2_hpg_core.inl" + +namespace NEO { + +template <> +int ProductHelperHw::configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) const { + enableCompression(hwInfo); + enableBlitterOperationsSupport(hwInfo); + + return 0; +} + +template <> +uint64_t ProductHelperHw::overridePatIndex(bool isUncachedType, uint64_t patIndex, AllocationType allocationType) const { + if (this->overridePatAndUsageForDcFlushMitigation(allocationType)) { + return 2; // L3: WB, L4: UC, 2-Way coh + } + + return patIndex; +} + +template <> +bool ProductHelperHw::isDirectSubmissionSupported(ReleaseHelper *releaseHelper) const { + return true; +} + +template <> +bool ProductHelperHw::restartDirectSubmissionForHostptrFree() const { + return true; +} + +template <> +bool ProductHelperHw::isStagingBuffersEnabled() const { + return true; +} + +template class ProductHelperHw; +} // namespace NEO diff --git a/shared/test/common/helpers/includes/test_traits_common.h b/shared/test/common/helpers/includes/test_traits_common.h index 70c3cf9aee..34e93f21b8 100644 --- a/shared/test/common/helpers/includes/test_traits_common.h +++ b/shared/test/common/helpers/includes/test_traits_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -10,5 +10,6 @@ #include "shared/test/common/gen12lp/test_traits_gen12lp.h" #include "shared/test/common/gen8/test_traits_gen8.h" #include "shared/test/common/gen9/test_traits_gen9.h" +#include "shared/test/common/xe2_hpg_core/test_traits_xe2_hpg_core.h" #include "shared/test/common/xe_hpc_core/test_traits_xe_hpc_core.h" #include "shared/test/common/xe_hpg_core/test_traits_xe_hpg_core.h" diff --git a/shared/test/common/helpers/unit_test_helper_xe2_and_later.inl b/shared/test/common/helpers/unit_test_helper_xe2_and_later.inl new file mode 100644 index 0000000000..57366619c3 --- /dev/null +++ b/shared/test/common/helpers/unit_test_helper_xe2_and_later.inl @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/helpers/hw_info.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/helpers/unit_test_helper.h" + +namespace NEO { + +template +const AuxTranslationMode UnitTestHelper::requiredAuxTranslationMode = AuxTranslationMode::none; + +template +bool UnitTestHelper::isAdditionalMiSemaphoreWaitRequired(const RootDeviceEnvironment &rootDeviceEnvironment) { + auto programGlobalFenceAsMiMemFenceCommandInCommandStream = true; + if (debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.get() != -1) { + programGlobalFenceAsMiMemFenceCommandInCommandStream = !!debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.get(); + } + return !programGlobalFenceAsMiMemFenceCommandInCommandStream; +} + +template +bool UnitTestHelper::getSystolicFlagValueFromPipelineSelectCommand(const typename GfxFamily::PIPELINE_SELECT &pipelineSelectCmd) { + return false; +} + +template +bool UnitTestHelper::requiresTimestampPacketsInSystemMemory(HardwareInfo &hwInfo) { + return !hwInfo.featureTable.flags.ftrLocalMemory; +} + +template +GenCmdList::iterator UnitTestHelper::findCsrBaseAddressCommand(GenCmdList::iterator begin, GenCmdList::iterator end) { + return find(begin, end); +} + +template +std::vector UnitTestHelper::findAllMidThreadPreemptionAllocationCommand(GenCmdList::iterator begin, GenCmdList::iterator end) { + return findAll(begin, end); +} + +template +bool UnitTestHelper::timestampRegisterHighAddress() { + return true; +} + +template +void UnitTestHelper::setExtraMidThreadPreemptionFlag(HardwareInfo &hwInfo, bool value) { + hwInfo.featureTable.flags.ftrWalkerMTP = value; +} + +template +bool UnitTestHelper::getPipeControlHdcPipelineFlush(const typename GfxFamily::PIPE_CONTROL &pipeControl) { + return pipeControl.getDataportFlush(); +} + +template +void UnitTestHelper::setPipeControlHdcPipelineFlush(typename GfxFamily::PIPE_CONTROL &pipeControl, bool hdcPipelineFlush) { + pipeControl.setDataportFlush(hdcPipelineFlush); +} + +} // namespace NEO diff --git a/shared/test/common/libult/CMakeLists.txt b/shared/test/common/libult/CMakeLists.txt index b29b14d88d..43c8056053 100644 --- a/shared/test/common/libult/CMakeLists.txt +++ b/shared/test/common/libult/CMakeLists.txt @@ -149,6 +149,12 @@ if(TESTS_PVC_AND_LATER) ) endif() +if(TESTS_XE2_AND_LATER) + list(APPEND neo_libult_common_SRCS_LIB_ULT + ${NEO_SHARED_TEST_DIRECTORY}/common/helpers/unit_test_helper_xe2_and_later.inl + ) +endif() + append_sources_from_properties(neo_libult_common_SRCS_LIB_ULT NEO_CORE_ENABLE_RELEASE_HELPER) set_property(GLOBAL PROPERTY neo_libult_common_SRCS_LIB_ULT ${neo_libult_common_SRCS_LIB_ULT}) diff --git a/shared/test/common/libult/xe2_hpg_core.cpp b/shared/test/common/libult/xe2_hpg_core.cpp new file mode 100644 index 0000000000..4f728797f3 --- /dev/null +++ b/shared/test/common/libult/xe2_hpg_core.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/populate_factory.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/libult/ult_command_stream_receiver.h" +#include "shared/test/common/mocks/mock_l0_debugger.h" + +namespace NEO { + +using Family = Xe2HpgCoreFamily; +constexpr auto gfxCore = IGFX_XE2_HPG_CORE; + +extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE]; + +template <> +void populateFactoryTable>() { + commandStreamReceiverFactory[IGFX_MAX_CORE + gfxCore] = UltCommandStreamReceiver::create; +} + +struct EnableXe2HpgCore { + EnableXe2HpgCore() { + populateFactoryTable>(); + } +}; + +static EnableXe2HpgCore enable; +static MockDebuggerL0HwPopulateFactory mockDebuggerXe2HpgCore; +template class UltCommandStreamReceiver; +} // namespace NEO diff --git a/shared/test/common/test_configuration/aub_tests/xe2_hpg_core/CMakeLists.txt b/shared/test/common/test_configuration/aub_tests/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..411e858022 --- /dev/null +++ b/shared/test/common/test_configuration/aub_tests/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,15 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XE2_HPG_CORE) + set(NEO_SHARED_aub_tests_configurations + ${NEO_SHARED_aub_tests_configurations} + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/aub_tests_configuration_xe2_hpg_core.cpp + ) + + set(NEO_SHARED_aub_tests_configurations ${NEO_SHARED_aub_tests_configurations} PARENT_SCOPE) +endif() diff --git a/shared/test/common/test_configuration/aub_tests/xe2_hpg_core/aub_tests_configuration_xe2_hpg_core.cpp b/shared/test/common/test_configuration/aub_tests/xe2_hpg_core/aub_tests_configuration_xe2_hpg_core.cpp new file mode 100644 index 0000000000..fc97c3d78c --- /dev/null +++ b/shared/test/common/test_configuration/aub_tests/xe2_hpg_core/aub_tests_configuration_xe2_hpg_core.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/test_configuration/aub_tests/aub_tests_configuration.h" +#include "shared/test/common/test_macros/test.h" +using namespace NEO; + +template <> +AubTestsConfig getAubTestsConfig() { + AubTestsConfig aubTestsConfig; + aubTestsConfig.testCanonicalAddress = false; + return aubTestsConfig; +} diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index bb5145cc30..70888f0228 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -339,6 +339,10 @@ UseImmDataWriteModeOnPostSyncOperation = 0 OverridePostSyncMocs = -1 EnableImmediateVmBindExt = -1 EnablePipelineSelectTracking = -1 +PipelinedPipelineSelect = false +ForceDispatchTimeoutCounter = -1 +ForceTheMaximumNumberOfOutstandingRayqueriesPerSs = -1 +CFEStackIDControl = -1 ForceExecutionTile = -1 DisableCachingForHeaps = 0 OverrideTimestampPacketSize = -1 diff --git a/shared/test/common/test_macros/header/common_matchers.h b/shared/test/common/test_macros/header/common_matchers.h index e58c38f951..47fba5ac7f 100644 --- a/shared/test/common/test_macros/header/common_matchers.h +++ b/shared/test/common/test_macros/header/common_matchers.h @@ -16,6 +16,8 @@ using IsXeHpgCore = IsGfxCore; using IsXeHpcCore = IsGfxCore; using IsNotXeHpcCore = IsNotGfxCore; using IsNotXeHpgCore = IsNotGfxCore; +using IsXe2HpgCore = IsGfxCore; +using IsNotXe2HpgCore = IsNotGfxCore; using IsAtMostGen9 = IsAtMostGfxCore; using IsAtLeastGen9 = IsAtLeastGfxCore; @@ -42,6 +44,8 @@ using IsAtLeastXeHpcCore = IsAtLeastGfxCore; using IsAtMostXeHpcCore = IsAtMostGfxCore; using IsBeforeXeHpcCore = IsBeforeGfxCore; +using IsAtLeastXe2HpgCore = IsAtLeastGfxCore; + using IsXeHpOrXeHpgCore = IsAnyGfxCores; using IsXeHpOrXeHpcCore = IsAnyGfxCores; using IsXeHpcOrXeHpgCore = IsAnyGfxCores; @@ -74,6 +78,9 @@ using IsDG2 = IsProduct; using IsPVC = IsProduct; +using IsBMG = IsProduct; +using IsLNL = IsProduct; + using IsAtLeastSkl = IsAtLeastProduct; using IsAtLeastMtl = IsAtLeastProduct; diff --git a/shared/test/common/test_macros/header/per_product_test_definitions.h b/shared/test/common/test_macros/header/per_product_test_definitions.h index 808fc9c3d5..d98c12ae6b 100644 --- a/shared/test/common/test_macros/header/per_product_test_definitions.h +++ b/shared/test/common/test_macros/header/per_product_test_definitions.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -35,6 +35,11 @@ #define GEN12LPTEST_F(test_fixture, test_name) GENTEST_F(IGFX_GEN12LP_CORE, test_fixture, test_name) #define GEN12LPTEST_P(test_fixture, test_name) GENTEST_P(IGFX_GEN12LP_CORE, test_fixture, test_name) #endif +#ifdef TESTS_XE2_HPG_CORE +#define XE2_HPG_CORETEST_F(test_fixture, test_name) GENTEST_F(IGFX_XE2_HPG_CORE, test_fixture, test_name) +#define XE2_HPG_CORETEST_P(test_fixture, test_name) GENTEST_P(IGFX_XE2_HPG_CORE, test_fixture, test_name) +#endif + #ifdef TESTS_GEN8 #define BDWTEST_F(test_fixture, test_name) \ FAMILYTEST_TEST_(test_fixture, test_name, test_fixture, \ @@ -234,3 +239,23 @@ IGFX_XE_HPC_CORE, \ IGFX_PVC) #endif +#ifdef TESTS_BMG +#define BMGTEST_F(test_fixture, test_name) \ + FAMILYTEST_TEST_(test_fixture, test_name, test_fixture, \ + ::testing::internal::GetTypeId(), \ + IGFX_XE2_HPG_CORE, IGFX_BMG) +#define BMGTEST_P(test_suite_name, test_name) \ + FAMILYTEST_TEST_P(test_suite_name, test_name, \ + IGFX_XE2_HPG_CORE, \ + IGFX_BMG) +#endif +#ifdef TESTS_LNL +#define LNLTEST_F(test_fixture, test_name) \ + FAMILYTEST_TEST_(test_fixture, test_name, test_fixture, \ + ::testing::internal::GetTypeId(), \ + IGFX_XE2_HPG_CORE, IGFX_LUNARLAKE) +#define LNLTEST_P(test_suite_name, test_name) \ + FAMILYTEST_TEST_P(test_suite_name, test_name, \ + IGFX_XE2_HPG_CORE, \ + IGFX_LUNARLAKE) +#endif diff --git a/shared/test/common/test_macros/header/per_product_test_selector.h b/shared/test/common/test_macros/header/per_product_test_selector.h index ca9ed07495..1319284771 100644 --- a/shared/test/common/test_macros/header/per_product_test_selector.h +++ b/shared/test/common/test_macros/header/per_product_test_selector.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -29,6 +29,9 @@ case IGFX_XE_HPC_CORE: \ XEHPC_TYPED_TEST(methodName) \ break; \ + case IGFX_XE2_HPG_CORE: \ + XE2HPG_TYPED_TEST(methodName) \ + break; \ default: \ ASSERT_TRUE((false && "Unknown hardware family")); \ break; \ @@ -56,6 +59,9 @@ case IGFX_XE_HPC_CORE: \ supported = XEHPC_SUPPORTED_TEST(cmdSetBase); \ break; \ + case IGFX_XE2_HPG_CORE: \ + supported = XE2HPG_SUPPORTED_TEST(cmdSetBase); \ + break; \ default: \ ASSERT_TRUE((false && "Unknown hardware family")); \ break; \ diff --git a/shared/test/common/test_macros/header/per_product_test_selector_definitions.h b/shared/test/common/test_macros/header/per_product_test_selector_definitions.h index c3895ee72c..3dd218bd8c 100644 --- a/shared/test/common/test_macros/header/per_product_test_selector_definitions.h +++ b/shared/test/common/test_macros/header/per_product_test_selector_definitions.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -49,3 +49,10 @@ #define XEHPC_TYPED_TEST(method) #define XEHPC_SUPPORTED_TEST(cmdSetBase) false #endif +#ifdef TESTS_XE2_HPG_CORE +#define XE2HPG_TYPED_TEST(method) method::GfxFamily>(); +#define XE2HPG_SUPPORTED_TEST(cmdSetBase) NEO::GfxFamilyMapper::GfxFamily::supportsCmdSet(cmdSetBase) +#else +#define XE2HPG_TYPED_TEST(method) +#define XE2HPG_SUPPORTED_TEST(cmdSetBase) false +#endif diff --git a/shared/test/common/xe2_hpg_core/CMakeLists.txt b/shared/test/common/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..3cb5acb79b --- /dev/null +++ b/shared/test/common/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,12 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XE2_HPG_CORE) + target_sources(neo_libult_common PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/test_traits_xe2_hpg_core.h + ) +endif() diff --git a/shared/test/common/xe2_hpg_core/bmg/CMakeLists.txt b/shared/test/common/xe2_hpg_core/bmg/CMakeLists.txt new file mode 100644 index 0000000000..9b20b26d9a --- /dev/null +++ b/shared/test/common/xe2_hpg_core/bmg/CMakeLists.txt @@ -0,0 +1,12 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_BMG) + target_sources(neo_libult_common PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/product_configs_bmg.h + ) +endif() diff --git a/shared/test/common/xe2_hpg_core/bmg/mock_product_helper_bmg.cpp b/shared/test/common/xe2_hpg_core/bmg/mock_product_helper_bmg.cpp new file mode 100644 index 0000000000..2329fd6599 --- /dev/null +++ b/shared/test/common/xe2_hpg_core/bmg/mock_product_helper_bmg.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/helpers/mock_product_helper_hw.h" + +constexpr static auto gfxProduct = IGFX_BMG; + +#include "shared/test/common/helpers/mock_product_helper_hw.inl" + +template struct NEO::MockProductHelperHw; diff --git a/shared/test/common/xe2_hpg_core/bmg/product_configs_bmg.h b/shared/test/common/xe2_hpg_core/bmg/product_configs_bmg.h new file mode 100644 index 0000000000..3d3f4dc666 --- /dev/null +++ b/shared/test/common/xe2_hpg_core/bmg/product_configs_bmg.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "platforms.h" + +namespace AOT_BMG { +constexpr AOT::PRODUCT_CONFIG productConfigs[] = { + AOT::BMG_G21_A0, AOT::BMG_G21_A1, AOT::BMG_G21_B0}; +} diff --git a/shared/test/common/xe2_hpg_core/cmd_parse_xe2_hpg_core.cpp b/shared/test/common/xe2_hpg_core/cmd_parse_xe2_hpg_core.cpp new file mode 100644 index 0000000000..8934c96a1b --- /dev/null +++ b/shared/test/common/xe2_hpg_core/cmd_parse_xe2_hpg_core.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +using GenStruct = NEO::Xe2HpgCore; +using GenGfxFamily = NEO::Xe2HpgCoreFamily; + +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" + +using MI_MEM_FENCE = GenStruct::MI_MEM_FENCE; +using STATE_SYSTEM_MEM_FENCE_ADDRESS = GenStruct::STATE_SYSTEM_MEM_FENCE_ADDRESS; +using STATE_PREFETCH = GenStruct::STATE_PREFETCH; +using MEM_SET = GenStruct::MEM_SET; +using STATE_CONTEXT_DATA_BASE_ADDRESS = GenStruct::STATE_CONTEXT_DATA_BASE_ADDRESS; + +template <> +MI_MEM_FENCE *genCmdCast(void *buffer) { + auto pCmd = reinterpret_cast(buffer); + + return (0x0 == pCmd->TheStructure.Common.MiCommandSubOpcode && + 0x9 == pCmd->TheStructure.Common.MiCommandOpcode && + 0x0 == pCmd->TheStructure.Common.CommandType) + ? pCmd + : nullptr; +} + +template <> +STATE_SYSTEM_MEM_FENCE_ADDRESS *genCmdCast(void *buffer) { + auto pCmd = reinterpret_cast(buffer); + + return (0x1 == pCmd->TheStructure.Common.DwordLength && + 0x9 == pCmd->TheStructure.Common._3DCommandSubOpcode && + 0x1 == pCmd->TheStructure.Common._3DCommandOpcode && + 0x0 == pCmd->TheStructure.Common.CommandSubtype && + 0x3 == pCmd->TheStructure.Common.CommandType) + ? pCmd + : nullptr; +} + +template <> +STATE_PREFETCH *genCmdCast(void *buffer) { + auto pCmd = reinterpret_cast(buffer); + + return (0x2 == pCmd->TheStructure.Common.DwordLength && + 0x3 == pCmd->TheStructure.Common._3DCommandSubOpcode && + 0x0 == pCmd->TheStructure.Common._3DCommandOpcode && + 0x0 == pCmd->TheStructure.Common.CommandSubtype && + 0x3 == pCmd->TheStructure.Common.CommandType) + ? pCmd + : nullptr; +} + +template <> +MEM_SET *genCmdCast(void *buffer) { + auto pCmd = reinterpret_cast(buffer); + + return (0x5 == pCmd->TheStructure.Common.DwordLength && + 0x5B == pCmd->TheStructure.Common.InstructionTarget_Opcode && + 0x2 == pCmd->TheStructure.Common.Client) + ? pCmd + : nullptr; +} + +template <> +STATE_CONTEXT_DATA_BASE_ADDRESS *genCmdCast(void *buffer) { + auto pCmd = reinterpret_cast(buffer); + + return (0x1 == pCmd->TheStructure.Common.DwordLength && + 0xb == pCmd->TheStructure.Common._3DCommandSubOpcode && + 0x1 == pCmd->TheStructure.Common._3DCommandOpcode && + 0x0 == pCmd->TheStructure.Common.CommandSubtype && + 0x3 == pCmd->TheStructure.Common.CommandType) + ? pCmd + : nullptr; +} + +template <> +size_t CmdParse::getAdditionalCommandLength(void *cmd) { + { + if (genCmdCast(cmd)) { + return sizeof(MI_MEM_FENCE) / sizeof(uint32_t); + } + } + { + if (genCmdCast(cmd)) { + return sizeof(STATE_SYSTEM_MEM_FENCE_ADDRESS) / sizeof(uint32_t); + } + } + { + if (genCmdCast(cmd)) { + return sizeof(STATE_PREFETCH) / sizeof(uint32_t); + } + } + { + if (genCmdCast(cmd)) { + return sizeof(MEM_SET) / sizeof(uint32_t); + } + } + { + if (genCmdCast(cmd)) { + return sizeof(STATE_CONTEXT_DATA_BASE_ADDRESS) / sizeof(uint32_t); + } + } + + return 0; +} + +template <> +const char *CmdParse::getAdditionalCommandName(void *cmd) { + if (genCmdCast(cmd)) { + return "MI_MEM_FENCE"; + } + if (genCmdCast(cmd)) { + return "STATE_SYSTEM_MEM_FENCE_ADDRESS"; + } + if (genCmdCast(cmd)) { + return "STATE_PREFETCH"; + } + if (genCmdCast(cmd)) { + return "MEM_SET"; + } + if (genCmdCast(cmd)) { + return "STATE_CONTEXT_DATA_BASE_ADDRESS"; + } + + return "UNKNOWN"; +} + +#include "shared/test/common/cmd_parse/hw_parse.h" + +template <> +bool NEO::HardwareParse::requiresPipelineSelectBeforeMediaState() { + return false; +} + +#include "shared/test/common/cmd_parse/cmd_parse_pvc_and_later.inl" + +template <> +void HardwareParse::findCsrBaseAddress() { + using STATE_CONTEXT_DATA_BASE_ADDRESS = typename GenGfxFamily::STATE_CONTEXT_DATA_BASE_ADDRESS; + itorGpgpuCsrBaseAddress = find(cmdList.begin(), cmdList.end()); + if (itorGpgpuCsrBaseAddress != cmdList.end()) { + cmdGpgpuCsrBaseAddress = *itorGpgpuCsrBaseAddress; + } +} + +template const typename GenGfxFamily::RENDER_SURFACE_STATE *NEO::HardwareParse::getSurfaceState(IndirectHeap *ssh, uint32_t index); diff --git a/shared/test/common/xe2_hpg_core/lnl/mock_product_helper_lnl.cpp b/shared/test/common/xe2_hpg_core/lnl/mock_product_helper_lnl.cpp new file mode 100644 index 0000000000..19f259109c --- /dev/null +++ b/shared/test/common/xe2_hpg_core/lnl/mock_product_helper_lnl.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/helpers/mock_product_helper_hw.h" + +constexpr static auto gfxProduct = IGFX_LUNARLAKE; + +#include "shared/test/common/helpers/mock_product_helper_hw.inl" + +template struct NEO::MockProductHelperHw; diff --git a/shared/test/common/xe2_hpg_core/test_traits_xe2_hpg_core.h b/shared/test/common/xe2_hpg_core/test_traits_xe2_hpg_core.h new file mode 100644 index 0000000000..f89fe727c3 --- /dev/null +++ b/shared/test/common/xe2_hpg_core/test_traits_xe2_hpg_core.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "shared/test/common/helpers/test_traits.h" + +template <> +struct TestTraits { + static constexpr bool surfaceStateCompressionParamsSupported = false; + static constexpr bool clearColorAddressMatcher = false; + static constexpr bool auxBuiltinsSupported = false; + static constexpr bool localMemCompressionAubsSupported = true; + static constexpr bool systemMemCompressionAubsSupported = true; + static constexpr bool l3ControlSupported = false; + static constexpr bool forceNonCoherentSupported = false; + static constexpr bool threadPreemptionDisableBitMatcher = false; + static constexpr bool programOnlyChangedFieldsInComputeStateMode = true; + static constexpr bool iohInSbaSupported = false; + static constexpr bool auxTranslationSupported = false; + static constexpr bool deviceEnqueueSupport = false; + static constexpr bool fusedEuDispatchSupported = false; + static constexpr bool numberOfWalkersInCfeStateSupported = false; + static constexpr bool forceGpuNonCoherent = false; + static constexpr bool imagesSupported = true; + static constexpr bool isPipeControlExtendedPriorToNonPipelinedStateCommandSupported = false; + static constexpr bool largeGrfModeInStateComputeModeSupported = true; + static constexpr bool heaplessAllowed = false; + static constexpr bool isUsingNonDefaultIoctls = false; +}; diff --git a/shared/test/common/xe2_hpg_core/unit_test_helper_xe2_hpg_core.cpp b/shared/test/common/xe2_hpg_core/unit_test_helper_xe2_hpg_core.cpp new file mode 100644 index 0000000000..c739f07c02 --- /dev/null +++ b/shared/test/common/xe2_hpg_core/unit_test_helper_xe2_hpg_core.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info.h" +#include "shared/test/common/helpers/unit_test_helper.h" +#include "shared/test/common/helpers/unit_test_helper.inl" +#include "shared/test/common/helpers/unit_test_helper_xe2_and_later.inl" +#include "shared/test/common/helpers/unit_test_helper_xe_hpc_and_later.inl" +#include "shared/test/common/helpers/unit_test_helper_xehp_and_later.inl" + +using Family = NEO::Xe2HpgCoreFamily; + +namespace NEO { + +template struct UnitTestHelper; + +} // namespace NEO diff --git a/shared/test/unit_test/encoders/CMakeLists.txt b/shared/test/unit_test/encoders/CMakeLists.txt index c747111702..3b8b156a0d 100644 --- a/shared/test/unit_test/encoders/CMakeLists.txt +++ b/shared/test/unit_test/encoders/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020-2023 Intel Corporation +# Copyright (C) 2020-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -67,4 +67,8 @@ if(TESTS_PVC_AND_LATER) ) endif() +if(TESTS_XE2_AND_LATER) + target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tests_xe2_and_later.cpp) +endif() + add_subdirectories() diff --git a/shared/test/unit_test/encoders/command_encoder_tests_xe2_and_later.cpp b/shared/test/unit_test/encoders/command_encoder_tests_xe2_and_later.cpp new file mode 100644 index 0000000000..547075c1da --- /dev/null +++ b/shared/test/unit_test/encoders/command_encoder_tests_xe2_and_later.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/encode_surface_state.h" +#include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/gmm_helper/gmm_lib.h" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/hw_test.h" +#include "shared/test/common/test_macros/test.h" +#include "shared/test/unit_test/encoders/test_encode_dispatch_kernel_dg2_and_later.h" +#include "shared/test/unit_test/fixtures/command_container_fixture.h" +#include "shared/test/unit_test/fixtures/implicit_scaling_fixture.h" +#include "shared/test/unit_test/mocks/mock_dispatch_kernel_encoder_interface.h" + +using namespace NEO; + +using CommandEncodeStatesTestXe2AndLater = Test; + +using CommandEncoderTestXe2AndLater = ::testing::Test; + +HWTEST2_F(CommandEncoderTestXe2AndLater, whenAdjustCompressionFormatForPlanarImageThenNothingHappens, IsAtLeastXe2HpgCore) { + for (auto plane : {GMM_NO_PLANE, GMM_PLANE_Y, GMM_PLANE_U, GMM_PLANE_V}) { + uint32_t compressionFormat = 0u; + EncodeWA::adjustCompressionFormatForPlanarImage(compressionFormat, plane); + EXPECT_EQ(0u, compressionFormat); + + compressionFormat = 0xFFu; + EncodeWA::adjustCompressionFormatForPlanarImage(compressionFormat, plane); + EXPECT_EQ(0xFFu, compressionFormat); + } +} + +HWTEST2_F(CommandEncodeStatesTestXe2AndLater, whenDebugFlagIsEnabledForAdjustPipelineSelectThenCommandIsAdded, IsAtLeastXe2HpgCore) { + DebugManagerStateRestore restorer{}; + debugManager.flags.PipelinedPipelineSelect.set(true); + + const auto usedSpaceBefore = cmdContainer->getCommandStream()->getUsed(); + NEO::EncodeComputeMode::adjustPipelineSelect(*cmdContainer, descriptor); + const auto usedSpaceAfter = cmdContainer->getCommandStream()->getUsed(); + + EXPECT_GT(usedSpaceAfter, usedSpaceBefore); +} + +HWTEST2_F(CommandEncodeStatesTestXe2AndLater, whenDebugFlagIsDisabledForAdjustPipelineSelectThenNoCommandIsAdded, IsAtLeastXe2HpgCore) { + DebugManagerStateRestore restorer{}; + debugManager.flags.PipelinedPipelineSelect.set(false); + + const auto usedSpaceBefore = cmdContainer->getCommandStream()->getUsed(); + NEO::EncodeComputeMode::adjustPipelineSelect(*cmdContainer, descriptor); + const auto usedSpaceAfter = cmdContainer->getCommandStream()->getUsed(); + + EXPECT_EQ(usedSpaceAfter, usedSpaceBefore); +} + +HWTEST2_F(ImplicitScalingTests, GivenXeAtLeastHpg2WhenCheckingPipeControlStallRequiredThenExpectTrue, IsAtLeastXe2HpgCore) { + EXPECT_FALSE(ImplicitScalingDispatch::getPipeControlStallRequired()); +} diff --git a/shared/test/unit_test/helpers/CMakeLists.txt b/shared/test/unit_test/helpers/CMakeLists.txt index 485768f2d1..2ea64be215 100644 --- a/shared/test/unit_test/helpers/CMakeLists.txt +++ b/shared/test/unit_test/helpers/CMakeLists.txt @@ -79,4 +79,10 @@ if(TESTS_PVC_AND_LATER) ) endif() +if(TESTS_XE2_AND_LATER) + target_sources(neo_shared_tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/gfx_core_helper_xe2_and_later.cpp + ) +endif() + add_subdirectories() diff --git a/shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp b/shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp new file mode 100644 index 0000000000..e3f2ecbc79 --- /dev/null +++ b/shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/gfx_core_helper.h" +#include "shared/source/helpers/register_offsets.h" +#include "shared/test/common/cmd_parse/hw_parse.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/mocks/mock_command_stream_receiver.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_execution_environment.h" +#include "shared/test/common/test_macros/hw_test.h" + +using namespace NEO; + +using GfxCoreHelperXe2AndLaterTests = ::testing::Test; +HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenAtLeastXe2HpgWhenCallIsTimestampShiftRequiredThenFalseIsReturned, IsAtLeastXe2HpgCore) { + MockExecutionEnvironment mockExecutionEnvironment{}; + + auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); + EXPECT_FALSE(gfxCoreHelper.isTimestampShiftRequired()); +} + +HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenAtLeastXe2HpgWhenGetIOHAlignmentThenReturnsCorrectValue, IsAtLeastXe2HpgCore) { + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); + EXPECT_EQ(gfxCoreHelper.getIOHAlignment(), 256u); +} + +HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenAtLeastXe2HpgAndForceIOHAlignmentFlagWhenGetIOHAlignmentThenReturnsCorrectValue, IsAtLeastXe2HpgCore) { + DebugManagerStateRestore restorer; + debugManager.flags.ForceIOHAlignment.set(1024); + + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); + EXPECT_EQ(gfxCoreHelper.getIOHAlignment(), 1024u); +} + +HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenDebugFlagWhenCheckingIsResolveDependenciesByPipeControlsSupportedThenCorrectValueIsReturned, IsLNL) { + DebugManagerStateRestore restorer; + + auto pInHwInfo = *defaultHwInfo; + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); + MockCommandStreamReceiver csr(*mockDevice->getExecutionEnvironment(), mockDevice->getRootDeviceIndex(), mockDevice->getDeviceBitfield()); + csr.taskCount = 2; + auto productHelper = &mockDevice->getProductHelper(); + + // ResolveDependenciesViaPipeControls = -1 (default) + EXPECT_TRUE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 2, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 2, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 3, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 3, csr)); + + debugManager.flags.ResolveDependenciesViaPipeControls.set(0); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 2, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 2, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 3, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 3, csr)); + + debugManager.flags.ResolveDependenciesViaPipeControls.set(1); + EXPECT_TRUE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 2, csr)); + EXPECT_TRUE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 2, csr)); + EXPECT_TRUE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 3, csr)); + EXPECT_TRUE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 3, csr)); +} + +HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenDebugFlagWhenCheckingIsResolveDependenciesByPipeControlsSupportedThenCorrectValueIsReturned, IsBMG) { + DebugManagerStateRestore restorer; + + auto pInHwInfo = *defaultHwInfo; + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); + MockCommandStreamReceiver csr(*mockDevice->getExecutionEnvironment(), mockDevice->getRootDeviceIndex(), mockDevice->getDeviceBitfield()); + csr.taskCount = 2; + auto productHelper = &mockDevice->getProductHelper(); + + // ResolveDependenciesViaPipeControls = -1 (default) + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 2, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 2, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 3, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 3, csr)); + + debugManager.flags.ResolveDependenciesViaPipeControls.set(0); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 2, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 2, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 3, csr)); + EXPECT_FALSE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 3, csr)); + + debugManager.flags.ResolveDependenciesViaPipeControls.set(1); + EXPECT_TRUE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 2, csr)); + EXPECT_TRUE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 2, csr)); + EXPECT_TRUE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, false, 3, csr)); + EXPECT_TRUE(productHelper->isResolveDependenciesByPipeControlsSupported(pInHwInfo, true, 3, csr)); +} + +HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenAtLeastXe2HpgWhenEncodeAdditionalTimestampOffsetsThenOffsetsEncoded, IsAtLeastXe2HpgCore) { + using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM; + constexpr static auto bufferSize = sizeof(MI_STORE_REGISTER_MEM) * 2; + + char streamBuffer[bufferSize]; + LinearStream stream(streamBuffer, bufferSize); + uint64_t fstAddress = 12; + uint64_t sndAddress = 100; + MemorySynchronizationCommands::encodeAdditionalTimestampOffsets(stream, fstAddress, sndAddress); + + HardwareParse hwParser; + hwParser.parseCommands(stream, 0); + GenCmdList storeRegMemList = hwParser.getCommandsList(); + EXPECT_EQ(2u, storeRegMemList.size()); + auto storeRegMemIt = find(hwParser.cmdList.begin(), hwParser.cmdList.end()); + EXPECT_NE(storeRegMemIt, hwParser.cmdList.end()); + + auto storeRegMem = genCmdCast(*storeRegMemIt); + EXPECT_EQ(storeRegMem->getRegisterAddress(), RegisterOffsets::gpThreadTimeRegAddressOffsetHigh); + EXPECT_EQ(storeRegMem->getMemoryAddress(), fstAddress + sizeof(uint32_t)); + + storeRegMem = genCmdCast(*(++storeRegMemIt)); + EXPECT_EQ(storeRegMem->getRegisterAddress(), RegisterOffsets::globalTimestampUn); + EXPECT_EQ(storeRegMem->getMemoryAddress(), sndAddress + sizeof(uint32_t)); +} diff --git a/shared/test/unit_test/preamble/CMakeLists.txt b/shared/test/unit_test/preamble/CMakeLists.txt index 37ecbd6ef3..6dd1418c43 100644 --- a/shared/test/unit_test/preamble/CMakeLists.txt +++ b/shared/test/unit_test/preamble/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2022 Intel Corporation +# Copyright (C) 2019-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -13,6 +13,10 @@ if(TESTS_XE_HPG_CORE) list(APPEND NEO_CORE_PREAMBLE_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_xe_hpg_core.cpp) endif() +if(TESTS_XE2_AND_LATER) + list(APPEND NEO_CORE_PREAMBLE_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_xe2_and_later.cpp) +endif() + target_sources(neo_shared_tests PRIVATE ${NEO_CORE_PREAMBLE_TESTS}) -add_subdirectories() \ No newline at end of file +add_subdirectories() diff --git a/shared/test/unit_test/preamble/test_preamble_xe2_and_later.cpp b/shared/test/unit_test/preamble/test_preamble_xe2_and_later.cpp new file mode 100644 index 0000000000..7a9253d4e9 --- /dev/null +++ b/shared/test/unit_test/preamble/test_preamble_xe2_and_later.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/linear_stream.h" +#include "shared/source/command_stream/stream_properties.h" +#include "shared/source/helpers/preamble.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/fixtures/preamble_fixture.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/mocks/mock_execution_environment.h" +#include "shared/test/common/mocks/mock_graphics_allocation.h" +#include "shared/test/common/test_macros/test.h" + +using namespace NEO; + +using atLeastXe2HpgCore = IsAtLeastXe2HpgCore; + +using PreambleTest = ::testing::Test; + +HWTEST2_F(PreambleTest, givenAtLeastXe2HpgCoreAndNotSetDebugFlagWhenPreambleCfeStateIsProgrammedThenStackIDControlIsDefault, IsXe2HpgCore) { + using CFE_STATE = typename FamilyType::CFE_STATE; + using STACK_ID_CONTROL = typename CFE_STATE::STACK_ID_CONTROL; + + char buffer[64]; + MockGraphicsAllocation graphicsAllocation(buffer, sizeof(buffer)); + LinearStream preambleStream(&graphicsAllocation, graphicsAllocation.getUnderlyingBuffer(), graphicsAllocation.getUnderlyingBufferSize()); + + auto pVfeCmd = PreambleHelper::getSpaceForVfeState(&preambleStream, *defaultHwInfo, EngineGroupType::renderCompute); + StreamProperties streamProperties{}; + + MockExecutionEnvironment executionEnvironment{}; + PreambleHelper::programVfeState(pVfeCmd, *executionEnvironment.rootDeviceEnvironments[0], 0u, 0, 0, streamProperties); + + auto &cfeState = *reinterpret_cast(pVfeCmd); + EXPECT_EQ(cfeState.getStackIdControl(), static_cast(0b00u)); +} + +HWTEST2_F(PreambleTest, givenAtLeastXe2HpgCoreAndSetDebugFlagWhenPreambleCfeStateIsProgrammedThenStackIDControlIsChanged, IsXe2HpgCore) { + using CFE_STATE = typename FamilyType::CFE_STATE; + using STACK_ID_CONTROL = typename CFE_STATE::STACK_ID_CONTROL; + char buffer[64]; + MockGraphicsAllocation graphicsAllocation(buffer, sizeof(buffer)); + LinearStream preambleStream(&graphicsAllocation, graphicsAllocation.getUnderlyingBuffer(), graphicsAllocation.getUnderlyingBufferSize()); + DebugManagerStateRestore debugRestore; + + debugManager.flags.CFEStackIDControl.set(0b10u); + + auto pVfeCmd = PreambleHelper::getSpaceForVfeState(&preambleStream, *defaultHwInfo, EngineGroupType::renderCompute); + StreamProperties streamProperties{}; + + MockExecutionEnvironment executionEnvironment{}; + PreambleHelper::programVfeState(pVfeCmd, *executionEnvironment.rootDeviceEnvironments[0], 0u, 0, 0, streamProperties); + + auto &cfeState = *reinterpret_cast(pVfeCmd); + EXPECT_EQ(cfeState.getStackIdControl(), static_cast(0b10u)); +} + +HWTEST2_F(PreambleTest, givenPreambleHelperThenSystolicModeIsDisabled, atLeastXe2HpgCore) { + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; + EXPECT_FALSE(PreambleHelper::isSystolicModeConfigurable(rootDeviceEnvironment)); +} + +HWTEST2_F(PreambleTest, givenPreambleHelperThenGetCmdSizeForPipelineSelectReturnsZero, atLeastXe2HpgCore) { + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; + EXPECT_EQ(0u, PreambleHelper::getCmdSizeForPipelineSelect(rootDeviceEnvironment)); +} + +HWTEST2_F(PreambleTest, givenPreambleHelperAndDebugFlagThenGetCmdSizeForPipelineSelectReturnsCorrectSize, atLeastXe2HpgCore) { + DebugManagerStateRestore restorer{}; + debugManager.flags.PipelinedPipelineSelect.set(true); + + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; + + EXPECT_EQ(sizeof(typename FamilyType::PIPELINE_SELECT), PreambleHelper::getCmdSizeForPipelineSelect(rootDeviceEnvironment)); +} + +HWTEST2_F(PreambleFixture, givenPreambleHelperWhenCallingProgramPipelineSelectThenStreamDoesNotChange, atLeastXe2HpgCore) { + const auto initialStreamSize = linearStream.getUsed(); + PipelineSelectArgs pipelineArgs; + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; + + PreambleHelper::programPipelineSelect(&linearStream, pipelineArgs, rootDeviceEnvironment); + EXPECT_EQ(initialStreamSize, linearStream.getUsed()); +} + +HWTEST2_F(PreambleFixture, givenPreambleHelperAndDebugFlagEnabledWhenCallingProgramPipelineSelectThenPipelineSelectionIsProgrammed, atLeastXe2HpgCore) { + using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT; + + DebugManagerStateRestore restorer{}; + debugManager.flags.PipelinedPipelineSelect.set(true); + + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; + + PipelineSelectArgs pipelineArgs; + PreambleHelper::programPipelineSelect(&linearStream, pipelineArgs, rootDeviceEnvironment); + + parseCommands(linearStream); + const auto cmdIt = find(cmdList.begin(), cmdList.end()); + + ASSERT_NE(cmdIt, cmdList.cend()); + + auto cmd = genCmdCast(*cmdIt); + EXPECT_EQ(cmd->getPipelineSelection(), PIPELINE_SELECT::PIPELINE_SELECTION_GPGPU); +} diff --git a/shared/test/unit_test/preemption/CMakeLists.txt b/shared/test/unit_test/preemption/CMakeLists.txt index c58e1ef43f..3940ca7b3d 100644 --- a/shared/test/unit_test/preemption/CMakeLists.txt +++ b/shared/test/unit_test/preemption/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2022 Intel Corporation +# Copyright (C) 2019-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -13,4 +13,8 @@ if(TESTS_XEHP_AND_LATER) target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_xehp_and_later.cpp) endif() -add_subdirectories() \ No newline at end of file +if(TESTS_XE2_AND_LATER) + target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_xe2_and_later.cpp) +endif() + +add_subdirectories() diff --git a/shared/test/unit_test/preemption/test_preemption_xe2_and_later.cpp b/shared/test/unit_test/preemption/test_preemption_xe2_and_later.cpp new file mode 100644 index 0000000000..f98511534f --- /dev/null +++ b/shared/test/unit_test/preemption/test_preemption_xe2_and_later.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/preemption.h" +#include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/memory_manager/memory_allocation.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/cmd_parse/hw_parse.h" +#include "shared/test/common/mocks/mock_csr.h" +#include "shared/test/common/mocks/mock_debugger.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/hw_test.h" +#include "shared/test/unit_test/fixtures/preemption_fixture.h" + +using namespace NEO; + +struct Xe2PreemptionTests : public DevicePreemptionTests { + void SetUp() override { + DevicePreemptionTests::SetUp(); + + commandStream.replaceBuffer(buffer, Xe2PreemptionTests::bufferSize); + } + void TearDown() override { + DevicePreemptionTests::TearDown(); + } + + constexpr static size_t bufferSize = 128u; + uint8_t buffer[bufferSize]; + LinearStream commandStream; +}; + +struct Xe2MidThreadPreemptionTests : public Xe2PreemptionTests { + void SetUp() override { + dbgRestore.reset(new DebugManagerStateRestore()); + + debugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::MidThread)); + preemptionMode = PreemptionMode::MidThread; + + Xe2PreemptionTests::SetUp(); + } + void TearDown() override { + Xe2PreemptionTests::TearDown(); + } +}; + +struct Xe2ThreadGroupPreemptionTests : public Xe2PreemptionTests { + void SetUp() override { + dbgRestore.reset(new DebugManagerStateRestore()); + + debugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::ThreadGroup)); + preemptionMode = PreemptionMode::ThreadGroup; + + Xe2PreemptionTests::SetUp(); + } + void TearDown() override { + Xe2PreemptionTests::TearDown(); + } +}; + +HWTEST2_F(Xe2MidThreadPreemptionTests, givenMidThreadPreemptionOrDebugEnabledWhenQueryingRequiredPreambleSizeThenExpectCorrectSize, IsAtLeastXe2HpgCore) { + using STATE_CONTEXT_DATA_BASE_ADDRESS = typename FamilyType::STATE_CONTEXT_DATA_BASE_ADDRESS; + + // Mid thread preemption is forced And debugger not enabled + size_t cmdSize = PreemptionHelper::getRequiredPreambleSize(*device); + EXPECT_EQ(sizeof(STATE_CONTEXT_DATA_BASE_ADDRESS), cmdSize); + + // No mid thread preemption but debugger enabled + device->overridePreemptionMode(PreemptionMode::Initial); + device->getExecutionEnvironment()->rootDeviceEnvironments[0]->initDebuggerL0(device.get()); + cmdSize = PreemptionHelper::getRequiredPreambleSize(*device); + EXPECT_EQ(sizeof(STATE_CONTEXT_DATA_BASE_ADDRESS), cmdSize); +} + +HWTEST2_F(Xe2MidThreadPreemptionTests, givenNeitherMidThreadPreemptionNOrDebugEnabledWhenQueryingRequiredPreambleSizeThenExpectZeroSize, IsAtLeastXe2HpgCore) { + device->overridePreemptionMode(PreemptionMode::Initial); + size_t cmdSize = PreemptionHelper::getRequiredPreambleSize(*device); + EXPECT_EQ(0u, cmdSize); +} + +HWTEST2_F(Xe2MidThreadPreemptionTests, givenMidThreadPreemptionWhenProgrammingPreemptionThenExpectZeroCommandsDispatched, IsAtLeastXe2HpgCore) { + auto &csr = device->getUltCommandStreamReceiver(); + MemoryAllocation *csrSurface = static_cast(csr.getPreemptionAllocation()); + ASSERT_NE(nullptr, csrSurface); + + size_t cmdSize = PreemptionHelper::getRequiredCmdStreamSize(PreemptionMode::MidThread, PreemptionMode::Initial); + EXPECT_EQ(0u, cmdSize); + + PreemptionHelper::programCmdStream(commandStream, PreemptionMode::MidThread, PreemptionMode::Initial, csrSurface); + EXPECT_EQ(0u, commandStream.getUsed()); +} + +HWTEST2_F(Xe2MidThreadPreemptionTests, givenMidThreadPreemptionWhenProgrammingPreemptionPreambleThenExpectCsrCommandDispatched, IsXe2HpgCore) { + using STATE_CONTEXT_DATA_BASE_ADDRESS = typename FamilyType::STATE_CONTEXT_DATA_BASE_ADDRESS; + + auto &csr = device->getUltCommandStreamReceiver(); + MemoryAllocation *csrSurface = static_cast(csr.getPreemptionAllocation()); + ASSERT_NE(nullptr, csrSurface); + + uint64_t gpuVa = 0x1230000; + auto gmmHelper = device->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(gpuVa); + csrSurface->setCpuPtrAndGpuAddress(csrSurface->getUnderlyingBuffer(), canonizedGpuAddress); + + size_t cmdSize = PreemptionHelper::getRequiredPreambleSize(*device); + EXPECT_EQ(sizeof(STATE_CONTEXT_DATA_BASE_ADDRESS), cmdSize); + + PreemptionHelper::programCsrBaseAddress(commandStream, *device, csrSurface); + EXPECT_EQ(cmdSize, commandStream.getUsed()); + + HardwareParse hwParse; + hwParse.parseCommands(commandStream, 0u); + hwParse.findCsrBaseAddress(); + ASSERT_NE(nullptr, hwParse.cmdGpgpuCsrBaseAddress); + auto cmd = static_cast(hwParse.cmdGpgpuCsrBaseAddress); + EXPECT_EQ(canonizedGpuAddress, cmd->getContextDataBaseAddress()); +} + +HWTEST2_F(Xe2ThreadGroupPreemptionTests, givenThreadGroupPreemptionWhenProgrammingPreemptionPreambleThenExpectNoCsrCommandDispatched, IsAtLeastXe2HpgCore) { + using STATE_CONTEXT_DATA_BASE_ADDRESS = typename FamilyType::STATE_CONTEXT_DATA_BASE_ADDRESS; + + size_t cmdSize = PreemptionHelper::getRequiredPreambleSize(*device); + EXPECT_EQ(0u, cmdSize); + + PreemptionHelper::programCsrBaseAddress(commandStream, *device, nullptr); + EXPECT_EQ(0u, commandStream.getUsed()); +} + +HWTEST2_F(Xe2MidThreadPreemptionTests, whenProgramStateSipIsCalledThenStateSipCmdIsAddedToStream, IsXe2HpgCore) { + size_t requiredSize = PreemptionHelper::getRequiredStateSipCmdSize(*device, false); + EXPECT_NE(0U, requiredSize); + + constexpr auto bufferSize = 128u; + uint64_t buffer[bufferSize]; + LinearStream cmdStream{buffer, bufferSize * sizeof(uint64_t)}; + PreemptionHelper::programStateSip(cmdStream, *device, nullptr); + EXPECT_NE(0U, cmdStream.getUsed()); +} diff --git a/shared/test/unit_test/xe2_hpg_core/CMakeLists.txt b/shared/test/unit_test/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..577c568b23 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,32 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XE2_HPG_CORE) + set(NEO_CORE_tests_xe2_hpg_core_excludes ${CMAKE_CURRENT_SOURCE_DIR}/excludes_xe2_hpg_core.cpp) + set_property(GLOBAL APPEND PROPERTY NEO_CORE_tests_excludes ${NEO_CORE_tests_xe2_hpg_core_excludes}) + + target_sources(neo_shared_tests PRIVATE + ${NEO_CORE_tests_xe2_hpg_core_excludes} + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/aub_command_stream_receiver_2_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/compute_mode_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gfx_core_helper_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/hw_cmds_xe2_hpg_core_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/simd_helper_tests_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_blit_commands_helper_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_device_caps_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_encode_3dstate_btd_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_encode_xe2_hpg_core.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_xe2_hpg_core.cpp + ) + + if(DEFINED AUB_STREAM_PROJECT_NAME) + target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/aub_center_using_aubstream_lib_tests_xe2_hpg_core.cpp) + endif() + + add_subdirectories() +endif() diff --git a/shared/test/unit_test/xe2_hpg_core/aub_center_using_aubstream_lib_tests_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/aub_center_using_aubstream_lib_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..075b72aa93 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/aub_center_using_aubstream_lib_tests_xe2_hpg_core.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/gmm_helper/client_context/gmm_client_context.h" +#include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/helpers/hw_info.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/helpers/variable_backup.h" +#include "shared/test/common/mocks/mock_aub_center.h" +#include "shared/test/common/mocks/mock_execution_environment.h" +#include "shared/test/common/test_macros/hw_test.h" + +#include "aubstream/aubstream.h" + +#include + +using namespace NEO; + +namespace aub_stream_stubs { +extern aub_stream::MMIOList mmioListInjected; // NOLINT(readability-identifier-naming) +} // namespace aub_stream_stubs +using AubHelperCompressionXe2AndLaterTests = ::testing::Test; + +HWTEST2_F(AubHelperCompressionXe2AndLaterTests, givenCompressionEnabledAndWhenCreatingAubCenterThenPassAdditionalMmioList, IsAtLeastXe2HpgCore) { + DebugManagerStateRestore stateRestore; + debugManager.flags.RenderCompressedBuffersEnabled.set(true); + MockExecutionEnvironment executionEnvironment{}; + RootDeviceEnvironment &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + + const std::string aubName("file.aub"); + + { + debugManager.flags.ForceBufferCompressionFormat.set(0xE); + + VariableBackup backup(&aub_stream_stubs::mmioListInjected); + AubCenter aubCenter(rootDeviceEnvironment, false, aubName, CommandStreamReceiverType::aub); + + ASSERT_EQ(1u, aub_stream_stubs::mmioListInjected.size()); + + EXPECT_EQ(0x4148u, aub_stream_stubs::mmioListInjected[0].first); + EXPECT_EQ(0xEu, aub_stream_stubs::mmioListInjected[0].second); + } +} + +HWTEST2_F(AubHelperCompressionXe2AndLaterTests, givenCompressionEnabledAndAddMmioRegisterListDebugFlagsWhenCreatingAubCenterThenPassAdditionalMmioList, IsAtLeastXe2HpgCore) { + DebugManagerStateRestore stateRestore; + debugManager.flags.RenderCompressedBuffersEnabled.set(true); + + const std::string aubName("file.aub"); + + MockExecutionEnvironment executionEnvironment{}; + RootDeviceEnvironment &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto &gmmHelper = *rootDeviceEnvironment.getGmmHelper(); + uint32_t compressionFormat = gmmHelper.getClientContext()->getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT::GMM_FORMAT_GENERIC_8BIT); + + { + VariableBackup backup(&aub_stream_stubs::mmioListInjected); + + debugManager.flags.AubDumpAddMmioRegistersList.set("0x123;0x1;0x234;0x2"); + AubCenter aubCenter(rootDeviceEnvironment, false, aubName, CommandStreamReceiverType::aub); + + ASSERT_EQ(3u, aub_stream_stubs::mmioListInjected.size()); + + EXPECT_EQ(0x4148u, aub_stream_stubs::mmioListInjected[0].first); + EXPECT_EQ(compressionFormat, aub_stream_stubs::mmioListInjected[0].second); + + EXPECT_EQ(0x123u, aub_stream_stubs::mmioListInjected[1].first); + EXPECT_EQ(0x1u, aub_stream_stubs::mmioListInjected[1].second); + + EXPECT_EQ(0x234u, aub_stream_stubs::mmioListInjected[2].first); + EXPECT_EQ(0x2u, aub_stream_stubs::mmioListInjected[2].second); + } +} + +HWTEST2_F(AubHelperCompressionXe2AndLaterTests, givenCompressionDisabledWhenCreatingAubCenterThenDontPassAdditionalMmioList, IsAtLeastXe2HpgCore) { + DebugManagerStateRestore stateRestore; + + const std::string aubName("file.aub"); + + static constexpr std::array, 4> params = {{ + std::make_pair(true, false), + std::make_pair(false, true), + std::make_pair(false, false), + std::make_pair(true, true), + }}; + + MockExecutionEnvironment executionEnvironment{}; + RootDeviceEnvironment &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + auto &gmmHelper = *rootDeviceEnvironment.getGmmHelper(); + uint32_t compressionFormat = gmmHelper.getClientContext()->getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT::GMM_FORMAT_GENERIC_8BIT); + + for (auto ¶m : params) { + VariableBackup backup(&aub_stream_stubs::mmioListInjected); + + debugManager.flags.RenderCompressedBuffersEnabled.set(param.first); + debugManager.flags.RenderCompressedImagesEnabled.set(param.second); + AubCenter aubCenter(rootDeviceEnvironment, false, aubName, CommandStreamReceiverType::aub); + + if (param.first || param.second) { + ASSERT_EQ(1u, aub_stream_stubs::mmioListInjected.size()); + + EXPECT_EQ(0x4148u, aub_stream_stubs::mmioListInjected[0].first); + EXPECT_EQ(compressionFormat, aub_stream_stubs::mmioListInjected[0].second); + } else { + EXPECT_EQ(0u, aub_stream_stubs::mmioListInjected.size()); + } + } +} diff --git a/shared/test/unit_test/xe2_hpg_core/aub_command_stream_receiver_2_tests_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/aub_command_stream_receiver_2_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..88a5ab4724 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/aub_command_stream_receiver_2_tests_xe2_hpg_core.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/aub_mem_dump/aub_alloc_dump.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/fixtures/aub_command_stream_receiver_fixture.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_aub_csr.h" +#include "shared/test/common/mocks/mock_aub_manager.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_os_context.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +using namespace NEO; + +using AubCommandStreamReceiverXe2HpgCoreTests = ::testing::Test; + +XE2_HPG_CORETEST_F(AubCommandStreamReceiverXe2HpgCoreTests, givenLinkBcsEngineWhenDumpAllocationCalledThenIgnore) { + DebugManagerStateRestore dbgRestore; + debugManager.flags.AUBDumpBufferFormat.set("BIN"); + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); + + auto memoryManager = device->getMemoryManager(); + auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties({device->getRootDeviceIndex(), MemoryConstants::pageSize, AllocationType::buffer, device->getDeviceBitfield()}); + gfxAllocation->setMemObjectsAllocationWithWritableFlags(true); + EXPECT_TRUE(AubAllocDump::isWritableBuffer(*gfxAllocation)); + + auto engineDescriptor = EngineDescriptorHelper::getDefaultDescriptor(); + + for (uint32_t i = aub_stream::EngineType::ENGINE_BCS1; i <= aub_stream::EngineType::ENGINE_BCS8; i++) { + MockAubCsr aubCsr("", true, *device->getExecutionEnvironment(), device->getRootDeviceIndex(), device->getDeviceBitfield()); + engineDescriptor.engineTypeUsage.first = static_cast(i); + + MockOsContext osContext(0, engineDescriptor); + aubCsr.setupContext(osContext); + + aubCsr.dumpAllocation(*gfxAllocation); + + auto mockHardwareContext = static_cast(aubCsr.hardwareContextController->hardwareContexts[0].get()); + + EXPECT_FALSE(mockHardwareContext->dumpSurfaceCalled); + EXPECT_TRUE(AubAllocDump::isWritableBuffer(*gfxAllocation)); + } + + memoryManager->freeGraphicsMemory(gfxAllocation); +} diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/CMakeLists.txt b/shared/test/unit_test/xe2_hpg_core/bmg/CMakeLists.txt new file mode 100644 index 0000000000..077896ced8 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/CMakeLists.txt @@ -0,0 +1,20 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_BMG) + target_sources(neo_shared_tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper_tests_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/excludes_xe2_hpg_core_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/hw_aot_config_tests_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gfx_core_helper_tests_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/product_helper_tests_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_tests_bmg.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_device_caps_bmg.cpp + ) + + add_subdirectories() +endif() diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/engine_node_helper_tests_bmg.cpp b/shared/test/unit_test/xe2_hpg_core/bmg/engine_node_helper_tests_bmg.cpp new file mode 100644 index 0000000000..a63b341658 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/engine_node_helper_tests_bmg.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/engine_node_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_bmg.h" +#include "shared/test/common/fixtures/device_fixture.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +using namespace NEO; +using EngineNodeHelperBmgTests = ::Test; + +HWTEST_EXCLUDE_PRODUCT(CommandEncodeSemaphore, givenIndirectModeSetWhenProgrammingSemaphoreThenSetIndirectBit_IsAtLeastXeHpCore, IGFX_BMG); + +BMGTEST_F(EngineNodeHelperBmgTests, WhenGetBcsEngineTypeIsCalledForBmgThenCorrectBcsEngineIsReturned) { + using namespace aub_stream; + + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); + auto pHwInfo = rootDeviceEnvironment.getMutableHardwareInfo(); + auto deviceBitfield = pDevice->getDeviceBitfield(); + + pHwInfo->featureTable.ftrBcsInfo = 1; + auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); + selectorCopyEngine.isMainUsed.store(true); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + + pHwInfo->featureTable.ftrBcsInfo = 0b111; + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + + pHwInfo->featureTable.ftrBcsInfo = 0b11; + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + + pHwInfo->featureTable.ftrBcsInfo = 0b101; + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); +} diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/excludes_xe2_hpg_core_bmg.cpp b/shared/test/unit_test/xe2_hpg_core/bmg/excludes_xe2_hpg_core_bmg.cpp new file mode 100644 index 0000000000..15fbe8031e --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/excludes_xe2_hpg_core_bmg.cpp @@ -0,0 +1,10 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/test_macros/hw_test_base.h" + +HWTEST_EXCLUDE_PRODUCT(ProductHelperXe2AndLaterTests, givenProductHelperWhenCheckingIsBufferPoolAllocatorSupportedThenCorrectValueIsReturned_IsAtLeastXe2HpgCore, IGFX_BMG); \ No newline at end of file diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/gfx_core_helper_tests_bmg.cpp b/shared/test/unit_test/xe2_hpg_core/bmg/gfx_core_helper_tests_bmg.cpp new file mode 100644 index 0000000000..87e3ad5732 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/gfx_core_helper_tests_bmg.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/gfx_core_helper.h" +#include "shared/source/indirect_heap/indirect_heap.h" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/release_helper/release_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_bmg.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/gfx_core_helper_tests.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_graphics_allocation.h" +#include "shared/test/common/mocks/mock_memory_manager.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" + +struct GfxCoreHelperTestsBmg : public GfxCoreHelperTest { + void setUpImpl() { + hardwareInfo = *defaultHwInfo; + auto releaseHelper = ReleaseHelper::create(hardwareInfo.ipVersion); + hardwareInfoSetup[hardwareInfo.platform.eProductFamily](&hardwareInfo, true, 0, releaseHelper.get()); + DeviceFixture::setUpImpl(&hardwareInfo); + } + + void SetUp() override {} +}; + +BMGTEST_F(GfxCoreHelperTestsBmg, givenCommandBufferAllocationTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) { + setUpImpl(); + AllocationData allocData; + AllocationProperties properties(mockRootDeviceIndex, true, 10, AllocationType::commandBuffer, false, mockDeviceBitfield); + + MockMemoryManager mockMemoryManager{*pDevice->getExecutionEnvironment()}; + mockMemoryManager.getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties)); + + EXPECT_FALSE(allocData.flags.useSystemMemory); +} + +BMGTEST_F(GfxCoreHelperTestsBmg, WhenAskingForDcFlushThenReturnFalse) { + setUpImpl(); + EXPECT_FALSE(MemorySynchronizationCommands::getDcFlushEnable(true, pDevice->getRootDeviceEnvironment())); +} diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/hw_aot_config_tests_bmg.cpp b/shared/test/unit_test/xe2_hpg_core/bmg/hw_aot_config_tests_bmg.cpp new file mode 100644 index 0000000000..25cd413874 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/hw_aot_config_tests_bmg.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/product_config_helper.h" +#include "shared/test/common/test_macros/test.h" +#include "shared/test/common/xe2_hpg_core/bmg/product_configs_bmg.h" +#include "shared/test/unit_test/fixtures/product_config_fixture.h" + +using namespace NEO; +INSTANTIATE_TEST_SUITE_P(ProductConfigHwInfoBmgTests, + ProductConfigHwInfoTests, + ::testing::Combine(::testing::ValuesIn(AOT_BMG::productConfigs), + ::testing::Values(IGFX_BMG))); diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/hw_info_tests_bmg.cpp b/shared/test/unit_test/xe2_hpg_core/bmg/hw_info_tests_bmg.cpp new file mode 100644 index 0000000000..1fcd48e2e6 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/hw_info_tests_bmg.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/compiler_product_helper.h" +#include "shared/source/helpers/constants.h" +#include "shared/source/helpers/hw_info.h" +#include "shared/source/release_helper/release_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_bmg.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +using namespace NEO; + +using BmgHwInfoTest = ::testing::Test; + +BMGTEST_F(BmgHwInfoTest, WhenGettingHardwareInfoThenBmgIsReturned) { + EXPECT_EQ(IGFX_BMG, defaultHwInfo->platform.eProductFamily); +} + +BMGTEST_F(BmgHwInfoTest, givenBoolWhenCallBmgHardwareInfoSetupThenFeatureTableAndWorkaroundTableAreSetCorrect) { + HardwareInfo hwInfo = *defaultHwInfo; + auto compilerProductHelper = CompilerProductHelper::create(hwInfo.platform.eProductFamily); + auto releaseHelper = ReleaseHelper::create(hwInfo.ipVersion); + GT_SYSTEM_INFO >SystemInfo = hwInfo.gtSystemInfo; + FeatureTable &featureTable = hwInfo.featureTable; + WorkaroundTable &workaroundTable = hwInfo.workaroundTable; + + for (auto setParamBool : ::testing::Bool()) { + + gtSystemInfo = {0}; + featureTable = {}; + workaroundTable = {}; + hardwareInfoSetup[productFamily](&hwInfo, setParamBool, compilerProductHelper->getHwInfoConfig(hwInfo), releaseHelper.get()); + + EXPECT_EQ(setParamBool, featureTable.flags.ftrL3IACoherency); + EXPECT_EQ(setParamBool, featureTable.flags.ftrLocalMemory); + EXPECT_EQ(setParamBool, featureTable.flags.ftrLinearCCS); + EXPECT_EQ(setParamBool, featureTable.flags.ftrFlatPhysCCS); + EXPECT_EQ(setParamBool, featureTable.flags.ftrCCSNode); + EXPECT_EQ(setParamBool, featureTable.flags.ftrCCSRing); + EXPECT_EQ(setParamBool, featureTable.flags.ftrPPGTT); + EXPECT_EQ(setParamBool, featureTable.flags.ftrSVM); + EXPECT_EQ(setParamBool, featureTable.flags.ftrIA32eGfxPTEs); + EXPECT_EQ(setParamBool, featureTable.flags.ftrStandardMipTailFormat); + EXPECT_EQ(setParamBool, featureTable.flags.ftrTranslationTable); + EXPECT_EQ(setParamBool, featureTable.flags.ftrUserModeTranslationTable); + EXPECT_EQ(setParamBool, featureTable.flags.ftrTileMappedResource); + EXPECT_EQ(setParamBool, featureTable.flags.ftrFbc); + EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcHdr2D); + EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcLdr2D); + EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuMidBatchPreempt); + EXPECT_EQ(setParamBool, featureTable.flags.ftrE2ECompression); + EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuThreadGroupLevelPreempt); + EXPECT_EQ(setParamBool, featureTable.flags.ftrTile64Optimization); + EXPECT_FALSE(featureTable.flags.ftrTileY); + EXPECT_FALSE(featureTable.flags.ftrMultiTileArch); + EXPECT_EQ(1u, featureTable.ftrBcsInfo.to_ulong()); + EXPECT_EQ(setParamBool, featureTable.flags.ftrWalkerMTP); + EXPECT_EQ(setParamBool, featureTable.flags.ftrXe2Compression); + EXPECT_EQ(setParamBool, featureTable.flags.ftrXe2PlusTiling); + EXPECT_EQ(setParamBool, featureTable.flags.ftrL3TransientDataFlush); + EXPECT_EQ(setParamBool, featureTable.flags.ftrPml5Support); + } +} + +BMGTEST_F(BmgHwInfoTest, whenSetupHardwareInfoThenCorrectValuesOfCCSAndMultiTileInfoAreSet) { + HardwareInfo hwInfo = *defaultHwInfo; + auto compilerProductHelper = CompilerProductHelper::create(hwInfo.platform.eProductFamily); + auto releaseHelper = ReleaseHelper::create(hwInfo.ipVersion); + GT_SYSTEM_INFO >SystemInfo = hwInfo.gtSystemInfo; + + hardwareInfoSetup[productFamily](&hwInfo, false, compilerProductHelper->getHwInfoConfig(hwInfo), releaseHelper.get()); + EXPECT_FALSE(gtSystemInfo.MultiTileArchInfo.IsValid); + + EXPECT_TRUE(gtSystemInfo.CCSInfo.IsValid); + EXPECT_TRUE(1u == gtSystemInfo.CCSInfo.NumberOfCCSEnabled); + EXPECT_TRUE(0b1u == gtSystemInfo.CCSInfo.Instances.CCSEnableMask); +} + +BMGTEST_F(BmgHwInfoTest, whenCheckDirectSubmissionEnginesThenProperValuesAreSetToTrue) { + HardwareInfo hwInfo = *defaultHwInfo; + const auto &directSubmissionEngines = hwInfo.capabilityTable.directSubmissionEngines; + + for (uint32_t i = 0; i < aub_stream::NUM_ENGINES; i++) { + switch (i) { + case aub_stream::ENGINE_CCS: + EXPECT_TRUE(directSubmissionEngines.data[i].engineSupported); + EXPECT_FALSE(directSubmissionEngines.data[i].submitOnInit); + EXPECT_FALSE(directSubmissionEngines.data[i].useNonDefault); + EXPECT_TRUE(directSubmissionEngines.data[i].useRootDevice); + EXPECT_FALSE(directSubmissionEngines.data[i].useInternal); + EXPECT_FALSE(directSubmissionEngines.data[i].useLowPriority); + break; + case aub_stream::ENGINE_CCS1: + EXPECT_TRUE(directSubmissionEngines.data[i].engineSupported); + EXPECT_FALSE(directSubmissionEngines.data[i].submitOnInit); + EXPECT_TRUE(directSubmissionEngines.data[i].useNonDefault); + EXPECT_TRUE(directSubmissionEngines.data[i].useRootDevice); + EXPECT_FALSE(directSubmissionEngines.data[i].useInternal); + EXPECT_FALSE(directSubmissionEngines.data[i].useLowPriority); + break; + default: + EXPECT_FALSE(directSubmissionEngines.data[i].engineSupported); + EXPECT_FALSE(directSubmissionEngines.data[i].submitOnInit); + EXPECT_FALSE(directSubmissionEngines.data[i].useNonDefault); + EXPECT_FALSE(directSubmissionEngines.data[i].useRootDevice); + EXPECT_FALSE(directSubmissionEngines.data[i].useInternal); + EXPECT_FALSE(directSubmissionEngines.data[i].useLowPriority); + } + } +} diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/linux/CMakeLists.txt b/shared/test/unit_test/xe2_hpg_core/bmg/linux/CMakeLists.txt new file mode 100644 index 0000000000..049220c5a9 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/linux/CMakeLists.txt @@ -0,0 +1,9 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(UNIX) + target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/product_helper_tests_bmg_linux.cpp) +endif() diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/linux/product_helper_tests_bmg_linux.cpp b/shared/test/unit_test/xe2_hpg_core/bmg/linux/product_helper_tests_bmg_linux.cpp new file mode 100644 index 0000000000..a34122eac0 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/linux/product_helper_tests_bmg_linux.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/os_interface.h" +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/os_interface/linux/drm_mock_extended.h" +#include "shared/test/unit_test/os_interface/linux/product_helper_linux_tests.h" + +#include "per_product_test_definitions.h" + +using namespace NEO; + +struct BmgProductHelperLinux : ProductHelperTestLinux { + void SetUp() override { + ProductHelperTestLinux::SetUp(); + + drm = new DrmMockExtended(*executionEnvironment->rootDeviceEnvironments[0]); + osInterface->setDriverModel(std::unique_ptr(drm)); + } +}; + +BMGTEST_F(BmgProductHelperLinux, WhenConfiguringHwInfoThenZeroIsReturned) { + + int ret = productHelper->configureHwInfoDrm(&pInHwInfo, &outHwInfo, getRootDeviceEnvironment()); + EXPECT_EQ(0, ret); +} + +BMGTEST_F(BmgProductHelperLinux, given57bAddressSpaceWhenConfiguringHwInfoThenSetFtrFlag) { + + outHwInfo.featureTable.flags.ftr57bGPUAddressing = false; + outHwInfo.platform.eRenderCoreFamily = defaultHwInfo->platform.eRenderCoreFamily; + + outHwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(48); + + int ret = productHelper->configureHardwareCustom(&outHwInfo, osInterface); + EXPECT_EQ(0, ret); + EXPECT_FALSE(outHwInfo.featureTable.flags.ftr57bGPUAddressing); + + outHwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(57); + ret = productHelper->configureHardwareCustom(&outHwInfo, osInterface); + EXPECT_EQ(0, ret); + EXPECT_TRUE(outHwInfo.featureTable.flags.ftr57bGPUAddressing); +} + +BMGTEST_F(BmgProductHelperLinux, givenProductHelperWhenAskedIfPatIndexProgrammingSupportedThenReturnTrue) { + EXPECT_TRUE(productHelper->isVmBindPatIndexProgrammingSupported()); +} + +BMGTEST_F(BmgProductHelperLinux, givenProductHelperWhenCheckDirectSubmissionSupportedThenFalseIsReturned) { + EXPECT_FALSE(productHelper->isDirectSubmissionSupported(releaseHelper)); +} + +BMGTEST_F(BmgProductHelperLinux, givenProductHelperWhenAskedIsPageFaultSupportedThenReturnFalse) { + EXPECT_FALSE(productHelper->isPageFaultSupported()); +} + +BMGTEST_F(BmgProductHelperLinux, givenProductHelperWhenAskedIsKmdMigrationSupportedThenReturnFalse) { + EXPECT_FALSE(productHelper->isKmdMigrationSupported()); +} + +BMGTEST_F(BmgProductHelperLinux, givenProductHelperWhenAskedIsDisableScratchPagesSupportedThenReturnFalse) { + EXPECT_FALSE(productHelper->isDisableScratchPagesSupported()); +} + +BMGTEST_F(BmgProductHelperLinux, WhenGtIsSetupThenGtSystemInfoIsCorrect) { + auto executionEnvironment = std::make_unique(); + executionEnvironment->prepareRootDeviceEnvironments(1); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get()); + executionEnvironment->rootDeviceEnvironments[0]->initGmm(); + + DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]); + DeviceDescriptor device = {0, &BmgHwConfig::hwInfo, &BmgHwConfig::setupHardwareInfo}; + + int ret = drm.setupHardwareInfo(&device, false); + + const auto >SystemInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->gtSystemInfo; + + EXPECT_EQ(ret, 0); + EXPECT_GT(gtSystemInfo.EUCount, 0u); + EXPECT_GT(gtSystemInfo.ThreadCount, 0u); + EXPECT_GT(gtSystemInfo.SliceCount, 0u); + EXPECT_GT(gtSystemInfo.SubSliceCount, 0u); + EXPECT_GT(gtSystemInfo.DualSubSliceCount, 0u); + EXPECT_GT_VAL(gtSystemInfo.L3CacheSizeInKb, 0u); + EXPECT_EQ(gtSystemInfo.CsrSizeInMb, 0u); + EXPECT_FALSE(gtSystemInfo.IsDynamicallyPopulated); + EXPECT_GT(gtSystemInfo.DualSubSliceCount, 0u); + EXPECT_GT(gtSystemInfo.MaxDualSubSlicesSupported, 0u); +} diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/product_helper_tests_bmg.cpp b/shared/test/unit_test/xe2_hpg_core/bmg/product_helper_tests_bmg.cpp new file mode 100644 index 0000000000..28f1d6d389 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/product_helper_tests_bmg.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/stream_properties.h" +#include "shared/source/helpers/compiler_product_helper.h" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" +#include "shared/test/unit_test/os_interface/product_helper_tests.h" + +#include "aubstream/product_family.h" +#include "platforms.h" + +using namespace NEO; + +using BmgProductHelper = ProductHelperTest; + +BMGTEST_F(BmgProductHelper, whenGettingAubstreamProductFamilyThenProperEnumValueIsReturned) { + EXPECT_EQ(aub_stream::ProductFamily::Bmg, productHelper->getAubStreamProductFamily()); +} + +BMGTEST_F(BmgProductHelper, givenProductHelperWhenGettingEvictIfNecessaryFlagSupportedThenExpectTrue) { + + EXPECT_TRUE(productHelper->isEvictionIfNecessaryFlagSupported()); +} + +BMGTEST_F(BmgProductHelper, whenGettingMidThreadPreemptionSupportForRtKernelsThenExpectNoSupport) { + + EXPECT_TRUE(productHelper->isMidThreadPreemptionDisallowedForRayTracingKernels()); +} + +BMGTEST_F(BmgProductHelper, givenBmgProductHelperWhenIsInitBuiltinAsyncSupportedThenReturnFalse) { + EXPECT_FALSE(productHelper->isInitBuiltinAsyncSupported(*defaultHwInfo)); +} + +BMGTEST_F(BmgProductHelper, givenProductHelperWhenGetCommandsStreamPropertiesSupportThenExpectCorrectValues) { + + EXPECT_TRUE(productHelper->getScmPropertyThreadArbitrationPolicySupport()); + EXPECT_TRUE(productHelper->getScmPropertyCoherencyRequiredSupport()); + EXPECT_FALSE(productHelper->getScmPropertyZPassAsyncComputeThreadLimitSupport()); + EXPECT_FALSE(productHelper->getScmPropertyPixelAsyncComputeThreadLimitSupport()); + EXPECT_TRUE(productHelper->getScmPropertyLargeGrfModeSupport()); + EXPECT_FALSE(productHelper->getScmPropertyDevicePreemptionModeSupport()); + + EXPECT_TRUE(productHelper->getStateBaseAddressPropertyBindingTablePoolBaseAddressSupport()); + + EXPECT_TRUE(productHelper->getFrontEndPropertyScratchSizeSupport()); + EXPECT_TRUE(productHelper->getFrontEndPropertyPrivateScratchSizeSupport()); + + EXPECT_FALSE(productHelper->getPreemptionDbgPropertyPreemptionModeSupport()); + EXPECT_TRUE(productHelper->getPreemptionDbgPropertyStateSipSupport()); + EXPECT_TRUE(productHelper->getPreemptionDbgPropertyCsrSurfaceSupport()); + + EXPECT_FALSE(productHelper->getFrontEndPropertyComputeDispatchAllWalkerSupport()); + EXPECT_FALSE(productHelper->getFrontEndPropertyDisableEuFusionSupport()); + EXPECT_TRUE(productHelper->getFrontEndPropertyDisableOverDispatchSupport()); + EXPECT_TRUE(productHelper->getFrontEndPropertySingleSliceDispatchCcsModeSupport()); + + EXPECT_FALSE(productHelper->getPipelineSelectPropertyMediaSamplerDopClockGateSupport()); + EXPECT_FALSE(productHelper->getPipelineSelectPropertySystolicModeSupport()); +} + +BMGTEST_F(BmgProductHelper, WhenFillingScmPropertiesSupportThenExpectUseCorrectExtraGetters) { + StateComputeModePropertiesSupport scmPropertiesSupport = {}; + + productHelper->fillScmPropertiesSupportStructure(scmPropertiesSupport); + + EXPECT_EQ(true, scmPropertiesSupport.allocationForScratchAndMidthreadPreemption); +} + +BMGTEST_F(BmgProductHelper, givenProductHelperWhenAdditionalKernelExecInfoSupportCheckedThenCorrectValueIsReturned) { + + EXPECT_TRUE(productHelper->isDisableOverdispatchAvailable(*defaultHwInfo)); + + FrontEndPropertiesSupport fePropertiesSupport{}; + productHelper->fillFrontEndPropertiesSupportStructure(fePropertiesSupport, *defaultHwInfo); + EXPECT_TRUE(fePropertiesSupport.disableOverdispatch); +} + +BMGTEST_F(BmgProductHelper, givenCompilerProductHelperWhenGetDefaultHwIpVersionThenCorrectValueIsSet) { + EXPECT_EQ(compilerProductHelper->getDefaultHwIpVersion(), AOT::BMG_G21_B0); +} + +BMGTEST_F(BmgProductHelper, givenProductHelperWhenCheckingIsBufferPoolAllocatorSupportedThenCorrectValueIsReturned) { + EXPECT_TRUE(productHelper->isBufferPoolAllocatorSupported()); +} + +BMGTEST_F(BmgProductHelper, givenProductHelperWhenAdjustNumberOfCcsThenOverrideToSingleCcs) { + auto hwInfo = *defaultHwInfo; + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 223; + productHelper->adjustNumberOfCcs(hwInfo); + EXPECT_EQ(hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled, 1u); +} diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/test_device_caps_bmg.cpp b/shared/test/unit_test/xe2_hpg_core/bmg/test_device_caps_bmg.cpp new file mode 100644 index 0000000000..04719819e4 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/test_device_caps_bmg.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_bmg.h" +#include "shared/test/common/fixtures/device_fixture.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" + +using namespace NEO; + +using BmgDeviceIdTest = Test; + +BMGTEST_F(BmgDeviceIdTest, givenBmgProductWhenCheckingCapabilitiesThenReturnCorrectValues) { + EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.blitterOperationsSupported); + + EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.supportCacheFlushAfterWalker); + + EXPECT_TRUE(BMG::hwInfo.capabilityTable.supportsImages); + + EXPECT_EQ(1024u, pDevice->getDeviceInfo().maxWorkGroupSize); + + EXPECT_EQ(128u, pDevice->getHardwareInfo().capabilityTable.slmSize); + + EXPECT_EQ(64u, pDevice->getHardwareInfo().capabilityTable.kernelTimestampValidBits); + EXPECT_EQ(64u, pDevice->getHardwareInfo().capabilityTable.timestampValidBits); +} diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/windows/CMakeLists.txt b/shared/test/unit_test/xe2_hpg_core/bmg/windows/CMakeLists.txt new file mode 100644 index 0000000000..7b7078b346 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/windows/CMakeLists.txt @@ -0,0 +1,9 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(WIN32) + target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/product_helper_tests_bmg_windows.cpp) +endif() diff --git a/shared/test/unit_test/xe2_hpg_core/bmg/windows/product_helper_tests_bmg_windows.cpp b/shared/test/unit_test/xe2_hpg_core/bmg/windows/product_helper_tests_bmg_windows.cpp new file mode 100644 index 0000000000..21380cf441 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/bmg/windows/product_helper_tests_bmg_windows.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_bmg.h" +#include "shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h" +#include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/unit_test/os_interface/product_helper_tests.h" + +#include "per_product_test_definitions.h" + +using namespace NEO; + +using BmgProductHelperWindows = ProductHelperTest; + +BMGTEST_F(BmgProductHelperWindows, givenProductHelperWhenCheckDirectSubmissionSupportedThenTrueIsReturned) { + EXPECT_TRUE(productHelper->isDirectSubmissionSupported(releaseHelper)); +} + +BMGTEST_F(BmgProductHelperWindows, givenProductHelperWhenIsStagingBuffersEnabledThenTrueIsReturned) { + EXPECT_TRUE(productHelper->isStagingBuffersEnabled()); +} diff --git a/shared/test/unit_test/xe2_hpg_core/compute_mode_tests_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/compute_mode_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..ad5940d72d --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/compute_mode_tests_xe2_hpg_core.cpp @@ -0,0 +1,326 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/bit_helpers.h" +#include "shared/source/kernel/grf_config.h" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h" +#include "shared/test/common/helpers/unit_test_helper.h" +#include "shared/test/common/mocks/mock_allocation_properties.h" +#include "shared/test/common/mocks/mock_execution_environment.h" +#include "shared/test/unit_test/command_stream/compute_mode_tests.h" + +#include "per_product_test_definitions.h" + +using namespace NEO; + +using ThreadArbitrationXe2HpgCore = ::testing::Test; +XE2_HPG_CORETEST_F(ThreadArbitrationXe2HpgCore, givenBmgWhenCallingGetDefaultThreadArbitrationPolicyThenRoundRobinIsReturned) { + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); + EXPECT_EQ(ThreadArbitrationPolicy::RoundRobinAfterDependency, gfxCoreHelper.getDefaultThreadArbitrationPolicy()); +} + +using ComputeModeRequirementsXe2HpgCore = ComputeModeRequirements; + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenNewRequiredThreadArbitrationPolicyWhenComputeModeIsProgrammedThenStateComputeIsProgrammedAgain) { + setUpImpl(); + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + + auto cmdsSize = sizeof(STATE_COMPUTE_MODE); + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + auto &gfxCoreHelper = device->getGfxCoreHelper(); + auto newEuThreadSchedulingMode = gfxCoreHelper.getDefaultThreadArbitrationPolicy(); + typename STATE_COMPUTE_MODE::EU_THREAD_SCHEDULING_MODE_OVERRIDE expectedEuThreadSchedulingMode = static_cast(UnitTestHelper::getAppropriateThreadArbitrationPolicy(newEuThreadSchedulingMode)); + + auto expectedScmCmd = FamilyType::cmdInitStateComputeMode; + expectedScmCmd.setMask1(FamilyType::stateComputeModeLargeGrfModeMask | FamilyType::stateComputeModeEuThreadSchedulingModeOverrideMask); + expectedScmCmd.setEuThreadSchedulingModeOverride(expectedEuThreadSchedulingMode); + + overrideComputeModeRequest(false, false, false, true, true); + getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); + EXPECT_EQ(cmdsSize, stream.getUsed()); + + auto scmCmd = reinterpret_cast(stream.getCpuBase()); + EXPECT_TRUE(memcmp(&expectedScmCmd, scmCmd, sizeof(STATE_COMPUTE_MODE)) == 0); + + EXPECT_EQ(expectedEuThreadSchedulingMode, static_cast(stream.getCpuBase())->getEuThreadSchedulingModeOverride()); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenRequiredThreadArbitrationPolicyAlreadySetWhenComputeModeIsProgrammedThenStateComputeIsNotProgrammedAgain) { + setUpImpl(); + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + + auto cmdsSize = 0u; + char buff[1024] = {0}; + LinearStream stream(buff, 1024); + + auto expectedScmCmd = FamilyType::cmdInitStateComputeMode; + expectedScmCmd.setMask1(FamilyType::stateComputeModeLargeGrfModeMask); + + getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); + EXPECT_EQ(cmdsSize, stream.getUsed()); + + auto scmCmd = reinterpret_cast(stream.getCpuBase()); + EXPECT_FALSE(memcmp(&expectedScmCmd, scmCmd, sizeof(STATE_COMPUTE_MODE)) == 0); + + EXPECT_NE(STATE_COMPUTE_MODE::EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_ROUND_ROBIN, static_cast(stream.getCpuBase())->getEuThreadSchedulingModeOverride()); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenCoherencyWithoutSharedHandlesWhenCommandSizeIsCalculatedThenCorrectCommandSizeIsReturned) { + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + setUpImpl(); + + auto cmdsSize = sizeof(STATE_COMPUTE_MODE); + + overrideComputeModeRequest(false, false, false, false); + EXPECT_FALSE(getCsrHw()->streamProperties.stateComputeMode.isDirty()); + + overrideComputeModeRequest(false, false, false, true); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->streamProperties.stateComputeMode.isDirty()); + EXPECT_EQ(cmdsSize, retSize); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenNumGrfRequiredChangedWhenCommandSizeIsCalculatedThenCorrectCommandSizeIsReturned) { + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + setUpImpl(); + + auto numGrfRequired = 128u; + auto numGrfRequiredChanged = false; + overrideComputeModeRequest(false, false, false, numGrfRequiredChanged, numGrfRequired); + EXPECT_FALSE(getCsrHw()->streamProperties.stateComputeMode.isDirty()); + + numGrfRequiredChanged = true; + overrideComputeModeRequest(false, false, false, numGrfRequiredChanged, numGrfRequired); + EXPECT_TRUE(getCsrHw()->streamProperties.stateComputeMode.isDirty()); + EXPECT_EQ(sizeof(STATE_COMPUTE_MODE), getCsrHw()->getCmdSizeForComputeMode()); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenComputeModeProgrammingWhenLargeGrfModeDoesntChangeButRequiredThreadArbitrationPolicyIsNewThenSCMIsReloaded) { + setUpImpl(); + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + + char buff[1024]; + LinearStream stream(buff, 1024); + auto cmdsSize = sizeof(STATE_COMPUTE_MODE); + + overrideComputeModeRequest(false, false, false, true); + getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); + EXPECT_EQ(cmdsSize, stream.getUsed()); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenComputeModeProgrammingWhenLargeGrfModeChangedThenSCMIsReloadedAndLargeGrfModeProgrammed) { + setUpImpl(); + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + + char buff[1024]; + LinearStream stream(buff, 1024); + auto cmdsSize = sizeof(STATE_COMPUTE_MODE); + uint32_t numGrfRequired = GrfConfig::largeGrfNumber; + + overrideComputeModeRequest(false, false, false, true, numGrfRequired); + getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); + EXPECT_EQ(cmdsSize, stream.getUsed()); + EXPECT_TRUE(static_cast(stream.getCpuBase())->getLargeGrfMode()); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenComputeModeProgrammingWhenLargeGrfRequiredChangedButValueIsDefaultThenSCMIsReloadedButLargeGrfModeNotProgrammed) { + setUpImpl(); + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + + char buff[1024]; + LinearStream stream(buff, 1024); + auto cmdsSize = sizeof(STATE_COMPUTE_MODE); + uint32_t numGrfRequired = GrfConfig::defaultGrfNumber; + + overrideComputeModeRequest(false, false, false, true, numGrfRequired); + getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); + EXPECT_EQ(cmdsSize, stream.getUsed()); + EXPECT_FALSE(static_cast(stream.getCpuBase())->getLargeGrfMode()); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, giventhreadArbitrationPolicyWithoutSharedHandlesWhenFlushTaskCalledThenProgramCmdOnlyIfChanged) { + setUpImpl(); + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + auto startOffset = getCsrHw()->commandStream.getUsed(); + + auto graphicAlloc = csr->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}); + IndirectHeap stream(graphicAlloc); + + auto flushTask = [&](bool threadArbitrationPolicyChanged) { + if (threadArbitrationPolicyChanged) { + getCsrHw()->streamProperties.stateComputeMode.threadArbitrationPolicy.value = -1; + } + startOffset = getCsrHw()->commandStream.getUsed(); + csr->flushTask(stream, 0, &stream, &stream, &stream, 0, flags, *device); + }; + + auto findCmd = [&](bool expectToBeProgrammed) { + HardwareParse hwParser; + hwParser.parseCommands(getCsrHw()->commandStream, startOffset); + bool foundOne = false; + + uint32_t expectedMask = FamilyType::stateComputeModeEuThreadSchedulingModeOverrideMask; + + for (auto it = hwParser.cmdList.begin(); it != hwParser.cmdList.end(); it++) { + auto cmd = genCmdCast(*it); + if (cmd) { + + EXPECT_EQ(expectToBeProgrammed ? expectedMask : 0u, cmd->getMask1()); + EXPECT_FALSE(foundOne); + foundOne = true; + auto pc = genCmdCast(*(++it)); + EXPECT_EQ(nullptr, pc); + } + } + EXPECT_EQ(expectToBeProgrammed, foundOne); + }; + + getCsrHw()->streamProperties.stateComputeMode.setPropertiesAll(false, flags.numGrfRequired, + flags.threadArbitrationPolicy, PreemptionMode::Disabled); + + flushTask(true); + findCmd(true); // first time + + flushTask(false); + findCmd(false); // not changed + + flushTask(true); + findCmd(true); // changed + + csr->getMemoryManager()->freeGraphicsMemory(graphicAlloc); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenComputeModeProgrammingWhenLargeGrfModeChangeIsRequiredThenCorrectCommandsAreAdded) { + setUpImpl(); + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + auto cmdsSize = sizeof(STATE_COMPUTE_MODE); + char buff[1024]; + LinearStream stream(buff, 1024); + + auto expectedScmCmd = FamilyType::cmdInitStateComputeMode; + expectedScmCmd.setLargeGrfMode(true); + expectedScmCmd.setEuThreadSchedulingModeOverride(STATE_COMPUTE_MODE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_STALL_BASED_ROUND_ROBIN); + expectedScmCmd.setMask1(FamilyType::stateComputeModeLargeGrfModeMask | FamilyType::stateComputeModeEuThreadSchedulingModeOverrideMask); + + overrideComputeModeRequest(false, false, false, true, true, 256u); + getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); + EXPECT_EQ(cmdsSize, stream.getUsed()); + + auto scmCmd = reinterpret_cast(stream.getCpuBase()); + EXPECT_TRUE(memcmp(&expectedScmCmd, scmCmd, sizeof(STATE_COMPUTE_MODE)) == 0); + + auto startOffset = stream.getUsed(); + + overrideComputeModeRequest(false, false, false, true, true, 128u); + getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); + EXPECT_EQ(cmdsSize * 2, stream.getUsed()); + + expectedScmCmd = FamilyType::cmdInitStateComputeMode; + expectedScmCmd.setLargeGrfMode(false); + expectedScmCmd.setEuThreadSchedulingModeOverride(STATE_COMPUTE_MODE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_STALL_BASED_ROUND_ROBIN); + expectedScmCmd.setMask1(FamilyType::stateComputeModeLargeGrfModeMask | FamilyType::stateComputeModeEuThreadSchedulingModeOverrideMask); + scmCmd = reinterpret_cast(ptrOffset(stream.getCpuBase(), startOffset)); + EXPECT_TRUE(memcmp(&expectedScmCmd, scmCmd, sizeof(STATE_COMPUTE_MODE)) == 0); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenComputeModeProgrammingWhenRequiredGRFNumberIsLowerThan128ThenSmallGRFModeIsProgrammed) { + setUpImpl(); + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + + auto cmdsSize = sizeof(STATE_COMPUTE_MODE); + char buff[1024]; + LinearStream stream(buff, 1024); + + auto expectedScmCmd = FamilyType::cmdInitStateComputeMode; + expectedScmCmd.setLargeGrfMode(false); + expectedScmCmd.setEuThreadSchedulingModeOverride(STATE_COMPUTE_MODE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_STALL_BASED_ROUND_ROBIN); + expectedScmCmd.setMask1(FamilyType::stateComputeModeLargeGrfModeMask | FamilyType::stateComputeModeEuThreadSchedulingModeOverrideMask); + + overrideComputeModeRequest(false, false, false, true, true, 127u); + getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); + EXPECT_EQ(cmdsSize, stream.getUsed()); + + auto scmCmd = reinterpret_cast(stream.getCpuBase()); + EXPECT_TRUE(memcmp(&expectedScmCmd, scmCmd, sizeof(STATE_COMPUTE_MODE)) == 0); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenComputeModeProgrammingWhenRequiredGRFNumberIsGreaterThan128ThenLargeGRFModeIsProgrammed) { + setUpImpl(); + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + auto cmdsSize = sizeof(STATE_COMPUTE_MODE); + char buff[1024]; + LinearStream stream(buff, 1024); + + auto expectedScmCmd = FamilyType::cmdInitStateComputeMode; + expectedScmCmd.setLargeGrfMode(true); + auto expectedBitsMask = FamilyType::stateComputeModeLargeGrfModeMask; + + overrideComputeModeRequest(false, false, false, true, 256u); + getCsrHw()->programComputeMode(stream, flags, *defaultHwInfo); + EXPECT_EQ(cmdsSize, stream.getUsed()); + + auto scmCmd = reinterpret_cast(stream.getCpuBase()); + EXPECT_TRUE(isValueSet(scmCmd->getMask1(), expectedBitsMask)); + expectedScmCmd.setMask1(scmCmd->getMask1()); + EXPECT_TRUE(memcmp(&expectedScmCmd, scmCmd, sizeof(STATE_COMPUTE_MODE)) == 0); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenFlushWithoutSharedHandlesWhenPreviouslyUsedThenPcAndSCMAreNotProgrammed) { + setUpImpl(); + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + auto graphicAlloc = csr->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}); + IndirectHeap stream(graphicAlloc); + + makeResidentSharedAlloc(); + csr->flushTask(stream, 0, &stream, &stream, &stream, 0, flags, *device); + EXPECT_TRUE(getCsrHw()->getCsrRequestFlags()->hasSharedHandles); + auto startOffset = getCsrHw()->commandStream.getUsed(); + + csr->flushTask(stream, 0, &stream, &stream, &stream, 0, flags, *device); + EXPECT_TRUE(getCsrHw()->getCsrRequestFlags()->hasSharedHandles); + + HardwareParse hwParser; + hwParser.parseCommands(getCsrHw()->commandStream, startOffset); + + EXPECT_EQ(0u, hwParser.cmdList.size()); + + csr->getMemoryManager()->freeGraphicsMemory(graphicAlloc); +} + +XE2_HPG_CORETEST_F(ComputeModeRequirementsXe2HpgCore, givenComputeModeCmdSizeWhenLargeGrfModeChangeIsRequiredThenSCMCommandSizeIsCalculated) { + setUpImpl(); + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + auto cmdSize = sizeof(STATE_COMPUTE_MODE); + + overrideComputeModeRequest(false, false, false, false, 128u); + EXPECT_FALSE(getCsrHw()->streamProperties.stateComputeMode.isDirty()); + + cmdSize = sizeof(STATE_COMPUTE_MODE); + + overrideComputeModeRequest(false, false, false, true, 256u); + auto retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->streamProperties.stateComputeMode.isDirty()); + EXPECT_EQ(cmdSize, retSize); + + overrideComputeModeRequest(true, false, false, true, 256u); + retSize = getCsrHw()->getCmdSizeForComputeMode(); + EXPECT_TRUE(getCsrHw()->streamProperties.stateComputeMode.isDirty()); + EXPECT_EQ(cmdSize, retSize); +} diff --git a/shared/test/unit_test/xe2_hpg_core/excludes_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/excludes_xe2_hpg_core.cpp new file mode 100644 index 0000000000..04b9de6828 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/excludes_xe2_hpg_core.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/test_macros/hw_test_base.h" + +HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenAskedIfBlitterForImagesIsSupportedThenFalseIsReturned, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(AubHelperCompressionTests, givenStatelessCompressionAndAddMmioRegisterListDebugFlagsWhenCreatingAubCenterThenPassAdditionalMmioList, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(AubHelperCompressionTests, givenStatelessCompressionDebugFlagWhenCreatingAubCenterThenPassAdditionalMmioList, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(CommandEncodeStatesTest, givenOverrideSlmTotalSizeDebugVariableWhenDispatchingKernelThenSharedMemorySizeIsSetCorrectly, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(ImageSurfaceStateTests, givenGmmWhenSetAuxParamsForCCSThenAuxiliarySurfaceModeIsSet, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(WalkerPartitionTests, givenMiAtomicWhenItIsProgrammedThenAllFieldsAreSetCorrectly, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(WalkerPartitionTests, givenProgramBatchBufferStartCommandWhenItIsCalledThenCommandIsProgrammedCorrectly, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GfxCoreHelperTest, whenAdjustPreemptionSurfaceSizeIsCalledThenCsrSizeDoesntChange, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GfxCoreHelperTest, whenSetSipKernelDataIsCalledThenSipKernelDataDoesntChange, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GfxCoreHelperTest, givenDefaultGfxCoreHelperHwWhenMinimalSIMDSizeIsQueriedThen8IsReturned, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GfxCoreHelperTest, givenGfxCoreHelperWhenAskingForTimestampPacketAlignmentThenReturnFourCachelines, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GfxCoreHelperTest, whenSetCompressedFlagThenProperFlagSet, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GfxCoreHelperTest, whenIsSipKernelAsHexadecimalArrayPreferredIsCalledThenReturnFalse, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GfxCoreHelperTest, givenNumGrfAndSimdSizeWhenAdjustingMaxWorkGroupSizeThenAlwaysReturnDeviceDefault, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(PipeControlHelperTests, givenGfxCoreHelperwhenAskingForDcFlushThenReturnTrue, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(XeHPAndLaterPreemptionTests, whenProgramStateSipIsCalledThenStateSipCmdIsNotAddedToStream, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(XeHPAndLaterPreemptionTests, WhenProgrammingPreemptionThenExpectLoadRegisterCommandRemapFlagEnabled, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(BlitTests, givenXyCopyBltCommandWhenAppendBlitCommandsMemCopyIsCalledThenNothingChanged, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenIsGlobalFenceInCommandStreamRequiredThenFalseIsReturned, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(MemoryManagerGetAlloctionDataTests, givenCommandBufferAllocationTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(MidThreadPreemptionTests, givenKernelWithRayTracingWhenGettingPreemptionFlagsThenMidThreadPreemptionIsNotDisabled, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenAskedIfPatIndexProgrammingSupportedThenReturnFalse, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GmmCompressionTests, givenAllValidInputsWhenQueryingThenSetAppropriateFlags, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GmmCompressionTests, givenNotAllowedCompressionAndEnabledDebugFlagWhenQueryingThenSetAppropriateFlags, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GmmCompressionTests, whenConstructedWithPreferCompressionFlagThenApplyAuxFlags, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GmmCompressionTests, givenDisabledE2ECAndEnabledDebugFlagWhenApplyingForBuffersThenSetValidFlags, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GmmCompressionTests, givenEnabledAndPreferredE2ECWhenApplyingForBuffersThenSetValidFlags, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(CommandEncodeSemaphore, givenIndirectModeSetWhenProgrammingSemaphoreThenSetIndirectBit_IsAtLeastXeHpCore, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenBooleanUncachedWhenCallOverridePatIndexThenProperPatIndexIsReturned, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(GfxCoreHelperTest, whenEncodeAdditionalTimestampOffsetsThenNothingEncoded, IGFX_XE2_HPG_CORE); diff --git a/shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..738d910527 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp @@ -0,0 +1,749 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/command_encoder.h" +#include "shared/source/helpers/compiler_product_helper.h" +#include "shared/source/helpers/engine_node_helper.h" +#include "shared/source/helpers/gfx_core_helper.h" +#include "shared/source/memory_manager/allocation_properties.h" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/program/kernel_info.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/cmd_parse/hw_parse.h" +#include "shared/test/common/fixtures/device_fixture.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/gfx_core_helper_tests.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_graphics_allocation.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" + +using GfxCoreHelperTestsXe2HpgCore = GfxCoreHelperTest; + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenGfxCoreHelperWhenAskingForTimestampPacketAlignmentThenReturnCachelineSize) { + auto &gfxCoreHelper = getHelper(); + + constexpr auto expectedAlignment = MemoryConstants::cacheLineSize; + + EXPECT_EQ(expectedAlignment, gfxCoreHelper.getTimestampPacketAllocatorAlignment()); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenGfxCoreHelperWhenCheckTimestampWaitSupportThenReturnFalse) { + auto &gfxCoreHelper = getHelper(); + EXPECT_FALSE(gfxCoreHelper.isTimestampWaitSupportedForQueues()); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenXe2HpgCoreWhenAskedForMinimialSimdThen16IsReturned) { + auto &gfxCoreHelper = getHelper(); + EXPECT_EQ(16u, gfxCoreHelper.getMinimalSIMDSize()); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, GivenBarrierEncodingWhenCallingGetBarriersCountFromHasBarrierThenNumberOfBarriersIsReturned) { + auto &gfxCoreHelper = getHelper(); + + EXPECT_EQ(0u, gfxCoreHelper.getBarriersCountFromHasBarriers(0u)); + EXPECT_EQ(1u, gfxCoreHelper.getBarriersCountFromHasBarriers(1u)); + EXPECT_EQ(2u, gfxCoreHelper.getBarriersCountFromHasBarriers(2u)); + EXPECT_EQ(4u, gfxCoreHelper.getBarriersCountFromHasBarriers(3u)); + EXPECT_EQ(8u, gfxCoreHelper.getBarriersCountFromHasBarriers(4u)); + EXPECT_EQ(16u, gfxCoreHelper.getBarriersCountFromHasBarriers(5u)); + EXPECT_EQ(24u, gfxCoreHelper.getBarriersCountFromHasBarriers(6u)); + EXPECT_EQ(32u, gfxCoreHelper.getBarriersCountFromHasBarriers(7u)); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, whenGetGpgpuEnginesThenReturnTwoCccsEnginesAndFourCcsEnginesAndEightLinkCopyEnginesAndTwoRegularCopyEngines) { + const size_t numEngines = 18; + + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.featureTable.flags.ftrCCSNode = true; + hwInfo.featureTable.ftrBcsInfo = maxNBitValue(9); + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + auto &gfxCoreHelper = device->getGfxCoreHelper(); + EXPECT_EQ(numEngines, device->allEngines.size()); + auto &engines = gfxCoreHelper.getGpgpuEngineInstances(device->getRootDeviceEnvironment()); + EXPECT_EQ(numEngines, engines.size()); + + struct EnginePropertiesMap { + aub_stream::EngineType engineType; + bool isCcs; + bool isBcs; + }; + + const std::array enginePropertiesMap = {{ + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_CCS1, true, false}, + {aub_stream::ENGINE_CCS2, true, false}, + {aub_stream::ENGINE_CCS3, true, false}, + {aub_stream::ENGINE_CCCS, false, false}, + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_BCS, false, true}, + {aub_stream::ENGINE_BCS, false, true}, + {aub_stream::ENGINE_BCS1, false, true}, + {aub_stream::ENGINE_BCS2, false, true}, + {aub_stream::ENGINE_BCS3, false, true}, + {aub_stream::ENGINE_BCS3, false, true}, + {aub_stream::ENGINE_BCS4, false, true}, + {aub_stream::ENGINE_BCS5, false, true}, + {aub_stream::ENGINE_BCS6, false, true}, + {aub_stream::ENGINE_BCS7, false, true}, + {aub_stream::ENGINE_BCS8, false, true}, + }}; + + for (size_t i = 0; i < numEngines; i++) { + EXPECT_EQ(enginePropertiesMap[i].engineType, engines[i].first); + EXPECT_EQ(enginePropertiesMap[i].isCcs, EngineHelpers::isCcs(enginePropertiesMap[i].engineType)); + EXPECT_EQ(enginePropertiesMap[i].isBcs, EngineHelpers::isBcs(enginePropertiesMap[i].engineType)); + } +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenCccsAsDefaultEngineWhenGetEnginesCalledThenChangeDefaultEngine) { + const size_t numEngines = 18; + + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.featureTable.flags.ftrCCSNode = true; + hwInfo.featureTable.ftrBcsInfo = maxNBitValue(9); + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCCS; + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + auto &gfxCoreHelper = device->getGfxCoreHelper(); + EXPECT_EQ(numEngines, device->allEngines.size()); + auto &engines = gfxCoreHelper.getGpgpuEngineInstances(device->getRootDeviceEnvironment()); + EXPECT_EQ(numEngines, engines.size()); + + struct EnginePropertiesMap { + aub_stream::EngineType engineType; + bool isCcs; + bool isBcs; + }; + + const std::array enginePropertiesMap = {{ + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_CCS1, true, false}, + {aub_stream::ENGINE_CCS2, true, false}, + {aub_stream::ENGINE_CCS3, true, false}, + {aub_stream::ENGINE_CCCS, false, false}, + {aub_stream::ENGINE_CCCS, false, false}, + {aub_stream::ENGINE_CCCS, false, false}, + {aub_stream::ENGINE_BCS, false, true}, + {aub_stream::ENGINE_BCS, false, true}, + {aub_stream::ENGINE_BCS1, false, true}, + {aub_stream::ENGINE_BCS2, false, true}, + {aub_stream::ENGINE_BCS3, false, true}, + {aub_stream::ENGINE_BCS3, false, true}, + {aub_stream::ENGINE_BCS4, false, true}, + {aub_stream::ENGINE_BCS5, false, true}, + {aub_stream::ENGINE_BCS6, false, true}, + {aub_stream::ENGINE_BCS7, false, true}, + {aub_stream::ENGINE_BCS8, false, true}, + }}; + + for (size_t i = 0; i < numEngines; i++) { + EXPECT_EQ(enginePropertiesMap[i].engineType, engines[i].first); + EXPECT_EQ(enginePropertiesMap[i].isCcs, EngineHelpers::isCcs(enginePropertiesMap[i].engineType)); + EXPECT_EQ(enginePropertiesMap[i].isBcs, EngineHelpers::isBcs(enginePropertiesMap[i].engineType)); + } +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenOneCcsEnabledWhenGetEnginesCalledThenCreateOnlyOneCcs) { + const size_t numEngines = 15; + + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.featureTable.flags.ftrCCSNode = true; + hwInfo.featureTable.ftrBcsInfo = maxNBitValue(9); + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1; + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + auto &gfxCoreHelper = device->getGfxCoreHelper(); + EXPECT_EQ(numEngines, device->allEngines.size()); + auto &engines = gfxCoreHelper.getGpgpuEngineInstances(device->getRootDeviceEnvironment()); + EXPECT_EQ(numEngines, engines.size()); + + struct EnginePropertiesMap { + aub_stream::EngineType engineType; + bool isCcs; + bool isBcs; + }; + + const std::array enginePropertiesMap = {{ + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_CCCS, false, false}, + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_BCS, false, true}, + {aub_stream::ENGINE_BCS, false, true}, + {aub_stream::ENGINE_BCS1, false, true}, + {aub_stream::ENGINE_BCS2, false, true}, + {aub_stream::ENGINE_BCS3, false, true}, + {aub_stream::ENGINE_BCS3, false, true}, + {aub_stream::ENGINE_BCS4, false, true}, + {aub_stream::ENGINE_BCS5, false, true}, + {aub_stream::ENGINE_BCS6, false, true}, + {aub_stream::ENGINE_BCS7, false, true}, + {aub_stream::ENGINE_BCS8, false, true}, + }}; + + for (size_t i = 0; i < numEngines; i++) { + EXPECT_EQ(enginePropertiesMap[i].engineType, engines[i].first); + EXPECT_EQ(enginePropertiesMap[i].isCcs, EngineHelpers::isCcs(enginePropertiesMap[i].engineType)); + EXPECT_EQ(enginePropertiesMap[i].isBcs, EngineHelpers::isBcs(enginePropertiesMap[i].engineType)); + } +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenNotAllCopyEnginesWhenSettingEngineTableThenDontAddUnsuportted) { + const size_t numEngines = 10; + + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.featureTable.flags.ftrCCSNode = true; + hwInfo.featureTable.ftrBcsInfo = maxNBitValue(9); + hwInfo.featureTable.ftrBcsInfo.set(0, false); + hwInfo.featureTable.ftrBcsInfo.set(2, false); + hwInfo.featureTable.ftrBcsInfo.set(7, false); + hwInfo.featureTable.ftrBcsInfo.set(8, false); + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1; + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + auto &gfxCoreHelper = device->getGfxCoreHelper(); + EXPECT_EQ(numEngines, device->allEngines.size()); + auto &engines = gfxCoreHelper.getGpgpuEngineInstances(device->getRootDeviceEnvironment()); + EXPECT_EQ(numEngines, engines.size()); + + struct EnginePropertiesMap { + aub_stream::EngineType engineType; + bool isCcs; + bool isBcs; + }; + + const std::array enginePropertiesMap = {{ + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_CCCS, false, false}, + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_BCS1, false, true}, + {aub_stream::ENGINE_BCS3, false, true}, // regular + {aub_stream::ENGINE_BCS3, false, true}, // internal + {aub_stream::ENGINE_BCS4, false, true}, + {aub_stream::ENGINE_BCS5, false, true}, + {aub_stream::ENGINE_BCS6, false, true}, + }}; + + for (size_t i = 0; i < numEngines; i++) { + EXPECT_EQ(enginePropertiesMap[i].engineType, engines[i].first); + EXPECT_EQ(enginePropertiesMap[i].isCcs, EngineHelpers::isCcs(enginePropertiesMap[i].engineType)); + EXPECT_EQ(enginePropertiesMap[i].isBcs, EngineHelpers::isBcs(enginePropertiesMap[i].engineType)); + } +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenOneBcsEnabledWhenGetEnginesCalledThenCreateOnlyOneBcs) { + const size_t numEngines = 9; + + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.featureTable.flags.ftrCCSNode = true; + hwInfo.featureTable.ftrBcsInfo = 1; + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + auto &gfxCoreHelper = device->getGfxCoreHelper(); + EXPECT_EQ(numEngines, device->allEngines.size()); + auto &engines = gfxCoreHelper.getGpgpuEngineInstances(device->getRootDeviceEnvironment()); + EXPECT_EQ(numEngines, engines.size()); + + struct EnginePropertiesMap { + aub_stream::EngineType engineType; + bool isCcs; + bool isBcs; + }; + + const std::array enginePropertiesMap = {{ + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_CCS1, true, false}, + {aub_stream::ENGINE_CCS2, true, false}, + {aub_stream::ENGINE_CCS3, true, false}, + {aub_stream::ENGINE_CCCS, false, false}, + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_BCS, false, true}, + {aub_stream::ENGINE_BCS, false, true}, + }}; + + for (size_t i = 0; i < numEngines; i++) { + EXPECT_EQ(enginePropertiesMap[i].engineType, engines[i].first); + EXPECT_EQ(enginePropertiesMap[i].isCcs, EngineHelpers::isCcs(enginePropertiesMap[i].engineType)); + EXPECT_EQ(enginePropertiesMap[i].isBcs, EngineHelpers::isBcs(enginePropertiesMap[i].engineType)); + } +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenBcsDisabledWhenGetEnginesCalledThenDontCreateAnyBcs) { + const size_t numEngines = 7; + + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.featureTable.flags.ftrCCSNode = true; + hwInfo.featureTable.ftrBcsInfo = 0; + hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + auto &gfxCoreHelper = device->getGfxCoreHelper(); + EXPECT_EQ(numEngines, device->allEngines.size()); + auto &engines = gfxCoreHelper.getGpgpuEngineInstances(device->getRootDeviceEnvironment()); + EXPECT_EQ(numEngines, engines.size()); + + struct EnginePropertiesMap { + aub_stream::EngineType engineType; + bool isCcs; + bool isBcs; + }; + + const std::array enginePropertiesMap = {{ + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_CCS1, true, false}, + {aub_stream::ENGINE_CCS2, true, false}, + {aub_stream::ENGINE_CCS3, true, false}, + {aub_stream::ENGINE_CCCS, false, false}, + {aub_stream::ENGINE_CCS, true, false}, + {aub_stream::ENGINE_CCS, true, false}, + }}; + + for (size_t i = 0; i < numEngines; i++) { + EXPECT_EQ(enginePropertiesMap[i].engineType, engines[i].first); + EXPECT_EQ(enginePropertiesMap[i].isCcs, EngineHelpers::isCcs(enginePropertiesMap[i].engineType)); + EXPECT_EQ(enginePropertiesMap[i].isBcs, EngineHelpers::isBcs(enginePropertiesMap[i].engineType)); + } +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenCcsDisabledAndNumberOfCcsEnabledWhenGetGpgpuEnginesThenReturnCccsEngines) { + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.featureTable.flags.ftrCCSNode = false; + hwInfo.featureTable.ftrBcsInfo = 0; + hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCCS; + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4; + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + auto &gfxCoreHelper = device->getGfxCoreHelper(); + EXPECT_EQ(3u, device->allEngines.size()); + auto &engines = gfxCoreHelper.getGpgpuEngineInstances(device->getRootDeviceEnvironment()); + EXPECT_EQ(3u, engines.size()); + + EXPECT_EQ(aub_stream::ENGINE_CCCS, engines[0].first); + EXPECT_EQ(aub_stream::ENGINE_CCCS, engines[1].first); + EXPECT_EQ(aub_stream::ENGINE_CCCS, engines[2].first); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenCcsDisabledWhenGetGpgpuEnginesThenReturnCccsEngines) { + HardwareInfo hwInfo = *defaultHwInfo; + hwInfo.featureTable.flags.ftrCCSNode = false; + hwInfo.featureTable.ftrBcsInfo = 0; + hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCCS; + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 0; + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo, 0)); + auto &gfxCoreHelper = device->getGfxCoreHelper(); + EXPECT_EQ(3u, device->allEngines.size()); + auto &engines = gfxCoreHelper.getGpgpuEngineInstances(device->getRootDeviceEnvironment()); + EXPECT_EQ(3u, engines.size()); + + EXPECT_EQ(aub_stream::ENGINE_CCCS, engines[0].first); + EXPECT_EQ(aub_stream::ENGINE_CCCS, engines[1].first); + EXPECT_EQ(aub_stream::ENGINE_CCCS, engines[2].first); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, whenNonBcsEngineIsVerifiedThenReturnFalse) { + EXPECT_FALSE(EngineHelpers::isBcs(static_cast(aub_stream::ENGINE_BCS8 + 1))); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, whenPipecontrolWaIsProgrammedThenFlushL1Cache) { + DebugManagerStateRestore restorer; + debugManager.flags.DisablePipeControlPrecedingPostSyncCommand.set(1); + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + uint32_t buffer[64] = {}; + LinearStream cmdStream(buffer, sizeof(buffer)); + uint64_t gpuAddress = 0x1234; + + MemorySynchronizationCommands::addBarrierWa(cmdStream, gpuAddress, this->pDevice->getRootDeviceEnvironment()); + + auto pipeControl = reinterpret_cast(buffer); + EXPECT_TRUE(pipeControl->getCommandStreamerStallEnable()); + EXPECT_TRUE(pipeControl->getDataportFlush()); + EXPECT_TRUE(pipeControl->getUnTypedDataPortCacheFlush()); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenGfxCoreHelperWhenAskedIfFenceAllocationRequiredThenReturnCorrectValue) { + DebugManagerStateRestore dbgRestore; + + auto hwInfo = *defaultHwInfo; + auto &gfxCoreHelper = getHelper(); + + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(-1); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(-1); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(-1); + EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo)); + + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0); + EXPECT_FALSE(gfxCoreHelper.isFenceAllocationRequired(hwInfo)); + + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(1); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0); + EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo)); + + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(1); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0); + EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo)); + + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0); + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0); + debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(1); + EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo)); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenDefaultMemorySynchronizationCommandsWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) { + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + EXPECT_EQ(sizeof(MI_MEM_FENCE), MemorySynchronizationCommands::getSizeForAdditonalSynchronization(pDevice->getRootDeviceEnvironment())); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenDebugMemorySynchronizationCommandsWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) { + DebugManagerStateRestore restorer; + debugManager.flags.DisablePipeControlPrecedingPostSyncCommand.set(1); + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + EXPECT_EQ(2 * sizeof(MI_MEM_FENCE), MemorySynchronizationCommands::getSizeForAdditonalSynchronization(pDevice->getRootDeviceEnvironment())); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenDontProgramGlobalFenceAsMiMemFenceCommandInCommandStreamWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) { + DebugManagerStateRestore debugRestorer; + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0); + + EXPECT_EQ(NEO::EncodeSemaphore::getSizeMiSemaphoreWait(), MemorySynchronizationCommands::getSizeForAdditonalSynchronization(pDevice->getRootDeviceEnvironment())); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenProgramGlobalFenceAsMiMemFenceCommandInCommandStreamWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) { + DebugManagerStateRestore debugRestorer; + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(1); + + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + EXPECT_EQ(sizeof(MI_MEM_FENCE), MemorySynchronizationCommands::getSizeForAdditonalSynchronization(pDevice->getRootDeviceEnvironment())); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenDefaultMemorySynchronizationCommandsWhenAddingAdditionalSynchronizationThenMemoryFenceIsReleased) { + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + auto &rootDeviceEnvironment = this->pDevice->getRootDeviceEnvironment(); + auto &hardwareInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); + + hardwareInfo.featureTable.flags.ftrLocalMemory = true; + uint8_t buffer[128] = {}; + LinearStream commandStream(buffer, 128); + + MemorySynchronizationCommands::addAdditionalSynchronization(commandStream, 0x0, false, rootDeviceEnvironment); + + HardwareParse hwParser; + hwParser.parseCommands(commandStream); + EXPECT_EQ(1u, hwParser.cmdList.size()); + auto fenceCmd = genCmdCast(*hwParser.cmdList.begin()); + ASSERT_NE(nullptr, fenceCmd); + EXPECT_EQ(MI_MEM_FENCE::FENCE_TYPE::FENCE_TYPE_RELEASE, fenceCmd->getFenceType()); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenDontProgramGlobalFenceAsMiMemFenceCommandInCommandStreamWhenAddingAdditionalSynchronizationThenSemaphoreWaitIsCalled) { + DebugManagerStateRestore debugRestorer; + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0); + + using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; + + auto &rootDeviceEnvironment = this->pDevice->getRootDeviceEnvironment(); + auto &hardwareInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); + hardwareInfo.featureTable.flags.ftrLocalMemory = true; + uint8_t buffer[128] = {}; + LinearStream commandStream(buffer, 128); + uint64_t gpuAddress = 0x12345678; + + MemorySynchronizationCommands::addAdditionalSynchronization(commandStream, gpuAddress, false, rootDeviceEnvironment); + + HardwareParse hwParser; + hwParser.parseCommands(commandStream); + EXPECT_EQ(1u, hwParser.cmdList.size()); + auto semaphoreCmd = genCmdCast(*hwParser.cmdList.begin()); + ASSERT_NE(nullptr, semaphoreCmd); + EXPECT_EQ(static_cast(-2), semaphoreCmd->getSemaphoreDataDword()); + EXPECT_EQ(gpuAddress, semaphoreCmd->getSemaphoreGraphicsAddress()); + EXPECT_EQ(MI_SEMAPHORE_WAIT::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD, semaphoreCmd->getCompareOperation()); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenProgramGlobalFenceAsMiMemFenceCommandInCommandStreamWhenAddingAdditionalSynchronizationThenMemoryFenceIsReleased) { + DebugManagerStateRestore debugRestorer; + debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(1); + + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + + auto &rootDeviceEnvironment = this->pDevice->getRootDeviceEnvironment(); + auto &hardwareInfo = *rootDeviceEnvironment.getMutableHardwareInfo(); + hardwareInfo.featureTable.flags.ftrLocalMemory = true; + uint8_t buffer[128] = {}; + LinearStream commandStream(buffer, 128); + + MemorySynchronizationCommands::addAdditionalSynchronization(commandStream, 0x0, false, rootDeviceEnvironment); + + HardwareParse hwParser; + hwParser.parseCommands(commandStream); + EXPECT_EQ(1u, hwParser.cmdList.size()); + auto fenceCmd = genCmdCast(*hwParser.cmdList.begin()); + ASSERT_NE(nullptr, fenceCmd); + EXPECT_EQ(MI_MEM_FENCE::FENCE_TYPE::FENCE_TYPE_RELEASE, fenceCmd->getFenceType()); +} + +using ProductHelperTestXe2HpgCore = Test; + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenGettingIsBlitCopyRequiredForLocalMemoryThenFalseIsReturned) { + auto &productHelper = getHelper(); + MockGraphicsAllocation allocation; + allocation.overrideMemoryPool(MemoryPool::localMemory); + allocation.setAllocationType(AllocationType::bufferHostMemory); + EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(pDevice->getRootDeviceEnvironment(), allocation)); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenDebugVariableSetWhenConfigureIsCalledThenSetupBlitterOperationsSupportedFlag) { + DebugManagerStateRestore restore; + auto &productHelper = getHelper(); + + HardwareInfo hwInfo = *defaultHwInfo; + + debugManager.flags.EnableBlitterOperationsSupport.set(0); + productHelper.configureHardwareCustom(&hwInfo, nullptr); + EXPECT_FALSE(hwInfo.capabilityTable.blitterOperationsSupported); + + debugManager.flags.EnableBlitterOperationsSupport.set(1); + productHelper.configureHardwareCustom(&hwInfo, nullptr); + EXPECT_TRUE(hwInfo.capabilityTable.blitterOperationsSupported); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenMultitileConfigWhenConfiguringHwInfoThenBlitterIsEnabled) { + auto &productHelper = getHelper(); + + HardwareInfo hwInfo = *defaultHwInfo; + + for (uint32_t tileCount = 0; tileCount <= 4; tileCount++) { + hwInfo.gtSystemInfo.MultiTileArchInfo.TileCount = tileCount; + hwInfo.capabilityTable.blitterOperationsSupported = false; + + productHelper.configureHardwareCustom(&hwInfo, nullptr); + + EXPECT_TRUE(hwInfo.capabilityTable.blitterOperationsSupported); + } +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenRevisionEnumThenProperMaxThreadsForWorkgroupIsReturned) { + auto hardwareInfo = *defaultHwInfo; + const auto &productHelper = getHelper(); + uint32_t numThreadsPerEU = hardwareInfo.gtSystemInfo.ThreadCount / hardwareInfo.gtSystemInfo.EUCount; + EXPECT_EQ(64u * numThreadsPerEU, productHelper.getMaxThreadsForWorkgroupInDSSOrSS(hardwareInfo, 64u, 64u)); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenIsBlitterForImagesSupportedIsCalledThenTrueIsReturned) { + const auto &productHelper = getHelper(); + EXPECT_TRUE(productHelper.isBlitterForImagesSupported()); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenCallUseGemCreateExtInAllocateMemoryByKMDThenTrueIsReturned) { + const auto &productHelper = getHelper(); + EXPECT_TRUE(productHelper.useGemCreateExtInAllocateMemoryByKMD()); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenAskingForGlobalFenceSupportThenReturnTrue) { + const auto &productHelper = getHelper(); + EXPECT_TRUE(productHelper.isGlobalFenceInCommandStreamRequired(*defaultHwInfo)); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenAskingForCooperativeEngineSupportThenReturnTrue) { + const auto &productHelper = getHelper(); + EXPECT_TRUE(productHelper.isCooperativeEngineSupported(*defaultHwInfo)); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenAskingForIsIpSamplingSupportedThenReturnFalse) { + const auto &productHelper = getHelper(); + EXPECT_TRUE(productHelper.isIpSamplingSupported(*defaultHwInfo)); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenCallIsNewCoherencyModelSupportedThenTrueIsReturned) { + const auto &productHelper = getHelper(); + EXPECT_TRUE(productHelper.isNewCoherencyModelSupported()); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenCallDeferMOCSToPatThenTrueIsReturned) { + const auto &productHelper = getHelper(); + EXPECT_TRUE(productHelper.deferMOCSToPatIndex()); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenPatIndexWhenCheckIsCoherentAllocationThenReturnProperValue) { + const auto &productHelper = getHelper(); + std::vector listOfCoherentPatIndexes = {1, 2, 4, 5, 7, 22, 23, 26, 27, 30, 31}; + for (auto patIndex : listOfCoherentPatIndexes) { + EXPECT_TRUE(productHelper.isCoherentAllocation(patIndex).value()); + } + std::vector listOfNonCoherentPatIndexes = {3, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 25, 28, 29}; + for (auto patIndex : listOfNonCoherentPatIndexes) { + EXPECT_FALSE(productHelper.isCoherentAllocation(patIndex).value()); + } +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenCallIsTimestampWaitSupportedForEventsThenTrueIsReturned) { + const auto &productHelper = getHelper(); + EXPECT_TRUE(productHelper.isTimestampWaitSupportedForEvents()); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenCallGetCommandBuffersPreallocatedPerCommandQueueThenReturnCorrectValue) { + const auto &productHelper = getHelper(); + EXPECT_EQ(2u, productHelper.getCommandBuffersPreallocatedPerCommandQueue()); +} + +XE2_HPG_CORETEST_F(ProductHelperTestXe2HpgCore, givenProductHelperWhenCallGetInternalHeapsPreallocatedThenReturnCorrectValue) { + const auto &productHelper = getHelper(); + EXPECT_EQ(productHelper.getInternalHeapsPreallocated(), 1u); + + DebugManagerStateRestore restorer; + debugManager.flags.SetAmountOfInternalHeapsToPreallocate.set(3); + EXPECT_EQ(productHelper.getInternalHeapsPreallocated(), 3u); +} + +using LriHelperTestsXe2HpgCore = ::testing::Test; + +XE2_HPG_CORETEST_F(LriHelperTestsXe2HpgCore, whenProgrammingLriCommandThenExpectMmioRemapEnableCorrectlySet) { + using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; + std::unique_ptr buffer(new uint8_t[128]); + + LinearStream stream(buffer.get(), 128); + uint32_t address = 0x8888; + uint32_t data = 0x1234; + + auto expectedLri = FamilyType::cmdInitLoadRegisterImm; + EXPECT_FALSE(expectedLri.getMmioRemapEnable()); + expectedLri.setRegisterOffset(address); + expectedLri.setDataDword(data); + expectedLri.setMmioRemapEnable(true); + + LriHelper::program(&stream, address, data, true, false); + MI_LOAD_REGISTER_IMM *lri = genCmdCast(buffer.get()); + ASSERT_NE(nullptr, lri); + + EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM), stream.getUsed()); + EXPECT_EQ(lri, stream.getCpuBase()); + EXPECT_TRUE(memcmp(lri, &expectedLri, sizeof(MI_LOAD_REGISTER_IMM)) == 0); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenAllocDataWhenSetExtraAllocationDataThenSetLocalMemForProperTypes) { + auto &gfxCoreHelper = getHelper(); + + for (int type = 0; type < static_cast(AllocationType::count); type++) { + AllocationProperties allocProperties(0, 1, static_cast(type), {}); + AllocationData allocData{}; + allocData.flags.useSystemMemory = true; + allocData.flags.requiresCpuAccess = false; + + gfxCoreHelper.setExtraAllocationData(allocData, allocProperties, pDevice->getRootDeviceEnvironment()); + + if (defaultHwInfo->featureTable.flags.ftrLocalMemory) { + if (allocProperties.allocationType == AllocationType::commandBuffer || + allocProperties.allocationType == AllocationType::ringBuffer || + allocProperties.allocationType == AllocationType::semaphoreBuffer) { + EXPECT_FALSE(allocData.flags.useSystemMemory); + EXPECT_TRUE(allocData.flags.requiresCpuAccess); + } else { + EXPECT_FALSE(allocData.flags.useSystemMemory); + EXPECT_FALSE(allocData.flags.requiresCpuAccess); + } + } + } +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenXe2HpgWhenCallIsMatrixMultiplyAccumulateSupportedThenReturnTrue) { + const auto &compilerProductHelper = getHelper(); + auto releaseHelper = this->pDevice->getReleaseHelper(); + EXPECT_TRUE(compilerProductHelper.isMatrixMultiplyAccumulateSupported(releaseHelper)); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenNumGrfAndSimdSizeWhenAdjustingMaxWorkGroupSizeThenCorrectWorkGroupSizeIsReturned) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + using SIMD_SIZE = typename FamilyType::DefaultWalkerType::SIMD_SIZE; + auto defaultMaxWorkGroupSize = 2048u; + const auto &gfxCoreHelper = getHelper(); + const auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); + std::array, 12> values = {{ + {GrfConfig::defaultGrfNumber, 16u, 0u, 1024u}, // Grf Size, SIMT Size, HW local-id generation, Max Num of threads + {GrfConfig::defaultGrfNumber, 16u, 1u, 1024u}, + {GrfConfig::defaultGrfNumber, 32u, 1u, 1024u}, + {GrfConfig::defaultGrfNumber, 32u, 0u, 2048u}, + {GrfConfig::largeGrfNumber, 16u, 0u, 512u}, + {GrfConfig::largeGrfNumber, 16u, 1u, 512u}, + {GrfConfig::largeGrfNumber, 32u, 0u, 1024u}, + {GrfConfig::largeGrfNumber, 32u, 1u, 1024u}, + {GrfConfig::defaultGrfNumber, 1u, 1u, 32u}, + {GrfConfig::defaultGrfNumber, 1u, 0u, 64u}, + {GrfConfig::largeGrfNumber, 1u, 0u, 32u}, + {GrfConfig::largeGrfNumber, 1u, 1u, 32u}, + }}; + + for (auto &[grfSize, simtSize, isHwLocalIdGeneration, expectedNumThreadsPerThreadGroup] : values) { + EXPECT_EQ(expectedNumThreadsPerThreadGroup, gfxCoreHelper.adjustMaxWorkGroupSize(grfSize, simtSize, isHwLocalIdGeneration, defaultMaxWorkGroupSize, rootDeviceEnvironment)); + } +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenParamsWhenCalculateNumThreadsPerThreadGroupThenMethodReturnProperValue) { + auto &gfxCoreHelper = getHelper(); + const auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); + auto totalWgSize = 2048u; + std::array, 12> values = {{ + {GrfConfig::defaultGrfNumber, 16u, 0u, 64u}, // Grf Size, SIMT Size, HW local-id generation, Max Num of threads + {GrfConfig::defaultGrfNumber, 16u, 1u, 64u}, + {GrfConfig::defaultGrfNumber, 32u, 1u, 32u}, + {GrfConfig::defaultGrfNumber, 32u, 0u, 64u}, + {GrfConfig::defaultGrfNumber, 1u, 1u, 32u}, + {GrfConfig::defaultGrfNumber, 1u, 0u, 64u}, + {GrfConfig::largeGrfNumber, 16u, 0u, 32u}, + {GrfConfig::largeGrfNumber, 16u, 1u, 32u}, + {GrfConfig::largeGrfNumber, 32u, 0u, 32u}, + {GrfConfig::largeGrfNumber, 32u, 1u, 32u}, + {GrfConfig::largeGrfNumber, 1u, 0u, 32u}, + {GrfConfig::largeGrfNumber, 1u, 1u, 32u}, + }}; + + for (auto &[grfSize, simtSize, isHwLocalIdGeneration, expectedNumThdreadsPerThreadGroup] : values) { + EXPECT_EQ(expectedNumThdreadsPerThreadGroup, gfxCoreHelper.calculateNumThreadsPerThreadGroup(simtSize, totalWgSize, grfSize, isHwLocalIdGeneration, rootDeviceEnvironment)); + } +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenXe2HpgWhenLargeGrfModeSupportedIsQueriedThenTrueIsReturned) { + auto &gfxCoreHelper = getHelper(); + EXPECT_TRUE(gfxCoreHelper.largeGrfModeSupported()); +} + +XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenGfxCoreHelperWhenFlagSetAndCallGetAmountOfAllocationsToFillThenReturnCorrectValue) { + DebugManagerStateRestore restorer; + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); + EXPECT_EQ(gfxCoreHelper.getAmountOfAllocationsToFill(), 1u); + + debugManager.flags.SetAmountOfReusableAllocations.set(0); + EXPECT_EQ(gfxCoreHelper.getAmountOfAllocationsToFill(), 0u); + + debugManager.flags.SetAmountOfReusableAllocations.set(1); + EXPECT_EQ(gfxCoreHelper.getAmountOfAllocationsToFill(), 1u); +} diff --git a/shared/test/unit_test/xe2_hpg_core/hw_cmds_xe2_hpg_core_tests.cpp b/shared/test/unit_test/xe2_hpg_core/hw_cmds_xe2_hpg_core_tests.cpp new file mode 100644 index 0000000000..8b43cbbbaf --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/hw_cmds_xe2_hpg_core_tests.cpp @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +using namespace NEO; + +using Xe2HpgCoreHwCmdTest = ::testing::Test; + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenMediaSurfaceStateWhenProgrammingMocsThenMocsIndexIsSetProperly) { + auto mediaSurfaceState = FamilyType::cmdInitMediaSurfaceState; + uint32_t mocs = 4u; + uint32_t expectedMocsIndex = (mocs >> 1); + mediaSurfaceState.setSurfaceMemoryObjectControlState(mocs); + EXPECT_EQ(expectedMocsIndex, mediaSurfaceState.TheStructure.Common.SurfaceMemoryObjectControlStateIndexToMocsTables); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenMediaSurfaceStateWhenSettingSurfaceBaseAddressThenCorrectvalueIsSet) { + auto mediaSurfaceState = FamilyType::cmdInitMediaSurfaceState; + uint64_t address = 0x12345678ABCD; + uint32_t expectedAddressLow = 0x5678ABCD; + uint32_t expectedAddressHigh = 0x1234; + mediaSurfaceState.setSurfaceBaseAddress(address); + EXPECT_EQ(address, mediaSurfaceState.getSurfaceBaseAddress()); + EXPECT_EQ(expectedAddressLow, mediaSurfaceState.TheStructure.Common.SurfaceBaseAddress); + EXPECT_EQ(expectedAddressHigh, mediaSurfaceState.TheStructure.Common.SurfaceBaseAddressHigh); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenRenderSurfaceStateThenDefaultHorizontalAlignmentIs128) { + auto defaultHorizontalAlignmentValue = FamilyType::RENDER_SURFACE_STATE::SURFACE_HORIZONTAL_ALIGNMENT_HALIGN_DEFAULT; + auto horizontalAlignment128Value = FamilyType::RENDER_SURFACE_STATE::SURFACE_HORIZONTAL_ALIGNMENT_HALIGN_128; + EXPECT_EQ(defaultHorizontalAlignmentValue, horizontalAlignment128Value); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenRenderSurfaceStateWhenProgrammingMocsThenMocsIndexIsSetProperly) { + auto renderSurfaceState = FamilyType::cmdInitRenderSurfaceState; + uint32_t mocs = 4u; + uint32_t expectedMocsIndex = (mocs >> 1); + renderSurfaceState.setMemoryObjectControlState(mocs); + EXPECT_EQ(expectedMocsIndex, renderSurfaceState.TheStructure.Common.MemoryObjectControlStateIndexToMocsTables); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenStateBaseAddressWhenProgrammingMocsThenMocsIndexIsSetProperly) { + auto stateBaseAddress = FamilyType::cmdInitStateBaseAddress; + uint32_t mocs = 4u; + uint32_t expectedMocsIndex = (mocs >> 1); + stateBaseAddress.setGeneralStateMemoryObjectControlState(mocs); + EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.GeneralStateMemoryObjectControlStateIndexToMocsTables); + + stateBaseAddress.setStatelessDataPortAccessMemoryObjectControlState(mocs); + EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.StatelessDataPortAccessMemoryObjectControlStateIndexToMocsTables); + + stateBaseAddress.setSurfaceStateMemoryObjectControlState(mocs); + EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.SurfaceStateMemoryObjectControlStateIndexToMocsTables); + + stateBaseAddress.setDynamicStateMemoryObjectControlState(mocs); + EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.DynamicStateMemoryObjectControlStateIndexToMocsTables); + + stateBaseAddress.setInstructionMemoryObjectControlState(mocs); + EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.InstructionMemoryObjectControlStateIndexToMocsTables); + + stateBaseAddress.setBindlessSurfaceStateMemoryObjectControlState(mocs); + EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.BindlessSurfaceStateMemoryObjectControlStateIndexToMocsTables); + + stateBaseAddress.setBindlessSamplerStateMemoryObjectControlState(mocs); + EXPECT_EQ(expectedMocsIndex, stateBaseAddress.TheStructure.Common.BindlessSamplerStateMemoryObjectControlStateIndexToMocsTables); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenPostSyncDataWhenProgrammingMocsThenMocsIndexIsSetProperly) { + auto postSyncData = FamilyType::cmdInitPostSyncData; + uint32_t mocs = 4u; + uint32_t expectedMocsIndex = (mocs >> 1); + postSyncData.setMocs(mocs); + EXPECT_EQ(expectedMocsIndex, postSyncData.TheStructure.Common.MocsIndexToMocsTables); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenArbCheckWhenProgrammingPreParserDisableThenMaskBitIsSet) { + { + auto arbCheck = FamilyType::cmdInitArbCheck; + EXPECT_EQ(0u, arbCheck.TheStructure.Common.MaskBits); + arbCheck.setPreParserDisable(true); + EXPECT_EQ(1u, arbCheck.TheStructure.Common.MaskBits); + } + { + auto arbCheck = FamilyType::cmdInitArbCheck; + EXPECT_EQ(0u, arbCheck.TheStructure.Common.MaskBits); + arbCheck.setPreParserDisable(false); + EXPECT_EQ(1u, arbCheck.TheStructure.Common.MaskBits); + } +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenXyColorBltkWhenSetFillColorThenProperValuesAreSet) { + auto xyColorBlt = FamilyType::cmdInitXyColorBlt; + uint32_t fillColor[4] = {0x1234, 0x5678, 0x9ABC, 0xDEF0}; + + xyColorBlt.setFillColor(fillColor); + EXPECT_EQ(0x1234u, xyColorBlt.TheStructure.Common.FillColorValue[0]); + EXPECT_EQ(0x5678u, xyColorBlt.TheStructure.Common.FillColorValue[1]); + EXPECT_EQ(0x9ABCu, xyColorBlt.TheStructure.Common.FillColorValue[2]); + EXPECT_EQ(0xDEF0u, xyColorBlt.TheStructure.Common.FillColorValue[3]); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenXyColorBltkWhenSettingDestinationMocsThenProperValuesAreSet) { + auto xyColorBlt = FamilyType::cmdInitXyColorBlt; + uint32_t mocs = 4u; + uint32_t expectedMocsIndex = (mocs >> 1); + xyColorBlt.setDestinationMOCS(mocs); + EXPECT_EQ(expectedMocsIndex, xyColorBlt.TheStructure.Common.DestinationMocs); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenXyBlockCopyBltkWhenSettingDestinationMocsThenProperValuesAreSet) { + auto xyBlockCopyBlt = FamilyType::XY_BLOCK_COPY_BLT::sInit(); + uint32_t mocs = 4u; + uint32_t expectedMocsIndex = (mocs >> 1); + xyBlockCopyBlt.setDestinationMOCS(mocs); + EXPECT_EQ(expectedMocsIndex, xyBlockCopyBlt.TheStructure.Common.DestinationMocs); + + xyBlockCopyBlt.setSourceMOCS(mocs); + EXPECT_EQ(expectedMocsIndex, xyBlockCopyBlt.TheStructure.Common.SourceMocs); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenMemCopyWhenSettingMocsThenProperValuesAreSet) { + auto memCopy = FamilyType::MEM_COPY::sInit(); + uint32_t mocs = 4u; + uint32_t expectedMocsIndex = (mocs >> 1); + memCopy.setDestinationMOCS(mocs); + EXPECT_EQ(expectedMocsIndex, memCopy.TheStructure.Common.DestinationMocs); + + memCopy.setSourceMOCS(mocs); + EXPECT_EQ(expectedMocsIndex, memCopy.TheStructure.Common.SourceMocs); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenStatePrefetchWhenSettingMocsThenProperValuesAreSet) { + auto statePrefetch = FamilyType::cmdInitStatePrefetch; + uint32_t mocs = 4u; + uint32_t expectedMocsIndex = (mocs >> 1); + statePrefetch.setMemoryObjectControlState(mocs); + EXPECT_EQ(expectedMocsIndex, statePrefetch.TheStructure.Common.MemoryObjectControlStateIndexToMocsTables); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenMemSetWhenSettingDestinationMocsThenProperValuesAreSet) { + auto memSet = FamilyType::cmdInitMemSet; + uint32_t mocs = 4u; + uint32_t expectedMocsIndex = (mocs >> 1); + memSet.setDestinationMOCS(mocs); + EXPECT_EQ(expectedMocsIndex, memSet.TheStructure.Common.DestinationMocs); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreHwCmdTest, givenMemSetWhenSettingDestinationStartAddressThenProperValuesAreSet) { + auto memSet = FamilyType::cmdInitMemSet; + uint64_t address = 0x12345678ABCD; + uint32_t expectedAddressLow = 0x5678ABCD; + uint32_t expectedAddressHigh = 0x1234; + memSet.setDestinationStartAddress(address); + EXPECT_EQ(address, memSet.getDestinationStartAddress()); + EXPECT_EQ(expectedAddressLow, memSet.TheStructure.Common.DestinationStartAddressLow); + EXPECT_EQ(expectedAddressHigh, memSet.TheStructure.Common.DestinationStartAddressHigh); +} diff --git a/shared/test/unit_test/xe2_hpg_core/image_surface_state_tests_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/image_surface_state_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..5236346525 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/image_surface_state_tests_xe2_hpg_core.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/encode_surface_state.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/mocks/mock_gmm_client_context.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" +#include "shared/test/unit_test/image/image_surface_state_fixture.h" + +using namespace NEO; + +using ImageSurfaceStateTestsXe2HpgCore = ImageSurfaceStateTests; + +XE2_HPG_CORETEST_F(ImageSurfaceStateTestsXe2HpgCore, givenGmmWithMediaCompressedWhenSetMipTailStartLodThenMipTailStartLodIsSet) { + auto size = sizeof(typename FamilyType::RENDER_SURFACE_STATE); + auto surfaceState = std::make_unique(size); + auto castSurfaceState = reinterpret_cast(surfaceState.get()); + + setMipTailStartLod(castSurfaceState, nullptr); + + EXPECT_EQ(castSurfaceState->getMipTailStartLod(), 0u); + + setMipTailStartLod(castSurfaceState, mockGmm.get()); + + EXPECT_EQ(castSurfaceState->getMipTailStartLod(), mockGmm->gmmResourceInfo->getMipTailStartLodSurfaceState()); +} + +XE2_HPG_CORETEST_F(ImageSurfaceStateTestsXe2HpgCore, givenNotMediaCompressedImageWhenAppendingSurfaceStateParamsForCompressionThenCallAppriopriateFunction) { + using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; + + RENDER_SURFACE_STATE rss = {}; + + mockGmm->setCompressionEnabled(true); + + MockGraphicsAllocation allocation; + allocation.setDefaultGmm(mockGmm.get()); + + auto gmmClientContext = static_cast(pDevice->getGmmHelper()->getClientContext()); + + EncodeSurfaceState::appendImageCompressionParams(&rss, &allocation, pDevice->getGmmHelper(), false, GMM_NO_PLANE); + + EXPECT_EQ(gmmClientContext->compressionFormatToReturn, rss.getCompressionFormat()); +} diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/CMakeLists.txt b/shared/test/unit_test/xe2_hpg_core/lnl/CMakeLists.txt new file mode 100644 index 0000000000..515a7d54c1 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/lnl/CMakeLists.txt @@ -0,0 +1,19 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_LNL) + target_sources(neo_shared_tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper_tests_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/excludes_xe2_hpg_core_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gfx_core_helper_tests_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/product_helper_tests_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_tests_lnl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_device_caps_lnl.cpp + ) + + add_subdirectories() +endif() diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/engine_node_helper_tests_lnl.cpp b/shared/test/unit_test/xe2_hpg_core/lnl/engine_node_helper_tests_lnl.cpp new file mode 100644 index 0000000000..7eae36442d --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/lnl/engine_node_helper_tests_lnl.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/engine_node_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_lnl.h" +#include "shared/test/common/fixtures/device_fixture.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +using namespace NEO; +using EngineNodeHelperLnlTests = ::Test; + +HWTEST_EXCLUDE_PRODUCT(CommandEncodeSemaphore, givenIndirectModeSetWhenProgrammingSemaphoreThenSetIndirectBit_IsAtLeastXeHpCore, IGFX_LUNARLAKE); + +LNLTEST_F(EngineNodeHelperLnlTests, WhenGetBcsEngineTypeIsCalledForLnlThenCorrectBcsEngineIsReturned) { + using namespace aub_stream; + + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment(); + auto pHwInfo = rootDeviceEnvironment.getMutableHardwareInfo(); + auto deviceBitfield = pDevice->getDeviceBitfield(); + + pHwInfo->featureTable.ftrBcsInfo = 1; + auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine(); + selectorCopyEngine.isMainUsed.store(true); + EXPECT_EQ(ENGINE_BCS, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + + pHwInfo->featureTable.ftrBcsInfo = 0b111; + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + + pHwInfo->featureTable.ftrBcsInfo = 0b11; + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS1, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + + pHwInfo->featureTable.ftrBcsInfo = 0b101; + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); + EXPECT_EQ(ENGINE_BCS2, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, false)); +} diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/excludes_xe2_hpg_core_lnl.cpp b/shared/test/unit_test/xe2_hpg_core/lnl/excludes_xe2_hpg_core_lnl.cpp new file mode 100644 index 0000000000..c7fa652fa8 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/lnl/excludes_xe2_hpg_core_lnl.cpp @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/test_macros/hw_test_base.h" + +HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, whenGettingPreferredAllocationMethodThenNoPreferenceIsReturned, IGFX_LUNARLAKE); +HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenCheckBlitEnqueueAllowedThenReturnTrue, IGFX_LUNARLAKE); diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/gfx_core_helper_tests_lnl.cpp b/shared/test/unit_test/xe2_hpg_core/lnl/gfx_core_helper_tests_lnl.cpp new file mode 100644 index 0000000000..42a019e1d0 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/lnl/gfx_core_helper_tests_lnl.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/gfx_core_helper.h" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_lnl.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/helpers/gfx_core_helper_tests.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_graphics_allocation.h" +#include "shared/test/common/mocks/mock_memory_manager.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" + +using GfxCoreHelperTestsLnl = GfxCoreHelperTest; + +LNLTEST_F(GfxCoreHelperTestsLnl, givenCommandBufferAllocationTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) { + AllocationData allocData; + AllocationProperties properties(mockRootDeviceIndex, true, 10, AllocationType::commandBuffer, false, mockDeviceBitfield); + + MockMemoryManager mockMemoryManager; + mockMemoryManager.getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties)); + + EXPECT_TRUE(allocData.flags.useSystemMemory); +} + +LNLTEST_F(GfxCoreHelperTestsLnl, WhenAskingForDcFlushThenReturnTrue) { + EXPECT_TRUE(MemorySynchronizationCommands::getDcFlushEnable(true, this->pDevice->getRootDeviceEnvironment())); +} diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/hw_info_tests_lnl.cpp b/shared/test/unit_test/xe2_hpg_core/lnl/hw_info_tests_lnl.cpp new file mode 100644 index 0000000000..b8570efc8c --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/lnl/hw_info_tests_lnl.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/compiler_product_helper.h" +#include "shared/source/helpers/constants.h" +#include "shared/source/helpers/hw_info.h" +#include "shared/source/release_helper/release_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_lnl.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +using namespace NEO; + +using LnlHwInfoTest = ::testing::Test; + +LNLTEST_F(LnlHwInfoTest, WhenGettingHardwareInfoThenLnlIsReturned) { + EXPECT_EQ(IGFX_LUNARLAKE, defaultHwInfo->platform.eProductFamily); +} + +LNLTEST_F(LnlHwInfoTest, givenBoolWhenCallLnlHardwareInfoSetupThenFeatureTableAndWorkaroundTableAreSetCorrect) { + bool boolValue[]{ + true, false}; + HardwareInfo hwInfo = *defaultHwInfo; + auto compilerProductHelper = CompilerProductHelper::create(hwInfo.platform.eProductFamily); + auto releaseHelper = ReleaseHelper::create(hwInfo.ipVersion); + GT_SYSTEM_INFO >SystemInfo = hwInfo.gtSystemInfo; + FeatureTable &featureTable = hwInfo.featureTable; + WorkaroundTable &workaroundTable = hwInfo.workaroundTable; + + for (auto setParamBool : boolValue) { + + gtSystemInfo = {0}; + featureTable = {}; + workaroundTable = {}; + hardwareInfoSetup[productFamily](&hwInfo, setParamBool, compilerProductHelper->getHwInfoConfig(hwInfo), releaseHelper.get()); + + EXPECT_EQ(setParamBool, featureTable.flags.ftrL3IACoherency); + EXPECT_EQ(setParamBool, featureTable.flags.ftrLinearCCS); + EXPECT_EQ(setParamBool, featureTable.flags.ftrFlatPhysCCS); + EXPECT_EQ(setParamBool, featureTable.flags.ftrCCSNode); + EXPECT_EQ(setParamBool, featureTable.flags.ftrCCSRing); + EXPECT_EQ(setParamBool, featureTable.flags.ftrPPGTT); + EXPECT_EQ(setParamBool, featureTable.flags.ftrSVM); + EXPECT_EQ(setParamBool, featureTable.flags.ftrStandardMipTailFormat); + EXPECT_EQ(setParamBool, featureTable.flags.ftrTranslationTable); + EXPECT_EQ(setParamBool, featureTable.flags.ftrUserModeTranslationTable); + EXPECT_EQ(setParamBool, featureTable.flags.ftrTileMappedResource); + EXPECT_EQ(setParamBool, featureTable.flags.ftrFbc); + EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcHdr2D); + EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcLdr2D); + EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuMidBatchPreempt); + EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuThreadGroupLevelPreempt); + EXPECT_EQ(setParamBool, featureTable.flags.ftrE2ECompression); + EXPECT_EQ(setParamBool, featureTable.flags.ftrIA32eGfxPTEs); + EXPECT_EQ(setParamBool, featureTable.flags.ftrTile64Optimization); + EXPECT_EQ(setParamBool, featureTable.flags.ftrXe2Compression); + EXPECT_EQ(setParamBool, featureTable.flags.ftrXe2PlusTiling); + EXPECT_EQ(setParamBool, featureTable.flags.ftrPml5Support); + EXPECT_EQ(false, featureTable.flags.ftrTileY); + EXPECT_EQ(setParamBool, featureTable.flags.ftrWalkerMTP); + EXPECT_EQ(setParamBool, workaroundTable.flags.wa4kAlignUVOffsetNV12LinearSurface); + EXPECT_EQ(1u, featureTable.ftrBcsInfo.to_ulong()); + } +} + +LNLTEST_F(LnlHwInfoTest, whenSetupHardwareInfoBaseThenCorrectValuesOfCCSAndMultiTileInfoAreSet) { + HardwareInfo hwInfo = *defaultHwInfo; + auto compilerProductHelper = CompilerProductHelper::create(hwInfo.platform.eProductFamily); + auto releaseHelper = ReleaseHelper::create(hwInfo.ipVersion); + GT_SYSTEM_INFO >SystemInfo = hwInfo.gtSystemInfo; + + hardwareInfoSetup[productFamily](&hwInfo, false, compilerProductHelper->getHwInfoConfig(hwInfo), releaseHelper.get()); + EXPECT_FALSE(gtSystemInfo.MultiTileArchInfo.IsValid); + EXPECT_TRUE(gtSystemInfo.CCSInfo.IsValid); + EXPECT_TRUE(1u == gtSystemInfo.CCSInfo.NumberOfCCSEnabled); + EXPECT_TRUE(0b1u == gtSystemInfo.CCSInfo.Instances.CCSEnableMask); +} + +LNLTEST_F(LnlHwInfoTest, whenCheckDirectSubmissionEnginesThenProperValuesAreSetToTrue) { + HardwareInfo hwInfo = *defaultHwInfo; + const auto &directSubmissionEngines = hwInfo.capabilityTable.directSubmissionEngines; + + for (uint32_t i = 0; i < aub_stream::NUM_ENGINES; i++) { + switch (i) { + case aub_stream::ENGINE_CCS: + EXPECT_TRUE(directSubmissionEngines.data[i].engineSupported); + EXPECT_FALSE(directSubmissionEngines.data[i].submitOnInit); + EXPECT_FALSE(directSubmissionEngines.data[i].useNonDefault); + EXPECT_TRUE(directSubmissionEngines.data[i].useRootDevice); + EXPECT_FALSE(directSubmissionEngines.data[i].useInternal); + EXPECT_FALSE(directSubmissionEngines.data[i].useLowPriority); + break; + default: + EXPECT_FALSE(directSubmissionEngines.data[i].engineSupported); + EXPECT_FALSE(directSubmissionEngines.data[i].submitOnInit); + EXPECT_FALSE(directSubmissionEngines.data[i].useNonDefault); + EXPECT_FALSE(directSubmissionEngines.data[i].useRootDevice); + EXPECT_FALSE(directSubmissionEngines.data[i].useInternal); + EXPECT_FALSE(directSubmissionEngines.data[i].useLowPriority); + } + } +} diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/linux/CMakeLists.txt b/shared/test/unit_test/xe2_hpg_core/lnl/linux/CMakeLists.txt new file mode 100644 index 0000000000..00f64409d2 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/lnl/linux/CMakeLists.txt @@ -0,0 +1,9 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(UNIX) + target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/product_helper_tests_lnl_linux.cpp) +endif() diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/linux/product_helper_tests_lnl_linux.cpp b/shared/test/unit_test/xe2_hpg_core/lnl/linux/product_helper_tests_lnl_linux.cpp new file mode 100644 index 0000000000..5d2a26c3ad --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/lnl/linux/product_helper_tests_lnl_linux.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/os_interface.h" +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/common/os_interface/linux/drm_mock_extended.h" +#include "shared/test/unit_test/os_interface/linux/product_helper_linux_tests.h" + +#include "per_product_test_definitions.h" + +using namespace NEO; + +struct LnlProductHelperLinux : ProductHelperTestLinux { + void SetUp() override { + ProductHelperTestLinux::SetUp(); + + drm = new DrmMockExtended(*executionEnvironment->rootDeviceEnvironments[0]); + osInterface->setDriverModel(std::unique_ptr(drm)); + } +}; + +LNLTEST_F(LnlProductHelperLinux, WhenConfiguringHwInfoThenZeroIsReturned) { + + int ret = productHelper->configureHwInfoDrm(&pInHwInfo, &outHwInfo, getRootDeviceEnvironment()); + EXPECT_EQ(0, ret); +} + +LNLTEST_F(LnlProductHelperLinux, given57bAddressSpaceWhenConfiguringHwInfoThenSetFtrFlag) { + + outHwInfo.featureTable.flags.ftr57bGPUAddressing = false; + outHwInfo.platform.eRenderCoreFamily = defaultHwInfo->platform.eRenderCoreFamily; + + outHwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(48); + int ret = productHelper->configureHardwareCustom(&outHwInfo, osInterface); + EXPECT_EQ(0, ret); + EXPECT_FALSE(outHwInfo.featureTable.flags.ftr57bGPUAddressing); + + outHwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(57); + ret = productHelper->configureHardwareCustom(&outHwInfo, osInterface); + EXPECT_EQ(0, ret); + EXPECT_TRUE(outHwInfo.featureTable.flags.ftr57bGPUAddressing); +} + +LNLTEST_F(LnlProductHelperLinux, givenProductHelperWhenAskedIfPatIndexProgrammingSupportedThenReturnTrue) { + EXPECT_TRUE(productHelper->isVmBindPatIndexProgrammingSupported()); +} + +LNLTEST_F(LnlProductHelperLinux, givenProductHelperWhenAskedIsPageFaultSupportedThenReturnFalse) { + EXPECT_FALSE(productHelper->isPageFaultSupported()); +} + +LNLTEST_F(LnlProductHelperLinux, givenProductHelperWhenAskedIsKmdMigrationSupportedThenReturnFalse) { + EXPECT_FALSE(productHelper->isKmdMigrationSupported()); +} + +LNLTEST_F(LnlProductHelperLinux, givenProductHelperWhenAskedIsDisableScratchPagesSupportedThenReturnFalse) { + EXPECT_FALSE(productHelper->isDisableScratchPagesSupported()); +} + +LNLTEST_F(LnlProductHelperLinux, givenProductHelperWhenCheckDirectSubmissionSupportedThenFalseIsReturned) { + EXPECT_FALSE(productHelper->isDirectSubmissionSupported(releaseHelper)); +} + +using LnlHwInfoLinux = ::testing::Test; + +LNLTEST_F(LnlHwInfoLinux, WhenGtIsSetupThenGtSystemInfoIsCorrect) { + auto executionEnvironment = std::make_unique(); + executionEnvironment->prepareRootDeviceEnvironments(1); + executionEnvironment->rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get()); + executionEnvironment->rootDeviceEnvironments[0]->initGmm(); + + DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]); + DeviceDescriptor device = {0, &LnlHwConfig::hwInfo, &LnlHwConfig::setupHardwareInfo}; + + int ret = drm.setupHardwareInfo(&device, false); + + const auto >SystemInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->gtSystemInfo; + + EXPECT_EQ(ret, 0); + EXPECT_GT(gtSystemInfo.EUCount, 0u); + EXPECT_GT(gtSystemInfo.ThreadCount, 0u); + EXPECT_GT(gtSystemInfo.SliceCount, 0u); + EXPECT_GT(gtSystemInfo.SubSliceCount, 0u); + EXPECT_GT_VAL(gtSystemInfo.L3CacheSizeInKb, 0u); + EXPECT_EQ(gtSystemInfo.CsrSizeInMb, 0u); + EXPECT_FALSE(gtSystemInfo.IsDynamicallyPopulated); + EXPECT_GT(gtSystemInfo.DualSubSliceCount, 0u); + EXPECT_GT(gtSystemInfo.MaxDualSubSlicesSupported, 0u); +} diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp b/shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp new file mode 100644 index 0000000000..259fcad030 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/stream_properties.h" +#include "shared/source/helpers/compiler_product_helper.h" +#include "shared/source/memory_manager/allocation_properties.h" +#include "shared/source/memory_manager/allocation_type.h" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" +#include "shared/test/unit_test/os_interface/product_helper_tests.h" + +#include "aubstream/product_family.h" +#include "platforms.h" + +using namespace NEO; + +using LnlProductHelper = ProductHelperTest; + +LNLTEST_F(LnlProductHelper, whenGettingAubstreamProductFamilyThenProperEnumValueIsReturned) { + EXPECT_EQ(aub_stream::ProductFamily::Lnl, productHelper->getAubStreamProductFamily()); +} + +LNLTEST_F(LnlProductHelper, givenProductHelperWhenGettingEvictIfNecessaryFlagSupportedThenExpectTrue) { + + EXPECT_TRUE(productHelper->isEvictionIfNecessaryFlagSupported()); +} + +LNLTEST_F(LnlProductHelper, whenGettingMidThreadPreemptionSupportForRtKernelsThenExpectNoSupport) { + + EXPECT_TRUE(productHelper->isMidThreadPreemptionDisallowedForRayTracingKernels()); +} + +LNLTEST_F(LnlProductHelper, givenProductHelperWhenGetCommandsStreamPropertiesSupportThenExpectCorrectValues) { + + EXPECT_TRUE(productHelper->getScmPropertyThreadArbitrationPolicySupport()); + EXPECT_TRUE(productHelper->getScmPropertyCoherencyRequiredSupport()); + EXPECT_FALSE(productHelper->getScmPropertyZPassAsyncComputeThreadLimitSupport()); + EXPECT_FALSE(productHelper->getScmPropertyPixelAsyncComputeThreadLimitSupport()); + EXPECT_TRUE(productHelper->getScmPropertyLargeGrfModeSupport()); + EXPECT_FALSE(productHelper->getScmPropertyDevicePreemptionModeSupport()); + + EXPECT_TRUE(productHelper->getStateBaseAddressPropertyBindingTablePoolBaseAddressSupport()); + + EXPECT_TRUE(productHelper->getFrontEndPropertyScratchSizeSupport()); + EXPECT_TRUE(productHelper->getFrontEndPropertyPrivateScratchSizeSupport()); + + EXPECT_FALSE(productHelper->getPreemptionDbgPropertyPreemptionModeSupport()); + EXPECT_TRUE(productHelper->getPreemptionDbgPropertyStateSipSupport()); + EXPECT_TRUE(productHelper->getPreemptionDbgPropertyCsrSurfaceSupport()); + + EXPECT_FALSE(productHelper->getFrontEndPropertyComputeDispatchAllWalkerSupport()); + EXPECT_FALSE(productHelper->getFrontEndPropertyDisableEuFusionSupport()); + EXPECT_TRUE(productHelper->getFrontEndPropertyDisableOverDispatchSupport()); + EXPECT_TRUE(productHelper->getFrontEndPropertySingleSliceDispatchCcsModeSupport()); + + EXPECT_FALSE(productHelper->getPipelineSelectPropertyMediaSamplerDopClockGateSupport()); + EXPECT_FALSE(productHelper->getPipelineSelectPropertySystolicModeSupport()); +} + +LNLTEST_F(LnlProductHelper, WhenFillingScmPropertiesSupportThenExpectUseCorrectExtraGetters) { + StateComputeModePropertiesSupport scmPropertiesSupport = {}; + + productHelper->fillScmPropertiesSupportStructure(scmPropertiesSupport); + + EXPECT_EQ(true, scmPropertiesSupport.allocationForScratchAndMidthreadPreemption); +} + +LNLTEST_F(LnlProductHelper, givenProductHelperWhenAdditionalKernelExecInfoSupportCheckedThenCorrectValueIsReturned) { + + EXPECT_TRUE(productHelper->isDisableOverdispatchAvailable(*defaultHwInfo)); + + FrontEndPropertiesSupport fePropertiesSupport{}; + productHelper->fillFrontEndPropertiesSupportStructure(fePropertiesSupport, *defaultHwInfo); + EXPECT_TRUE(fePropertiesSupport.disableOverdispatch); +} + +LNLTEST_F(LnlProductHelper, givenCompilerProductHelperWhenGetDefaultHwIpVersionThenCorrectValueIsSet) { + EXPECT_EQ(compilerProductHelper->getDefaultHwIpVersion(), AOT::LNL_B0); +} + +LNLTEST_F(LnlProductHelper, whenCheckPreferredAllocationMethodThenAllocateByKmdIsReturnedExceptTagBufferAndTimestampPacketTagBuffer) { + DebugManagerStateRestore restorer; + for (auto i = 0; i < static_cast(AllocationType::count); ++i) { + auto allocationType = static_cast(i); + auto preferredAllocationMethod = productHelper->getPreferredAllocationMethod(allocationType); + if (allocationType == AllocationType::tagBuffer || + allocationType == AllocationType::timestampPacketTagBuffer) { + EXPECT_FALSE(preferredAllocationMethod.has_value()); + } else { + EXPECT_TRUE(preferredAllocationMethod.has_value()); + EXPECT_EQ(GfxMemoryAllocationMethod::allocateByKmd, preferredAllocationMethod.value()); + } + } + debugManager.flags.AllowDcFlush.set(0); + for (auto i = 0; i < static_cast(AllocationType::count); ++i) { + auto allocationType = static_cast(i); + auto preferredAllocationMethod = productHelper->getPreferredAllocationMethod(allocationType); + if (allocationType == AllocationType::tagBuffer || + allocationType == AllocationType::timestampPacketTagBuffer) { + EXPECT_TRUE(preferredAllocationMethod.has_value()); + EXPECT_EQ(GfxMemoryAllocationMethod::allocateByKmd, preferredAllocationMethod.value()); + } + } +} + +LNLTEST_F(LnlProductHelper, givenProductHelperWhenCallIsCachingOnCpuAvailableThenFalseIsReturned) { + EXPECT_FALSE(productHelper->isCachingOnCpuAvailable()); +} + +LNLTEST_F(LnlProductHelper, givenProductHelperWhenCheckOverrideAllocationCacheableThenTrueIsReturnedForCommandBuffer) { + AllocationData allocationData{}; + allocationData.type = AllocationType::commandBuffer; + EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData)); + + allocationData.type = AllocationType::buffer; + EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData)); +} + +LNLTEST_F(LnlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideCacheable) { + AllocationData allocationData{}; + allocationData.type = AllocationType::externalHostPtr; + EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData)); + + DebugManagerStateRestore restorer; + debugManager.flags.AllowDcFlush.set(0); + + for (auto i = 0; i < static_cast(AllocationType::count); ++i) { + auto allocationType = static_cast(i); + allocationData.type = allocationType; + if (allocationType == AllocationType::externalHostPtr || + allocationType == AllocationType::bufferHostMemory || + allocationType == AllocationType::mapAllocation || + allocationType == AllocationType::svmCpu || + allocationType == AllocationType::svmZeroCopy || + allocationType == AllocationType::internalHostMemory || + allocationType == AllocationType::commandBuffer || + allocationType == AllocationType::internalHeap || + allocationType == AllocationType::linearStream || + allocationType == AllocationType::printfSurface) { + EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData)); + } else { + EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData)); + } + } +} + +LNLTEST_F(LnlProductHelper, givenProductHelperWhenCheckBlitEnqueueAllowedThenReturnCorrectValue) { + EXPECT_TRUE(productHelper->blitEnqueueAllowed(true)); + EXPECT_FALSE(productHelper->blitEnqueueAllowed(false)); +} + +LNLTEST_F(LnlProductHelper, givenProductHelperWhenCheckingIsDeviceUsmAllocationReuseSupportedThenCorrectValueIsReturned) { + EXPECT_TRUE(productHelper->isDeviceUsmAllocationReuseSupported()); +} diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/test_device_caps_lnl.cpp b/shared/test/unit_test/xe2_hpg_core/lnl/test_device_caps_lnl.cpp new file mode 100644 index 0000000000..bbd926de58 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/lnl/test_device_caps_lnl.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_lnl.h" +#include "shared/test/common/fixtures/device_fixture.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" + +using namespace NEO; + +using LnlDeviceIdTest = Test; + +LNLTEST_F(LnlDeviceIdTest, givenLnlProductWhenCheckingCapabilitiesThenReturnCorrectValues) { + EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.blitterOperationsSupported); + + EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.supportCacheFlushAfterWalker); + + EXPECT_TRUE(LNL::hwInfo.capabilityTable.supportsImages); + + EXPECT_EQ(512u, pDevice->getHardwareInfo().gtSystemInfo.ThreadCount); + EXPECT_EQ(1024u, pDevice->getDeviceInfo().maxWorkGroupSize); + + EXPECT_EQ(128u, pDevice->getHardwareInfo().capabilityTable.slmSize); + + EXPECT_EQ(64u, pDevice->getHardwareInfo().capabilityTable.kernelTimestampValidBits); + EXPECT_EQ(64u, pDevice->getHardwareInfo().capabilityTable.timestampValidBits); +} diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/windows/CMakeLists.txt b/shared/test/unit_test/xe2_hpg_core/lnl/windows/CMakeLists.txt new file mode 100644 index 0000000000..872c32ae0b --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/lnl/windows/CMakeLists.txt @@ -0,0 +1,9 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(WIN32) + target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/product_helper_tests_lnl_windows.cpp) +endif() diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/windows/product_helper_tests_lnl_windows.cpp b/shared/test/unit_test/xe2_hpg_core/lnl/windows/product_helper_tests_lnl_windows.cpp new file mode 100644 index 0000000000..c8f386a2d6 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/lnl/windows/product_helper_tests_lnl_windows.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/memory_manager/allocation_type.h" +#include "shared/source/os_interface/product_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_lnl.h" +#include "shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/gtest_helpers.h" +#include "shared/test/unit_test/os_interface/product_helper_tests.h" + +#include "per_product_test_definitions.h" + +using namespace NEO; + +using LnlProductHelperWindows = ProductHelperTest; + +LNLTEST_F(LnlProductHelperWindows, givenProductHelperWhenCheckDirectSubmissionSupportedThenTrueIsReturned) { + EXPECT_TRUE(productHelper->isDirectSubmissionSupported(releaseHelper)); +} + +LNLTEST_F(LnlProductHelperWindows, givenProductHelperWhenOverridePatIndexCalledThenCorrectValueIsReturned) { + DebugManagerStateRestore restorer; + + uint64_t expectedPatIndex = 6u; + EXPECT_EQ(expectedPatIndex, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::bufferHostMemory)); + EXPECT_EQ(expectedPatIndex, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::mapAllocation)); + EXPECT_EQ(expectedPatIndex, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::svmCpu)); + EXPECT_EQ(expectedPatIndex, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::svmZeroCopy)); + EXPECT_EQ(expectedPatIndex, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::internalHostMemory)); + EXPECT_EQ(expectedPatIndex, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::timestampPacketTagBuffer)); + EXPECT_EQ(expectedPatIndex, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::tagBuffer)); + + debugManager.flags.AllowDcFlush.set(0); + + uint64_t expectedPatIndexOverride = 2u; + EXPECT_EQ(expectedPatIndexOverride, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::bufferHostMemory)); + EXPECT_EQ(expectedPatIndexOverride, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::mapAllocation)); + EXPECT_EQ(expectedPatIndexOverride, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::svmCpu)); + EXPECT_EQ(expectedPatIndexOverride, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::svmZeroCopy)); + EXPECT_EQ(expectedPatIndexOverride, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::internalHostMemory)); + EXPECT_EQ(expectedPatIndexOverride, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::timestampPacketTagBuffer)); + EXPECT_EQ(expectedPatIndexOverride, productHelper->overridePatIndex(0u, expectedPatIndex, AllocationType::tagBuffer)); +} + +LNLTEST_F(LnlProductHelperWindows, givenProductHelperWhenIsStagingBuffersEnabledThenTrueIsReturned) { + EXPECT_TRUE(productHelper->isStagingBuffersEnabled()); +} diff --git a/shared/test/unit_test/xe2_hpg_core/simd_helper_tests_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/simd_helper_tests_xe2_hpg_core.cpp new file mode 100644 index 0000000000..c34c407b31 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/simd_helper_tests_xe2_hpg_core.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h" +#include "shared/test/unit_test/helpers/simd_helper_tests_pvc_and_later.inl" + +#include "per_product_test_definitions.h" + +using namespace NEO; + +using TestSimdConfigSet = ::testing::Test; + +XE2_HPG_CORETEST_F(TestSimdConfigSet, GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturnedXe2HpgCore) { + GivenSimdSizeWhenGetSimdConfigCalledThenCorrectEnumReturnedPVCAndLater::testBodyImpl(); +} diff --git a/shared/test/unit_test/xe2_hpg_core/test_blit_commands_helper_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/test_blit_commands_helper_xe2_hpg_core.cpp new file mode 100644 index 0000000000..aefb3864b3 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/test_blit_commands_helper_xe2_hpg_core.cpp @@ -0,0 +1,378 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/gmm_helper/client_context/gmm_client_context.h" +#include "shared/source/helpers/blit_properties.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_gmm.h" +#include "shared/test/common/mocks/mock_gmm_resource_info.h" +#include "shared/test/common/test_macros/hw_test.h" +#include "shared/test/unit_test/helpers/blit_commands_helper_tests.inl" + +#include "gtest/gtest.h" + +using BlitTests = Test; + +HWTEST2_F(BlitTests, givenOneBytePatternWhenFillPatternWithBlitThenCommandIsProgrammed, IsXe2HpgCore) { + using MEM_SET = typename FamilyType::MEM_SET; + uint32_t pattern = 1; + uint32_t streamBuffer[100] = {}; + LinearStream stream(streamBuffer, sizeof(streamBuffer)); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + BlitCommandsHelper::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), pDevice->getRootDeviceEnvironmentRef()); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); +} + +HWTEST2_F(BlitTests, givenOverridedMocksValueWhenAppendBlitCommandsForVillBufferThenDebugMocksValueIsSet, IsXe2HpgCore) { + using MEM_SET = typename FamilyType::MEM_SET; + DebugManagerStateRestore dbgRestore; + uint32_t mockValue = pDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) + 1; + debugManager.flags.OverrideBlitterMocs.set(mockValue); + + uint32_t pattern = 1; + uint32_t streamBuffer[100] = {}; + LinearStream stream(streamBuffer, sizeof(streamBuffer)); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + BlitCommandsHelper::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), pDevice->getRootDeviceEnvironmentRef()); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + { + auto blitCmd = genCmdCast(*itor); + EXPECT_EQ(blitCmd->getDestinationMOCS(), mockValue); + } +} + +HWTEST2_F(BlitTests, givenEnableStatelessCompressionWithUnifiedMemoryAndSystemMemWhenAppendBlitCommandsForVillBufferThenCompresionDisabled, IsXe2HpgCore) { + using MEM_SET = typename FamilyType::MEM_SET; + DebugManagerStateRestore dbgRestore; + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(true); + debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.set(2); + + uint32_t pattern = 1; + uint32_t streamBuffer[100] = {}; + LinearStream stream(streamBuffer, sizeof(streamBuffer)); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + BlitCommandsHelper::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), pDevice->getRootDeviceEnvironmentRef()); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + { + auto blitCmd = genCmdCast(*itor); + EXPECT_EQ(blitCmd->getCompressionFormat(), 0u); + } +} + +HWTEST2_F(BlitTests, givenEnableStatelessCompressionWithUnifiedMemoryAndLocalMemWhenAppendBlitCommandsForVillBufferThenCompresionEnabled, IsXe2HpgCore) { + using MEM_SET = typename FamilyType::MEM_SET; + DebugManagerStateRestore dbgRestore; + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(true); + debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.set(2); + + uint32_t pattern = 1; + uint32_t streamBuffer[100] = {}; + LinearStream stream(streamBuffer, sizeof(streamBuffer)); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::localMemory, MemoryManager::maxOsContextCount); + BlitCommandsHelper::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), pDevice->getRootDeviceEnvironmentRef()); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + { + auto blitCmd = genCmdCast(*itor); + EXPECT_EQ(blitCmd->getCompressionFormat(), 2u); + } +} + +HWTEST2_F(BlitTests, givenMemorySizeBiggerThanMaxWidthButLessThanTwiceMaxWidthWhenFillPatternWithBlitThenHeightIsOne, IsXe2HpgCore) { + using MEM_SET = typename FamilyType::MEM_SET; + uint32_t pattern = 1; + uint32_t streamBuffer[100] = {}; + LinearStream stream(streamBuffer, sizeof(streamBuffer)); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, (2 * BlitterConstants::maxBlitSetWidth) - 1, + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + BlitCommandsHelper::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), pDevice->getRootDeviceEnvironmentRef()); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + { + auto cmd = genCmdCast(*itor); + EXPECT_EQ(cmd->getFillHeight(), 1u); + } +} + +HWTEST2_F(BlitTests, givenMemorySizeTwiceBiggerThanMaxWidthWhenFillPatternWithBlitThenHeightIsTwo, IsXe2HpgCore) { + using MEM_SET = typename FamilyType::MEM_SET; + uint32_t pattern = 1; + uint32_t streamBuffer[100] = {}; + LinearStream stream(streamBuffer, sizeof(streamBuffer)); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, (2 * BlitterConstants::maxBlitSetWidth), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + BlitCommandsHelper::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), pDevice->getRootDeviceEnvironmentRef()); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + { + auto cmd = genCmdCast(*itor); + EXPECT_EQ(cmd->getFillHeight(), 2u); + } +} + +HWTEST2_F(BlitTests, givenGmmWithEnabledCompresionWhenAppendBlitCommandsForFillBufferThenDstCompressionEnabled, IsXe2HpgCore) { + using MEM_SET = typename FamilyType::MEM_SET; + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + + uint32_t pattern = 1; + uint32_t streamBuffer[100] = {}; + LinearStream stream(streamBuffer, sizeof(streamBuffer)); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0u); + auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironmentRef(); + BlitCommandsHelper::dispatchBlitMemoryColorFill(&mockAllocation, 0, &pattern, sizeof(uint8_t), stream, mockAllocation.getUnderlyingBufferSize(), rootDeviceEnvironment); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); + { + auto blitCmd = genCmdCast(*itor); + + auto resourceFormat = gmm->gmmResourceInfo->getResourceFormat(); + auto compressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); + EXPECT_EQ(compressionFormat, blitCmd->getCompressionFormat()); + } +} + +HWTEST2_F(BlitTests, givenLinearResourcesWhenAppendSliceOffsetsIsCalledThenAddressesAreOffsetted, IsXe2HpgCore) { + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + + auto blitCmd = FamilyType::cmdInitXyBlockCopyBlt; + blitCmd.setSourceTiling(XY_BLOCK_COPY_BLT::TILING::TILING_LINEAR); + blitCmd.setDestinationTiling(XY_BLOCK_COPY_BLT::TILING::TILING_LINEAR); + MockGraphicsAllocation mockAllocationSrc(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + MockGraphicsAllocation mockAllocationDst(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + MockGraphicsAllocation mockClearColor(reinterpret_cast(0x1234), sizeof(uint32_t)); + BlitProperties properties{}; + properties.copySize = {0x10, 0x10, 0x1}; + properties.srcAllocation = &mockAllocationSrc; + properties.dstAllocation = &mockAllocationDst; + properties.srcSlicePitch = 0x4000; + properties.dstSlicePitch = 0x8000; + properties.srcGpuAddress = mockAllocationSrc.getGpuAddress(); + properties.dstGpuAddress = mockAllocationDst.getGpuAddress(); + properties.clearColorAllocation = &mockClearColor; + properties.bytesPerPixel = 1; + uint32_t sliceIndex = 1; + auto srcSlicePitch = static_cast(properties.srcSlicePitch); + auto dstSlicePitch = static_cast(properties.dstSlicePitch); + + BlitCommandsHelper::appendSliceOffsets(properties, blitCmd, sliceIndex, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch); + + EXPECT_EQ(blitCmd.getSourceBaseAddress(), ptrOffset(mockAllocationSrc.getGpuAddress(), srcSlicePitch)); + EXPECT_EQ(blitCmd.getDestinationBaseAddress(), ptrOffset(mockAllocationDst.getGpuAddress(), dstSlicePitch)); +} + +HWTEST2_F(BlitTests, givenTiledResourcesWhenAppendSliceOffsetsIsCalledThenIndexesAreSet, IsXe2HpgCore) { + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + + auto blitCmd = FamilyType::cmdInitXyBlockCopyBlt; + blitCmd.setSourceTiling(XY_BLOCK_COPY_BLT::TILING::TILING_TILE64); + blitCmd.setDestinationTiling(XY_BLOCK_COPY_BLT::TILING::TILING_TILE64); + MockGraphicsAllocation mockAllocationSrc(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + MockGraphicsAllocation mockAllocationDst(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + BlitProperties properties{}; + uint32_t sliceIndex = 1; + auto srcSlicePitch = static_cast(properties.srcSlicePitch); + auto dstSlicePitch = static_cast(properties.dstSlicePitch); + + BlitCommandsHelper::appendSliceOffsets(properties, blitCmd, sliceIndex, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch); + + EXPECT_EQ(blitCmd.getDestinationArrayIndex(), sliceIndex + 1); + EXPECT_EQ(blitCmd.getSourceArrayIndex(), sliceIndex + 1); +} + +HWTEST2_F(BlitTests, givenCompressionInfoWhenAppendImageCommandsThenCorrectPropertiesAreSet, IsAtLeastXe2HpgCore) { + auto verifyCompressionFormat = [](bool mediaCompressed, bool renderCompressed, uint32_t compressionFormat) { + if (mediaCompressed || renderCompressed) { + EXPECT_GT(compressionFormat, 0u); + } else { + EXPECT_EQ(compressionFormat, 0u); + } + }; + + BlitProperties properties = {}; + properties.srcSize = {1, 1, 1}; + properties.dstSize = {1, 1, 1}; + properties.dstRowPitch = 0x100; + properties.srcRowPitch = 0x100; + auto srcSlicePitch = static_cast(properties.srcSlicePitch); + auto dstSlicePitch = static_cast(properties.dstSlicePitch); + + std::tuple params[]{ + {false, false}, + {false, true}, + {true, false}}; + + for (auto &[mediaCompressedSrc, renderCompressedSrc] : params) { + auto gmmSrc = std::make_unique(pDevice->getGmmHelper()); + auto resourceInfoSrc = static_cast(gmmSrc->gmmResourceInfo.get()); + resourceInfoSrc->getResourceFlags()->Info.MediaCompressed = mediaCompressedSrc; + resourceInfoSrc->getResourceFlags()->Info.RenderCompressed = renderCompressedSrc; + MockGraphicsAllocation mockAllocationSrc(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + mockAllocationSrc.setGmm(gmmSrc.get(), 0); + properties.srcAllocation = &mockAllocationSrc; + + for (auto &[mediaCompressedDst, renderCompressedDst] : params) { + auto gmmDst = std::make_unique(pDevice->getGmmHelper()); + auto resourceInfoDst = static_cast(gmmDst->gmmResourceInfo.get()); + resourceInfoDst->getResourceFlags()->Info.MediaCompressed = mediaCompressedDst; + resourceInfoDst->getResourceFlags()->Info.RenderCompressed = renderCompressedDst; + MockGraphicsAllocation mockAllocationDst(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + mockAllocationDst.setGmm(gmmDst.get(), 0); + properties.dstAllocation = &mockAllocationDst; + auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + BlitCommandsHelper::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), + srcSlicePitch, dstSlicePitch); + + verifyCompressionFormat(mediaCompressedSrc, renderCompressedSrc, bltCmd.getSourceCompressionFormat()); + verifyCompressionFormat(mediaCompressedDst, renderCompressedDst, bltCmd.getDestinationCompressionFormat()); + } + } +} + +HWTEST2_F(BlitTests, givenFastCopyBltCommandWhenSettingForbidenColorDepthThenExpectThrow, IsXe2HpgCore) { + using XY_COLOR_BLT = typename FamilyType::XY_COLOR_BLT; + auto forbidenColorDepth = XY_COLOR_BLT::COLOR_DEPTH::COLOR_DEPTH_96_BIT_COLOR_ONLY_SUPPORTED_FOR_LINEAR_CASE; + auto blitCmd = FamilyType::cmdInitXyColorBlt; + EXPECT_THROW(blitCmd.setColorDepth(forbidenColorDepth), std::exception); +} + +struct BlitTestsTestXe2HpgCore : BlitColorTests {}; + +template +class GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammedXe2HpgCore : public GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed { + public: + GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammedXe2HpgCore(Device *device) : GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammed(device) {} +}; + +template +typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH getColorDepth(size_t patternSize) { + using COLOR_DEPTH = typename FamilyType::XY_COLOR_BLT::COLOR_DEPTH; + COLOR_DEPTH depth = {}; + switch (patternSize) { + case 1: + depth = COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR; + break; + case 2: + depth = COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR; + break; + case 4: + depth = COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR; + break; + case 8: + depth = COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR; + break; + case 16: + depth = COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR; + break; + } + return depth; +} + +HWTEST2_P(BlitTestsTestXe2HpgCore, givenCommandStreamWhenCallToDispatchMemoryFillThenColorDepthAreProgrammedCorrectly, IsXe2HpgCore) { + auto patternSize = GetParam(); + auto expecttedDepth = getColorDepth(patternSize); + GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProgrammedXe2HpgCore test(pDevice); + test.testBodyImpl(patternSize, expecttedDepth); +} + +HWTEST2_F(BlitTests, givenCopyCommandListWhenBytesPerPixelIsCalledForNonBlitCopySupportedPlatformThenExpectOne, IsAtLeastXe2HpgCore) { + size_t copySize{}, srcSize{}, dstSize{}; + uint32_t srcOrigin{}, dstOrigin{}; + uint32_t bytesPerPixel = NEO::BlitCommandsHelper::getAvailableBytesPerPixel(copySize, srcOrigin, dstOrigin, srcSize, dstSize); + EXPECT_EQ(bytesPerPixel, 1u); +} + +INSTANTIATE_TEST_SUITE_P(size_t, + BlitTestsTestXe2HpgCore, + testing::Values(2, + 4, + 8, + 16)); + +HWTEST2_F(BlitTests, givenMemoryAndImageWhenDispatchCopyImageCallThenCommandAddedToStream, IsXe2HpgCore) { + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + MockGraphicsAllocation srcAlloc; + MockGraphicsAllocation dstAlloc; + MockGraphicsAllocation clearColorAlloc; + + Vec3 dstOffsets = {0, 0, 0}; + Vec3 srcOffsets = {0, 0, 0}; + + Vec3 copySize = {0x100, 0x40, 0x1}; + Vec3 srcSize = {0x100, 0x40, 0x1}; + Vec3 dstSize = {0x100, 0x40, 0x1}; + + size_t srcRowPitch = srcSize.x; + size_t srcSlicePitch = srcSize.y; + size_t dstRowPitch = dstSize.x; + size_t dstSlicePitch = dstSize.y; + + auto blitProperties = BlitProperties::constructPropertiesForCopy(&dstAlloc, &srcAlloc, + dstOffsets, srcOffsets, copySize, srcRowPitch, srcSlicePitch, + dstRowPitch, dstSlicePitch, &clearColorAlloc); + + uint32_t streamBuffer[100] = {}; + LinearStream stream(streamBuffer, sizeof(streamBuffer)); + blitProperties.bytesPerPixel = 4; + blitProperties.srcSize = srcSize; + blitProperties.dstSize = dstSize; + NEO::BlitCommandsHelper::dispatchBlitCommandsForImageRegion(blitProperties, stream, pDevice->getRootDeviceEnvironmentRef()); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, ptrOffset(stream.getCpuBase(), 0), stream.getUsed())); + auto itor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), itor); +} diff --git a/shared/test/unit_test/xe2_hpg_core/test_device_caps_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/test_device_caps_xe2_hpg_core.cpp new file mode 100644 index 0000000000..6f7592ace1 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/test_device_caps_xe2_hpg_core.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/gfx_core_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/fixtures/device_fixture.h" +#include "shared/test/common/helpers/gfx_core_helper_tests.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" + +using namespace NEO; + +using Xe2HpgCoreDeviceCaps = Test; + +XE2_HPG_CORETEST_F(Xe2HpgCoreDeviceCaps, givenXe2HpgCoreWhenCheckFtrSupportsInteger64BitAtomicsThenReturnTrue) { + EXPECT_TRUE(pDevice->getHardwareInfo().capabilityTable.ftrSupportsInteger64BitAtomics); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreDeviceCaps, givenXe2HpgCoreWhenCheckingImageSupportThenReturnFalse) { + EXPECT_TRUE(pDevice->getHardwareInfo().capabilityTable.supportsImages); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreDeviceCaps, givenXe2HpgCoreWhenCheckingMediaBlockSupportThenReturnFalse) { + EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.supportsMediaBlock); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreDeviceCaps, givenXe2HpgCoreWhenCheckingCoherencySupportThenReturnFalse) { + EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.ftrSupportsCoherency); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreDeviceCaps, givenXe2HpgCoreWhenCheckingFloatAtomicsSupportThenReturnTrue) { + EXPECT_TRUE(pDevice->getHardwareInfo().capabilityTable.supportsFloatAtomics); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreDeviceCaps, givenXe2HpgCoreWhenCheckingCxlTypeThenReturnZero) { + EXPECT_EQ(0u, pDevice->getHardwareInfo().capabilityTable.cxlType); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreDeviceCaps, givenXe2HpgCoreWhenCheckingDefaltPreemptionModeThenDefaultPreemptionModeIsMidThread) { + EXPECT_EQ(PreemptionMode::MidThread, pDevice->getHardwareInfo().capabilityTable.defaultPreemptionMode); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreDeviceCaps, givenDeviceWhenAskingForSubGroupSizesThenReturnCorrectValues) { + auto &gfxCoreHelper = getHelper(); + + const auto deviceSubgroups = gfxCoreHelper.getDeviceSubGroupSizes(); + + EXPECT_EQ(2u, deviceSubgroups.size()); + EXPECT_EQ(16u, deviceSubgroups[0]); + EXPECT_EQ(32u, deviceSubgroups[1]); +} + +XE2_HPG_CORETEST_F(Xe2HpgCoreDeviceCaps, givenSlmSizeWhenEncodingThenReturnCorrectValues) { + const auto &hwInfo = pDevice->getHardwareInfo(); + auto &gfxCoreHelper = getHelper(); + + ComputeSlmTestInput computeSlmValuesXe2AndLaterTestsInput[] = { + {0, 0 * MemoryConstants::kiloByte}, + {1, 0 * MemoryConstants::kiloByte + 1}, + {1, 1 * MemoryConstants::kiloByte}, + {2, 1 * MemoryConstants::kiloByte + 1}, + {2, 2 * MemoryConstants::kiloByte}, + {3, 2 * MemoryConstants::kiloByte + 1}, + {3, 4 * MemoryConstants::kiloByte}, + {4, 4 * MemoryConstants::kiloByte + 1}, + {4, 8 * MemoryConstants::kiloByte}, + {5, 8 * MemoryConstants::kiloByte + 1}, + {5, 16 * MemoryConstants::kiloByte}, + {8, 16 * MemoryConstants::kiloByte + 1}, + {8, 24 * MemoryConstants::kiloByte}, + {6, 24 * MemoryConstants::kiloByte + 1}, + {6, 32 * MemoryConstants::kiloByte}, + {9, 32 * MemoryConstants::kiloByte + 1}, + {9, 48 * MemoryConstants::kiloByte}, + {7, 48 * MemoryConstants::kiloByte + 1}, + {7, 64 * MemoryConstants::kiloByte}, + {10, 64 * MemoryConstants::kiloByte + 1}, + {10, 96 * MemoryConstants::kiloByte}, + {11, 96 * MemoryConstants::kiloByte + 1}, + {11, 128 * MemoryConstants::kiloByte}}; + + for (const auto &testInput : computeSlmValuesXe2AndLaterTestsInput) { + EXPECT_EQ(testInput.expected, gfxCoreHelper.computeSlmValues(hwInfo, testInput.slmSize)); + } + + EXPECT_THROW(gfxCoreHelper.computeSlmValues(hwInfo, 128 * MemoryConstants::kiloByte + 1), std::exception); +} diff --git a/shared/test/unit_test/xe2_hpg_core/test_encode_3dstate_btd_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/test_encode_3dstate_btd_xe2_hpg_core.cpp new file mode 100644 index 0000000000..94b2925b11 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/test_encode_3dstate_btd_xe2_hpg_core.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/command_encoder.h" +#include "shared/source/command_stream/linear_stream.h" +#include "shared/source/helpers/ptr_math.h" +#include "shared/test/common/cmd_parse/hw_parse.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_graphics_allocation.h" +#include "shared/test/common/test_macros/hw_test.h" +#include "shared/test/unit_test/fixtures/command_container_fixture.h" + +using namespace NEO; + +using CommandEncodeEnableRayTracing = Test; + +HWTEST2_F(CommandEncodeEnableRayTracing, givenDefaultDebugFlagsWhenProgramEnableRayTracingThenBtdStateBodyIsSetProperly, IsXe2HpgCore) { + using _3DSTATE_BTD = typename FamilyType::_3DSTATE_BTD; + DebugManagerStateRestore restore; + debugManager.flags.ForceTheMaximumNumberOfOutstandingRayqueriesPerSs.set(-1); + debugManager.flags.ForceDispatchTimeoutCounter.set(-1); + + uint32_t pCmdBuffer[1024]; + uint32_t pMemoryBackedBuffer[1024]; + + MockGraphicsAllocation gfxAllocation(static_cast(pCmdBuffer), sizeof(pCmdBuffer)); + LinearStream stream(&gfxAllocation); + + uint64_t memoryBackedBuffer = reinterpret_cast(&pMemoryBackedBuffer); + + EncodeEnableRayTracing::programEnableRayTracing(stream, memoryBackedBuffer); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, stream.getCpuBase(), stream.getUsed()); + + auto iterator3dStateBtd = find<_3DSTATE_BTD *>(commands.begin(), commands.end()); + ASSERT_NE(iterator3dStateBtd, commands.end()); + + auto cmd3dStateBtd = genCmdCast<_3DSTATE_BTD *>(*iterator3dStateBtd); + EXPECT_EQ(static_cast(cmd3dStateBtd->getBtdStateBody().getControlsTheMaximumNumberOfOutstandingRayqueriesPerSs()), 0); + EXPECT_EQ(static_cast(cmd3dStateBtd->getBtdStateBody().getDispatchTimeoutCounter()), 0); +} + +HWTEST2_F(CommandEncodeEnableRayTracing, givenDebugFlagsWhenProgramEnableRayTracingThenBtdStateBodyIsSetProperly, IsXe2HpgCore) { + using _3DSTATE_BTD = typename FamilyType::_3DSTATE_BTD; + DebugManagerStateRestore restore; + debugManager.flags.ForceTheMaximumNumberOfOutstandingRayqueriesPerSs.set(1); + debugManager.flags.ForceDispatchTimeoutCounter.set(2); + + uint32_t pCmdBuffer[1024]; + uint32_t pMemoryBackedBuffer[1024]; + + MockGraphicsAllocation gfxAllocation(static_cast(pCmdBuffer), sizeof(pCmdBuffer)); + LinearStream stream(&gfxAllocation); + + uint64_t memoryBackedBuffer = reinterpret_cast(&pMemoryBackedBuffer); + + EncodeEnableRayTracing::programEnableRayTracing(stream, memoryBackedBuffer); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, stream.getCpuBase(), stream.getUsed()); + + auto iterator3dStateBtd = find<_3DSTATE_BTD *>(commands.begin(), commands.end()); + ASSERT_NE(iterator3dStateBtd, commands.end()); + + auto cmd3dStateBtd = genCmdCast<_3DSTATE_BTD *>(*iterator3dStateBtd); + EXPECT_EQ(static_cast(cmd3dStateBtd->getBtdStateBody().getControlsTheMaximumNumberOfOutstandingRayqueriesPerSs()), debugManager.flags.ForceTheMaximumNumberOfOutstandingRayqueriesPerSs.get()); + EXPECT_EQ(static_cast(cmd3dStateBtd->getBtdStateBody().getDispatchTimeoutCounter()), debugManager.flags.ForceDispatchTimeoutCounter.get()); +} diff --git a/shared/test/unit_test/xe2_hpg_core/test_encode_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/test_encode_xe2_hpg_core.cpp new file mode 100644 index 0000000000..9ae095a835 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/test_encode_xe2_hpg_core.cpp @@ -0,0 +1,684 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/command_encoder.h" +#include "shared/source/command_container/encode_surface_state.h" +#include "shared/source/command_stream/stream_properties.h" +#include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/gmm_helper/gmm_lib.h" +#include "shared/source/helpers/definitions/command_encoder_args.h" +#include "shared/source/helpers/gfx_core_helper.h" +#include "shared/source/helpers/hw_walk_order.h" +#include "shared/source/kernel/kernel_descriptor.h" +#include "shared/source/xe2_hpg_core/hw_cmds.h" +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/helpers/default_hw_info.h" +#include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_execution_environment.h" +#include "shared/test/common/mocks/mock_release_helper.h" +#include "shared/test/common/test_macros/test.h" +#include "shared/test/unit_test/fixtures/command_container_fixture.h" +#include "shared/test/unit_test/helpers/state_base_address_tests.h" +#include "shared/test/unit_test/mocks/mock_dispatch_kernel_encoder_interface.h" + +#include "per_product_test_definitions.h" +#include "release_definitions.h" + +using namespace NEO; + +HWTEST_EXCLUDE_PRODUCT(XeHPAndLaterEncodeMiFlushDWTest, whenMiFlushDwIsProgrammedThenSetFlushCcsAndLlc, IGFX_XE2_HPG_CORE); +HWTEST_EXCLUDE_PRODUCT(CommandEncoderTests, whenEncodeMemoryPrefetchCalledThenDoNothing, IGFX_XE2_HPG_CORE); + +using CommandEncodeXe2HpgCoreTest = ::testing::Test; + +XE2_HPG_CORETEST_F(CommandEncodeXe2HpgCoreTest, whenMiFlushDwIsProgrammedThenSetAndFlushLlcWithoutCcs) { + using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW; + uint8_t buffer[2 * sizeof(MI_FLUSH_DW)] = {}; + LinearStream linearStream(buffer, sizeof(buffer)); + MockExecutionEnvironment mockExecutionEnvironment{}; + NEO::EncodeDummyBlitWaArgs waArgs{false, mockExecutionEnvironment.rootDeviceEnvironments[0].get()}; + MiFlushArgs args{waArgs}; + args.commandWithPostSync = true; + + EncodeMiFlushDW::programWithWa(linearStream, 0x1230000, 456, args); + auto miFlushDwCmd = reinterpret_cast(buffer); + auto expectedFlushCcs = NEO::MemorySynchronizationCommands::getDcFlushEnable(true, *mockExecutionEnvironment.rootDeviceEnvironments[0]) ? 1u : 0u; + EXPECT_EQ(expectedFlushCcs, miFlushDwCmd->getFlushCcs()); + EXPECT_EQ(1u, miFlushDwCmd->getFlushLlc()); +} + +XE2_HPG_CORETEST_F(CommandEncodeXe2HpgCoreTest, givenDebugVariableSetwhenProgramingStatePrefetchThenSetCorrectFields) { + using STATE_PREFETCH = typename FamilyType::STATE_PREFETCH; + MockExecutionEnvironment mockExecutionEnvironment{}; + uint8_t buffer[sizeof(STATE_PREFETCH) * 4] = {}; + auto statePrefetchCmd = reinterpret_cast(buffer); + + constexpr uint64_t gpuVa = 0x100000; + constexpr uint32_t mocsIndexForL3 = (1 << 1); + constexpr size_t numCachelines = 3; + + const GraphicsAllocation allocation(0, 1u /*num gmms*/, AllocationType::buffer, nullptr, gpuVa, 0, 4096, MemoryPool::localMemory, MemoryManager::maxOsContextCount); + + static constexpr std::array expectedSizes = {{ + MemoryConstants::cacheLineSize - 1, + MemoryConstants::cacheLineSize, + MemoryConstants::cacheLineSize + 1, + MemoryConstants::cacheLineSize * numCachelines, + MemoryConstants::pageSize64k - 1, + MemoryConstants::pageSize64k, + (MemoryConstants::pageSize64k * 2) + 1, + }}; + + for (auto expectedSize : expectedSizes) { + memset(buffer, 0, sizeof(buffer)); + LinearStream linearStream(buffer, sizeof(buffer)); + + uint32_t alignedSize = alignUp(expectedSize, MemoryConstants::pageSize64k); + uint32_t expectedCmdsCount = std::max((alignedSize / static_cast(MemoryConstants::pageSize64k)), 1u); + + EXPECT_EQ(sizeof(STATE_PREFETCH) * expectedCmdsCount, EncodeMemoryPrefetch::getSizeForMemoryPrefetch(expectedSize, *mockExecutionEnvironment.rootDeviceEnvironments[0])); + + EncodeMemoryPrefetch::programMemoryPrefetch(linearStream, allocation, expectedSize, 0, *mockExecutionEnvironment.rootDeviceEnvironments[0]); + EXPECT_EQ(sizeof(STATE_PREFETCH) * expectedCmdsCount, linearStream.getUsed()); + + for (uint32_t i = 0; i < expectedCmdsCount; i++) { + uint32_t programmedSize = statePrefetchCmd[i].getPrefetchSize() * MemoryConstants::cacheLineSize; + + EXPECT_EQ(statePrefetchCmd[i].getAddress(), gpuVa + (i * MemoryConstants::pageSize64k)); + EXPECT_FALSE(statePrefetchCmd[i].getKernelInstructionPrefetch()); + EXPECT_FALSE(statePrefetchCmd[i].getParserStall()); + EXPECT_EQ(mocsIndexForL3, statePrefetchCmd[i].getMemoryObjectControlState()); + + if (programmedSize > expectedSize) { + // cacheline alignemnt + EXPECT_TRUE((programmedSize - expectedSize) < MemoryConstants::cacheLineSize); + expectedSize = 0; + } else { + expectedSize -= programmedSize; + } + } + EXPECT_EQ(0u, expectedSize); + } +} + +XE2_HPG_CORETEST_F(CommandEncodeXe2HpgCoreTest, givenIsaAllocationWhenProgrammingPrefetchThenSetKernelInstructionPrefetchBit) { + using STATE_PREFETCH = typename FamilyType::STATE_PREFETCH; + MockExecutionEnvironment mockExecutionEnvironment{}; + + uint8_t buffer[sizeof(STATE_PREFETCH)] = {}; + auto statePrefetchCmd = reinterpret_cast(buffer); + + EXPECT_EQ(sizeof(STATE_PREFETCH), EncodeMemoryPrefetch::getSizeForMemoryPrefetch(4096, *mockExecutionEnvironment.rootDeviceEnvironments[0])); + + AllocationType isaTypes[] = {AllocationType::kernelIsa, AllocationType::kernelIsaInternal}; + + for (auto &isaType : isaTypes) { + memset(buffer, 0, sizeof(STATE_PREFETCH)); + LinearStream linearStream(buffer, sizeof(buffer)); + + const GraphicsAllocation allocation(0, 1u /*num gmms*/, isaType, nullptr, + 1234, 0, 4096, MemoryPool::localMemory, MemoryManager::maxOsContextCount); + + EncodeMemoryPrefetch::programMemoryPrefetch(linearStream, allocation, 123, 0, *mockExecutionEnvironment.rootDeviceEnvironments[0]); + EXPECT_EQ(sizeof(STATE_PREFETCH), linearStream.getUsed()); + + EXPECT_TRUE(statePrefetchCmd->getKernelInstructionPrefetch()); + } +} + +XE2_HPG_CORETEST_F(CommandEncodeXe2HpgCoreTest, givenDebugFlagSetWhenProgramPrefetchCalledThenDoPrefetchIfSetToOne) { + using STATE_PREFETCH = typename FamilyType::STATE_PREFETCH; + DebugManagerStateRestore restore; + MockExecutionEnvironment mockExecutionEnvironment{}; + + uint8_t buffer[sizeof(STATE_PREFETCH)] = {}; + + AllocationType isaTypes[] = {AllocationType::kernelIsa, AllocationType::kernelIsaInternal}; + + for (auto &isaType : isaTypes) { + memset(buffer, 0, sizeof(STATE_PREFETCH)); + LinearStream linearStream(buffer, sizeof(buffer)); + + const GraphicsAllocation allocation(0, 1u /*num gmms*/, isaType, + nullptr, 1234, 0, 4096, MemoryPool::localMemory, MemoryManager::maxOsContextCount); + + debugManager.flags.EnableMemoryPrefetch.set(0); + EXPECT_EQ(0u, EncodeMemoryPrefetch::getSizeForMemoryPrefetch(100, *mockExecutionEnvironment.rootDeviceEnvironments[0])); + EncodeMemoryPrefetch::programMemoryPrefetch(linearStream, allocation, 100, 0, *mockExecutionEnvironment.rootDeviceEnvironments[0]); + EXPECT_EQ(0u, linearStream.getUsed()); + + debugManager.flags.EnableMemoryPrefetch.set(1); + EncodeMemoryPrefetch::programMemoryPrefetch(linearStream, allocation, 123, 0, *mockExecutionEnvironment.rootDeviceEnvironments[0]); + EXPECT_EQ(sizeof(STATE_PREFETCH), linearStream.getUsed()); + auto statePrefetchCmd = reinterpret_cast(buffer); + EXPECT_TRUE(statePrefetchCmd->getKernelInstructionPrefetch()); + } +} + +XE2_HPG_CORETEST_F(CommandEncodeXe2HpgCoreTest, givenDebugFlagSetWhenProgrammingPrefetchThenSetParserStall) { + using STATE_PREFETCH = typename FamilyType::STATE_PREFETCH; + MockExecutionEnvironment mockExecutionEnvironment{}; + + DebugManagerStateRestore restore; + debugManager.flags.ForceCsStallForStatePrefetch.set(1); + + const GraphicsAllocation allocation(0, 1u /*num gmms*/, AllocationType::buffer, + nullptr, 1234, 0, 4096, MemoryPool::localMemory, MemoryManager::maxOsContextCount); + uint8_t buffer[sizeof(STATE_PREFETCH)] = {}; + + LinearStream linearStream(buffer, sizeof(buffer)); + + EncodeMemoryPrefetch::programMemoryPrefetch(linearStream, allocation, 123, 0, *mockExecutionEnvironment.rootDeviceEnvironments[0]); + + auto statePrefetchCmd = reinterpret_cast(buffer); + + EXPECT_TRUE(statePrefetchCmd->getParserStall()); +} + +XE2_HPG_CORETEST_F(CommandEncodeXe2HpgCoreTest, givenOffsetWhenProgrammingStatePrefetchThenSetCorrectGpuVa) { + using STATE_PREFETCH = typename FamilyType::STATE_PREFETCH; + MockExecutionEnvironment mockExecutionEnvironment{}; + + uint8_t buffer[sizeof(STATE_PREFETCH) * 4] = {}; + auto statePrefetchCmd = reinterpret_cast(buffer); + + constexpr uint64_t gpuVa = 0x100000; + constexpr uint32_t gpuVaOffset = 0x10000; + + const GraphicsAllocation allocation(0, 1u /*num gmms*/, AllocationType::buffer, nullptr, gpuVa, 0, 4096, MemoryPool::localMemory, MemoryManager::maxOsContextCount); + + memset(buffer, 0, sizeof(buffer)); + LinearStream linearStream(buffer, sizeof(buffer)); + + uint32_t expectedCmdsCount = 3; + uint32_t alignedSize = MemoryConstants::pageSize64k * expectedCmdsCount; + + EncodeMemoryPrefetch::programMemoryPrefetch(linearStream, allocation, alignedSize, gpuVaOffset, *mockExecutionEnvironment.rootDeviceEnvironments[0]); + EXPECT_EQ(sizeof(STATE_PREFETCH) * expectedCmdsCount, linearStream.getUsed()); + + for (uint32_t i = 0; i < expectedCmdsCount; i++) { + uint64_t expectedVa = gpuVa + gpuVaOffset + (i * MemoryConstants::pageSize64k); + EXPECT_EQ(expectedVa, statePrefetchCmd[i].getAddress()); + } +} + +XE2_HPG_CORETEST_F(CommandEncodeXe2HpgCoreTest, whenProgrammingStateComputeModeThenProperFieldsAreSet) { + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + using EU_THREAD_SCHEDULING_MODE_OVERRIDE = typename STATE_COMPUTE_MODE::EU_THREAD_SCHEDULING_MODE_OVERRIDE; + uint8_t buffer[64]{}; + + MockExecutionEnvironment executionEnvironment{}; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + + StateComputeModeProperties properties; + auto pLinearStream = std::make_unique(buffer, sizeof(buffer)); + EncodeComputeMode::programComputeModeCommand(*pLinearStream, properties, rootDeviceEnvironment); + auto pScm = reinterpret_cast(pLinearStream->getCpuBase()); + EXPECT_EQ(0u, pScm->getMask1()); + EXPECT_EQ(0u, pScm->getMask2()); + EXPECT_FALSE(pScm->getMemoryAllocationForScratchAndMidthreadPreemptionBuffers()); + EXPECT_EQ(EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_HW_DEFAULT, pScm->getEuThreadSchedulingModeOverride()); + EXPECT_FALSE(pScm->getLargeGrfMode()); + + properties.memoryAllocationForScratchAndMidthreadPreemptionBuffers.value = 1; + properties.threadArbitrationPolicy.value = ThreadArbitrationPolicy::RoundRobin; + properties.largeGrfMode.value = 1; + pLinearStream = std::make_unique(buffer, sizeof(buffer)); + EncodeComputeMode::programComputeModeCommand(*pLinearStream, properties, rootDeviceEnvironment); + pScm = reinterpret_cast(pLinearStream->getCpuBase()); + EXPECT_EQ(0u, pScm->getMask1()); + EXPECT_EQ(0u, pScm->getMask2()); + EXPECT_FALSE(pScm->getMemoryAllocationForScratchAndMidthreadPreemptionBuffers()); + EXPECT_EQ(EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_HW_DEFAULT, pScm->getEuThreadSchedulingModeOverride()); + EXPECT_FALSE(pScm->getLargeGrfMode()); + + properties.memoryAllocationForScratchAndMidthreadPreemptionBuffers.isDirty = true; + properties.threadArbitrationPolicy.isDirty = true; + properties.largeGrfMode.isDirty = true; + pLinearStream = std::make_unique(buffer, sizeof(buffer)); + EncodeComputeMode::programComputeModeCommand(*pLinearStream, properties, rootDeviceEnvironment); + pScm = reinterpret_cast(pLinearStream->getCpuBase()); + auto expectedMask = FamilyType::stateComputeModeEuThreadSchedulingModeOverrideMask | FamilyType::stateComputeModeLargeGrfModeMask; + EXPECT_EQ(expectedMask, pScm->getMask1()); + EXPECT_EQ(FamilyType::stateComputeModeMemoryAllocationForScratchAndMidthreadPreemptionBuffersMask, pScm->getMask2()); + EXPECT_TRUE(pScm->getMemoryAllocationForScratchAndMidthreadPreemptionBuffers()); + EXPECT_EQ(EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_ROUND_ROBIN, pScm->getEuThreadSchedulingModeOverride()); + EXPECT_TRUE(pScm->getLargeGrfMode()); +} + +XE2_HPG_CORETEST_F(CommandEncodeXe2HpgCoreTest, whenAdjustComputeModeIsCalledThenCorrectPolicyIsProgrammed) { + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + using EU_THREAD_SCHEDULING_MODE_OVERRIDE = typename STATE_COMPUTE_MODE::EU_THREAD_SCHEDULING_MODE_OVERRIDE; + + uint8_t buffer[64]{}; + StreamProperties properties{}; + + MockExecutionEnvironment executionEnvironment{}; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + properties.initSupport(rootDeviceEnvironment); + + auto pLinearStream = std::make_unique(buffer, sizeof(buffer)); + properties.stateComputeMode.setPropertiesAll(false, 0, ThreadArbitrationPolicy::AgeBased, PreemptionMode::Disabled); + EncodeComputeMode::programComputeModeCommand(*pLinearStream, properties.stateComputeMode, rootDeviceEnvironment); + auto pScm = reinterpret_cast(pLinearStream->getCpuBase()); + EXPECT_EQ(EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_OLDEST_FIRST, pScm->getEuThreadSchedulingModeOverride()); + + pLinearStream = std::make_unique(buffer, sizeof(buffer)); + properties.stateComputeMode.setPropertiesAll(false, 0, ThreadArbitrationPolicy::RoundRobin, PreemptionMode::Disabled); + EncodeComputeMode::programComputeModeCommand(*pLinearStream, properties.stateComputeMode, rootDeviceEnvironment); + pScm = reinterpret_cast(pLinearStream->getCpuBase()); + EXPECT_EQ(EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_ROUND_ROBIN, pScm->getEuThreadSchedulingModeOverride()); + + pLinearStream = std::make_unique(buffer, sizeof(buffer)); + properties.stateComputeMode.setPropertiesAll(false, 0, ThreadArbitrationPolicy::RoundRobinAfterDependency, PreemptionMode::Disabled); + EncodeComputeMode::programComputeModeCommand(*pLinearStream, properties.stateComputeMode, rootDeviceEnvironment); + pScm = reinterpret_cast(pLinearStream->getCpuBase()); + EXPECT_EQ(EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_STALL_BASED_ROUND_ROBIN, pScm->getEuThreadSchedulingModeOverride()); + + pLinearStream = std::make_unique(buffer, sizeof(buffer)); + properties.stateComputeMode.setPropertiesAll(false, 0, ThreadArbitrationPolicy::NotPresent, PreemptionMode::Disabled); + EncodeComputeMode::programComputeModeCommand(*pLinearStream, properties.stateComputeMode, rootDeviceEnvironment); + pScm = reinterpret_cast(pLinearStream->getCpuBase()); + EXPECT_EQ(EU_THREAD_SCHEDULING_MODE_OVERRIDE::EU_THREAD_SCHEDULING_MODE_OVERRIDE_HW_DEFAULT, pScm->getEuThreadSchedulingModeOverride()); +} + +using EncodeKernelXe2HpgCoreTest = Test; + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenNoFenceAsPostSyncOperationInComputeWalkerWhenEnqueueKernelIsCalledThenDoNotGenerateFenceCommands) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + DebugManagerStateRestore restore; + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0); + + uint32_t dims[] = {1, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + dispatchInterface->getCrossThreadDataSizeResult = 0; + + bool requiresUncachedMocs = false; + EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); + + EncodeDispatchKernel::template encode(*cmdContainer.get(), dispatchArgs); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenFenceAsPostSyncOperationInComputeWalkerWhenEnqueueKernelIsCalledThenGenerateFenceCommands) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + DebugManagerStateRestore restore; + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(1); + + uint32_t dims[] = {1, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + dispatchInterface->getCrossThreadDataSizeResult = 0; + + EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, false); + + EncodeDispatchKernel::template encode(*cmdContainer.get(), dispatchArgs); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_TRUE(postSyncData.getSystemMemoryFenceRequest()); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenDefaultSettingForFenceAsPostSyncOperationInComputeWalkerWhenEnqueueKernelIsCalledThenGenerateFenceCommands) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE; + DebugManagerStateRestore restore; + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(-1); + + uint32_t dims[] = {1, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + dispatchInterface->getCrossThreadDataSizeResult = 0; + + EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, false); + + EncodeDispatchKernel::template encode(*cmdContainer.get(), dispatchArgs); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenDefaultSettingForFenceWhenKernelUsesSystemMemoryFlagTrueAndNoHostSignalEventThenNotUseSystemFence) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + + DebugManagerStateRestore restore; + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(-1); + + uint32_t dims[] = {1, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + dispatchInterface->getCrossThreadDataSizeResult = 0; + + EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, false); + dispatchArgs.isKernelUsingSystemAllocation = true; + + EncodeDispatchKernel::template encode(*cmdContainer.get(), dispatchArgs); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenDefaultSettingForFenceWhenEventHostSignalScopeFlagTrueAndNoSystemMemoryThenNotUseSystemFence) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + + DebugManagerStateRestore restore; + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(-1); + + uint32_t dims[] = {1, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + dispatchInterface->getCrossThreadDataSizeResult = 0; + + EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, false); + dispatchArgs.isHostScopeSignalEvent = true; + + EncodeDispatchKernel::template encode(*cmdContainer.get(), dispatchArgs); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_FALSE(postSyncData.getSystemMemoryFenceRequest()); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenDefaultSettingForFenceWhenKernelUsesSystemMemoryAndHostSignalEventFlagTrueThenUseSystemFence) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + + DebugManagerStateRestore restore; + debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(-1); + + uint32_t dims[] = {1, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + dispatchInterface->getCrossThreadDataSizeResult = 0; + + EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, false); + dispatchArgs.isKernelUsingSystemAllocation = true; + dispatchArgs.isHostScopeSignalEvent = true; + + EncodeDispatchKernel::template encode(*cmdContainer.get(), dispatchArgs); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(itor, commands.end()); + + auto walkerCmd = genCmdCast(*itor); + auto &postSyncData = walkerCmd->getPostSync(); + EXPECT_TRUE(postSyncData.getSystemMemoryFenceRequest()); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenCleanHeapsAndSlmNotChangedAndUncachedMocsRequestedThenSBAIsProgrammedAndMocsAreSet) { + uint32_t dims[] = {2, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + cmdContainer->slmSizeRef() = 1; + cmdContainer->setDirtyStateForAllHeaps(false); + dispatchInterface->getSlmTotalSizeResult = cmdContainer->slmSizeRef(); + + bool requiresUncachedMocs = true; + EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); + + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + EncodeDispatchKernel::template encode(*cmdContainer.get(), dispatchArgs); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + auto itor = find(commands.begin(), commands.end()); + ASSERT_NE(commands.end(), itor); + + auto cmdSba = genCmdCast(*itor); + auto gmmHelper = cmdContainer->getDevice()->getGmmHelper(); + EXPECT_EQ(cmdSba->getStatelessDataPortAccessMemoryObjectControlState(), + (gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED))); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenDebugFlagSetWhenAdjustIsCalledThenUpdateRequiredScratchSizeField) { + using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE; + + DebugManagerStateRestore restore; + MockExecutionEnvironment executionEnvironment{}; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + + uint8_t buffer[2 * sizeof(STATE_COMPUTE_MODE)] = {}; + + constexpr uint32_t expectedMask = (1 << 11); + + { + // default + LinearStream linearStream(buffer, sizeof(buffer)); + + StreamProperties streamProperties{}; + streamProperties.initSupport(rootDeviceEnvironment); + streamProperties.stateComputeMode.setPropertiesAll(false, 0, 0, PreemptionMode::Disabled); + EncodeComputeMode::programComputeModeCommand(linearStream, streamProperties.stateComputeMode, rootDeviceEnvironment); + + auto &stateComputeModeCmd = *reinterpret_cast(linearStream.getCpuBase()); + EXPECT_FALSE(stateComputeModeCmd.getMemoryAllocationForScratchAndMidthreadPreemptionBuffers()); + EXPECT_EQ(0u, stateComputeModeCmd.getMask2()); + } + + { + // enabled + debugManager.flags.ForceScratchAndMTPBufferSizeMode.set(1); + + LinearStream linearStream(buffer, sizeof(buffer)); + + StreamProperties streamProperties{}; + streamProperties.initSupport(rootDeviceEnvironment); + streamProperties.stateComputeMode.setPropertiesAll(false, 0, 0, PreemptionMode::Disabled); + EncodeComputeMode::programComputeModeCommand(linearStream, streamProperties.stateComputeMode, rootDeviceEnvironment); + + auto &stateComputeModeCmd = *reinterpret_cast(linearStream.getCpuBase()); + EXPECT_TRUE(stateComputeModeCmd.getMemoryAllocationForScratchAndMidthreadPreemptionBuffers()); + EXPECT_EQ(expectedMask, stateComputeModeCmd.getMask2()); + } + + { + // disabled + debugManager.flags.ForceScratchAndMTPBufferSizeMode.set(0); + + LinearStream linearStream(buffer, sizeof(buffer)); + + StreamProperties streamProperties{}; + streamProperties.initSupport(rootDeviceEnvironment); + streamProperties.stateComputeMode.setPropertiesAll(false, 0, 0, PreemptionMode::Disabled); + EncodeComputeMode::programComputeModeCommand(linearStream, streamProperties.stateComputeMode, rootDeviceEnvironment); + + auto &stateComputeModeCmd = *reinterpret_cast(linearStream.getCpuBase()); + EXPECT_FALSE(stateComputeModeCmd.getMemoryAllocationForScratchAndMidthreadPreemptionBuffers()); + EXPECT_EQ(expectedMask, stateComputeModeCmd.getMask2()); + } +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenSystolicModeRequiredWhenEncodeIsCalledThenDontReprogramPipelineSelect) { + bool requiresUncachedMocs = false; + uint32_t dims[] = {1, 1, 1}; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + dispatchInterface->kernelDescriptor.kernelAttributes.flags.usesSystolicPipelineSelectMode = true; + cmdContainer->lastPipelineSelectModeRequiredRef() = false; + + EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); + dispatchArgs.preemptionMode = PreemptionMode::Initial; + + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + EncodeDispatchKernel::template encode(*cmdContainer.get(), dispatchArgs); + EXPECT_FALSE(cmdContainer->lastPipelineSelectModeRequiredRef()); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenXe2ThenPipelineSelectIsNotProgrammed) { + using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT; + std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); + + EncodeComputeMode::adjustPipelineSelect(*cmdContainer.get(), dispatchInterface->kernelDescriptor); + + GenCmdList commands; + CmdParse::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed()); + + auto itor = find(commands.begin(), commands.end()); + EXPECT_EQ(itor, commands.end()); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenRequiredWorkGroupOrderWhenCallAdjustWalkOrderThenDispatchWalkOrderIsProgrammedCorrectly) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + MockExecutionEnvironment executionEnvironment{}; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + + DefaultWalkerType walkerCmd{}; + uint32_t yOrder = 2u; + EXPECT_EQ(HwWalkOrderHelper::compatibleDimensionOrders[yOrder], HwWalkOrderHelper::yOrderWalk); + + EncodeDispatchKernel::adjustWalkOrder(walkerCmd, yOrder, rootDeviceEnvironment); + EXPECT_EQ(DefaultWalkerType::DISPATCH_WALK_ORDER::Y_ORDER_WALKER, walkerCmd.getDispatchWalkOrder()); + + uint32_t linearOrder = 0u; + EXPECT_EQ(HwWalkOrderHelper::compatibleDimensionOrders[linearOrder], HwWalkOrderHelper::linearWalk); + + EncodeDispatchKernel::adjustWalkOrder(walkerCmd, linearOrder, rootDeviceEnvironment); + EXPECT_EQ(DefaultWalkerType::DISPATCH_WALK_ORDER::LINERAR_WALKER, walkerCmd.getDispatchWalkOrder()); + + auto currentDispatchWalkOrder = walkerCmd.getDispatchWalkOrder(); + uint32_t fakeOrder = 5u; + EncodeDispatchKernel::adjustWalkOrder(walkerCmd, fakeOrder, rootDeviceEnvironment); + EXPECT_EQ(currentDispatchWalkOrder, walkerCmd.getDispatchWalkOrder()); // no change +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenRequiredWorkGroupOrderWhenCallEncodeThreadDataThenDispatchWalkOrderIsProgrammedCorrectly) { + using DefaultWalkerType = typename FamilyType::DefaultWalkerType; + DefaultWalkerType walkerCmd = FamilyType::cmdInitGpgpuWalker; + + uint32_t startWorkGroup[3] = {1, 1, 1}; + uint32_t numWorkGroups[3] = {1, 1, 1}; + uint32_t workGroupSizes[3] = {1, 1, 1}; + + uint32_t yOrder = 2u; + EXPECT_EQ(HwWalkOrderHelper::compatibleDimensionOrders[yOrder], HwWalkOrderHelper::yOrderWalk); + + auto &rootDeviceEnvironment = this->pDevice->getRootDeviceEnvironment(); + EncodeDispatchKernel::encodeThreadData(walkerCmd, startWorkGroup, numWorkGroups, workGroupSizes, 0, 3, + 0, 1, false, false, true, yOrder, rootDeviceEnvironment); + EXPECT_EQ(DefaultWalkerType::DISPATCH_WALK_ORDER::Y_ORDER_WALKER, walkerCmd.getDispatchWalkOrder()); + + EncodeDispatchKernel::encodeThreadData(walkerCmd, startWorkGroup, numWorkGroups, workGroupSizes, 0, 3, + 0, 1, true, false, true, yOrder, rootDeviceEnvironment); + EXPECT_EQ(DefaultWalkerType::DISPATCH_WALK_ORDER::Y_ORDER_WALKER, walkerCmd.getDispatchWalkOrder()); + + uint32_t linearOrder = 0u; + EXPECT_EQ(HwWalkOrderHelper::compatibleDimensionOrders[linearOrder], HwWalkOrderHelper::linearWalk); + EncodeDispatchKernel::encodeThreadData(walkerCmd, startWorkGroup, numWorkGroups, workGroupSizes, 0, 3, + 0, 1, false, false, true, linearOrder, rootDeviceEnvironment); + EXPECT_EQ(DefaultWalkerType::DISPATCH_WALK_ORDER::LINERAR_WALKER, walkerCmd.getDispatchWalkOrder()); + + EncodeDispatchKernel::encodeThreadData(walkerCmd, startWorkGroup, numWorkGroups, workGroupSizes, 0, 3, + 0, 1, true, false, true, linearOrder, rootDeviceEnvironment); + EXPECT_EQ(DefaultWalkerType::DISPATCH_WALK_ORDER::LINERAR_WALKER, walkerCmd.getDispatchWalkOrder()); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenSurfaceStateAndNullptrReleaseHelperWhenAuxParamsForMCSCCSAreSetThenCorrectAuxModeIsSet) { + auto surfaceState = FamilyType::cmdInitRenderSurfaceState; + auto originalAuxMode = surfaceState.getAuxiliarySurfaceMode(); + + EncodeSurfaceState::setAuxParamsForMCSCCS(&surfaceState, nullptr); + + EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), originalAuxMode); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenSurfaceStateAndAuxSurfaceModeOverrideRequiredIsFalseWhenAuxParamsForMCSCCSAreSetThenCorrectAuxModeIsSet) { + auto surfaceState = FamilyType::cmdInitRenderSurfaceState; + auto releaseHelper = std::make_unique(); + releaseHelper->isAuxSurfaceModeOverrideRequiredResult = false; + auto originalAuxMode = surfaceState.getAuxiliarySurfaceMode(); + + EncodeSurfaceState::setAuxParamsForMCSCCS(&surfaceState, releaseHelper.get()); + + EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), originalAuxMode); +} + +XE2_HPG_CORETEST_F(EncodeKernelXe2HpgCoreTest, givenSurfaceStateAndAuxSurfaceModeOverrideRequiredIsTrueWhenAuxParamsForMCSCCSAreSetThenCorrectAuxModeIsSet) { + auto surfaceState = FamilyType::cmdInitRenderSurfaceState; + auto releaseHelper = std::make_unique(); + releaseHelper->isAuxSurfaceModeOverrideRequiredResult = true; + + EncodeSurfaceState::setAuxParamsForMCSCCS(&surfaceState, releaseHelper.get()); + + EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), EncodeSurfaceState::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_MCS); +} + +using Xe2HpgSbaTest = SbaTest; + +XE2_HPG_CORETEST_F(Xe2HpgSbaTest, givenSpecificProductFamilyWhenAppendingSbaThenProgramWtL1CachePolicy) { + auto sbaCmd = FamilyType::cmdInitStateBaseAddress; + + StateBaseAddressHelperArgs args = createSbaHelperArgs(&sbaCmd, pDevice->getRootDeviceEnvironment().getGmmHelper(), &ssh, nullptr, nullptr); + args.setGeneralStateBaseAddress = true; + + StateBaseAddressHelper::appendStateBaseAddressParameters(args); + + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, sbaCmd.getL1CachePolicyL1CacheControl()); +} + +XE2_HPG_CORETEST_F(Xe2HpgSbaTest, givenL1CachingOverrideWhenStateBaseAddressIsProgrammedThenItMatchesTheOverrideValue) { + DebugManagerStateRestore restorer; + debugManager.flags.ForceStatelessL1CachingPolicy.set(0u); + auto sbaCmd = FamilyType::cmdInitStateBaseAddress; + + StateBaseAddressHelperArgs args = createSbaHelperArgs(&sbaCmd, pDevice->getRootDeviceEnvironment().getGmmHelper(), &ssh, nullptr, nullptr); + args.setGeneralStateBaseAddress = true; + auto &productHelper = getHelper(); + + updateSbaHelperArgsL1CachePolicy(args, productHelper); + StateBaseAddressHelper::appendStateBaseAddressParameters(args); + + EXPECT_EQ(0u, sbaCmd.getL1CachePolicyL1CacheControl()); + + debugManager.flags.ForceStatelessL1CachingPolicy.set(2u); + + updateSbaHelperArgsL1CachePolicy(args, productHelper); + StateBaseAddressHelper::appendStateBaseAddressParameters(args); + + EXPECT_EQ(2u, sbaCmd.getL1CachePolicyL1CacheControl()); + + debugManager.flags.ForceAllResourcesUncached.set(true); + + updateSbaHelperArgsL1CachePolicy(args, productHelper); + StateBaseAddressHelper::appendStateBaseAddressParameters(args); + + EXPECT_EQ(1u, sbaCmd.getL1CachePolicyL1CacheControl()); +} diff --git a/shared/test/unit_test/xe2_hpg_core/test_preemption_xe2_hpg_core.cpp b/shared/test/unit_test/xe2_hpg_core/test_preemption_xe2_hpg_core.cpp new file mode 100644 index 0000000000..c8dbc436b6 --- /dev/null +++ b/shared/test/unit_test/xe2_hpg_core/test_preemption_xe2_hpg_core.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/preemption.h" +#include "shared/source/helpers/gfx_core_helper.h" +#include "shared/source/xe2_hpg_core/hw_cmds_base.h" +#include "shared/source/xe2_hpg_core/hw_info_xe2_hpg_core.h" +#include "shared/test/unit_test/fixtures/preemption_fixture.h" + +#include "per_product_test_definitions.h" + +using namespace NEO; + +template <> +PreemptionTestHwDetails getPreemptionTestHwDetails() { + PreemptionTestHwDetails ret; + return ret; +} + +using Xe2HpgPreemptionTests = DevicePreemptionTests; + +XE2_HPG_CORETEST_F(Xe2HpgPreemptionTests, givenXe2HpgInterfaceDescriptorDataWhenPreemptionModeIsMidThreadThenThreadPreemptionBitIsEnabled) { + using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; + + INTERFACE_DESCRIPTOR_DATA iddArg; + iddArg = FamilyType::cmdInitInterfaceDescriptorData; + + PreemptionHelper::programInterfaceDescriptorDataPreemption(&iddArg, PreemptionMode::Disabled); + EXPECT_FALSE(iddArg.getThreadPreemption()); + + PreemptionHelper::programInterfaceDescriptorDataPreemption(&iddArg, PreemptionMode::MidBatch); + EXPECT_FALSE(iddArg.getThreadPreemption()); + + PreemptionHelper::programInterfaceDescriptorDataPreemption(&iddArg, PreemptionMode::ThreadGroup); + EXPECT_FALSE(iddArg.getThreadPreemption()); + + PreemptionHelper::programInterfaceDescriptorDataPreemption(&iddArg, PreemptionMode::MidThread); + EXPECT_TRUE(iddArg.getThreadPreemption()); +} diff --git a/target_unit_tests/xe2_hpg_core/CMakeLists.txt b/target_unit_tests/xe2_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..c93b0a46ac --- /dev/null +++ b/target_unit_tests/xe2_hpg_core/CMakeLists.txt @@ -0,0 +1,9 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XE2_HPG_CORE) + add_subdirectories() +endif() diff --git a/target_unit_tests/xe2_hpg_core/bmg/CMakeLists.txt b/target_unit_tests/xe2_hpg_core/bmg/CMakeLists.txt new file mode 100644 index 0000000000..5e9e780233 --- /dev/null +++ b/target_unit_tests/xe2_hpg_core/bmg/CMakeLists.txt @@ -0,0 +1,10 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_BMG) + set(unit_test_config "bmg/2/4/8/4") + include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake) +endif() diff --git a/target_unit_tests/xe2_hpg_core/lnl/CMakeLists.txt b/target_unit_tests/xe2_hpg_core/lnl/CMakeLists.txt new file mode 100644 index 0000000000..cb79c93995 --- /dev/null +++ b/target_unit_tests/xe2_hpg_core/lnl/CMakeLists.txt @@ -0,0 +1,11 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_LNL) + set(unit_test_config "lnl/2/4/8/4") + include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake) +endif() +