Skip to content

Commit 5f4a445

Browse files
authored
[CPU] CACHE_DIR hash optimization (#25624)
### Details: - *JIT implementation of the hash function in the ConstantWriter* ### Tickets: - *127331*
1 parent d34cdda commit 5f4a445

File tree

10 files changed

+1410
-89
lines changed

10 files changed

+1410
-89
lines changed

src/core/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ target_include_directories(openvino_core_dev INTERFACE
4949
$<BUILD_INTERFACE:${OpenVINO_SOURCE_DIR}/src/common/transformations/include>
5050
$<BUILD_INTERFACE:${OpenVINO_SOURCE_DIR}/src/common/low_precision_transformations/include>)
5151

52+
target_include_directories(openvino_core_dev SYSTEM INTERFACE
53+
$<BUILD_INTERFACE:$<$<TARGET_EXISTS:xbyak::xbyak>:$<TARGET_PROPERTY:xbyak::xbyak,INTERFACE_INCLUDE_DIRECTORIES>>>)
54+
5255
target_link_libraries(openvino_core_dev INTERFACE openvino::itt openvino::util)
5356

5457
set_target_properties(openvino_core_dev PROPERTIES EXPORT_NAME core::dev)
@@ -81,7 +84,7 @@ if(ENABLE_SYSTEM_PUGIXML)
8184
set_target_properties(openvino_core_obj PROPERTIES NO_SYSTEM_FROM_IMPORTED ON)
8285
endif()
8386

84-
target_compile_definitions(openvino_core_obj PRIVATE IMPLEMENT_OPENVINO_API)
87+
target_compile_definitions(openvino_core_obj PRIVATE IMPLEMENT_OPENVINO_API XBYAK_NO_OP_NAMES XBYAK64)
8588

8689
ov_build_target_faster(openvino_core_obj
8790
UNITY
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (C) 2018-2024 Intel Corporation
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
5+
#pragma once
6+
7+
#include <cstddef>
8+
9+
namespace ov {
10+
namespace runtime {
11+
12+
/**
13+
* @brief Computes the hash value for the input data
14+
* @param src A pointer to the input data
15+
* @param size The length of the input data in bytes
16+
*/
17+
size_t compute_hash(const void* src, size_t size);
18+
19+
} // namespace runtime
20+
} // namespace ov

src/core/reference/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ target_include_directories(${TARGET_NAME} PUBLIC
5050
$<BUILD_INTERFACE:${OV_CORE_DEV_API_PATH}>
5151
$<BUILD_INTERFACE:${OV_CORE_INCLUDE_PATH}>)
5252

53-
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE
54-
$<BUILD_INTERFACE:$<$<TARGET_EXISTS:xbyak::xbyak>:$<TARGET_PROPERTY:xbyak::xbyak,INTERFACE_INCLUDE_DIRECTORIES>>>)
55-
5653
find_package(Threads REQUIRED)
5754
target_link_libraries(${TARGET_NAME} PRIVATE Threads::Threads openvino::core::dev)
5855

src/core/reference/src/op/jit_generator.hpp src/core/reference/include/openvino/reference/utils/jit_generator.hpp

+39-31
Original file line numberDiff line numberDiff line change
@@ -15,66 +15,69 @@
1515
namespace ov {
1616
namespace reference {
1717
namespace jit {
18-
#ifdef XBYAK64
1918
static const Xbyak::Operand::Code abi_save_gpr_regs[] = {
2019
Xbyak::Operand::RBX,
2120
Xbyak::Operand::RBP,
2221
Xbyak::Operand::R12,
2322
Xbyak::Operand::R13,
2423
Xbyak::Operand::R14,
2524
Xbyak::Operand::R15,
26-
# ifdef _WIN32
25+
#ifdef _WIN32
2726
Xbyak::Operand::RDI,
2827
Xbyak::Operand::RSI,
29-
# endif
28+
#endif
3029
};
3130

32-
# ifdef _WIN32
33-
# define abi_param1 Xbyak::Reg64(Xbyak::Operand::RCX) // RCX
34-
# else
35-
# define abi_param1 Xbyak::Reg64(Xbyak::Operand::RDI) // RDI
36-
# endif
37-
#endif // XBYAK64
31+
#ifdef _WIN32
32+
# define abi_param1 Xbyak::Reg64(Xbyak::Operand::RCX) // RCX
33+
#else
34+
# define abi_param1 Xbyak::Reg64(Xbyak::Operand::RDI) // RDI
35+
#endif
3836

39-
class Generator : public Xbyak::CodeGenerator {
40-
static constexpr size_t xmm_len = 16;
37+
typedef enum {
38+
isa_any,
39+
sse42,
40+
avx,
41+
avx2,
42+
avx512_common,
43+
avx512_core,
44+
avx512_core_vnni,
45+
avx512_mic,
46+
avx512_mic_4ops,
47+
avx512_core_bf16,
48+
avx512_vpopcnt,
49+
fp16,
50+
pclmulqdq,
51+
vpclmulqdq
52+
} cpu_isa_t;
4153

54+
class Generator : public Xbyak::CodeGenerator {
4255
#ifdef _WIN32
43-
static constexpr size_t xmm_to_preserve_start = 6;
44-
static constexpr size_t xmm_to_preserve = 10;
56+
static constexpr size_t xmm_to_preserve_start = 6llu;
57+
static constexpr size_t xmm_to_preserve = 10llu;
4558
#else
46-
static constexpr size_t xmm_to_preserve_start = 0;
47-
static constexpr size_t xmm_to_preserve = 0;
59+
static constexpr size_t xmm_to_preserve_start = 0lu;
60+
static constexpr size_t xmm_to_preserve = 0lu;
4861
#endif
4962

5063
static const size_t num_abi_save_gpr_regs = sizeof(abi_save_gpr_regs) / sizeof(abi_save_gpr_regs[0]);
5164
const size_t size_of_abi_save_regs;
5265

5366
const Xbyak::Reg64 reg_EVEX_max_8b_offt;
5467
static constexpr int EVEX_max_8b_offt = 0x200;
68+
size_t m_vlen = ymm_len;
5569

5670
public:
57-
const Xbyak::Reg64 param = abi_param1;
71+
static constexpr size_t xmm_len = 16lu;
72+
static constexpr size_t ymm_len = 32lu;
73+
static constexpr size_t zmm_len = 64lu;
5874

59-
typedef enum {
60-
isa_any,
61-
sse42,
62-
avx,
63-
avx2,
64-
avx512_common,
65-
avx512_core,
66-
avx512_core_vnni,
67-
avx512_mic,
68-
avx512_mic_4ops,
69-
avx512_core_bf16,
70-
avx512_vpopcnt,
71-
fp16
72-
} cpu_isa_t;
75+
const Xbyak::Reg64 param = abi_param1;
7376

7477
static bool mayiuse(const cpu_isa_t cpu_isa);
7578
static bool is_x64();
7679

77-
Generator(void* code_ptr = nullptr, size_t code_size = 16 * 1024);
80+
Generator(cpu_isa_t isa = avx2, void* code_ptr = nullptr, size_t code_size = 16lu * 1024lu);
7881
void preamble();
7982
void postamble();
8083

@@ -85,7 +88,12 @@ class Generator : public Xbyak::CodeGenerator {
8588

8689
template <typename T>
8790
void copy(const Xbyak::Reg64& dst, const Xbyak::Reg64& src, const Xbyak::Reg64& size);
91+
92+
size_t get_vlen() {
93+
return m_vlen;
94+
}
8895
};
96+
8997
} // namespace jit
9098
} // namespace reference
9199
} // namespace ov

0 commit comments

Comments
 (0)