Skip to content

Commit c4950eb

Browse files
Method to get attention bitmask from threads vector
Signed-off-by: Mateusz Hoppe <[email protected]>
1 parent 9bca773 commit c4950eb

File tree

11 files changed

+47
-6
lines changed

11 files changed

+47
-6
lines changed

level_zero/core/source/debugger/debugger_l0.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,27 @@ void DebuggerL0::getAttentionBitmaskForThread(uint32_t slice, uint32_t subslice,
167167
}
168168
}
169169

170+
void DebuggerL0::getAttentionBitmaskForSingleThreads(std::vector<ze_device_thread_t> &threads, const NEO::HardwareInfo &hwInfo, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) {
171+
const uint32_t numSubslicesPerSlice = hwInfo.gtSystemInfo.MaxSubSlicesSupported / hwInfo.gtSystemInfo.MaxSlicesSupported;
172+
const uint32_t numEuPerSubslice = hwInfo.gtSystemInfo.MaxEuPerSubSlice;
173+
const uint32_t numThreadsPerEu = (hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount);
174+
const uint32_t bytesPerEu = alignUp(numThreadsPerEu, 8) / 8;
175+
const uint32_t threadsSizePerSlice = numSubslicesPerSlice * numEuPerSubslice * bytesPerEu;
176+
177+
bitmaskSize = hwInfo.gtSystemInfo.MaxSubSlicesSupported * hwInfo.gtSystemInfo.MaxEuPerSubSlice * bytesPerEu;
178+
bitmask = std::make_unique<uint8_t[]>(bitmaskSize);
179+
180+
memset(bitmask.get(), 0, bitmaskSize);
181+
182+
for (auto &thread : threads) {
183+
uint8_t *sliceData = ptrOffset(bitmask.get(), threadsSizePerSlice * thread.slice);
184+
uint8_t *subsliceData = ptrOffset(sliceData, numEuPerSubslice * bytesPerEu * thread.subslice);
185+
uint8_t *euData = ptrOffset(subsliceData, bytesPerEu * thread.eu);
186+
UNRECOVERABLE_IF(thread.thread > 7);
187+
*euData |= (1 << thread.thread);
188+
}
189+
}
190+
170191
std::vector<ze_device_thread_t> DebuggerL0::getThreadsFromAttentionBitmask(const NEO::HardwareInfo &hwInfo, const uint8_t *bitmask, const size_t bitmaskSize) {
171192
const uint32_t numSubslicesPerSlice = hwInfo.gtSystemInfo.MaxSubSlicesSupported / hwInfo.gtSystemInfo.MaxSlicesSupported;
172193
const uint32_t numEuPerSubslice = hwInfo.gtSystemInfo.MaxEuPerSubSlice;

level_zero/core/source/debugger/debugger_l0.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
9191
virtual void programSbaTrackingCommands(NEO::LinearStream &cmdStream, const SbaAddresses &sba) = 0;
9292

9393
static void getAttentionBitmaskForThread(uint32_t slice, uint32_t subslice, uint32_t eu, uint32_t thread, const NEO::HardwareInfo &hwInfo, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize);
94+
static void getAttentionBitmaskForSingleThreads(std::vector<ze_device_thread_t> &threads, const NEO::HardwareInfo &hwInfo, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize);
9495
static std::vector<ze_device_thread_t> getThreadsFromAttentionBitmask(const NEO::HardwareInfo &hwInfo, const uint8_t *bitmask, const size_t bitmaskSize);
9596

9697
protected:

level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "shared/source/os_interface/os_context.h"
1515
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
1616
#include "shared/test/common/helpers/variable_backup.h"
17+
#include "shared/test/common/test_macros/matchers.h"
1718

1819
#include "test.h"
1920

@@ -1526,6 +1527,24 @@ TEST(DebuggerL0, givenAllSliceSubsliceEuAndThreadIdsWhenGettingBitmaskThenCorrec
15261527
EXPECT_EQ(0, memcmp(bitmask.get(), expectedBitmask.get(), size));
15271528
}
15281529

1530+
TEST(DebuggerL0, givenSingleThreadsWhenGettingBitmaskThenCorrectBitsAreSet) {
1531+
auto hwInfo = *NEO::defaultHwInfo.get();
1532+
std::unique_ptr<uint8_t[]> bitmask;
1533+
size_t size = 0;
1534+
1535+
std::vector<ze_device_thread_t> threads;
1536+
threads.push_back({0, 0, 0, 3});
1537+
threads.push_back({0, 0, 1, 0});
1538+
1539+
DebuggerL0::getAttentionBitmaskForSingleThreads(threads, hwInfo, bitmask, size);
1540+
1541+
auto data = bitmask.get();
1542+
EXPECT_EQ(1u << 3, data[0]);
1543+
EXPECT_EQ(1u, data[1]);
1544+
1545+
EXPECT_THAT(&data[2], MemoryZeroed(size - 2));
1546+
}
1547+
15291548
TEST(DebuggerL0, givenBitmaskWithAttentionBitsForSingleThreadWhenGettingThreadsThenSingleCorrectThreadReturned) {
15301549
auto hwInfo = *NEO::defaultHwInfo.get();
15311550
std::unique_ptr<uint8_t[]> bitmask;

opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
#include "shared/test/common/mocks/mock_execution_environment.h"
2525
#include "shared/test/common/mocks/mock_graphics_allocation.h"
2626
#include "shared/test/common/mocks/ult_device_factory.h"
27+
#include "shared/test/common/test_macros/matchers.h"
2728
#include "shared/test/common/test_macros/test_checks_shared.h"
2829

2930
#include "opencl/source/command_stream/definitions/command_stream_receiver_simulated_hw.h"
3031
#include "opencl/source/mem_obj/buffer.h"
3132
#include "opencl/source/platform/platform.h"
3233
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
3334
#include "opencl/test/unit_test/fixtures/multi_root_device_fixture.h"
34-
#include "opencl/test/unit_test/gen_common/matchers.h"
3535
#include "opencl/test/unit_test/helpers/raii_hw_helper.h"
3636
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
3737
#include "opencl/test/unit_test/mocks/mock_buffer.h"

opencl/test/unit_test/device_queue/device_queue_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
*/
77

88
#include "shared/source/device/device_info.h"
9+
#include "shared/test/common/test_macros/matchers.h"
910

1011
#include "opencl/source/helpers/dispatch_info.h"
1112
#include "opencl/test/unit_test/fixtures/device_host_queue_fixture.h"
12-
#include "opencl/test/unit_test/gen_common/matchers.h"
1313
#include "opencl/test/unit_test/mocks/mock_context.h"
1414
#include "opencl/test/unit_test/mocks/mock_kernel.h"
1515
#include "opencl/test/unit_test/mocks/mock_program.h"

opencl/test/unit_test/gen_common/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ set(IGDRCL_SRCS_tests_gen_common
99
${CMAKE_CURRENT_SOURCE_DIR}/exclude_tests/exclude_test_declare.cpp
1010
${CMAKE_CURRENT_SOURCE_DIR}/exclude_tests/exclude_test_exclude.cpp
1111
${CMAKE_CURRENT_SOURCE_DIR}/gen_commands_common_validation.h
12-
${CMAKE_CURRENT_SOURCE_DIR}/matchers.h
1312
${NEO_SHARED_TEST_DIRECTORY}/common/test_macros/header${BRANCH_DIR_SUFFIX}/test.h
1413
)
1514
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen_common})

opencl/test/unit_test/kernel/kernel_reflection_surface_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include "shared/test/common/helpers/debug_manager_state_restore.h"
9+
#include "shared/test/common/test_macros/matchers.h"
910

1011
#include "opencl/source/execution_model/device_enqueue.h"
1112
#include "opencl/source/kernel/kernel.h"
@@ -15,7 +16,6 @@
1516
#include "opencl/test/unit_test/fixtures/execution_model_kernel_fixture.h"
1617
#include "opencl/test/unit_test/fixtures/image_fixture.h"
1718
#include "opencl/test/unit_test/fixtures/multi_root_device_fixture.h"
18-
#include "opencl/test/unit_test/gen_common/matchers.h"
1919
#include "opencl/test/unit_test/helpers/gtest_helpers.h"
2020
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
2121
#include "opencl/test/unit_test/mocks/mock_context.h"

opencl/test/unit_test/mem_obj/buffer_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
#include "shared/test/common/mocks/mock_device.h"
1616
#include "shared/test/common/mocks/mock_execution_environment.h"
1717
#include "shared/test/common/mocks/ult_device_factory.h"
18+
#include "shared/test/common/test_macros/matchers.h"
1819

1920
#include "opencl/extensions/public/cl_ext_private.h"
2021
#include "opencl/source/command_queue/command_queue_hw.h"
2122
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
2223
#include "opencl/test/unit_test/fixtures/memory_management_fixture.h"
2324
#include "opencl/test/unit_test/fixtures/multi_root_device_fixture.h"
24-
#include "opencl/test/unit_test/gen_common/matchers.h"
2525
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
2626
#include "opencl/test/unit_test/mocks/mock_buffer.h"
2727
#include "opencl/test/unit_test/mocks/mock_command_queue.h"

shared/test/common/test_macros/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
set(NEO_CORE_test_macros
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
99
${CMAKE_CURRENT_SOURCE_DIR}/header${BRANCH_DIR_SUFFIX}/test.h
10+
${CMAKE_CURRENT_SOURCE_DIR}/matchers.h
1011
${CMAKE_CURRENT_SOURCE_DIR}/test_checks_shared.cpp
1112
${CMAKE_CURRENT_SOURCE_DIR}/test_checks_shared.h
1213
)
File renamed without changes.

0 commit comments

Comments
 (0)