2020-08-27 14:55:09 +08:00
|
|
|
/*
|
2023-01-17 00:40:13 +08:00
|
|
|
* Copyright (C) 2020-2023 Intel Corporation
|
2020-08-27 14:55:09 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "shared/source/helpers/heap_assigner.h"
|
2022-11-16 23:50:07 +08:00
|
|
|
#include "shared/source/memory_manager/allocation_type.h"
|
|
|
|
#include "shared/source/memory_manager/gfx_partition.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/fixtures/device_fixture.h"
|
2023-01-17 00:40:13 +08:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
2022-06-30 03:17:47 +08:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2020-08-27 14:55:09 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
2022-08-11 22:01:11 +08:00
|
|
|
class AlocationHelperTests : public Test<DeviceFixture> {
|
2020-08-27 14:55:09 +08:00
|
|
|
public:
|
2023-10-19 22:24:35 +08:00
|
|
|
HeapAssigner heapAssigner{false};
|
2020-08-27 14:55:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
HWTEST_F(AlocationHelperTests, givenKernelIsaTypeWhenUse32BitHeapCalledThenTrueReturned) {
|
|
|
|
|
2022-02-04 21:59:01 +08:00
|
|
|
EXPECT_TRUE(heapAssigner.use32BitHeap(AllocationType::KERNEL_ISA));
|
|
|
|
EXPECT_TRUE(heapAssigner.use32BitHeap(AllocationType::KERNEL_ISA_INTERNAL));
|
2020-08-27 14:55:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(AlocationHelperTests, givenKernelIsaTypeWhenUseIternalAllocatorThenUseHeapInternal) {
|
2022-02-04 21:59:01 +08:00
|
|
|
auto heapIndex = heapAssigner.get32BitHeapIndex(AllocationType::KERNEL_ISA, true, *defaultHwInfo, false);
|
2020-08-27 14:55:09 +08:00
|
|
|
EXPECT_EQ(heapIndex, NEO::HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY);
|
2020-11-13 02:53:30 +08:00
|
|
|
|
2022-02-04 21:59:01 +08:00
|
|
|
heapIndex = heapAssigner.get32BitHeapIndex(AllocationType::KERNEL_ISA_INTERNAL, true, *defaultHwInfo, false);
|
2020-11-13 02:53:30 +08:00
|
|
|
EXPECT_EQ(heapIndex, NEO::HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY);
|
2020-08-27 14:55:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(AlocationHelperTests, givenNotInternalTypeWhenUseIternalAllocatorThenUseHeapExternal) {
|
2022-02-04 21:59:01 +08:00
|
|
|
auto heapIndex = heapAssigner.get32BitHeapIndex(AllocationType::LINEAR_STREAM, true, *defaultHwInfo, false);
|
2020-08-27 14:55:09 +08:00
|
|
|
EXPECT_EQ(heapIndex, NEO::HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY);
|
|
|
|
}
|
|
|
|
|
2020-11-13 02:53:30 +08:00
|
|
|
HWTEST_F(AlocationHelperTests, givenKernelIsaTypesWhenUseInternalAllocatorCalledThenTrueReturned) {
|
2022-02-04 21:59:01 +08:00
|
|
|
EXPECT_TRUE(heapAssigner.useInternal32BitHeap(AllocationType::KERNEL_ISA));
|
|
|
|
EXPECT_TRUE(heapAssigner.useInternal32BitHeap(AllocationType::KERNEL_ISA_INTERNAL));
|
2020-08-27 14:55:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(AlocationHelperTests, givenInternalHeapTypeWhenUseInternalAllocatorCalledThenTrueReturned) {
|
2022-02-04 21:59:01 +08:00
|
|
|
EXPECT_TRUE(heapAssigner.useInternal32BitHeap(AllocationType::INTERNAL_HEAP));
|
2020-08-27 14:55:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
HWTEST_F(AlocationHelperTests, givenNotInternalHeapTypeWhenUseInternalAllocatorCalledThenFalseReturned) {
|
2022-02-04 21:59:01 +08:00
|
|
|
EXPECT_FALSE(heapAssigner.useInternal32BitHeap(AllocationType::BUFFER));
|
2020-08-27 14:55:09 +08:00
|
|
|
}
|
|
|
|
|
2022-11-16 23:50:07 +08:00
|
|
|
} // namespace NEO
|