Implementation method and device of universal fixed-point matrix multiplier based on high-performance computing architecture in FPGA (Field Programmable Gate Array) and medium

By designing the matrix blocking strategy and data scheduling multiplexing on the Versal ACAP platform, and using the AI ​​engine array and AXI streaming protocol, we solved the problem of high computational complexity of large matrix multiplication in the self-attention mechanism and achieved efficient matrix multiplication. Acceleration and hardware resource utilization significantly improve computing speed and parallelism.

CN118690115AActive Publication Date: 2024-09-24SOUTH CHINA UNIV OF TECH
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410783729.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-18
Publication Date
2024-09-24
Estimated Expiration
2044-06-18

AI Technical Summary

Technical Problem

The large matrix multiplication introduced by the self-attention mechanism in the Transformer model has high computational complexity, resulting in long calculation times, insufficient memory, and data transmission delays. In addition, existing hardware acceleration solutions have low performance and are difficult to practicalize.

Method used

Design a high-performance computing architecture based on the Versal ACAP platform. Through matrix blocking strategy and data scheduling multiplexing, AI engine array and AXI streaming protocol are used to achieve high-throughput vectorized matrix multiplication operations, optimize data flow and control logic, and reduce Transmission delay.

Benefits of technology

It improves the parallelism and data reuse rate of matrix multiplication, achieves efficient hardware resource utilization and high computing speed, and significantly accelerates large-scale matrix multiplication calculations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118690115A
    Figure CN118690115A
Patent Text Reader

Abstract

The invention discloses an implementation method and device for a universal fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA and a medium, and the method comprises the steps: designing different layers of matrix partitioning strategies based on the parallelism of AI engine array resources of a Versa ACAP platform; based on data scheduling and multiplexing of data packet flow and data packet exchange of an AI engine and an AXI flow, a kernel is accelerated through matrix block multiplication, and a data scheduling and multiplexing strategy is designed; a pipeline of matrix multiplication operations with high throughput vectorization is implemented on an AI engine vector processor. According to the invention, multi-level partitioning of matrix multiplication is realized based on an AXI stream transmission protocol of a Versa ACAP platform and an AI engine array, so that the matrix multiplication can efficiently utilize hardware resources to effectively improve the data reuse rate and realize higher parallelism, and higher operation speed is realized under a high-speed clock of an AI engine. The method can be widely applied to the field of high-performance computing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of high performance computing, and in particular to a method, device and medium for realizing a universal fixed-point matrix multiplier based on a high performance computing architecture in an FPGA. Background Art

[0002] The Transformer model relies on the unique architecture of the self-attention mechanism, which enables it to capture long-range dependencies in text. It allows the model to focus on information at different locations when processing input sequences. It is inspired by the human visual attention mechanism, which focuses on salient objects in the scene to make rational use of limited visual information processing resources. The self-attention mechanism allows the model to be trained in parallel and make full use of the global information of the training data without being restricted by the sequential structure.

[0003] However, the computational complexity of large matrix multiplication introduced by the self-attention mechanism is very high. If the dimension of the matrix is ​​large, a large number of multiplication and addition operations will result in a long calculation time. And large matrix multiplication requires the storage of a large number of intermediate results. During the calculation process, sufficient memory needs to be allocated to store the intermediate matrix, which can easily lead to insufficient memory. Secondly, due to the limitation of the number of high-speed transmission channels on the hardware, data transmission is also challenging. The propagation delay of data between computing units may become a performance bottleneck. Furthermore, the realization of parallelism of large matrix multiplication is also limited by the computing resources of the hardware. How to effectively divide the matrix and manage parallel computing tasks is also a challenge in practical applications.

[0004] Although there have been many studies on accelerating matrix multiplication on hardware, they are basically at the academic research stage, and most of them are difficult to be put into practical use and deployed on high-performance hardware due to poor performance or being out of practical application. Moreover, most of the solutions adopted by these research institutes are based on FPGA hardware, or include SoC and FPGA hardware. SoC is only suitable for sending commands for state conversion and data scheduling. Although FPGA has wide parallel processing capabilities and can process large amounts of data at the same time, its clock frequency is low and it consumes a lot of hardware resources on matrix multiplication. Therefore, it is not the optimal solution for accelerating fixed-point matrix multiplication. Summary of the invention

[0005] In order to solve at least one of the technical problems existing in the prior art to a certain extent, the purpose of the present invention is to provide a method, device and medium for realizing a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA.

[0006] The first technical solution adopted by the present invention is:

[0007] A method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA comprises the following steps:

[0008] Based on the parallelism of the AI ​​engine array resources of the Versal ACAP platform, we designed matrix partitioning strategies at different levels.

[0009] Data scheduling and multiplexing of packet flows and packet switching based on AI engines and AXI flows, designing data scheduling and multiplexing strategies through matrix block multiplication acceleration cores;

[0010] Pipeline for high-throughput vectorized matrix multiplication operations on the AI ​​Engine vector processor.

[0011] Furthermore, the Versal ACAP platform includes four levels of blocks in five scales, including off-chip (memory), on-chip (programmable logic), AI engine array, AI engine core and vector processor, where the data cached off-chip is the complete input matrix without being partitioned.

[0012] Furthermore, the multi-level matrix partitioning strategy based on the Versal architecture includes:

[0013] Design matrix operation algorithms and corresponding data scheduling strategies for all levels of blocks except the highest level of blocks outside the slice according to hardware resources;

[0014] The data from the PS end is synchronously stored in an off-chip buffer, and the data scheduling unit performs the first outermost block division on these data;

[0015] Transfer different blocks from off-chip to on-chip, perform lower-level block division according to the local buffer capacity of the AI ​​engine array, and pass them to the AI ​​engine array in the form of AXI streams according to the blocks;

[0016] The AI ​​engine array organizes data into windows in the form of packet streams and packet exchanges. The underlying AI engine controls the movement of this window and performs calculations.

[0017] At the last level, the AI ​​engine’s special vector processor is used to implement high-throughput multiplication operations, aggregate the bottom-level calculation results in a preset format, and transmit them back to the PS end.

[0018] Furthermore, based on the parallelism of the AI ​​engine array resources of the Versal ACAP platform, different levels of matrix partitioning strategies are designed, including:

[0019] Through matrix partitioning, large matrices are divided into smaller sub-blocks, and then the products of these sub-blocks are calculated separately; by performing block processing and data reuse on the matrix at different levels, dedicated hardware resources are allocated to each sub-block; using the parallelism of FPGA and AI engine, multiple processing units are designed to calculate different sub-blocks at the same time, so that the product of each sub-block can be calculated independently, and finally the results are accumulated to form the final product matrix;

[0020] The off-chip buffer timing multiplexing, the address generation unit generates the address corresponding to the buffer according to the time sequence of different blocks and the time sequence of internal iterations of the blocks, and transmits it to the data reading unit;

[0021] On-chip buffer timing multiplexing: the PL side also plays the role of dividing the AI ​​engine array into blocks. Different blocks are transmitted to the AI ​​engine array in different time slots to achieve on-chip level multiplexing.

[0022] The AI ​​engine array uses spatial multiplexing to cache the data transmitted from the on-chip buffer to different local cache units according to the needs of a single AI engine core. The data transmission input to the AI ​​engine array is processed in a windowed manner. The data transmitted from the AXI stream is cached in the local cache around a single AI engine core according to the window size. The AI ​​engine core obtains the new data required for calculation by moving the window.

[0023] The AI ​​engine core is time-repeated, and the last level of matrix blocks is introduced into the matrix multiplication operation at the bottom layer of the core; the vector processor reads the blocks at this level in sequence for multiplication, and accumulates the calculation results and passes them to a higher level through the AXI stream interface.

[0024] Furthermore, the data packet flow is designed to divide the data into continuous data packets, each data packet consists of a packet header and multiple data words, and is routed and exchanged between the AI ​​engine and the programmable logic through the AXI stream; the data packet exchange is responsible for routing and exchanging data packets between the AI ​​engine and the programmable logic, and the AI ​​engine core accesses the corresponding input data according to the block responsible for calculation to meet the needs of multiple AI engine cores for the same block data, and the needs of a single AI engine core for multiple block data, thereby realizing the transmission and multiplexing of multiple data streams.

[0025] Furthermore, the data scheduling and multiplexing of the data packet flow and data packet switching based on the AI ​​engine and AXI flow, through the matrix block multiplication acceleration core, design data scheduling and multiplexing strategy, including:

[0026] Through the matrix block strategy, the matrix passed in from the previous layer is divided into smaller blocks, and these sub-block data are stored in the corresponding storage units of this layer;

[0027] According to the computing requirements of the AI ​​engine, the AXI flow starts working, reading data from the storage unit and transferring the data to the AI ​​engine through the AXI interface;

[0028] During the transmission process, the AXI stream distributes data to different cores according to the needs of each AI engine core. At the same time, the AXI stream is responsible for coordinating data transmission between multiple cores, which not only improves the data reuse rate but also improves real-time performance.

[0029] After the calculation is completed, the AXI stream transfers the result data from the AI ​​engine to the next computing unit or outputs it to the buffer.

[0030] Furthermore, the pipeline for implementing high-throughput vectorized matrix multiplication operations on the AI ​​engine vector processor includes:

[0031] Preprocess the input matrix data stream, using the AI ​​engine's local storage buffer to decompose the matrix into smaller data blocks through window functions to adapt to the vector size and parallelism of the processing unit;

[0032] Perform core multiplication operations, use the VLIW architecture to issue multiplication instructions in parallel, and execute compound instructions to enhance the execution capability of the instruction pipeline;

[0033] Utilize the parallelism of the core array to achieve multi-core synchronous multiplication operations, optimize data flow and control logic, and reduce transmission delays;

[0034] The processing results are post-processed and output, the results are aggregated in local storage, converted and output through window functions.

[0035] Furthermore, the pipeline of the matrix multiplication operation includes preprocessing of input data, core multiplication operation, operation acceleration processing, and postprocessing and output of the final result, as follows:

[0036] Preprocessing of input data: The AI ​​engine has a large amount of local storage as a buffer to store the input matrix data stream. It uses the window function to read the data stream and decompose the matrix into smaller data blocks again. It sets the sliding window parameters to update the data in the cache window. The data flows from the AI ​​engine array to the AI ​​engine core, and the data is realigned and formatted to match the processing requirements of the AI ​​engine.

[0037] Core multiplication operations: Instruction scheduling is performed to issue multiple multiplication instructions in parallel in the VLIW architecture of the AI ​​engine to fully utilize each processing cycle; parallel execution is implemented to execute compound instructions containing multiple multiplication operations to enhance the instruction pipeline processing capability of each core and improve computing density;

[0038] Computational acceleration: In the AI ​​engine array, multiple cores synchronize the execution of multiplication operations to achieve parallel work through the core array to accelerate processing; optimize data flow and control logic through different jumps and window increment management to reduce data transmission delays; in addition, through multiple iterations to fully process the previous level of blocks, effectively use AXI stream interfaces and data packet management to efficiently transmit data between AI engines;

[0039] Post-processing and output of final results: The final results of the processing are aggregated in local storage, and the results in the accumulator are divided and output through the window function and converted into a format suitable for output requirements; the results are transferred to the next processing stage or memory by utilizing the AI ​​engine's DMA controller and AXI stream.

[0040] The second technical solution adopted by the present invention is:

[0041] A device for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA, comprising:

[0042] at least one processor;

[0043] at least one memory for storing at least one program;

[0044] When the at least one program is executed by the at least one processor, the at least one processor implements the above method.

[0045] The third technical solution adopted by the present invention is:

[0046] A computer-readable storage medium stores a program executable by a processor, wherein the program executable by the processor is used to execute the method described above when executed by the processor.

[0047] The beneficial effects of the present invention are as follows: the present invention implements multi-level blocking of matrix multiplication based on the AXI stream transmission protocol and AI engine array of the Versal ACAP platform, so that matrix multiplication can efficiently utilize hardware resources, effectively improve data reuse rate and achieve higher parallelism, and achieve higher computing speed under the high-speed clock of the AI ​​engine. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the embodiments of the present invention or the drawings of related technical solutions in the prior art are introduced below. It should be understood that the drawings introduced below are only for the convenience of clearly describing some embodiments of the technical solutions of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0049] Figure 1is a schematic diagram of a multi-level matrix partitioning strategy based on the Versal architecture in an embodiment of the present invention;

[0050] Figure 2 is a schematic diagram of fixed-point block matrix multiplication in the AI ​​engine core in an embodiment of the present invention;

[0051] Figure 3 It is a flowchart of the steps of a method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA in an embodiment of the present invention. DETAILED DESCRIPTION

[0052] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and are not to be construed as limitations of the present invention. For the step numbers in the following embodiments, they are only provided for the convenience of explanation, and the order between the steps is not limited in any way, and the execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.

[0053] In the description of the present invention, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., and orientations or positional relationships indicated are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.

[0054] In the description of the present invention, the meaning of "several" is one or more, the meaning of "more" is two or more, and the meanings of "greater than", "less than", "exceed" and the like are understood as not including the number itself, and the meanings of "above", "below", "within" and the like are understood as including the number itself. If there is a description of the first and the second, it is only used for the purpose of distinguishing the technical features, and cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features. In addition, "and / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects before and after are in an "or" relationship.

[0055] In the description of the present invention, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention based on the specific content of the technical solution.

[0056] Terminology explanation:

[0057] PS side: Processing System, processing system, usually refers to the processing system side, especially in systems using ARM core.

[0058] PL: Programmable Logic, programmable logic part, usually related to FPGA (field programmable gate array) core.

[0059] In view of the existing technical problems, the present invention proposes a method for linear operations of fixed-point matrices based on AI engine architecture processors. The computing accelerator card of the Versal ACAP platform launched by Xilinx has introduced the new AI engine architecture. The VCK190 belonging to this platform includes an AI engine array, which is composed of 400 AI engine processors specialized for vector operations. This can be used to divide matrix operations into several vector multiplication and accumulation operations to realize a high-performance fixed-point matrix multiplier.

[0060] like Figure 3 As shown, this embodiment provides a method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA, comprising the following steps:

[0061] A1: Based on the parallelism of the AI ​​engine array resources of the Versal ACAP platform, design matrix partitioning strategies at different levels.

[0062] The first is a multi-level matrix partitioning strategy, such as Figure 1 As shown, it includes five scales and four levels of blocks: off-chip (memory), on-chip (programmable logic), AI engine array, AI engine core and vector processor, where the off-chip cache is the complete input matrix without block division. Specifically, step 1 includes the following steps:

[0063] A11: Design the matrix operation algorithms and corresponding data scheduling strategies for all levels of blocks except the highest level of off-chip blocks based on hardware resources. Determine the size of all blocks at each level and the number of iterations at each level during the top-level design, and then input them into the accelerator through the memory mapping on the PS side. Utilize the characteristics of the hardware platform buffer object to abstract the PL-side memory, and perform memory allocation and access without directly processing the hardware details. Create a buffer through the buffer object to synchronize data between the host memory and the PL-side memory. The memory mapping feature maps the PL-side memory area to the host address space, so that the host memory and the PL-side memory addresses correspond one to one, allowing the data transmission control unit on the PL side to process the buffer data according to the same data structure.

[0064] A12: The data on the PS side is synchronously stored in an off-chip buffer. The data scheduling unit will perform the first outermost block division on the data. The block size depends on the size that the PL side hardware resources can buffer at one time.

[0065] A13: Different blocks are transferred from outside the chip to inside the chip in a time-sharing manner, and lower-level blocks are performed according to the local buffer capacity of the AI ​​engine array, and are transmitted to the AI ​​engine array in the form of AXI streams according to the blocks.

[0066] A14: The AI ​​engine array organizes data into windows in the form of packet flows and packet exchanges. The underlying AI engine controls the movement of this window and performs calculations.

[0067] A15: At the last level, the AI ​​engine’s special vector processor is used to implement high-throughput multiplication operations, including data input preprocessing, core multiplication operations, operation acceleration processing, and the output of the final result. Finally, the bottom-level calculation results are gathered in the same form and finally returned to the PS end.

[0068] A2. Data scheduling and multiplexing of packet flow and packet switching based on AI engine and AXI flow, design data scheduling and multiplexing strategies through matrix block multiplication acceleration core.

[0069] Secondly, the data scheduling and reuse strategy based on the AI ​​engine and AXI stream achieves efficient data processing by accelerating the core through matrix block multiplication. The data packet stream design divides the data into continuous data packet streams, each of which contains a header and multiple data words, and routes and exchanges them between the AI ​​engine and the programmable logic through the AXI stream. The AI ​​engine accesses the corresponding data block on demand to meet the needs of multiple engines for the same block of data or a single engine for multiple blocks of data, and realizes multi-data stream transmission and reuse. The AXI stream coordinates data transmission between cores to ensure data reuse and real-time performance, and outputs it to the next unit or buffer after calculation is completed.

[0070] A3. Implement a pipeline for high-throughput vectorized matrix multiplication operations on the AI ​​Engine vector processor.

[0071] Finally, a pipeline for high-throughput vectorized matrix multiplication operations is implemented on the AI ​​engine vector processor. First, the input matrix data stream is preprocessed, and the matrix is ​​decomposed into smaller data blocks through the window function using the local storage buffer of the AI ​​engine to adapt to the vector size and parallel capability of the processing unit. Secondly, core multiplication operations are performed, and multiplication instructions are issued in parallel using the VLIW architecture, and compound instructions are executed to enhance the execution capability of the instruction pipeline. Then, the parallelism of the core array is used to implement multi-core synchronous multiplication operations, which can optimize the data flow and control logic and reduce transmission delays. Finally, the processing results are post-processed and output, the results are aggregated in local storage, converted and output through window functions, including format conversion, shift rounding, saturation operations, etc., and the results are effectively transferred to the next stage or memory using the DMA controller and AXI stream. This process ensures that the core achieves high throughput and data reuse.

[0072] The above method is explained in detail below with reference to the accompanying drawings and specific embodiments.

[0073] This embodiment provides a method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA, comprising the following steps:

[0074] S1: Based on the parallelism of the AI ​​engine array resources of the Versal ACAP platform, design different levels of matrix partitioning strategies. Introduce technologies such as data scheduling and data multiplexing to balance data access latency, computational latency, and reasonably consume hardware resources such as memory and programmable logic. Data scheduling refers to the process of controlling the transmission order and time of matrix partitions, and data multiplexing refers to the simultaneous transmission of multiple data streams on the same physical channel. By designing AXI streams, ensure coordinated transmission between different data streams required by different computing units, including allocating the same input data stream to different cores and aggregating multiple data streams into a single core, as well as aggregating multiple output data streams into one data stream, thereby improving the AXI stream resource utilization efficiency and data multiplexing rate, and reducing the delay caused by multiple data transmissions.

[0075] In some embodiments, step S1 includes the following steps:

[0076] S1-1: First, the large matrix is ​​divided into smaller sub-blocks through matrix blocking, and then the products of these sub-blocks are calculated separately. By performing block processing and data reuse on the matrix at different levels, dedicated hardware resources are allocated to each sub-block. Taking advantage of the parallelism of FPGA and AI engine, multiple processing units are designed to calculate different sub-blocks at the same time. The product of each sub-block can be calculated independently, and finally the results are accumulated to form the final product matrix. This method is particularly suitable for large-scale matrix multiplication because it can significantly reduce the calculation time.

[0077] S1-2: Off-chip buffer timing multiplexing, the address generation unit generates a 32-bit address corresponding to the buffer according to the time sequence of different blocks and the time sequence of internal iterations of the blocks, and transmits it to the data reading unit. Each address corresponds to 512 bits of data on the off-chip buffer, which is also the maximum number of bits that the AXI bus can transmit at one time. Every time the data reading unit receives an address, it reads 512 bits from the off-chip buffer and transmits it to the on-chip matrix block unit.

[0078] S1-3: On-chip buffer timing multiplexing. The PL end also plays the role of dividing the AI ​​engine array as a whole. Different blocks are transmitted to the AI ​​engine array in different time slots to achieve on-chip multiplexing. The on-chip matrix block unit further divides the data read from outside the chip and stores it in the on-chip buffer. At the same time, the different dimensions of the on-chip buffer are expanded or packaged into blocks to improve the efficiency of parallel reading and writing. Finally, the divided data is transmitted to the AI ​​engine array through the AXI stream according to the time sequence and the size that the AI ​​engine array can process at one time.

[0079] S1-4: AI engine array spatial multiplexing, through programming to design a unique calculation graph for the AI ​​engine array, the data transmitted from the on-chip buffer is cached in different local cache units according to the needs of a single AI engine core. The designed calculation graph contains several AI engine cores, and a local group of AI engine cores processes a block at this level. In addition, the data transmission input to the AI ​​engine array adopts window processing, and the data transmitted from the AXI stream is cached in the local cache around a single AI engine core according to the window size. The AI ​​engine core obtains the new data required for the operation by moving the window.

[0080] S1-5: AI engine core timing multiplexing, after multi-level block matrix size is still very large, the kernel of the bottom of the matrix multiplication operation introduced the last level of matrix block, the size of the block is determined by the AI ​​engine core can be performed a single vector multiplication. The vector processor reads this level of blocks in sequence for multiplication, and the accumulated calculation results are passed to the higher level through the AXI stream interface.

[0081] S2: Data scheduling and multiplexing of packet flows and packet switching based on AI engines and AXI streams. According to the data multiplexing requirements of the matrix block multiplication acceleration core, an efficient data scheduling and multiplexing strategy is designed and implemented. The protocol divides the data into continuous packets, each of which consists of multiple data words. Packet switching is responsible for routing and exchanging packets between the AI ​​engine and programmable logic. The AI ​​engine core takes the corresponding input data according to the block responsible for calculation to meet the requirements of multiple AI engine cores for the same block data and the requirements of a single AI engine core for multiple block data, realizing the transmission and multiplexing of multiple data streams.

[0082] First, through the matrix block strategy, the matrix passed in from the previous layer is divided into smaller blocks, and these sub-block data are stored in the corresponding storage units of this level. Then, according to the computing requirements of the AI ​​engine, the AXI stream starts working, reads data from the storage unit, and transmits the data to the AI ​​engine through the AXI interface. During the transmission process, the AXI stream will allocate data to different cores according to the needs of each AI engine core. At the same time, the AXI stream is also responsible for coordinating data transmission between multiple cores, which ensures both data reuse rate and real-time performance. After the calculation is completed, the AXI stream transfers the result data from the AI ​​engine to the next computing unit or outputs it to the buffer.

[0083] S3: Use AI engine to achieve high throughput multiplication operations, such as Figure 2 As shown, it includes data input preprocessing, core multiplication operation, operation acceleration processing, and post-processing and output of the final result.

[0084] In some embodiments, step S3 includes the following steps:

[0085] S3-1: Preprocessing of input matrix data stream. The AI ​​engine has a large amount of local storage as a buffer to store the input matrix data stream. In particular, the use of window functions for data stream reading requires the matrix to be decomposed into smaller data blocks again. The decomposition will take into account the vector size and parallel processing capabilities of the AI ​​engine's vector processing unit. One of the processing units can process data of limited width at the same time, and the matrix will be vectorized into multiple smaller blocks. At the same time, the sliding window parameters are set to update the data in the cache window. The data flows from the AI ​​engine array to the AI ​​engine core, and the data is realigned and format converted as necessary to match the processing requirements of the AI ​​engine.

[0086] S3-2: Core multiplication operation. Perform instruction scheduling to issue multiple multiplication instructions in parallel in the VLIW architecture of the AI ​​engine to fully utilize each processing cycle. Implement parallel execution to execute compound instructions containing multiple multiplication operations to enhance the instruction pipeline processing capability of each core and improve computing density.

[0087] S3-3: Accelerated processing. In the AI ​​engine array, multiple cores synchronize the execution of multiplication operations, enabling parallel work through the core array to accelerate processing. Through different jump and window increment management, the data flow and control logic are optimized to reduce data transmission delays. In addition, through multiple iterations, the blocks of the previous level are fully processed, and the AXI stream interface and data packet management are effectively used to efficiently transmit data between AI engines.

[0088] S3-4: Post-processing and output of final results. The final results of the processing are aggregated in local storage, and the results in the accumulator are divided and output through the window function, and converted into a format suitable for output requirements. This process includes converting the accumulator results stored in high bits into the fixed-point format of the desired output, including shift rounding and saturation operations, and adjusting the size and arrangement of the output matrix. By leveraging the AI ​​engine's DMA controller and AXI stream, the results are efficiently transferred to the next processing stage or memory.

[0089] In general, the clock speed of the gated logic circuit of traditional FPGAs is slow, and processing a large amount of data in parallel with the same operation will repeatedly program a large amount of hardware resources. On the basis of ensuring that other processing modules can be realized, delays will be introduced through time multiplexing. The AI ​​engine resources of the Versal ACAP platform are highly optimized processing units designed for machine learning and advanced signal processing applications. The VLIW processor in the AI ​​engine can issue up to six instructions per clock cycle, including scalar operations, load / store operations, and fixed-point or floating-point vector operations, achieving higher computing density in high-clock cycle AI engine processors.

[0090] Existing matrix multipliers usually directly perform large-scale matrix multiplication by position, or use a systolic array to pipeline the matrix multiplication. Direct operations have a low data reuse rate, consume a lot of hardware resources, and the operations are highly serialized, with high calculation delays, making them difficult to deploy on mobile platforms. The matrix multiplication achieved by the systolic array has a high data reuse rate and relatively low calculation delay, but it cannot make good use of the parallelization characteristics of the FPGA. The present invention uses the AI ​​engine array on the Versal ACAP platform to implement block multiplication of matrices, saving parallel FPGA hardware resources while using arrayed high-speed dedicated AI engine processors to efficiently complete matrix-vector multiplication operations.

[0091] Matrix multiplication operations involve a large amount of data and high computational complexity. Existing technologies mostly communicate based on FPGA on-chip networks or DMA controllers, and the designed pipelines are difficult to effectively communicate or reuse data efficiently. The VersalACAP platform uses AXI streams as a high-speed communication protocol within or between PL and AI engine arrays. The data scheduling strategy designed by the present invention based on this protocol can efficiently and orderly manage the large amount of data streams generated during matrix block multiplication.

[0092] Compared with the prior art, the present invention has at least the following advantages and beneficial effects:

[0093] (1) The present invention utilizes the AI ​​engine resources on the selected Versal ACAP platform VCK190 computing card, designs a multi-level matrix partitioning strategy for fixed-point matrix multiplication and a corresponding pipeline for data scheduling and reuse, which can realize large-scale matrix multiplication calculations in parallel and at high speed, and has a significant acceleration effect on the inference of dense matrix multiplication models. This solution implements multi-level partitioning of matrix multiplication based on the AXI streaming protocol and AI engine array of the Versal ACAP platform, so that matrix multiplication can efficiently utilize hardware resources to effectively improve data reuse rate and achieve a higher degree of parallelism, and achieve a higher computing speed under the high-speed clock of the AI ​​engine.

[0094] (2) The present invention effectively utilizes the AXI stream of the Versal ACAP platform to transmit the input and output data of the block matrix between the AI ​​engine and the programmable logic, and coordinates the data requirements of different computing units. By optimizing the use strategy of the AXI stream, the data reuse rate and resource utilization efficiency are further improved. By designing a reasonable data packet size and data scheduling strategy, the delay of data transmission is reduced, and the utilization efficiency of AXI stream resources is improved by multiplexing the same input data stream and aggregating multiple output data streams. These optimization measures enable the present invention to have the advantages of low latency and high throughput in data transmission.

[0095] (3) The present invention takes advantage of the AI ​​engine resources of the Versal ACAP platform. The combination of SIMD and VLIW technologies of the AI ​​engine provides powerful computing power and efficient data processing performance. SIMD is a technology that allows a single operation instruction to operate on multiple data at the same time. In the AI ​​engine, the SIMD vector processor can perform the same operation on a set of data in each clock cycle, thereby achieving data-level parallel processing. This is particularly important for vector and matrix operations in machine learning applications, because they usually involve a large number of data points and require fast and repetitive calculations. VLIW technology allows multiple independent instructions to be executed in one clock cycle. This instruction-level parallelism enables the AI ​​engine to efficiently process vectorized matrix multiplication operations. Therefore, fixed-point block matrix multiplication operations based on the AI ​​engine architecture can be compressed within a few clock cycles to achieve low latency and high throughput of operations.

[0096] This embodiment also provides a device for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA, including:

[0097] at least one processor;

[0098] at least one memory for storing at least one program;

[0099] When the at least one program is executed by the at least one processor, the at least one processor implements Figure 3 The method shown.

[0100] The present embodiment provides an implementation device for a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA, which can execute an implementation method for a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA provided by an embodiment of the method of the present invention, and can execute any combination of implementation steps of the method embodiment, and has the corresponding functions and beneficial effects of the method.

[0101] The present application also discloses a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device can read the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes Figure 3 The method shown.

[0102] This embodiment also provides a storage medium, which stores instructions or programs that can execute a method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA provided by an embodiment of the method of the present invention. When the instructions or program are run, any combination of implementation steps of the method embodiment can be executed, and the corresponding functions and beneficial effects of the method can be obtained.

[0103] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the present invention is provided by way of example, for the purpose of providing a more comprehensive understanding of technology. The disclosed method is not limited to the operation and logic flow presented herein. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part for which is described as a larger operation is performed independently.

[0104] In addition, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise specified, one or more of the functions and / or features described may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in separate physical devices or software modules. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present invention. More specifically, in view of the properties, functions, and internal relationships of the various functional modules in the device disclosed herein, the actual implementation of the module will be understood within the conventional skills of the engineer. Therefore, those skilled in the art can implement the present invention set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.

[0105] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

[0106] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.

[0107] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.

[0108] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0109] In the above description of this specification, the description with reference to the terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0110] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.

[0111] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.

Claims

1. A method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA, characterized in that: The following steps are involved: Based on the parallelism of the AI ​​engine array resources of the Versal ACAP platform, we designed matrix partitioning strategies at different levels. Data scheduling and multiplexing of packet flows and packet switching based on AI engines and AXI flows, designing data scheduling and multiplexing strategies through matrix block multiplication acceleration cores; Pipeline for high-throughput vectorized matrix multiplication operations on the AI ​​Engine vector processor.

2. The method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in FPGA according to claim 1, characterized in that: The Versal ACAP platform includes four levels of blocks in five scales, including off-chip, on-chip, AI engine array, AI engine core and vector processor, where the data cached off-chip is the complete input matrix without being partitioned.

3. The method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in FPGA according to claim 2, characterized in that: Multi-level matrix partitioning strategy based on the Versal architecture, including: Design matrix operation algorithms and corresponding data scheduling strategies for all levels of blocks except for the blocks outside the slice according to hardware resources; The data from the PS end is synchronously stored in an off-chip buffer, and the data is first divided into blocks at the outermost level. Different blocks are transferred from the off-chip to the on-chip, and lower-level blocks are divided according to the local buffer capacity of the AI ​​engine array, and then transmitted to the AI ​​engine array in the form of AXI streams according to the blocks. The AI ​​engine array organizes data into windows in the form of packet streams and packet exchanges. The underlying AI engine controls the movement of this window and performs calculations. At the last level, the vector processor of the AI ​​engine is used to implement high-throughput multiplication operations, aggregate the calculation results of the lowest level in a preset format and transmit them back to the PS end.

4. The method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in FPGA according to claim 1, characterized in that: Based on the parallelism of the AI ​​engine array resources of the Versal ACAP platform, different levels of matrix partitioning strategies are designed, including: Through matrix partitioning, large matrices are divided into smaller sub-blocks, and then the products of these sub-blocks are calculated separately; by performing block processing and data reuse on the matrix at different levels, dedicated hardware resources are allocated to each sub-block; using the parallelism of FPGA and AI engine, multiple processing units are designed to calculate different sub-blocks at the same time, so that the product of each sub-block can be calculated independently, and finally the results are accumulated to form the final product matrix; The off-chip buffer timing multiplexing, the address generation unit generates the address corresponding to the buffer according to the time sequence of different blocks and the time sequence of internal iterations of the blocks, and transmits it to the data reading unit; On-chip buffer timing multiplexing: the PL side also plays the role of dividing the AI ​​engine array into blocks. Different blocks are transmitted to the AI ​​engine array in different time slots to achieve on-chip level multiplexing. The AI ​​engine array uses spatial multiplexing to cache the data transmitted from the on-chip buffer to different local cache units according to the needs of a single AI engine core. The data transmission input to the AI ​​engine array is processed in a windowed manner. The data transmitted from the AXI stream is cached in the local cache around a single AI engine core according to the window size. The AI ​​engine core obtains the new data required for calculation by moving the window. The AI ​​engine core is time-repeated, and the last level of matrix blocks is introduced into the matrix multiplication operation at the bottom layer of the core; the vector processor reads the blocks at this level in sequence for multiplication, and accumulates the calculation results and passes them to a higher level through the AXI stream interface.

5. The method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in FPGA according to claim 1, characterized in that: The data packet flow is designed to divide the data into continuous data packets, each of which consists of a packet header and multiple data words, and is routed and exchanged between the AI ​​engine and the programmable logic through the AXI stream; the data packet exchange is responsible for routing and exchanging data packets between the AI ​​engine and the programmable logic, and the AI ​​engine core accesses the corresponding input data according to the block responsible for calculation to meet the needs of multiple AI engine cores for the same block data, and the needs of a single AI engine core for multiple block data, thereby realizing the transmission and multiplexing of multiple data streams.

6. The method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in FPGA according to claim 1, characterized in that: The data scheduling and multiplexing of the packet flow and packet switching based on the AI ​​engine and AXI flow, through the matrix block multiplication acceleration core, design data scheduling and multiplexing strategies, including: Through the matrix block strategy, the matrix passed in from the previous layer is divided into smaller blocks, and these sub-block data are stored in the corresponding storage units of this layer; According to the computing requirements of the AI ​​engine, the AXI flow starts working, reading data from the storage unit and transferring the data to the AI ​​engine through the AXI interface; During the transmission process, the AXI stream distributes data to different cores according to the needs of each AI engine core. At the same time, the AXI stream is responsible for coordinating data transmission between multiple cores. After the calculation is completed, the AXI stream transfers the result data from the AI ​​engine to the next computing unit or outputs it to the buffer.

7. The method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in FPGA according to claim 1, characterized in that: The pipeline for implementing high-throughput vectorized matrix multiplication operations on an AI engine vector processor includes: Preprocess the input matrix data stream, using the AI ​​engine's local storage buffer to decompose the matrix into smaller data blocks through window functions to adapt to the vector size and parallelism of the processing unit; Perform core multiplication operations, use the VLIW architecture to issue multiplication instructions in parallel, and execute compound instructions to enhance the execution capability of the instruction pipeline; Utilize the parallelism of the core array to achieve multi-core synchronous multiplication operations, optimize data flow and control logic, and reduce transmission delays; The processing results are post-processed and output, the results are aggregated in local storage, converted and output through window functions.

8. The method for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in FPGA according to claim 1, characterized in that: The pipeline of the matrix multiplication operation includes preprocessing of input data, core multiplication operation, operation acceleration processing, and postprocessing and output of the final result, as follows: Preprocessing of input data: The AI ​​engine has a large amount of local storage as a buffer to store the input matrix data stream, use window functions to read the data stream, and decompose the matrix into smaller data blocks again; Set the sliding window parameters to update the data in the cache window. The data flows from the AI ​​engine array to the AI ​​engine core, and the data is realigned and formatted to match the AI ​​engine processing requirements. Core multiplication operations: Instruction scheduling is performed to issue multiple multiplication instructions in parallel in the VLIW architecture of the AI ​​engine to fully utilize each processing cycle; parallel execution is implemented to execute compound instructions containing multiple multiplication operations to enhance the instruction pipeline processing capability of each core and improve computing density; Computational acceleration: In the AI ​​engine array, multiple cores synchronize the execution of multiplication operations to achieve parallel work through the core array to accelerate processing; optimize data flow and control logic through different jumps and window increment management to reduce data transmission delays; in addition, through multiple iterations to fully process the previous level of blocks, effectively use AXI stream interfaces and data packet management to efficiently transmit data between AI engines; Post-processing and output of final results: The final results of the processing are aggregated in local storage, and the results in the accumulator are divided and output through the window function and converted into a format suitable for output requirements; the results are transferred to the next processing stage or memory by utilizing the AI ​​engine's DMA controller and AXI stream.

9. A device for implementing a general fixed-point matrix multiplier based on a high-performance computing architecture in an FPGA, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 8.

10. A computer-readable storage medium storing a program executable by a processor, characterized in that: The processor-executable program is used to perform the method according to any one of claims 1 to 8 when executed by the processor.

Citation Information

Patent Citations

  • Method for accelerating convolution neutral network hardware and AXI bus IP core thereof

    CN104915322A

  • Efficient LSTM accelerator based on FPGA

    CN113191494A

  • Acceleration of operation

    CN115248688A

  • Universal synchronous FIFO IP core for field programmable gate arrays

    US20220335004A1

  • High performance layer normalization for large models

    US20230385234A1