/* * Copyright (C) 2020-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ #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/test_macros/hw_test.h" #include "shared/test/unit_test/fixtures/command_container_fixture.h" using namespace NEO; using CommandEncodeSemaphore = Test; HWTEST_F(CommandEncodeSemaphore, WhenProgrammingThenMiSemaphoreWaitIsUsed) { using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; MI_SEMAPHORE_WAIT miSemaphore1; EncodeSemaphore::programMiSemaphoreWait(&miSemaphore1, 0x123400, 4, MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD, false, true); EXPECT_EQ(MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD, miSemaphore1.getCompareOperation()); EXPECT_EQ(4u, miSemaphore1.getSemaphoreDataDword()); EXPECT_EQ(0x123400u, miSemaphore1.getSemaphoreGraphicsAddress()); EXPECT_EQ(MI_SEMAPHORE_WAIT::WAIT_MODE::WAIT_MODE_POLLING_MODE, miSemaphore1.getWaitMode()); MI_SEMAPHORE_WAIT miSemaphore2; EncodeSemaphore::programMiSemaphoreWait(&miSemaphore2, 0x123400, 4, MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD, false, false); EXPECT_EQ(MI_SEMAPHORE_WAIT::WAIT_MODE::WAIT_MODE_SIGNAL_MODE, miSemaphore2.getWaitMode()); } HWTEST_F(CommandEncodeSemaphore, whenAddingMiSemaphoreCommandThenExpectCompareFieldsAreSetCorrectly) { using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; using COMPARE_OPERATION = typename FamilyType::MI_SEMAPHORE_WAIT::COMPARE_OPERATION; using WAIT_MODE = typename FamilyType::MI_SEMAPHORE_WAIT::WAIT_MODE; std::unique_ptr buffer(new uint8_t[128]); LinearStream stream(buffer.get(), 128); COMPARE_OPERATION compareMode = COMPARE_OPERATION::COMPARE_OPERATION_SAD_GREATER_THAN_OR_EQUAL_SDD; EncodeSemaphore::addMiSemaphoreWaitCommand(stream, 0xFF00FF000u, 5u, compareMode); EXPECT_EQ(NEO::EncodeSemaphore::getSizeMiSemaphoreWait(), stream.getUsed()); HardwareParse hwParse; hwParse.parseCommands(stream); MI_SEMAPHORE_WAIT *miSemaphore = hwParse.getCommand(); ASSERT_NE(nullptr, miSemaphore); EXPECT_EQ(compareMode, miSemaphore->getCompareOperation()); EXPECT_EQ(5u, miSemaphore->getSemaphoreDataDword()); EXPECT_EQ(0xFF00FF000u, miSemaphore->getSemaphoreGraphicsAddress()); EXPECT_EQ(WAIT_MODE::WAIT_MODE_POLLING_MODE, miSemaphore->getWaitMode()); } HWTEST_F(CommandEncodeSemaphore, whenGettingMiSemaphoreCommandSizeThenExpectSingleMiSemaphoreCommandSize) { using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; size_t expectedSize = NEO::EncodeSemaphore::getSizeMiSemaphoreWait(); size_t actualSize = EncodeSemaphore::getSizeMiSemaphoreWait(); EXPECT_EQ(expectedSize, actualSize); }