Data compression unit, data decompression unit, processor and related methods

Through the design of data compression and decompression units, using multiple compression schemes to split and compress data, the problem of high bandwidth occupancy when the processor exchanges data with the main memory is solved, and the read and write speed of the processor is improved.

CN118944672APending Publication Date: 2024-11-12T-HEAD (SHANGHAI) SEMICON CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310521921.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-09
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

When the processor exchanges data with the main memory, the amount of data between the last-level cache and the main memory is too large, resulting in a high access bandwidth occupancy, affecting the processor's read and write speed.

Method used

Design a data compression unit and a data decompression unit, divide the data to be compressed into multiple data groups through multiple compression schemes, and generate corresponding bit masks. The compressed data includes a bit mask and an incompressible data group to reduce transmission Data volume, realizes data compression and decompression.

Benefits of technology

By reducing the amount of data transmitted between the last-level cache and the main memory, the main memory access bandwidth is reduced, and the processor can read and write the main memory speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118944672A_ABST
    Figure CN118944672A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data compression unit, a data decompression unit, a processor and a related method, and the data compression unit comprises a mask subunit which is used for segmenting to-be-compressed data into a plurality of data groups according to a plurality of compression schemes, and generating bit masks corresponding to the compression schemes according to data values included in the data groups, the bits of the data sets segmented according to different compression schemes are different, and the bit masks are used for indicating the to-be-compressed data sets; the compression subunit is used for generating compressed data corresponding to the compression scheme according to the bit mask of the compression scheme, and the compressed data comprises the bit mask of the corresponding compression scheme and data sets which are segmented according to the corresponding compression scheme and except the data set to be compressed; and the screening subunit is used for determining target compressed data corresponding to the to-be-compressed data according to the compressed data corresponding to each compression scheme. The scheme can improve the speed of accessing the main memory by the processor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of chip technology, and in particular, to a data compression unit, a data decompression unit, a processor and related methods. Background Art

[0002] Cache is a memory that can exchange data at high speed. It exchanges data with the processing unit before the memory, so it has a faster read and write rate. It is used in processors (Central Processing Unit, CPU), graphics processing units (Graphics Processing Unit, GPU) and general-purpose computing on graphics processing units (GPGPU). The processor usually includes multiple levels of cache. When the processor writes data to the main memory (memory), the data is written to the main memory through the last level cache (LLC).

[0003] Since the speed at which the processor reads and writes the main memory is limited by the access bandwidth of the main memory, if the amount of data transmitted between the last-level cache and the main memory can be reduced, the occupancy of the main memory access bandwidth can be reduced, thereby increasing the speed at which the processor reads and writes the main memory. Therefore, reducing the amount of data transmitted between the last-level cache and the main memory is a technical problem that needs to be solved urgently. Summary of the invention

[0004] In view of this, embodiments of the present application provide a data compression unit, a data decompression unit, a processor and related methods to at least partially solve the above problems.

[0005] According to a first aspect of an embodiment of the present application, a data compression unit is provided, comprising: a mask subunit, for dividing the data to be compressed into multiple data groups according to multiple compression schemes, and generating a bit mask of the corresponding compression scheme according to the data values ​​included in the data group, wherein the number of bits of the data groups divided according to different compression schemes is different, and the bit mask is used to indicate the data group to be compressed among the multiple data groups divided according to the corresponding compression scheme; a compression subunit, for generating compressed data corresponding to the compression scheme according to the bit mask of the compression scheme, wherein the compressed data includes the bit mask of the corresponding compression scheme and the data group other than the data group to be compressed divided according to the corresponding compression scheme; a screening subunit, for determining the target compressed data corresponding to the data to be compressed according to the compressed data corresponding to each compression scheme.

[0006] According to the second aspect of an embodiment of the present application, a data decompression unit is provided, comprising: a mask extraction subunit, for extracting a bit mask from the data to be decompressed according to a target compression scheme corresponding to the data to be decompressed, wherein the bit mask is used to indicate a data group to be compressed among multiple data groups obtained by segmenting the original data according to the target compression scheme, and the data to be decompressed includes the bit mask and a data group other than the data group to be compressed segmented from the original data according to the target compression scheme; a data group extraction subunit, for extracting the data group included in the data to be decompressed according to the target compression scheme; and a decompression subunit, for splicing the data group to be compressed with the data group included in the data to be decompressed according to the bit mask to obtain the original data.

[0007] According to a third aspect of an embodiment of the present application, a data compression method is provided, comprising: dividing the data to be compressed into multiple data groups according to multiple compression schemes, and generating a bit mask of the corresponding compression scheme according to the data values ​​included in the data group, wherein the number of bits of the data groups divided according to different compression schemes is different, and the bit mask is used to indicate the data group to be compressed among the multiple data groups divided according to the corresponding compression scheme; generating compressed data corresponding to the compression scheme according to the bit mask of the compression scheme, wherein the compressed data includes the bit mask of the corresponding compression scheme and the data groups other than the data group to be compressed divided according to the corresponding compression scheme; determining the target compressed data corresponding to the data to be compressed according to the compressed data corresponding to each compression scheme.

[0008] According to a fourth aspect of an embodiment of the present application, a data decompression method is provided, comprising: extracting a bit mask from the data to be decompressed according to a target compression scheme corresponding to the data to be decompressed, wherein the bit mask is used to indicate a data group to be compressed among multiple data groups obtained by segmenting the original data according to the target compression scheme, and the data to be decompressed includes data groups other than the data group to be compressed that are segmented from the original data according to the target compression scheme; extracting the data group included in the data to be decompressed according to the target compression scheme; and splicing the data group to be compressed with the data group included in the data to be decompressed according to the bit mask to obtain the original data.

[0009] According to a fifth aspect of an embodiment of the present application, a processor is provided, comprising: a data compression unit as described in the first aspect above, and / or a data decompression unit as described in the second aspect above; a cache memory for caching at least one of the following data: original data that needs to be compressed by the data compression unit, compressed data obtained by compressing the original data by the data compression unit, data to be decompressed that needs to be decompressed by the data decompression unit, and original data obtained by decompressing the data to be decompressed by the data decompression unit.

[0010] According to the sixth aspect of an embodiment of the present application, a system on chip is provided, comprising: a processor as described in the fifth aspect above, i.e., a memory coupled to the processor, the memory being used to store compressed data obtained by compressing original data by the data compression unit, and / or data to be decompressed that needs to be decompressed by the data decompression unit.

[0011] According to the data compression and decompression scheme provided in the embodiment of the present application, the data to be compressed is divided into multiple data groups according to the compression scheme, and a bit mask indicating the data group to be compressed is generated. The data group to be compressed in the data to be compressed is compressed according to the bit mask, and compressed data including the bit mask and the incompressible data group is generated. Then, according to the compressed data corresponding to different compression schemes, the target compressed data corresponding to the data to be compressed can be determined, and the compression of the data to be compressed is realized, so that the last-level cache can transfer the target compressed data to the main memory, thereby reducing the occupancy of the access bandwidth of the main memory and improving the speed of the processor in reading and writing the main memory. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0013] Figure 1 is a schematic diagram of a data center used in one embodiment of the present application;

[0014] Figure 2 is an internal structure diagram of a server according to an embodiment of the present application;

[0015] Figure 3 is an internal structure diagram of a processor according to an embodiment of the present application;

[0016] Figure 4 is an internal structure diagram of a data compression unit according to an embodiment of the present application;

[0017] Figure 5 is a schematic diagram of a data compression process of an embodiment of the present application;

[0018] Figure 6 is a schematic diagram of compressed data according to an embodiment of the present application;

[0019] Figure 7 is an internal structure diagram of a data compression unit according to another embodiment of the present application;

[0020] Figure 8 This is a schematic diagram of the working process of a data compression unit according to an embodiment of the present application;

[0021] Fig. 9 is an internal structure diagram of a data decompression unit according to an embodiment of the present application;

[0022] Fig.10 This is a schematic diagram of the workflow of a data decompression unit according to an embodiment of the present application;

[0023] Fig.11 is an internal structure diagram of a data decompression unit in another embodiment of the present application;

[0024] Fig.12 is a flow chart of a data compression method according to an embodiment of the present application;

[0025] Fig.13 It is a flow chart of a data decompression method according to an embodiment of the present application. DETAILED DESCRIPTION

[0026] The present application is described below based on embodiments, but the present application is not limited to these embodiments. In the detailed description of the present application below, some specific details are described in detail. It is possible for a person skilled in the art to fully understand the present application without the description of these details. In order to avoid confusing the essence of the present application, known methods, processes, and flows are not described in detail. In addition, the drawings are not necessarily drawn to scale.

[0027] The following terms are used in this article.

[0028] Computing device: A device with computing or processing capabilities, which can be in the form of a terminal, such as an IoT device, a mobile terminal, a desktop computer, a laptop computer, etc., or it can be in the form of a server or a server cluster.

[0029] Processor: It is the computing core and / or control core of a computing device. Its main function is to execute computer instructions and process data in computer software. The processor in the embodiment of the present application can be a CPU, GPU, GPGPU, etc.

[0030] Memory: A physical structure located inside a computer device and used to store information. Depending on the purpose, memory can be divided into main memory (also called internal memory, or simply internal memory / main memory) and auxiliary memory (also called external memory, or simply auxiliary memory / external memory). Main memory is used to store instruction information and / or data information represented by data signals, such as data provided by the processor, and can also be used to realize information exchange between the processor and external memory. The information provided by the external memory needs to be transferred to the main memory before it can be accessed by the processor, so the memory mentioned in this article generally refers to the main memory.

[0031] System on chip: System on a chip (SoC) refers to a technology that integrates a complete system on a single chip and groups all or part of the necessary electronic circuits. The so-called complete system generally includes a processor (CPU) or an acceleration unit, memory, and peripheral circuits. SoC is developed in parallel with other technologies, such as Silicon on Insulator (SOI), which can provide enhanced clock frequencies and thus reduce the power consumption of microchips.

[0032] Cache line: When a computer reads data from main memory into cache, it needs to read the data to be read and some of the data near it into the cache. The group of data read at one time is called a cache line. Each level of cache can store multiple cache lines.

[0033] Application environment of this application

[0034] The embodiment of the present application proposes a data compression and decompression scheme. The entire data compression and decompression scheme is relatively universal and can be used for various hardware devices including cache memory and main memory, such as CPU, artificial intelligence (AI) acceleration unit, graphics processing unit (GPU), general graphics processor (GPGPU), Internet of Things (IoT) devices for executing deep learning models, embedded devices, etc. The data compression and decompression scheme is independent of the hardware deployed by the computing device that executes the scheme, but for exemplary purposes, it will be mainly described below with the data center as the application scenario. Those skilled in the art should understand that the embodiments of the present application can also be applied to other application scenarios.

[0035] Data Center

[0036] Data centers are a globally collaborative network of specific devices used to transmit, accelerate, display, calculate, and store data information on the Internet network infrastructure. In the future, data centers will also become competitive assets for enterprises. With the widespread application of data centers, artificial intelligence and other technologies are increasingly being applied to data centers. As an important technology of artificial intelligence, neural networks have been widely used in data center big data analysis and calculation.

[0037] In traditional large data centers, the network structure is usually as follows Figure 1 As shown in the figure, it is the hierarchical inter-networking model. This model includes the following parts:

[0038] Server 140 : Each server 140 is a processing and storage entity of the data center. The processing and storage of a large amount of data in the data center are completed by these servers 140 .

[0039] Access switch 130: Access switch 130 is used to connect servers 140 to the switch in the data center. One access switch 130 connects to multiple servers 140. Access switches 130 are usually located at the top of the rack, so they are also called top of rack switches, and they are physically connected to the servers.

[0040] Aggregation switch 120: Each aggregation switch 120 connects to multiple access switches 130 and provides other services, such as firewall, intrusion detection, network analysis, etc.

[0041] Core switch 110: The core switch 110 provides high-speed forwarding for packets entering and leaving the data center, and provides connectivity for the aggregation switch 120. The network of the entire data center is divided into an L3 layer routing network and an L2 layer routing network. The core switch 110 usually provides a flexible L3 layer routing network for the network of the entire data center.

[0042] Generally, the aggregation switch 120 is the demarcation point between the L2 and L3 layer routing networks. The network below the aggregation switch 120 is the L2 network, and the network above is the L3 network. Each group of aggregation switches manages a delivery point (POD), and the POD is an independent VLAN network. The server does not need to modify the IP address and default gateway when migrating within the POD, because one POD corresponds to one L2 broadcast domain.

[0043] The spanning tree protocol (Spanning Tree Protocol, STP) is usually used between the aggregation switch 120 and the access switch 130. STP makes only one aggregation switch 120 available for a VLAN network, and other aggregation switches 120 are used only when a failure occurs. In other words, horizontal expansion cannot be achieved at the level of the aggregation switch 120, because even if multiple aggregation switches 120 are added, only one is still working.

[0044] server

[0045] Since the server 140 is the real processing device in the data center, Figure 2 FIG. 1 shows an internal structure diagram of a server 140 according to an embodiment of the present application. The server 140 may include multiple processors 22. As an example, Figure 2 As shown, the server 140 may include processor 0, processor 1, processor 2, and processor 3, but it should be understood that the number of processors should not be limited thereto.

[0046] like Figure 2 As shown, the server 140 may further include a memory 23. The memory 23 in the server 140 may be a main memory (abbreviated as main memory or internal memory), which is used to store instruction information and / or data information represented by data signals, for example, to store data (such as operation results) provided by the processor 22, and may also be used to implement data exchange between the processor 22 and an external storage device 26 (or referred to as an auxiliary memory or external memory).

[0047] In some cases, the processor 22 may need to access the memory 23 to obtain data in the memory 23 or modify the data in the memory 23. Since the access speed of the memory 23 is slow, in order to alleviate the speed gap between the processor 22 and the memory 23, the server 140 also includes a cache memory 24 coupled to the bus 21, and the cache memory 24 is used to cache some program data or message data in the memory 23 that may be repeatedly called. The cache memory 24 can be implemented by a storage device of the type of static random access memory (SRAM). The cache memory 24 can be a multi-level structure, such as a three-level cache structure with a first-level cache (L1 cache), a second-level cache (L2 cache) and a third-level cache (L3 cache), or a cache structure of more than three levels or other types of cache structures. In some embodiments, a portion of the cache memory 24 (such as a first-level cache, or a first-level cache and a second-level cache) can be integrated inside the processor 22 or integrated with the processor 22 in the same system on a chip.

[0048] The information exchange between the memory 23 and the cache memory 24 is usually organized in blocks. In some embodiments, the cache memory 24 and the memory 23 can be divided into data blocks according to the same spatial size, and the data block can be used as a unit of data exchange between the cache memory 24 and the memory 23 (including one or more data of a preset length). For the sake of simplicity and clarity, the data blocks in the cache memory 24 are referred to as cache blocks (which can be called cache lines or cache lines), and different cache blocks have different cache block addresses; the data blocks in the memory 23 are referred to as memory blocks, and different memory blocks have different memory block addresses. The cache block address, for example, includes an address tag for locating the data block.

[0049] Due to space and resource limitations, the cache memory 24 cannot cache all the contents in the memory 23, that is, the storage capacity of the cache memory 24 is usually smaller than that of the memory 23, and the cache block addresses provided by the cache memory 24 cannot correspond to all the memory block addresses provided by the memory 23. When the processor 22 needs to access the memory, it first accesses the cache memory 24 via the bus 21 to determine whether the content to be accessed has been stored in the cache memory 24. If so, the cache memory 24 hits, and the processor 22 directly calls the content to be accessed from the cache memory 24; if the content that the processor 22 needs to access is not in the cache memory 24, the processor 22 needs to access the memory 23 via the bus 21 to find the corresponding information in the memory 23. Because the access rate of the cache memory 24 is very fast, when the cache memory 24 hits, the efficiency of the processor 22 can be significantly improved, thereby improving the performance and efficiency of the entire server 140.

[0050] The processor 22, the cache memory 24, and the memory 23 may be packaged in a system on chip (SoC) 201. Designers may configure the SoC architecture so that the communication between the various components in the server 140 is secure.

[0051] The server 140 may also include hardware devices such as a display device (not shown), an audio device (not shown), and an input / output device 25. The input / output device 25 may be, for example, a text, audio, and video input / output device. As an example, Figure 2Input / output device 0, input / output device 1, input / output device 2 and input / output device 3 are shown, but it should be understood that the number of input / output devices should not be limited to this. Storage devices are, for example, hard disks, optical disks, flash memory devices, etc., which are coupled to bus 21 through corresponding interfaces for information access. Display devices can be coupled to bus 21 through corresponding graphics cards, and are used to display according to display signals provided by bus 21. Server 140 generally also includes a communication device (not shown), so it can communicate with a network or other devices in various ways. The communication device may include, for example, one or more communication modules. As an example, the communication device may include a wireless communication module suitable for a specific wireless communication protocol. For example, the communication device may include a WLAN module for implementing WiFi communication in accordance with the 802.11 standard established by the Institute of Electrical and Electronics Engineers (IEEE); the communication device may also include a WWAN module for implementing wireless wide area communication in accordance with cellular or other wireless wide area protocols; the communication device may also include a communication module using other protocols such as a Bluetooth module, or a communication module of other custom types; the communication device may also be a port for serial transmission of data.

[0052] It should be understood that Figure 2 The server 140 shown is an exemplary structure, and the structure of different computer systems may vary depending on the motherboard, operating system and instruction set architecture.

[0053] processor

[0054] Figure 3 FIG. 2 is a schematic block diagram of a processor 22 according to an embodiment of the present application. The processor 22 may be a CPU, a GPU, a GPGPU, etc.

[0055] In some embodiments, the processor 22 may include one or more processor cores 27 for processing instructions, and the processing and execution of instructions may be controlled by the user (e.g., through an application) and / or the system platform. In some embodiments, the processor core may be used to process a specific instruction set. In some embodiments, the instruction set may support complex instruction set computing (CISC), reduced instruction set computing (RISC), or very long instruction word (VLIW)-based computing. Different processor cores 27 may each process different instruction sets. In some embodiments, the processor core 27 may also include other processing modules, such as a digital signal processor (DSP), etc. As an example, Figure 3 Processor cores 1 to m are shown in FIG. 1 , where m is a positive integer.

[0056] In some embodiments, Figure 3 As shown, the processor 22 may include a cache memory 24, and according to different architectures, the cache memory 24 in the processor 22 may be a single or multi-level internal cache memory 24 located inside and / or outside each processor core 27 (e.g., Figure 2 3-level cache memory L1 to L3) shown in the figure may also include an instruction-oriented instruction cache and a data-oriented data cache. In some embodiments, various components in the processor 22 may share at least a portion of the cache memory 24, such as Figure 2 As shown, the processor cores 1 to m, for example, share a third-level cache memory L3. The processor 22 may also include an external cache (not shown), and other cache structures may also serve as the external cache of the processor 22.

[0057] In some embodiments, Figure 3 As shown, the processor 22 may include a register file 28. The register file 28 may include multiple registers for storing different types of data and / or instructions. These registers may be of different types. For example, the register file 28 may include integer registers, floating point registers, status registers, instruction registers, and pointer registers. The registers in the register file 28 may be implemented by using general registers, or may be implemented by using a specific design according to the actual needs of the processor 22.

[0058] In some embodiments, the processor 22 may include a data compression unit 210 and a data decompression unit 220. The data compression unit 210 and the data decompression unit 220 may be arranged between two adjacent levels of cache, such as between L1 and L2 or between L2 and L3. The data compression unit 210 and the data decompression unit 220 may also be arranged in the last level cache (corresponding to Figure 3 The processor 22 may include a set of data compression units 210 and data decompression units 220, which are arranged between any two adjacent levels of cache, or between the last level cache and the memory 23, such as the data compression unit 210 and the data decompression unit 220 are arranged between L1 and L2, between L2 and L3, or between L3 and the memory 23. The processor 22 may also include multiple sets of data compression units 210 and data decompression units 220, such as the data compression unit 210 and the data decompression unit 220 are respectively arranged between L1 and L2, and between L3 and the memory 23.

[0059] When a data compression unit 210 and a data decompression unit 220 are provided between two adjacent levels of cache, the data compression unit 210 can compress the data sent from the previous level cache to the next level cache, thereby reducing the amount of data received by the next level cache, and then the next level cache can send the compressed data to the memory 23, thereby reducing the occupation of the memory access bandwidth of the memory 23. When a data compression unit 210 and a data decompression unit 220 are provided between the final level cache and the memory 23, the data compression unit 210 can compress the data sent from the final level cache to the memory 23, and send the compressed data to the memory 23, thereby reducing the amount of data received by the memory 23, thereby reducing the occupation of the memory access bandwidth of the memory 23, and can reduce the occupation of the storage space of the memory 23.

[0060] When a data compression unit 210 and a data decompression unit 220 are provided between two adjacent levels of cache, the data decompression unit 220 can decompress the compressed data sent from the subsequent level cache to the previous level cache, and send the decompressed data to the previous level cache. When a data compression unit 210 and a data decompression unit 220 are provided between the final level cache and the memory 23, the data decompression unit 220 can decompress the compressed data sent from the memory 23 to the final level cache, and send the decompressed data to the final level cache.

[0061] Setting a data compression unit 210 and a data decompression unit 220 between any two adjacent levels of cache or between the final level cache and the memory 23 will reduce the amount of data sent to the memory 23, thereby reducing the occupancy of the access bandwidth of the memory 23 when reading and writing the memory 23, thereby improving the reading and writing speed of the processor 22 to the memory 23.

[0062] It should be noted that L1 is a front-level cache relative to L2 and L3, L2 is a back-level cache relative to L1, L2 is a front-level cache relative to L3, and L3 is a back-level cache relative to L1 and L2. Since L1 can bypass L2 and directly obtain data from L3, the data compression unit 210 can compress the data from L1 and send it to L3, and the data decompression unit 220 can decompress the compressed data from L3 and send it to L1. To this end, the data compression unit 210 and the data decompression unit 220 can be set at the exit of L1, L2 and / or L3, so as to compress and decompress the data entering and exiting the corresponding level cache.

[0063] In some embodiments, the processor 22 may include a memory management unit (MMU) 230 for implementing translation from virtual addresses to physical addresses. The memory management unit 230 caches a portion of the table entries in the page table, and the memory management unit 230 may also obtain uncached table entries from the memory 23. One or more memory management units 230 may be set in the processor core 27, and the memory management unit 230 in the processor core 27 may be synchronized with the memory management unit 230 in other processors or processor cores, so that different processors or processor cores can share a unified virtual storage system.

[0064] In some embodiments, the processor 22 may include multiple instruction execution units 29. The instruction execution unit 29 may obtain data information loaded by the memory management unit 230 from the register, and perform data parallel processing such as deep learning and matrix operations based on the obtained data information. The instruction execution unit 29 may also store the operation result in the corresponding register, and then the memory management unit 230 obtains the operation result from the register and stores the obtained operation result in the cache memory 24.

[0065] It should be noted that the above and Figure 3 It is used to exemplarily describe one of the processors in the system, and is not used to limit the specific implementation of the processor 22. The processor 22 may also include other components, such as an instruction fetch unit, an instruction decoding unit, etc. The various components of the processor 22 described above may also be appropriately omitted in actual applications.

[0066] System on Chip

[0067] An embodiment of the present application also provides a system on chip, including the processor 22 in the above embodiment and a memory coupled to the processor 22, the memory can store compressed data obtained by compressing the original data by the data compression unit 210, and can also store data to be compressed that needs to be decompressed by the data decompression unit 220.

[0068] Data Compression Unit

[0069] Figure 4 FIG. 1 is an internal structure diagram of a data compression unit according to an embodiment of the present application. Figure 4 As shown, the data compression unit 210 includes a mask subunit 211 , a compression subunit 212 and a screening subunit 213 .

[0070] The mask subunit 211 can divide the data to be compressed into multiple data groups according to multiple compression schemes, and generate a bit mask of the corresponding compression scheme according to the data values ​​included in the data group. The number of bits of the data groups divided according to different compression schemes is different, and the bit mask is used to indicate the data group to be compressed among the multiple data groups divided according to the corresponding compression scheme.

[0071] The compression subunit 212 can generate compressed data corresponding to the compression scheme according to the bit mask of the compression scheme, and the compressed data includes the bit mask of the corresponding compression scheme and the data groups other than the data group to be compressed divided according to the corresponding compression scheme.

[0072] The screening sub-unit 213 may determine target compressed data corresponding to the data to be compressed according to the compressed data corresponding to each compression scheme.

[0073] The compression scheme defines the rules for segmenting data. According to the compression scheme, the data can be segmented into multiple data groups. The data groups segmented according to the same compression scheme have the same data length, that is, the number of bits of the data groups segmented according to the same compression scheme is the same. Multiple compression schemes are preset, and the number of bits of the data groups segmented according to different compression schemes is different. The mask subunit 211 can segment the data to be compressed according to different compression schemes, and obtain multiple data groups segmented according to each compression scheme. For example, the mask subunit 211 segments the data to be compressed into 128 data groups according to compression scheme 1, and segments the data to be compressed into 64 data groups according to compression scheme 2.

[0074] After the data to be compressed is divided into a plurality of data groups according to the compression scheme, the mask subunit 211 can generate a bit mask of the compression scheme according to the data values ​​included in the data groups, and the bit mask can indicate the data groups to be compressed in the data groups divided according to the compression scheme. The data groups to be compressed are data groups that can be compressed, and the data values ​​included in the data groups to be compressed have a specific rule, so that after the data groups to be compressed in the data to be compressed are compressed, the compressed data can also be restored to the data to be compressed according to the rule, for example, the data values ​​included in the data groups to be compressed are all the same (binary number 1 or 0), or the data groups to be compressed are composed of a plurality of repeated array units, and the array units are composed of binary numbers 1 and 0, for example, the array units can be 10, 01, 110, 001, 1100, etc.

[0075] After the mask subunit 211 generates the bit mask of the compression scheme, the compression subunit 212 can compress the data to be compressed according to the bit mask of the compression scheme, remove the data group to be compressed divided according to the compression scheme from the data to be compressed, and obtain the compressed data corresponding to the compression scheme, and the compressed data includes the bit mask of the compression scheme, and the data groups other than the data group to be compressed divided according to the compression scheme. For example, the mask subunit 211 divides the data to be compressed into 32 data groups according to the compression scheme A, and these 32 data groups are data groups A1 to A32, wherein data groups A1 to A8 are the data groups to be compressed that can be compressed, then the compression subunit 212 can remove data groups A1 to A8 from the data to be compressed, and generate compressed data including data groups A9 to A32 and the bit mask of the compression scheme A as the compressed data corresponding to the compression scheme A. The mask sub-unit 211 divides the data to be compressed into 64 data groups according to compression scheme B. These 64 data groups are data group B1 to data group B64, among which data group B1 to data group B24 are data groups to be compressed that can be compressed. The compression sub-unit 212 can remove data groups B1 to data group B24 from the data to be compressed, and generate compressed data including data groups B25 to data group B64 and the bit mask of compression scheme B as the compressed data corresponding to compression scheme B.

[0076] Figure 5 FIG. 1 is a schematic diagram of a data compression process according to an embodiment of the present application. Figure 5 As shown, the length of the data to be compressed is 1024 bits, and the data to be compressed is divided into 32 data groups according to the length of each data group of 32 bits. If the 32-bit data included in the data group are all binary 0, the data value corresponding to the data group in the bit mask is set to 0. If at least one of the 32-bit data included in the data group is not binary 0, the data value corresponding to the data group in the bit mask is set to 1. The data value of the i-th bit in the bit mask is used to indicate whether the i-th data group in the data to be compressed is the data group to be compressed. If the data value of the i-th bit in the bit mask is 1, it indicates that the i-th data group in the data to be compressed is an incompressible data group. If the data value of the i-th bit in the bit mask is 0, it indicates that the i-th data group in the data to be compressed is the data group to be compressed. i is a positive integer greater than or equal to 1 and less than or equal to 32.

[0077] like Figure 5As shown, since the 32-bit data included in the 3rd data group D2, the 4th data group D3 and the 31st data group D30 are all binary 0, it is determined that the masks corresponding to the 3rd data group D2, the 4th data group D3 and the 31st data group D30 are binary 0, and the 1st data group D0, the 2nd data group D1, the 5th data group D4, the 30th data group D29 and the 32nd data group D31 include at least one binary 1, and it is determined that the masks corresponding to the 1st data group D0, the 2nd data group D1, the 5th data group D4, the 30th data group D29 and the 32nd data group D31 are binary 1. The masks corresponding to the 1st data group to the 32nd data group are sequentially combined to generate a bit mask. The bit mask is sequentially spliced ​​with the data group whose corresponding mask is not binary 0 to obtain a compressed data body that can constitute the compressed data.

[0078] The compressed data includes an uncompressed data group and a bit mask. According to the bit mask, the compressed data group to be compressed can be added to the compressed data, thereby obtaining the data to be compressed including the uncompressed data group and the data group to be compressed, thereby realizing decompression of the compressed data.

[0079] After the compression subunit 212 generates corresponding compressed data for different compression schemes, the screening subunit 213 can determine the target compressed data corresponding to the data to be compressed according to the compressed data corresponding to each compression scheme. For example, after the compression subunit 212 generates compressed data corresponding to compression schemes A, B, and C, the screening subunit 213 can determine the target compressed data corresponding to the data to be compressed according to the compressed data corresponding to compression schemes A, B, and C.

[0080] In an embodiment of the present application, the mask sub-unit 211 can divide the data to be compressed into multiple data groups according to the compression scheme, and generate a bit mask indicating the data group to be compressed. The compression sub-unit 212 can compress the data group to be compressed in the data to be compressed according to the bit mask, and generate compressed data including the bit mask and the incompressible data group. Then, the screening sub-unit 213 can determine the target compressed data corresponding to the data to be compressed according to the compressed data corresponding to different compression schemes, thereby realizing the compression of the data to be compressed, so that the last-level cache can transfer the target compressed data to the main memory, reduce the occupancy of the main memory access bandwidth, and improve the speed at which the processor reads and writes the main memory.

[0081] In a possible implementation manner, the preset multiple compression schemes include at least two of a first compression scheme, a second compression scheme, a third compression scheme, and a fourth compression scheme.

[0082] According to the first compression scheme, the mask subunit 211 can divide the data to be compressed into a plurality of data groups including 8 bits. According to the second compression scheme, the mask subunit 211 can divide the data to be compressed into a plurality of data groups including 16 bits. According to the third compression scheme, the mask subunit 211 can divide the data to be compressed into a plurality of data groups including 32 bits. According to the fourth compression scheme, the mask subunit 211 can first divide the data to be compressed into a plurality of data groups including 32 bits, and then compress the divided data groups to 19 bits.

[0083] When the mask subunit 211 divides the data to be compressed according to the compression scheme, it divides the data to be compressed into multiple data segments, and one data segment is a data group. According to different compression schemes, the length of the divided data groups is different. In an example, the data to be compressed is a data length of 1024 bits. The mask subunit 211 can divide the data to be compressed into 128 data groups according to the first compression scheme, and the length of each data group is 8 bits. The mask subunit 211 can divide the data to be compressed into 64 data groups according to the second compression scheme, and the length of each data group is 16 bits. The mask subunit 211 can divide the data to be compressed into 32 data groups according to the third compression scheme, and the length of each data group is 32 bits. The mask subunit 211 can divide the data to be compressed into 32 data groups according to the fourth compression scheme, and the length of each data group is 19 bits.

[0084] Since the processor reads and writes the main memory in units of cache lines, that is, the length of the data to be compressed is equal to the length of the cache line, and the length of the cache line is usually an integer power of 2, such as the length of the cache line is 1024 bits. Therefore, the length of the data group divided according to the first compression scheme, the second compression scheme, the third compression scheme and the fourth compression scheme is a multiple of the cache line length, ensuring that the data to be compressed can be divided into multiple data groups of equal length.

[0085] There are many possible ways to encode the data to be compressed. For example, the data to be compressed can be encoded in floating point formats such as FP8, FP16 (half-precision floating point numbers), FP32 (single-precision floating point numbers), and can also be encoded in tensor floating point formats such as TF32 (TensorFloat32). When data encoded in different encoding methods but of equal length are compressed based on the same compression scheme, there are differences in data compression rates. When the same data is compressed based on different compression schemes, there are also differences in data compression rates. The compression schemes correspond to possible encoding methods for the data to be compressed. The first compression scheme corresponds to FP8 format encoding, the second compression scheme corresponds to FP16 format encoding, the third compression scheme corresponds to FP32 format encoding, and the fourth compression scheme corresponds to TF32 format encoding.

[0086] The TF32 format has 13 fewer remainder bits than the FP32 format, but the storage format of the TF32 format data in the computer is consistent with the FP32 format data, so the lower 13 bits of the TF32 format data are redundant bits. Therefore, the lower 13 bits of the TF format data can be compressed, and the compressed data length is 19 bits.

[0087] It should be noted that when the mask sub-unit 211 splits the compressed data according to the compression scheme, the compression scheme is not limited to the first compression scheme, the second compression scheme, the third compression scheme and the fourth compression scheme. The mask sub-unit 211 can also split the compressed data according to other compression schemes. For example, the mask sub-unit 211 can also split the data to be compressed into multiple data groups including 64 bits.

[0088] In an embodiment of the present application, commonly used encoding formats of the data to be compressed include FP8, FP16, FP32 and TF32. The first compression scheme corresponds to FP8 format encoding, the second compression scheme corresponds to FP16 format encoding, the third compression scheme corresponds to FP32 format encoding, and the fourth compression scheme corresponds to TF32 format encoding. Using a compression scheme corresponding to the encoding format of the data to be compressed to compress the data to be compressed can usually reduce the compression rate of the data to be compressed. Therefore, the mask sub-unit 211 divides the data to be compressed according to the first compression scheme, the second compression scheme, the third compression scheme and the fourth compression scheme respectively, which can more comprehensively cover the encoding formats of the data to be compressed and improve the compression effect of the data to be compressed.

[0089] In one possible implementation, the number of bits of the bit mask is equal to the number of data groups obtained when the compressed data is segmented according to the compression scheme corresponding to the bit mask, different bits in the bit mask correspond to different data groups, and the data value of the bit in the bit mask is used to indicate whether the corresponding data group is the data group to be compressed.

[0090] After the mask subunit 211 divides the data to be compressed into multiple data groups according to the compression scheme, it generates a bit mask of the compression scheme. The number of bits of the bit mask is equal to the number of data groups divided according to the compression scheme. Each bit in the bit mask corresponds to a data group, and different bits in the bit mask correspond to different data groups. The data value of each bit in the bit mask is used to indicate whether the data group corresponding to the bit is the data group to be compressed. Therefore, according to the data value of each bit in the bit mask, it can be determined which data groups can be compressed.

[0091] In one example, the length of the data to be compressed is 1024 bits. The mask subunit 211 divides the data to be compressed into 128 data groups according to the first compression scheme, and the bit mask length of the first compression scheme is 128 bits. The mask subunit 211 divides the data to be compressed into 64 data groups according to the second compression scheme, and the bit mask length of the second compression scheme is 64 bits. The mask subunit 211 divides the data to be compressed into 32 data groups according to the third compression scheme, and the bit mask length of the third compression scheme is 32 bits. The mask subunit 211 divides the data to be compressed into 32 data groups according to the fourth compression scheme, and the bit mask length of the fourth compression scheme is 32 bits.

[0092] The data value included in the bit mask may be a binary number 0 or 1. For example, the data value of the bit corresponding to the incompressible data group in the bit mask is 1, and the data value of the bit corresponding to the to-be-compressed data group in the bit mask is 0.

[0093] In an embodiment of the present application, the length of the bit mask is equal to the number of data groups divided according to the corresponding compression scheme, each bit of the bit mask corresponds to a data group, different bits in the bit mask correspond to different data groups, and each bit in the bit mask indicates whether the corresponding data group can be compressed, so that the bit mask has a smaller length under the premise that it can refer to the data group to be compressed, so that the compressed data including the bit mask has a smaller length, thereby improving the compression effect of the data to be compressed.

[0094] In a possible implementation, the data group to be compressed is a data group that can be compressed, and the data group to be compressed may be a data group in which all data values ​​included are 0.

[0095] In the field of deep learning, sparse matrices can greatly improve the efficiency of deep learning. In a sparse matrix, the number of elements with a value of 0 is much greater than the number of non-zero elements, and the distribution of non-zero elements is irregular. When the processor operates on a sparse matrix, the sparse matrix is ​​the data to be compressed, and the data group with all data values ​​​​0 is determined as the data group to be compressed, which can effectively compress the data to be compressed.

[0096] In one example, after the mask subunit 211 divides the data to be compressed into multiple data groups, if all data values ​​included in the data group are 0, the data group is determined as the data group to be compressed, and then the bit corresponding to the data group in the bit mask is set to 0, indicating that the data group can be compressed. If the data group includes at least one data value that is not 0, the bit corresponding to the data group in the bit mask is set to 1, indicating that the data group cannot be compressed.

[0097] In an embodiment of the present application, a data group in which all data values ​​are 0 is determined as a data group to be compressed, which can effectively compress the sparse matrix, thereby reducing the main memory access bandwidth occupied by the processor during the operation of the sparse matrix, and reducing the storage space occupied by the main memory, thereby improving the efficiency of deep learning.

[0098] In one possible implementation, the compressed data generated by the compression sub-unit 212 includes a bit mask, and a data group other than the data group to be compressed that is split according to the corresponding compression scheme. In addition, the compressed data may also include identification information of the corresponding compression scheme, and compression rate information for indicating the compression rate.

[0099] After the mask subunit 211 divides the data to be compressed into multiple data groups according to the compression scheme and generates the bit mask of the compression scheme, the compression subunit 212 can generate compressed data including the bit mask of the compression scheme, the data groups other than the data group to be compressed divided according to the compression scheme, the identification information of the compression scheme and the compression rate information, wherein the compression rate information can indicate the compression rate of the compressed data obtained based on the compression scheme relative to the data to be compressed. The compression subunit 212 generates different compressed data for different compression schemes. For example, the compression subunit 212 can generate corresponding compressed data for the first compression scheme, the second compression scheme, the third compression scheme and the fourth compression scheme respectively.

[0100] The compression ratio of the data to be compressed refers to the ratio of the length of the compressed data to the length of the data to be compressed. For example, if the length of the data to be compressed is 1024 bits, if the length of the compressed data is 512 bits, the compression ratio corresponding to the compressed data is 0.5, and if the length of the compressed data is 256 bits, the compression ratio corresponding to the compressed data is 0.25. The compression ratio information is used to indicate the range of the compression ratio. For example, when the compression ratio information is 0 (binary number 00), it means that the compression ratio is greater than 3 / 4, when the compression ratio information is 1 (binary number 01), it means that the compression ratio is less than or equal to 1 / 4, when the compression ratio information is 2 (binary number 10), it means that the compression ratio is greater than 1 / 4 and less than or equal to 1 / 2, and when the compression ratio information is 3 (binary number 11), it means that the compression ratio is greater than 1 / 2 and less than or equal to 3 / 4.

[0101] Figure 6 This is a schematic diagram of compressed data of an embodiment of the present application. The length of the data to be compressed is 1024 bits. According to the first compression scheme, the data to be compressed is divided into 128 data groups with a length of 8 bits. According to the second compression scheme, the data to be compressed is divided into 64 data groups with a length of 16 bits. According to the third compression scheme, the data to be compressed is divided into 32 data groups with a length of 32 bits. According to the fourth compression scheme, the data to be compressed is divided into 32 data groups with a length of 19 bits. The identification information of the first compression scheme is the binary number 00, the identification information of the second compression scheme is the binary number 01, the identification information of the third compression scheme is the binary number 10, and the identification information of the fourth compression scheme is the binary number 11. Figure 6 As shown, the 1st and 2nd bits of the compressed data are used to store the identification information of the compression scheme, the 5th and 6th bits are used to store the compression rate information, the 3rd, 4th, 7th and 8th bits are reserved bits, and the information stored in the reserved bits is not limited in the embodiments of the present application.

[0102] In the compressed data obtained based on the first compression scheme, the 1st and 2nd bits store the binary number 00 (identification information of the first compression scheme), the 9th to 135th bits store the bit mask (128 bits) of the first compression scheme, and from the 137th to the X1+1th bit store the incompressible data groups other than the data groups to be compressed that are split according to the first compression scheme.

[0103] In the compressed data obtained based on the second compression scheme, the 1st and 2nd bits store the binary number 01 (identification information of the second compression scheme), the 9th to 72nd bits store the bit mask (64 bits) of the second compression scheme, and from the 73rd to the X2+1th bits store the incompressible data groups other than the data groups to be compressed that are split according to the second compression scheme.

[0104] In the compressed data obtained based on the third compression scheme, the 1st and 2nd bits store the binary number 10 (identification information of the third compression scheme), the 9th to 40th bits store the bit mask (32 bits) of the third compression scheme, and from the 41st to the X3+1th bit store the incompressible data groups other than the data group to be compressed that are split according to the third compression scheme.

[0105] In the compressed data obtained based on the fourth compression scheme, the 1st bit and the 2nd bit store the binary number 11 (identification information of the fourth compression scheme), the 9th bit to the 40th bit store the bit mask (32 bits) of the fourth compression scheme, and from the 41st bit to the X4+1th bit store the incompressible data groups other than the data group to be compressed divided according to the fourth compression scheme.

[0106] The lengths of the data groups divided according to different compression schemes are different, and the number of data groups to be compressed may be different, which will result in different lengths occupied by incompressible data groups in the compressed data. Except that the lengths of the bit masks corresponding to the third compression scheme and the fourth compression scheme are the same, the lengths of the bit masks of any other two compression schemes are different, which may result in different lengths of compressed data corresponding to different compression schemes, showing different compression rates.

[0107] In the embodiment of the present application, the compressed data includes a bit mask, incompressible data, identification information of the corresponding compression scheme, and compression rate information. Based on the compression rate information, it can be determined whether the compressed data meets the compression requirements, thereby guiding the screening subunit 213 to determine the target compressed data. If the compressed data is determined to be the target compressed data, when the compressed data is decompressed to obtain the data to be compressed, the compression scheme used to obtain the compressed data can be determined according to the identification information in the compressed data, and then the corresponding decompression scheme is used to decompress the compressed data to ensure the correctness of the decompressed data.

[0108] Figure 7 FIG. 1 is an internal structure diagram of a data compression unit according to another embodiment of the present application. Figure 7 As shown, the data compression unit 210 may further include a first output subunit 214 on the basis of including the mask subunit 211 , the compression subunit 212 and the screening subunit 213 .

[0109] After generating compressed data corresponding to each compression scheme, the compression subunit 212 sends the number of bits (length) of each compressed data to the screening subunit 213. The screening subunit 213 can determine the compressed data with the smallest number of bits as the target compressed data according to the number of bits of each compressed data. After the screening subunit 213 determines the target compressed data, it sends the target compressed data to the first output subunit 214. The first output subunit 214 can compare the compression rate of the target compressed data with the compression rate threshold. If the compression rate of the target compressed data is less than the compression rate threshold, the target compressed data is sent to the first data receiving end. If the compression rate of the target compressed data is greater than or equal to the compression rate threshold, the data to be compressed is sent to the first data receiving end.

[0110] Since decompressing compressed data requires computing resources and time, if the compression rate of the target compressed data is large, compared with storing the data to be compressed in the main memory, the performance improvement brought by storing the target compressed data in the main memory is lower, and may even lead to performance degradation. Therefore, a compression rate threshold is set. When the compression rate of the target compressed data is less than the compression rate threshold, the target compressed data is sent to the first data receiving end. When the compression rate of the target compressed data is greater than or equal to the compression rate threshold, the data to be compressed is sent to the first data receiving end to ensure the performance of the processor in reading and writing the main memory.

[0111] The first data receiving end may be different depending on the location of the data compression unit 210. When the data compression unit 210 is set between two adjacent levels of cache, the first data receiving end is the next level cache in the adjacent two levels of cache. When the data compression unit 210 is set between the last level cache and the main memory, the first data receiving end is the main memory.

[0112] Figure 8 FIG. 1 is a schematic diagram of the working process of a data compression unit according to an embodiment of the present application. Figure 8 As shown, the mask subunit 211 includes a first mask module 2111, a second mask module 2112, a third mask module 2113 and a fourth mask module 2114, and the compression subunit 212 includes a first compression module 2121, a second compression module 2122, a third compression module 2123 and a fourth compression module 2124.

[0113] After the data to be compressed is input into the data compression unit 210, the first mask module 2111, the second mask module 2112, the third mask module 2113 and the fourth mask module 2114 process the data to be compressed respectively. The first mask module 2111 divides the data to be compressed according to the first compression scheme, obtains the bit mask of the first compression scheme, and sends the bit mask of the first compression scheme to the first compression module 2121. The second mask module 2112 divides the data to be compressed according to the second compression scheme, obtains the bit mask of the second compression scheme, and sends the bit mask of the second compression scheme to the second compression module 2122. The third mask module 2123 divides the data to be compressed according to the third compression scheme, obtains the bit mask of the third compression scheme, and sends the bit mask of the third compression scheme to the third compression module 2123. The fourth mask module 2114 can detect whether the data to be compressed meets the TF32 format. If the data to be compressed does not meet the TF32 format, the data to be compressed will not be processed. If the data to be compressed meets the TF32 format, an indication signal will be sent to the fourth compression module 2124, and the data length information of the compressed data corresponding to the fourth compression scheme will be sent to the screening sub-unit 213.

[0114] The first compression module 2121 removes the data group to be compressed divided according to the first compression scheme from the data to be compressed according to the bit mask of the first compression scheme, obtains the compressed data corresponding to the first compression scheme, and sends the data length information of the compressed data corresponding to the first compression scheme to the screening sub-unit 213, and sends the compressed data corresponding to the first compression scheme to the first output sub-unit 214.

[0115] The second compression module 2122 removes the data group to be compressed divided according to the second compression scheme from the data to be compressed according to the bit mask of the second compression scheme, obtains the compressed data corresponding to the second compression scheme, and sends the data length information of the compressed data corresponding to the second compression scheme to the screening sub-unit 213, and sends the compressed data corresponding to the second compression scheme to the first output sub-unit 214.

[0116] The third compression module 2123 removes the data group to be compressed divided according to the third compression scheme from the data to be compressed according to the bit mask of the third compression scheme, obtains the compressed data corresponding to the third compression scheme, and sends the data length information of the compressed data corresponding to the third compression scheme to the screening sub-unit 213, and sends the compressed data corresponding to the third compression scheme to the first output sub-unit 214.

[0117] The fourth compression module 2124 is used to perform a step of compression on the compressed data corresponding to the third compression scheme upon receiving the indication signal of the fourth mask module 2114, obtain the compressed data corresponding to the fourth compression scheme, and send the compressed data corresponding to the fourth compression scheme to the first output subunit 214.

[0118] It should be noted that the first compression module 2121, the second compression module 2122 and the third compression module 2123 can remove the data to be compressed from the data to be compressed by using an inverse butterfly algorithm.

[0119] The screening subunit 213 determines the compressed data with the smallest data length as the target compressed data according to the data length information of each received compressed data, and sends a selection signal for indicating the target compressed data to the first output subunit 214, and sends the compression rate information corresponding to the target compressed data to the first output subunit 214. The first output subunit 214 determines the target compressed data from the received compressed data according to the received selection signal, and sends the target compressed data as output data to the first data receiving end if the compression rate information of the target compressed data indicates that the compression rate of the target compressed data is less than the compression rate threshold, and sends the target compressed data as output data to the first data receiving end if the compression rate information of the target compressed data indicates that the compression rate of the target compressed data is greater than or equal to the compression rate threshold, and sends the data to be compressed as output data to the first data receiving end.

[0120] It should be noted that if Figure 8 As shown, when the first output subunit 214 sends the data to be compressed as output data to the first data receiving end, the screening subunit 213 outputs and stores the compression rate information of the target compressed data. When the data decompression unit obtains the data to be compressed from the first data receiving end, the compression rate information of the target compressed data can be obtained, so that the data decompression unit can determine that the obtained data to be compressed is not compressed according to the obtained compression rate information, and thus the obtained data to be compressed is not decompressed, thereby ensuring the accuracy of the data obtained by the processor.

[0121] In an embodiment of the present application, the first output subunit 214 compares the compression rate of the target compressed data with the compression rate threshold. When the compression rate of the target compressed data is less than the compression rate threshold, the target compressed data is sent as output data to the first data receiving end. When the compression rate of the target compressed data is greater than the compression rate threshold, the data to be compressed is sent as output data to the first data receiving end, thereby reducing the main memory access bandwidth occupancy when the processor accesses the main memory and ensuring that the processor has a higher performance.

[0122] In a possible implementation, the data compression unit 210 may determine whether to compress the input data according to the instructions of the processor. Figure 8 As shown, the first output subunit 214 can receive an enable signal sent by the processor. When the enable signal is a binary number 1, the first output subunit 214 selects the data to be compressed or the target compressed data to be output according to the selection signal. When the enable signal is a binary number 0, the first output subunit 214 outputs the data to be compressed, that is, when the enable signal is a binary number 0, the data compression unit 210 is bypassed, and the data compression unit 210 does not need to process the data to be compressed.

[0123] When the data compression unit 210 receives uncompressed data that does not need to be compressed, if the first pipeline constructed by the mask subunit 211, the compression subunit 212 and the screening subunit 213 is empty, the uncompressed data is sent to the first data receiving end through the bypass of the mask subunit 211, the compression subunit 212 and the screening subunit 213; if the first pipeline constructed by the mask subunit 211, the compression subunit 212 and the screening subunit 213 is not empty, the uncompressed data is sent to the first data receiving end after passing through the first pipeline.

[0124] When the processor writes multiple data to the main memory, it needs to write the data to the main memory in order to ensure that the correct data can be read when reading data from the main memory. The mask subunit 211, the compression subunit 212 and the screening subunit 213 constitute the first pipeline, and the compressed data is compressed in the form of a pipeline. If the first pipeline is empty, it means that there is no data in the data compression unit 210 that is being compressed. After receiving the data that does not need to be compressed, the data compression unit 210 outputs the data that does not need to be compressed through the data bypass of the first pipeline, and does not cause the data written to the main memory to be out of order. If the first pipeline is not empty, it means that there is data in the data compression unit 210 that is being compressed. After receiving the data that does not need to be compressed, the data that does not need to be compressed needs to pass through the first pipeline. After the preceding data of the data that does not need to be compressed is output, the data that does not need to be compressed is output to ensure the order of writing data into the main memory.

[0125] In the embodiment of the present application, the processor controls the data compression unit 210 to compress the input data through an enable signal, so that while satisfying the need for compressing data, it can also satisfy the need for not compressing some data, thereby being applicable to more application scenarios and improving the applicability of the data compression unit 210. When the data compression unit 210 receives data that does not need to be compressed and does not need to be compressed, if the first pipeline composed of the mask subunit 211, the compression subunit 212, and the screening subunit 213 is empty, the data that does not need to be compressed is directly output; if the first pipeline is not empty, the data that does not need to be compressed is output after passing through the first pipeline, so that the data is written to the main memory in order, ensuring that the processor can read the correct data from the main memory.

[0126] Data decompression unit

[0127] Fig. 9 FIG. 1 is an internal structure diagram of a data decompression unit according to an embodiment of the present application. Fig. 9 As shown, the data decompression unit 220 includes a mask extraction subunit 221 , a data group extraction subunit 222 and a decompression subunit 223 .

[0128] The mask extraction subunit 221 can extract a bit mask from the data to be decompressed according to the target compression scheme corresponding to the data to be decompressed. The bit mask can indicate the data group to be compressed among the multiple data groups obtained when the original data is segmented according to the target compression scheme, and the data to be decompressed includes the bit mask and the data groups other than the data group to be compressed segmented from the original data according to the target compression scheme.

[0129] The data group extraction subunit 222 can extract the data groups included in the data to be decompressed according to the target compression scheme.

[0130] The decompression subunit 223 may concatenate the data group to be compressed and the data group included in the data to be decompressed according to the bit mask extracted by the mask extraction subunit 221 to obtain the original data.

[0131] The data to be decompressed is obtained by compressing the original data according to the target compression scheme, and the bit mask and data group included in the data to be decompressed can be determined according to the target compression scheme. When the original data is compressed according to the target compression scheme, the original data can be divided into multiple data groups, the data groups that can be compressed will be removed from the original data, and the data groups that cannot be compressed will be retained in the data to be decompressed.

[0132] Since different compression schemes correspond to different lengths of bit masks, the mask extraction subunit 221 can extract the bit mask from the to-be-decompressed data according to the target compression scheme. Figure 6 As shown, when the length of the original data is 1024 bits, the length of the bit mask when the original data is segmented based on the first compression scheme is 128 bits, the length of the bit mask when the original data is segmented based on the second compression scheme is 64 bits, the length of the bit mask when the original data is segmented based on the third compression scheme is 32 bits, and the length of the bit mask when the original data is segmented based on the fourth compression scheme is 32 bits. If the target compression scheme is the first compression scheme, the mask extraction subunit 211 can extract the data from the 9th bit to the 136th bit in the data to be decompressed as a bit mask. If the target compression scheme is the second compression scheme, the mask extraction subunit 221 can extract the data from the 9th bit to the 72nd bit in the data to be decompressed as a bit mask.

[0133] The mask extraction subunit 211 can extract identification information of the target compression scheme from the data to be decompressed, and then determine the target compression scheme according to the extracted identification information. Figure 6 As shown, the first bit and the second bit of the data to be decompressed are identification information of the target compression scheme, and the mask extraction subunit 211 extracts the first 2 bits of the data to be decompressed as identification information, and then determines the target compression scheme according to the extracted identification information.

[0134] Since different compression schemes correspond to different lengths of data groups, and the number of bits starting with a data group in the data to be decompressed is also different, the data group extraction subunit 222 can extract data groups from the data to be decompressed according to the target compression scheme. Figure 6As shown, when the length of the original data is 1024 bits, the compressed data obtained based on the first compression scheme starts to form data groups from the 137th bit, and the length of each data group is 8 bits, the compressed data obtained based on the second compression scheme starts to form data groups from the 73rd bit, and the length of each data group is 16 bits, the compressed data obtained based on the third compression scheme starts to form data groups from the 41st bit, and the length of each data group is 32 bits, and the compressed data obtained based on the fourth compression scheme starts to form data groups from the 41st bit, and the length of each data group is 19 bits.

[0135] The bit mask indicates which data groups in the original data are the data groups to be compressed, and can indicate the data values ​​included in the data groups to be compressed, so that the decompression subunit 223 can splice the data groups to be compressed with the data groups extracted by the data group extraction subunit 222 according to the bit mask, thereby obtaining the original data. Figure 5 As shown, the data group extraction subunit 222 can extract data groups D0, D1, D4, D29 and D31 etc. from the data to be decompressed, and the decompression subunit 223 can sequentially splice data groups D2, data group D3 and data group D31 etc., which are data groups to be compressed, with data groups D0, D1, D4, D29 and D31 etc. according to the bit mask extracted by the mask extraction subunit 221 to obtain the original data (data to be compressed).

[0136] It should be noted that the data compression unit 210 is used in conjunction with the data decompression unit 220. The data compression unit 210 can compress the data to be compressed into target compressed data, and the data decompression unit 220 can decompress the data to be decompressed into original data. The data to be compressed can be original data, and the target compressed data can be data to be decompressed. The aforementioned data compression unit embodiment has described the data compression process in detail. The data decompression unit can decompress the data to be decompressed in a manner opposite to the data compression process. The data structure, compression scheme, and other related contents of the data to be decompressed can refer to the description in the aforementioned embodiment, and will not be repeated here.

[0137] In an embodiment of the present application, the mask extraction subunit 221 can extract a bit mask from the data to be decompressed, the data group extraction subunit 222 can extract a data group from the data to be decompressed, and then the decompression subunit 223 can insert the data to be compressed into the data group extracted from the data group according to the bit mask, obtain the original data corresponding to the data to be decompressed, and realize the decompression of the data to be decompressed, so that the main memory can send the data to be decompressed to the last-level cache, reduce the occupancy of the main memory access bandwidth when the processor reads data from the memory, and improve the speed of the processor reading and writing the main memory.

[0138] In a possible implementation, if the number of bits of the data group divided according to the target compression scheme is equal to N, where N is a positive integer greater than or equal to 2, the mask extraction subunit 221 may send the bit mask extracted from the to-be-decompressed data to the decompression subunit 223. If the number of bits of the data group divided according to the target compression scheme is equal to k×N, where k is a positive integer greater than or equal to 2, the mask extraction subunit 221 may expand each bit of the bit mask extracted from the to-be-decompressed data into continuous k bits, and then send the expanded bit mask to the decompression subunit 223.

[0139] Different data to be decompressed can be obtained by compressing the original data based on different compression schemes. The lengths of the data groups divided according to different compression schemes are different. For example, the length of the data group divided according to the first compression scheme is 8 bits, the length of the data group divided according to the second compression scheme is 16 bits, the length of the data group divided according to the third compression scheme is 32 bits, and the length of the data group divided according to the fourth compression scheme is 32 bits. Taking the length of the data to be compressed as 1024 bits as an example, the length of the bit mask of the first compression scheme is 128 bits, the length of the bit mask of the second compression scheme is 64 bits, the length of the bit mask of the third compression scheme is 32 bits, and the length of the bit mask of the fourth compression scheme is 32 bits.

[0140] When the decompression subunit 223 generates the original data according to the bit mask, the data group to be compressed is concatenated with the data group included in the data to be decompressed by shifting, and the shifting is performed in units of the length of the data group. Figure 5 As shown, when the decompression subunit 223 inserts the data group D2 between the data group D1 and the data group D4 according to the bit mask, if the length of the data group is 8 bits, the data group D4 and its subsequent data groups are shifted backward by 8 bits, and then the data group D2 is inserted between the data group D1 and the data group D4; if the length of the data group is 16 bits, the data group D4 and its subsequent data groups are shifted backward by 16 bits, and then the data group D2 is inserted between the data group D1 and the data group D3.

[0141] When the decompression subunit 223 shifts the data group, the data group can be shifted by the butterfly algorithm (inverse butterfly), and the butterfly algorithm is implemented by the butterfly algorithm module included in the decompression subunit 223. The shift unit when each butterfly algorithm module executes the data group shift is fixed, such as the shift unit is 8bit, 16bit or 32bit, but the compression scheme corresponding to the data to be decompressed is not fixed, so the shift unit when decompressing the data to be decompressed is also different. For example, if the data to be decompressed is generated based on the first compression scheme, the decompression subunit 223 needs to use the butterfly algorithm module with a shift unit of 8bit to shift the data group, if the data to be decompressed is generated based on the second compression scheme, the decompression subunit 223 needs to use the butterfly algorithm module with a shift unit of 16bit to shift the data group, if the data to be decompressed is generated based on the third compression scheme or the fourth compression scheme, the decompression subunit 223 needs to use the butterfly algorithm module with a shift unit of 32bit to shift the data group.

[0142] If the decompression subunit 223 includes multiple butterfly algorithm modules corresponding to different shift units, the data decryption unit 220 will occupy a larger chip area and increase the power consumption of the data decryption unit 220. To this end, according to the shift unit corresponding to each compression scheme, the decompression subunit 223 includes a butterfly algorithm module corresponding to the smallest shift unit. For example, the shift unit corresponding to the first compression scheme is 8 bits, the shift unit corresponding to the second compression scheme is 16 bits, and the shift units corresponding to the third and fourth compression schemes are 32 bits, then the decompression subunit 223 includes a butterfly algorithm module corresponding to a shift unit of 8 bits.

[0143] After the mask extraction subunit 221 extracts the bit mask, if the length of the data group divided according to the target compression scheme is equal to the shift unit corresponding to the butterfly algorithm module, the extracted bit mask is sent to the decompression subunit 223; if the length of the data group divided according to the target compression scheme is k times the shift unit corresponding to the butterfly algorithm module, each bit of the extracted bit mask is expanded to k consecutive bits, and the expanded bit mask is sent to the decompression subunit 223, so that the decompression subunit 223 can decompress the data to be decompressed including data groups with different lengths through the same butterfly algorithm module.

[0144] For example, the shift unit of the butterfly algorithm module included in the decompression subunit 223 is 8 bits, and the length of the original data is 1024 bits. If the data to be decompressed is generated based on the first compression scheme, that is, the length of the data group included in the data to be decompressed is 8 bits, the mask extraction subunit 221 directly sends the extracted bit mask of 128 bits to the decompression subunit 223. If the data to be decompressed is generated based on the second compression scheme, that is, the length of the data group included in the data to be decompressed is 16 bits, the mask extraction subunit 221 expands the extracted bit mask of 64 bits to 128 bits and sends it to the decompression subunit 223. If the data to be decompressed is generated based on the third compression scheme, that is, the length of the data group included in the data to be decompressed is 32 bits, the mask extraction subunit 221 expands the extracted bit mask of 32 bits to 128 bits and sends it to the decompression subunit 223.

[0145] When the mask extraction subunit 221 expands the bit mask, each bit in the bit mask is expanded into continuous k bits, so that the length of the bit mask after expansion is k times the length of the bit mask before expansion. For example, when a bit mask with a length of 64 bits is expanded to 128 bits, the first 4 bits of the bit mask before expansion are 1100, and the first 8 bits of the bit mask after expansion are 11110000.

[0146] In an embodiment of the present application, after the mask extraction subunit 221 extends the length of the bit mask extension to N, the decompression subunit 223 can shift the data groups in the decompressed data through the same butterfly algorithm module to generate original data, thereby reducing the chip area occupied by the data decompression unit 220 and reducing the power consumption of the data decompression unit 220.

[0147] It should be noted that N is the minimum length of the data group divided according to each compression scheme. For example, the data to be decompressed can be generated based on the first compression scheme, the second compression scheme, the third compression scheme or the fourth compression scheme. Since the length of the data group divided according to the first compression scheme is 8 bits, the length of the data group divided according to the second compression scheme is 16 bits, the length of the data group divided according to the third compression scheme is 32 bits, and the length of the data group divided according to the fourth compression scheme is 32 bits, N is equal to 8.

[0148] Fig.10 FIG. 1 is a schematic diagram of the workflow of a data decompression unit according to an embodiment of the present application. Fig.10As shown, according to the target compression scheme corresponding to the data to be decompressed, the mask extraction subunit 221 extracts the bit mask from the data to be decompressed, and determines whether the extracted bit mask needs to be expanded according to the length of the extracted bit mask. If the bit mask does not need to be expanded, the extracted bit mask is directly sent to the decompression subunit 223. If the bit mask needs to be expanded, the length of the extracted bit mask is expanded and sent to the decompression subunit 223.

[0149] The data group extraction subunit 222 extracts data groups from the data to be decompressed according to different compression schemes. Figure 6 As shown, according to the first compression scheme, the 137th bit to the X1+1th bit of the data to be decompressed are extracted as a data group, according to the second compression scheme, the 73th bit to the X2+1th bit of the data to be decompressed are extracted as a data group, and according to the third compression scheme, the 41st bit to the X3+1th bit of the data to be decompressed are extracted as a data group. According to the fourth compression scheme, the 41st bit to the X3+1th bit of the data to be decompressed are extracted, and the extracted data are divided into data blocks in units of 19 bits, and after the lower 13 bits of redundant bits of each data block are supplemented, a plurality of data groups including 32 bits are obtained.

[0150] After extracting data groups according to different compression schemes, the data group extraction subunit 222 selects the data group corresponding to the target compression scheme according to the identifier of the compression scheme recorded in the first 2 bits of the data to be decompressed, and sends it to the decompression subunit 223. For example, if the target compression scheme is the first compression scheme, the 137th bit to the X1+1th bit of the data to be decompressed are sent to the decompression subunit 223; if the target compression scheme is the second compression scheme, the 73rd bit to the X2+1th bit of the data to be decompressed are sent to the decompression subunit 223.

[0151] The decompression subunit 223 concatenates the compressed data group to be compressed and the received data group according to the received bit mask and data group to obtain the original data.

[0152] Fig.11 FIG. 1 is an internal structure diagram of a data decompression unit in another embodiment of the present application. Fig.11 As shown, the data decompression unit 220 may further include a second output subunit 224 on the basis of including a mask extraction subunit 221 , a data group extraction subunit 222 and a decompression subunit 223 .

[0153] If the data of the input data decompression unit 220 does not need to be decompressed, that is, the data to be decompressed of the input data decompression unit 220 is the original data, the second output sub-unit 224 can determine whether the second pipeline composed of the mask extraction sub-unit 221, the data group extraction sub-unit 222 and the decompression sub-unit 223 is empty. If the second pipeline is empty, the data that does not need to be decompressed is sent to the second data receiving end through the data bypass of the mask extraction sub-unit 221, the data group extraction sub-unit 222 and the decompression sub-unit 223. If the second pipeline is not empty, the data that does not need to be decompressed is sent to the second data receiving end after passing through the second pipeline.

[0154] When the processor reads multiple data from the main memory, it needs to read the data from the main memory in order to ensure the correctness of the read data. The mask extraction subunit 221, the data group extraction subunit 222 and the decompression subunit 223 constitute the second pipeline, and the decompression processing is performed on the decompressed data in the form of a pipeline. If the second pipeline is empty, it means that there is no data in the decompression process in the data decompression unit 220. After receiving the data that does not need to be decompressed, the data decompression unit 220 outputs the data that does not need to be decompressed through the data bypass of the second pipeline, which will not cause the processor to read the data out of order. If the second pipeline is not empty, it means that there is data in the decompression process in the data decompression unit 220. After receiving the data that does not need to be compressed, the data that does not need to be decompressed needs to pass through the second pipeline. After the preceding data of the data that does not need to be decompressed are all output, the data that does not need to be decompressed is output, ensuring that the processor reads data from the main memory in order.

[0155] In an embodiment of the present application, when the data decompression unit 220 receives data that does not need to be decompressed, if the second pipeline formed by the mask extraction subunit 221, the data group extraction subunit 222 and the decompression subunit 223 is empty, the decompressed data that does not need to be decompressed is directly output; if the second pipeline is not empty, the data that does not need to be decompressed is output after passing through the second pipeline, so that the processor reads data from the main memory in sequence, ensuring the correctness of the data read by the processor from the main memory.

[0156] It should be noted that the data decompression unit 220 in the embodiment of the present application is used to decompress the data compressed by the above-mentioned data compression unit 210. Since the data decompression process is compared with the data compression process, the data decompression process of the data decompression unit 220 can at least partially refer to the data compression process of the data compression unit 210, and the data compression process of the data compression unit 210 can also at least partially refer to the data decompression process of the data decompression unit 220, and the repeated parts will not be repeated again.

[0157] Data compression method

[0158] Fig.12 FIG. 2 is a flow chart of a data compression method according to an embodiment of the present application. The data compression method can be executed by the data compression unit 210 in any of the above embodiments. Fig.12 As shown, the data compression method comprises the following steps:

[0159] Step 1201: divide the data to be compressed into multiple data groups according to multiple compression schemes, and generate a bit mask corresponding to the compression scheme according to the data values ​​included in the data group, wherein the number of bits of the data groups divided according to different compression schemes is different, and the bit mask is used to indicate the data group to be compressed among the multiple data groups divided according to the corresponding compression scheme;

[0160] Step 1202: Generate compressed data corresponding to the compression scheme according to the bit mask of the compression scheme, wherein the compressed data includes the bit mask of the corresponding compression scheme and the data group other than the data group to be compressed that is segmented according to the corresponding compression scheme;

[0161] Step 1203: Determine target compressed data corresponding to the data to be compressed according to the compressed data corresponding to each compression scheme.

[0162] In an embodiment of the present application, the data to be compressed is divided into multiple data groups according to a compression scheme, and a bit mask indicating the data groups to be compressed is generated. The data groups to be compressed in the data to be compressed are compressed according to the bit mask, and compressed data including the bit mask and the incompressible data groups are generated. Then, according to the compressed data corresponding to different compression schemes, the target compressed data corresponding to the data to be compressed can be determined, and the compression of the data to be compressed is realized, so that the last-level cache can transfer the target compressed data to the main memory, thereby reducing the occupancy of the access bandwidth of the main memory and improving the speed at which the processor reads and writes the main memory.

[0163] It should be noted that, since the details of the data compression method have been described in detail in the above data compression unit embodiment in conjunction with the structural schematic diagram, the specific process can be found in the description in the above data compression unit embodiment, and will not be repeated here.

[0164] Data decompression method

[0165] Fig.13 FIG. 2 is a flow chart of a data decompression method according to an embodiment of the present application. The data decompression method can be executed by the data decompression unit 220 in any of the above embodiments. Fig.13 As shown, the data decompression method includes the following steps:

[0166] Step 1301: extract a bit mask from the data to be decompressed according to a target compression scheme corresponding to the data to be decompressed, wherein the bit mask is used to indicate a data group to be compressed among a plurality of data groups obtained by segmenting the original data according to the target compression scheme, and the data to be decompressed includes data groups other than the data group to be compressed segmented from the original data according to the target compression scheme;

[0167] Step 1302: extracting data groups included in the data to be decompressed according to the target compression scheme;

[0168] Step 1303: According to the bit mask, the data group to be compressed and the data group included in the data to be decompressed are concatenated to obtain the original data.

[0169] In an embodiment of the present application, a bit mask is extracted from the data to be decompressed, and a data group is extracted from the data to be decompressed. Then, the data to be compressed can be inserted into the extracted data group according to the bit mask to obtain the original data corresponding to the data to be decompressed, thereby realizing decompression of the data to be decompressed, so that the main memory can send the data to be decompressed to the last-level cache, thereby reducing the occupancy of the main memory access bandwidth when the processor reads data from the memory, and improving the speed at which the processor reads and writes the main memory.

[0170] It should be noted that, since the details of the data decompression method have been described in detail in the above data decompression unit embodiment in conjunction with the structural diagram, the specific process can be found in the description in the above data decompression unit embodiment, and will not be repeated here.

[0171] Those skilled in the art will appreciate that the present application can be implemented as a system, method, and computer program product. Therefore, the present application can be specifically implemented in the following forms, i.e., complete hardware, complete software (including firmware, resident software, microcode), and can also be implemented in the form of a combination of software and hardware. In addition, in some embodiments, the present application can also be implemented in the form of a computer program product in one or more computer-readable media, and the computer-readable medium contains a computer-readable program code.

[0172] Any combination of one or more computer-readable media may be used. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium may be, for example but not limited to, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device or device, or any combination thereof. More specific examples of computer-readable storage media include: an electrical connection of one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this article, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by a processing unit, a device or a device, or used in combination with the program.

[0173] Computer readable signal media may include data signals propagated in baseband or as part of a chopped wave, which carry computer readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any other suitable combination. Computer readable signal media may also be any computer readable medium other than a computer readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction system, apparatus, or device.

[0174] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., and any suitable combination of the foregoing.

[0175] The computer program code for executing the embodiment of the present application can be written in one or more programming languages ​​or combinations. The programming language includes object-oriented programming languages, such as JAVA, C++, and can also include conventional procedural programming languages, such as C. The program code can be executed completely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on the remote computer, or completely on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer by any type of network including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (such as using an Internet service provider to connect to the Internet).

[0176] It should be noted that the user-related information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to sample data used to train the model, data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0177] It should be understood that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the method embodiment, since it is basically similar to the method described in the device and system embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of other embodiments.

[0178] It should be understood that the above is a description of a specific embodiment of the present specification. Other embodiments are within the scope of the claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0179] It should be understood that an element described in singular form herein or shown in the drawings as only one does not limit the number of the element to one. In addition, modules or elements described or shown as separate herein may be combined into a single module or element, and modules or elements described or shown as single herein may be split into multiple modules or elements.

[0180] It should also be understood that the terms and expressions used herein are for description only, and one or more embodiments of this specification should not be limited to these terms and expressions. The use of these terms and expressions does not mean to exclude any equivalent features of the illustrations and descriptions (or parts thereof), and it should be recognized that various modifications that may exist should also be included in the scope of the claims. Other modifications, changes and substitutions may also exist. Accordingly, the claims should be deemed to cover all such equivalents.

Claims

1. A data compression unit, comprising: a mask subunit, used to divide the data to be compressed into multiple data groups according to multiple compression schemes, and generate a bit mask corresponding to the compression scheme according to the data values ​​included in the data group, wherein the number of bits of the data groups divided according to different compression schemes is different, and the bit mask is used to indicate the data group to be compressed among the multiple data groups divided according to the corresponding compression scheme; A compression subunit, configured to generate compressed data corresponding to the compression scheme according to the bit mask of the compression scheme, wherein the compressed data includes the bit mask of the corresponding compression scheme and the data group other than the data group to be compressed that is segmented according to the corresponding compression scheme; The screening subunit is used to determine target compressed data corresponding to the data to be compressed according to the compressed data corresponding to each compression scheme.

2. The data compression unit according to claim 1, wherein: The plurality of compression schemes include at least two of a first compression scheme, a second compression scheme, a third compression scheme, and a fourth compression scheme; The first compression scheme divides the data to be compressed into a plurality of data groups including 8 bits; The second compression scheme divides the data to be compressed into a plurality of data groups including 16 bits; The third compression scheme divides the data to be compressed into a plurality of data groups including 32 bits; The fourth compression scheme divides the to-be-compressed data into a plurality of 32-bit data groups and then compresses the data groups to 19 bits.

3. The data compression unit according to claim 1, wherein: The number of bits of the bit mask is equal to the number of data groups obtained when the data to be compressed is divided according to the compression scheme corresponding to the bit mask. Different bits in the bit mask correspond to different data groups, and the data value of the bit in the bit mask is used to indicate whether the corresponding data group is the data group to be compressed.

4. The data compression unit according to claim 1, wherein: The data values ​​of the data group to be compressed are all 0.

5. The data compression unit according to claim 1, wherein: The compressed data also includes identification information of a corresponding compression scheme and compression rate information for indicating a compression rate.

6. The data compression unit according to any one of claims 1 to 5, further comprising: a first output subunit; The compression subunit is used to send the number of bits of each compressed data to the screening subunit respectively; The screening subunit is used to determine the compressed data with the smallest number of bits as the target compressed data according to the number of bits of each compressed data; The first output subunit is used to send the target compressed data to the first data receiving end when the compression rate of the target compressed data is less than the compression rate threshold, and to send the data to be compressed to the first data receiving end when the compression rate of the target compressed data is greater than or equal to the compression rate threshold.

7. The data compression unit according to claim 6, wherein: The first output subunit is used to send the data that does not need to be compressed to the first data receiving end through the bypass of the mask subunit, the compression subunit and the screening subunit when the first pipeline constructed by the mask subunit, the compression subunit and the screening subunit is empty, and to send the data that does not need to be compressed to the first data receiving end after passing the data that does not need to be compressed through the first pipeline when the first pipeline is not empty.

8. A data decompression unit, comprising: a mask extraction subunit, configured to extract a bit mask from the data to be decompressed according to a target compression scheme corresponding to the data to be decompressed, wherein the bit mask is used to indicate a data group to be compressed among a plurality of data groups obtained by segmenting the original data according to the target compression scheme, and the data to be decompressed includes the bit mask and data groups other than the data group to be compressed segmented from the original data according to the target compression scheme; A data group extraction subunit, used for extracting the data group included in the data to be decompressed according to the target compression scheme; The decompression subunit is used to splice the data group to be compressed with the data group included in the data to be decompressed according to the bit mask to obtain the original data.

9. The data decompression unit according to claim 8, wherein: The mask extraction subunit is used to send the bit mask extracted from the data to be decompressed to the decompression subunit when the number of bits of the data group divided according to the target compression scheme is equal to N, and to expand each bit of the bit mask extracted from the data to be decompressed to consecutive k bits when the number of bits of the data group divided according to the target compression scheme is equal to k×N, and then send the expanded bit mask to the decompression subunit, where N is a positive integer greater than or equal to 2, and k is a positive integer greater than or equal to 2.

10. The data decompression unit according to claim 8 or 9, further comprising: The second output subunit is used to send the data that does not need to be decompressed to the second data receiving end through the bypass of the mask extraction subunit, the data group extraction subunit and the decompression subunit when the second pipeline constructed by the mask extraction subunit, the data group extraction subunit and the decompression subunit is empty, and to send the data that does not need to be decompressed to the second data receiving end after passing the data through the second pipeline when the second pipeline is not empty.

11. A data compression method, comprising: According to a plurality of compression schemes, the data to be compressed are respectively divided into a plurality of data groups, and a bit mask corresponding to the compression scheme is generated according to the data values ​​included in the data group, wherein the number of bits of the data groups divided according to different compression schemes is different, and the bit mask is used to indicate the data group to be compressed among the plurality of data groups divided according to the corresponding compression scheme; Generate compressed data corresponding to the compression scheme according to the bit mask of the compression scheme, wherein the compressed data includes the bit mask of the corresponding compression scheme and the data group other than the data group to be compressed that is segmented according to the corresponding compression scheme; According to the compressed data corresponding to each compression scheme, target compressed data corresponding to the data to be compressed is determined.

12. A data decompression method, comprising: Extracting a bit mask from the data to be decompressed according to a target compression scheme corresponding to the data to be decompressed, wherein the bit mask is used to indicate a data group to be compressed among a plurality of data groups obtained by segmenting the original data according to the target compression scheme, and the data to be decompressed includes data groups other than the data group to be compressed that are segmented from the original data according to the target compression scheme; According to the target compression scheme, extracting the data group included in the data to be decompressed; According to the bit mask, the data group to be compressed is concatenated with the data group included in the data to be decompressed to obtain the original data.

13. A processor, comprising: The data compression unit according to any one of claims 1 to 7, and / or the data decompression unit according to any one of claims 8 to 10; A high-speed cache memory is used to cache at least one of the following data: original data that needs to be compressed by the data compression unit, compressed data obtained by compressing the original data by the data compression unit, data to be decompressed that needs to be decompressed by the data decompression unit, and original data obtained by decompressing the data to be decompressed by the data decompression unit.

14. A system on chip, comprising: The processor of claim 13; The memory is coupled to the processor and is used to store compressed data obtained by compressing the original data by the data compression unit, and / or data to be decompressed that needs to be decompressed by the data decompression unit.

Citation Information

Cited By

  • Parallel computing core caching method and device based on multi-compression scheme and medium

    CN119884023A