Data processing methods, equipment and storage media

By dividing the complex matrix into blocks and rearranging the real and imaginary parts, the problem of low efficiency in complex matrix operations on the ARM platform is solved, thereby improving the processor's computing power and performance.

CN123114413APending Publication Date: 2026-11-17PHYTIUM TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611239240.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-14
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing algorithms are insufficient to support the ever-increasing computing power demands of the ARM architecture, resulting in low efficiency of complex matrix operations on the ARM platform and making it difficult to meet the needs of high-performance computing.

Method used

By dividing the complex matrix into blocks and rearranging the real and imaginary parts of each block, complex multiplication is performed using a preset assembly kernel function, thus improving computational efficiency.

Benefits of technology

It improves the computational efficiency of complex matrix multiplication, meets the ever-increasing computing power requirements of the ARM architecture, and enhances processor performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114413A_ABST
    Figure CN123114413A_ABST
Patent Text Reader

Abstract

This application provides a data processing method, apparatus, and storage medium. The method includes: a processor, responding to an application instruction, calling a preset assembly kernel function to divide a first complex matrix and a second complex matrix involved in a complex matrix multiplication operation into blocks, obtaining first sub-blocks and second sub-blocks; the processor, according to a preset arrangement rule, rearranging the first real part and first imaginary part data of the first sub-blocks to generate target complex elements of the first sub-blocks; the processor, according to the preset arrangement rule, rearranging the second real part and second imaginary part data of the second sub-blocks to generate target complex elements of the second sub-blocks; and the processor performing complex multiplication operations based on the target complex elements of the first and second sub-blocks to obtain a target output matrix. By dividing the matrix into blocks and arranging the data, computing power is improved to meet the ever-increasing computing power demands of the ARM architecture and enhance processor performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more specifically, to a data processing method, apparatus, and storage medium. Background Technology

[0002] As a general-purpose computing platform, processors occupy an important position in the field of High Performance Computing (HPC). ARM, as a new instruction set architecture, is gradually replacing x86 in the HPC field. To meet the growing computing power demands of HPC applications, technologies to enhance floating-point performance have also been introduced into the ARM instruction set.

[0003] In related technologies, to fully leverage the ever-increasing computing power of the ARM architecture, it is necessary to highly optimize the core basic mathematical libraries and parallel applications. Among these, General Matrix Multiplication (GEMM) is one of the key research areas in high-performance computing and is also a core function of the Basic Linear Algebra Subprograms (BLAS). GEMM is one of the most widely used high-performance kernels in various fields such as deep learning, signal processing, and computational chemistry. Based on data type, GEMM can be divided into four types: single-precision real GEMM, double-precision real GEMM, single-precision complex GEMM, and double-precision complex GEMM, represented by (Single-precision real GEMM, SGEMM), (Double-precision real GEMM, DGEMM), (Single-precision complex GEMM, CGEMM), and (Double-precision complex GEMM, ZGEMM), respectively.

[0004] However, because the ARM platform is not as universal as the x86 platform, existing algorithms are insufficient to support the ever-increasing computing power requirements of the ARM architecture. Summary of the Invention

[0005] In view of this, embodiments of this application provide a data processing method, device, and storage medium to better support the ever-increasing computing power of the ARM architecture and improve processor performance.

[0006] In a first aspect, embodiments of this application provide a data processing method, including: In response to the application instruction, the processor calls the preset assembly kernel function to divide the first complex matrix and the second complex matrix of the complex matrix multiplication operation into blocks, resulting in each first sub-block and each second sub-block; The processor rearranges the first real part data and the first imaginary part data of the first sub-block according to a preset arrangement rule to generate each target complex element of the first sub-block, wherein the real part data of each target complex element of the first sub-block is arranged together and the imaginary part data is arranged together. The processor rearranges the second real part data and the second imaginary part data of the second sub-block according to the preset arrangement rules to generate each target complex element of the second sub-block, wherein the real part data of each target complex element of the second sub-block are arranged together and the imaginary part data are arranged together. The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the target output matrix.

[0007] In an optional implementation, the processor rearranges the first real part data and the first imaginary part data of the first sub-block according to a preset arrangement rule to generate each target complex element of the first sub-block, including: The processor loads the first real part data and the first imaginary part data from the memory address of the first complex matrix into the first real part register and the first imaginary part register, respectively; The processor reads the first real part data and the first imaginary part data from the first real part register and the first imaginary part register, respectively; The processor rearranges the first real part data and the first imaginary part data to generate the target complex elements of the first sub-block.

[0008] In an optional implementation, the processor rearranges the second real part data and the second imaginary part data of the second sub-block according to the preset arrangement rules to generate each target complex element of the second sub-block, including: The processor loads the second real part data and the second imaginary part data from the memory address of the second complex matrix into the second real part register and the second imaginary part register, respectively; The processor reads the second real part data and the second imaginary part data from the second real part register and the second imaginary part register, respectively; The processor rearranges the second real part data and the second imaginary part data to generate the target complex elements of the second sub-block.

[0009] In an optional implementation, the processor performs complex multiplication operations based on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain a target output matrix, including: The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the complex number operation result; The processor accumulates the results of the complex number operations to obtain the target output matrix.

[0010] Secondly, embodiments of this application also provide a data processing method, including: In response to the application instruction, the processor calls the preset assembly kernel function to divide the first complex matrix and the second complex matrix of the complex matrix multiplication operation into blocks, resulting in each first sub-block and each second sub-block; The processor obtains each initial complex element of the first sub-block based on the first real part data and the first imaginary part data of the first sub-block, and performs imaginary part swapping to obtain each target complex element of the first sub-block. The processor obtains each initial complex element of the second sub-block based on the second real part data and the second imaginary part data of the second sub-block, and performs real-imaginary part swapping to obtain each target complex element of the second sub-block; The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the target output matrix.

[0011] In an optional implementation, the processor obtains each initial complex element of the first sub-block based on the first real part data and the first imaginary part data of the first sub-block, and performs imaginary part swapping to obtain each target complex element of the first sub-block, including: The processor loads the first real part data and the first imaginary part data from the memory address of the first complex matrix, obtains each initial complex element of the first sub-block, and loads them into the third register. The processor reads each initial complex element of the first sub-block from the third register and performs imaginary part swapping to obtain each target complex element of the first sub-block.

[0012] In an optional implementation, the processor reads each initial complex element of the first sub-block from the third register and performs imaginary part swapping to obtain each target complex element of the first sub-block, including: The processor reads each initial complex element of the first sub-block from the third register; The processor groups the initial complex elements of the first sub-block to obtain the initial complex element groups of the first sub-block; The processor performs imaginary part swapping on each initial complex element group of the first sub-block to obtain each target complex element of the first sub-block.

[0013] In an optional implementation, the processor obtains each initial complex element of the second sub-block based on the second real part data and the second imaginary part data of the second sub-block, and performs real-imaginary part swapping to obtain each target complex element of the second sub-block, including: The processor loads the second real part data and the second imaginary part data from the memory address of the second complex matrix, obtains each initial complex element of the second sub-block, and loads them into the fourth register; The processor reads each initial complex element of the second sub-block from the fourth register and swaps the real and imaginary parts to obtain each target complex element of the second sub-block.

[0014] In an optional implementation, the processor reads each initial complex element of the second sub-block from the fourth register and performs a real-imaginary part swap to obtain each target complex element of the second sub-block, including: The processor reads each initial complex element of the second sub-block from the fourth register; The processor groups the initial complex elements of the second sub-block to obtain the initial complex element groups of the second sub-block; The processor swaps the real and imaginary parts of each initial complex element group in the second sub-block to obtain each target complex element of the second sub-block.

[0015] In an optional implementation, the processor performs complex multiplication operations based on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain a target output matrix, including: The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the complex number operation result; The processor accumulates the results of the complex number operations to obtain the target output matrix.

[0016] Thirdly, embodiments of this application also provide an electronic device, including: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory, and the processor executes the machine-readable instructions to perform the method described in any of the first aspects.

[0017] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the method described in any of the first aspects.

[0018] This application provides a data processing method, apparatus, and storage medium. The method includes: responding to an application instruction, a processor calls a preset assembly kernel function to divide a first complex matrix and a second complex matrix involved in a complex matrix multiplication operation into blocks, obtaining first sub-blocks and second sub-blocks; the processor rearranges the first real part and first imaginary part data of the first sub-blocks according to preset arrangement rules to generate target complex elements of the first sub-blocks; the processor rearranges the second real part and second imaginary part data of the second sub-blocks according to preset arrangement rules to generate target complex elements of the second sub-blocks; and the processor performs complex multiplication operations based on the target complex elements of the first and second sub-blocks to obtain a target output matrix. By dividing the complex matrix into blocks and rearranging the real and imaginary part data of each sub-block, computing power can be improved to meet the ever-increasing computing power requirements of the ARM architecture and enhance processor performance. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a schematic diagram of the conventional calculation process of matrix multiplication; Figure 2 Flowchart of the data processing method provided in the embodiments of this application Figure 1 ; Figure 3 Flowchart of the data processing method provided in the embodiments of this application Figure 2 ; Figure 4 A schematic diagram of the first complex matrix provided in an embodiment of this application; Figure 5 Flowchart of the data processing method provided in the embodiments of this application Figure 3 ; Figure 6 A schematic diagram of the second complex matrix provided in an embodiment of this application; Figure 7 Flowchart of the data processing method provided in the embodiments of this application Figure 4 ; Figure 8 A schematic diagram of the original complex matrix provided in the embodiments of this application; Figure 9 This is a schematic diagram of a column-recursive matrix provided in an embodiment of this application; Figure 10A schematic diagram of a row-recursive matrix provided for an embodiment of this application; Figure 11 Flowchart of the data processing method provided in the embodiments of this application Figure 5 ; Figure 12 Flowchart of the data processing method provided in the embodiments of this application Figure 6 ; Figure 13 A schematic diagram illustrating the speedup ratio of single-threaded single-precision complex matrix multiplication provided in this application embodiment; Figure 14 A schematic diagram illustrating the speedup ratio of multi-threaded single-precision complex matrix multiplication provided in this application embodiment; Figure 15 A schematic diagram illustrating the speedup of double-precision complex matrix multiplication in a single-threaded manner, as provided in an embodiment of this application. Figure 16 A schematic diagram illustrating the speedup of double-precision complex matrix multiplication under multithreading in an embodiment of this application; Figure 17 Schematic diagram of the data processing apparatus provided in the embodiments of this application Figure 1 ; Figure 18 Schematic diagram of the data processing apparatus provided in the embodiments of this application Figure 2 ; Figure 19 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0022] Before introducing the technical solution of this application, the key terms involved will be explained first: Matrix packing: rearranging and dividing matrix data into blocks according to specific rules to better utilize the processor's cache locality. By loading matrix blocks into the cache, memory bandwidth bottlenecks can be reduced, and the computational efficiency of matrix multiplication can be improved.

[0023] The assembly load instruction LD1 is used to read a continuous block of data from memory and store it sequentially into registers. LD1 can be configured to load in single-register, dual-register, or quad-register modes, representing loading data into a single vector register, two vector registers, and four registers, respectively. Assuming the data in memory is [A, B, C, D, E, F, G, H], executing LD1 {V0.4S, V1.4S}, [X0]: Register V0 retrieves the first four elements [A, B, C, D], and register V1 retrieves the last four elements [E, F, G, H]. This indicates that data is read continuously from memory starting at address [X0] (8 single-precision floating-point numbers). The first four floating-point numbers A, B, C, D are stored in V0, and the last four floating-point numbers E, F, G, H are stored in V1.

[0024] The assembly load instruction LDP is used to read continuous data from memory and put it into a pair of registers. In other words, the LDP instruction can choose to load the dual registers.

[0025] The assembly load instruction LD2 is used to read interleaved data from memory and automatically deinterleaves it during the loading process, placing the alternating data into two different registers. Assuming the data in memory is [A, B, C, D, E, F, G, H], executing LD2 {V0.4S, V1.4S}, after [X0]: register V0 retrieves the even-indexed element [A, C, E, G], and register V1 retrieves the odd-indexed element [B, D, F, H]. This means that starting from memory address [X0], even-indexed floating-point numbers A, C, E, G are read consecutively and stored in V0, while odd-indexed elements B, D, F, H are read and stored in V1.

[0026] Typically, due to additional data processing (deinterleaving) and more complex memory access patterns, the execution latency of a single LD2 instruction is usually higher than that of a single LD1 or LDP instruction. For example, the throughput of LD1 is generally two to three times that of LD2, which significantly reduces the performance of CGEMM and ZGEMM operations. In addition, LD2 instructions only have a dual-register loading mode, resulting in lower flexibility.

[0027] GEMM: Matrix multiplication accumulation operation, defined as C = αA·B + βC, where A and B are input matrices, α and β are input scalars, and C is the output matrix.

[0028] Taking an example where both α and β are 1, Figure 1This is a schematic diagram of the conventional calculation process of matrix multiplication, as shown below. Figure 1 As shown, it includes the following steps: Step 1: The initial state is that matrix C is an empty matrix, which means that C is obtained by performing matrix multiplication on A and B, C = A × B, where A is divided into columns (e.g., 3 column blocks) and B is divided into rows (e.g., 3 row blocks).

[0029] Step 2: C is divided into row blocks, and each column block of A is further divided into row blocks (e.g., each column block is divided into 2 row blocks). The row blocks of B retain their original structure. Each row block element of C is obtained by multiplying the corresponding row block of A and the row block of B and then summing the results.

[0030] Step 3: Each row block of C is further divided into column blocks (e.g., each row block is further divided into 7 column blocks). Matrix packing is then performed on the row blocks of A and the row blocks of B (the rearranged structure is indicated by slashes).

[0031] Step 4: Each column block of C is further divided into row blocks, while A and B retain their packed structure.

[0032] Step 5: Use the assembler kernel to calculate the row block elements of C. The row block elements of C are equal to the dot product of the elements of the row block of A after packing one row and the row block of B after packing one column.

[0033] It can be seen that in the conventional matrix multiplication calculation process, matrix partitioning and matrix packing are used to improve the spatial locality of data, so as to ensure that the processor is in the cache as much as possible. By manually writing or adjusting the NEON assembly code (assembly core), its parallel computing capabilities can be fully utilized to improve program performance.

[0034] However, due to the lack of versatility of the ARM platform compared to x86, research on CGEMM and ZGEMM is relatively weak and lacks refined design, resulting in a significant reduction in the efficiency of complex matrix operations using CGEMM and ZGEMM, making it difficult to support the ever-increasing computing power of the ARM architecture. Based on this, this application proposes to divide the complex matrix into blocks and rearrange the real and imaginary parts of each sub-block to better leverage the growing computing power of the ARM architecture and improve processor performance.

[0035] The following is combined with Figures 2 to 6 The example illustrates the optimization method for complex matrix multiplication in CGEMM.

[0036] Figure 2 Flowchart of the data processing method provided in the embodiments of this application Figure 1In this embodiment, the execution entity can be a processor, such as an ARM-based processor. In this embodiment, the processor includes memory, which can store the data to be processed. Furthermore, based on the complex multiplication operation to be processed, the processor also includes multiple registers, including real part registers, imaginary part registers, etc.

[0037] like Figure 2 As shown, the method may include: S101. In response to the application instruction, the processor calls the preset assembly kernel function to divide the first complex matrix and the second complex matrix of the complex matrix multiplication operation into blocks, respectively, to obtain each first sub-block and each second sub-block.

[0038] In this embodiment, the complex matrix multiplication is an algorithm called from the algorithm library at runtime. Generally, during application execution, the processor will call the required algorithms from the algorithm library. For example, when performing complex matrix-related tasks, complex matrix algorithms will be called, such as complex matrix multiplication.

[0039] The complex matrix multiplication operation can be CGEMM, and the first and second complex matrices can be single-precision complex matrices, for example... Figure 1 In the matrix, there are matrices A and B. The first and second complex matrices are the original matrices, meaning that when participating in matrix multiplication, the original form of the matrix is ​​used directly without swapping (transposing) or conjugate transposing the rows and columns.

[0040] It should be noted that the elements in a single-precision complex matrix are called single-precision complex elements, which include a real part and an imaginary part, and the real part and the imaginary part are each a single-precision floating-point number.

[0041] Preset assembly kernel functions refer to low-level subroutines written in assembly language for the instruction set of a computing platform (such as the ARM platform), which execute the core computing logic. A preset assembly kernel function can be an a×b assembly kernel function, representing the process of retrieving a rows (the number of columns can be set according to actual needs, such as 1 column) from the first complex matrix and b columns (the number of rows can be set according to actual needs, such as 1 row) from the second complex matrix. For example, a×b could be 8×4 or 4×4.

[0042] Each time, the processor takes the complex elements of row a from the first complex matrix as the first sub-block to divide the first complex matrix into blocks, thus obtaining each first sub-block of the first complex matrix. Similarly, each time, it takes the complex elements of column b from the second complex matrix as the second sub-block to divide the second complex matrix into blocks, thus obtaining each second sub-block of the second complex matrix.

[0043] Since complex matrices are stored column-wise in memory address space, meaning that different rows of the same column are contiguous in memory address space, retrieving data column by column is relatively fast because the memory address space is contiguous. However, if data is retrieved row by row, different columns of the same row are skipped in memory address space (the distance of the entire column must be skipped), which is relatively slow.

[0044] The recursive methods for the first and second complex matrices differ. The first complex matrix is ​​recursively processed column-wise, meaning it's divided into blocks column by column. That is, each time, a sub-block (dimension a×1) of complex elements in row a and column 1 is taken from the first complex matrix. Since complex matrices are stored column-wise in memory, the complex elements in row a and column 1 are contiguous in memory address space. The second complex matrix is ​​recursively processed row-wise, meaning it's divided into blocks row by row. That is, each time, a sub-block (dimension 1×b) of complex elements in row b is taken from the first complex matrix. Since complex matrices are stored column-wise in memory, the complex elements in row b and column 1 are not contiguous in memory address space.

[0045] In some embodiments, since the number of rows in the first complex matrix may not be an integer multiple of m, the first sub-block of complex elements in rows a and columns 1 can be selected from the first complex matrix each time according to m. When the number of remaining rows is less than an integer multiple of m, a preset selection strategy can be adopted to select the complex elements in the first row and / or the second row as the first sub-block in turn. For example, when m is 8, the number of the first row is 4 and the number of the second row is 2, which means that the complex elements in rows 8 and columns 1 are selected as the first sub-block in advance. When the number of remaining rows is 6 and less than an integer multiple of 8, the complex elements in rows 4 and columns 1 are selected as the first sub-block and the complex elements in rows 2 and columns 1 are selected as the first sub-block.

[0046] In some embodiments, since the number of columns in the second complex matrix may not be an integer multiple of n, the second sub-block of complex elements in row 1 and column b can be selected first, with n as the priority. When the number of remaining columns is less than an integer multiple of n, a preset selection strategy can be adopted to select the complex elements in the first column as the second sub-block in turn. For example, when n is 4, the number of the first column is 2, which means that the complex elements in row 1 and column 4 are selected first as the second sub-block. When the number of remaining columns is less than an integer multiple of 4, the complex elements in row 1 and column 2 are selected as the second sub-block.

[0047] In other words, for the first and second complex matrices, the complex matrices are first divided into blocks according to the maximum sub-block size (rows and columns) corresponding to the preset assembly kernel function.

[0048] S102. The processor rearranges the first real part data and the first imaginary part data of the first sub-block according to the preset arrangement rules to generate each target complex element of the first sub-block. In the target complex elements of the first sub-block, the real part data is arranged together and the imaginary part data is arranged together.

[0049] The preset arrangement rules are used to indicate that the real part data of each target complex element in the first sub-block is arranged together and the imaginary part data is arranged together.

[0050] The real part and imaginary part of the first sub-block are respectively the first real part and the first imaginary part, and there are multiple first real part data and multiple first imaginary part data. The processor arranges the first real part data of the first sub-block together and arranges the first imaginary part data together according to the preset arrangement rules to generate each target complex element of the first sub-block. Here, one first real part data and one first imaginary part data constitute one target complex element of the first sub-block, and the first sub-block includes multiple target complex elements.

[0051] S103. The processor rearranges the second real part data and the second imaginary part data of the second sub-block according to the preset arrangement rules to generate each target complex element of the second sub-block. In the target complex elements of the second sub-block, the real part data is arranged together and the imaginary part data is arranged together.

[0052] The preset arrangement rules are also used to indicate that the real part data of each target complex element in the second sub-block is arranged together and the imaginary part data is arranged together.

[0053] The real and imaginary data of the second sub-block are respectively the second real data and the second imaginary data, and there are multiple second real data and multiple second imaginary data. The processor arranges the second real data of the second sub-block together and arranges the second imaginary data together according to the preset arrangement rules to generate each target complex element of the second sub-block. Here, one second real data and one second imaginary data constitute one target complex element of the second sub-block, and the second sub-block includes multiple target complex elements.

[0054] S104. The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the target output matrix.

[0055] The processor uses each target complex element of the second sub-block and performs complex multiplication operations with each target complex element of the first sub-block, and accumulates them to obtain the output matrix of a set of sub-blocks. A set of sub-blocks includes a first sub-block and a second sub-block, and the first sub-block and the second sub-block have a one-to-one correspondence. Then, the output matrices of all sets of sub-blocks are accumulated to obtain the target output matrix of the first complex matrix and the second complex matrix.

[0056] The target output matrix can be the result of executing an application instruction. The entire process improves the efficiency of complex matrix multiplication, thereby increasing computing power and accelerating applications. This meets the ever-growing computing power requirements of the ARM architecture and improves processor performance.

[0057] In an optional implementation, step S104 above, in which the processor performs complex multiplication operations based on the target complex elements of the first sub-block and the target complex elements of the second sub-block to obtain the target output matrix, may include: The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the complex operation result; the complex operation result is accumulated to obtain the target output matrix.

[0058] The processor uses the first target complex element of the second sub-block and performs complex multiplication operations with all target complex elements of the first sub-block to obtain the first complex operation result of a set of sub-blocks. The number of complex elements in the first complex operation result is the same as the number of all target complex elements in the first sub-block.

[0059] The processor uses the second target complex element of the second sub-block and performs complex multiplication operations with all target complex elements of the first sub-block to obtain the second complex operation result of a set of sub-blocks. The number of complex elements in the second complex operation result is the same as the number of all target complex elements in the first sub-block. This process is repeated until the last target complex element of the second sub-block is used and performs complex multiplication operations with all target complex elements of the first sub-block to obtain the final complex operation result of a set of sub-blocks. The number of complex elements in the final complex operation result is the same as the number of all target complex elements in the first sub-block.

[0060] Then the processor takes the sum of the first complex number operation results of all sub-blocks as the first column complex element of the target output matrix, takes the sum of the second complex number operation results of all sub-blocks as the second column complex element of the target output matrix, and so on, taking the sum of the last complex number operation results of all sub-blocks as the last column complex element of the target output matrix.

[0061] It should be noted that complex matrix multiplication can be performed using the complex multiplication formula (a+bi)×(c+di) =(ac-bd)+(ad+bc)i. In the underlying assembly language, the combination of the two instructions fmla and fmls can be used to efficiently complete the complex multiplication operation. The fmla instruction is for multiplication and addition, and the fmls instruction is for multiplication and subtraction.

[0062] In this embodiment, for complex matrix multiplication operations in CGEMM, the processor improves the computational efficiency of complex matrix multiplication by dividing the complex matrix into blocks and rearranging the real and imaginary parts of each sub-block, such as giga-floating-point operations per second (GFLOPS). Since the algorithm's computational efficiency is improved, the application execution efficiency is also higher, thereby accelerating applications, increasing computing power, meeting the ever-growing computing power requirements of the ARM architecture, and further improving the processor's performance.

[0063] Figure 3 Flowchart of the data processing method provided in the embodiments of this application Figure 2 ,like Figure 3 As shown, in an optional implementation, step S102, in which the processor rearranges the first real part data and the first imaginary part data of the first sub-block according to a preset arrangement rule to generate each target complex element of the first sub-block, may include: S201. The processor loads the first real part data and the first imaginary part data from the memory address of the first complex matrix into the first real part register and the first imaginary part register, respectively.

[0064] Since complex matrices are stored column-wise in the memory address space, meaning that different rows of the same column are contiguous in the memory address space, and the first complex matrix is ​​recursively stored column-wise, meaning that it is divided into blocks one column at a time, that is, each time a complex element in row a and column 1 is taken from the first complex matrix as the first sub-block, the complex element in row a and column 1 taken each time is contiguous in the memory address space. The processor can use the assembly load instruction LD1 to load the first real part data from the memory address of the first complex matrix into the first real part register, and load the second imaginary part data into the second imaginary part register to complete the loading of complex elements.

[0065] The number of the first real part register and the first imaginary part register are the same, and the total number of the first real part register and the first imaginary part register is determined by the register loading mode of the assembly load instruction LD1. If the register loading mode is four-register mode, the total number of the first real part register and the first imaginary part register is 4, and the number of each is 2. If the register loading mode is two-register mode, the total number of the first real part register and the first imaginary part register is 2, and the number of each is 1.

[0066] For example, the assembly load instruction LD1 loads in four-register mode with m=8, loading 16 single-precision floating-point numbers (8 first real parts and 8 first imaginary parts) from the memory address of the first complex matrix into vector registers V0, V1, V2, and V3. This contains all the real and imaginary parts of the 8 complex elements in the first sub-block of the first complex matrix. Each complex element consists of two single-precision floating-point numbers: the first real part and the first imaginary part. Specifically, V0 stores [real 1, real 2, real 3, real 4], V1 stores [imaginary 1, imaginary 2, imaginary 3, imaginary 4], V2 stores [real 5, real 6, real 7, real 8], and V3 stores [imaginary 5, imaginary 6, imaginary 7, imaginary 8]. V0 and V2 are the first real part registers, and V1 and V3 are the first imaginary part registers.

[0067] Figure 4 A schematic diagram of the first complex matrix provided in the embodiments of this application, as shown below. Figure 4 As shown, taking m=8 as an example, before the optimization of 8 rows, it means taking the complex elements (real1, imaginary1, real2, imaginary2...real8, imaginary8) of the 8th row and 1st column of the first complex matrix. If the assembly loading instruction LD1 loads the four register mode, then after the optimization of 8 rows, [real1, real2, real3, real4] will be stored in V0, [imaginary1, imaginary2, imaginary3, imaginary4] will be stored in V1, [real5, real6, real7, real8] will be stored in V2, and [imaginary5, imaginary6, imaginary7, imaginary8] will be stored in V3.

[0068] Continue to refer to Figure 4 Taking m=4 as an example, before the optimization of the 4 rows, it means taking the complex elements (real 1, imaginary 1, real 2, imaginary 2... real 4, imaginary 4) of the first complex matrix. If the assembly loading instruction LD1 loads the dual register mode, then after the optimization of the 4 rows, [real 1, real 2, real 3, real 4] will be stored in V0, and [imaginary 1, imaginary 2, imaginary 3, imaginary 4] will be stored in V1.

[0069] Continue to refer to Figure 4 Taking m=2 as an example, before the optimization of the two lines, it means taking the complex elements (real 1, imaginary 1, real 2, imaginary 2) of the second row and first column of the first complex matrix. If the assembly loading instruction LD1 loads the dual register mode, then after the optimization of the two lines, [real 1, real 2] will be stored in V0 and [imaginary 1, imaginary 2] will be stored in V1.

[0070] S202, The processor reads the first real part data and the first imaginary part data from the first real part register and the first imaginary part register, respectively.

[0071] S203. The processor rearranges the first real part data and the first imaginary part data to generate the target complex elements of the first sub-block.

[0072] The processor reads the first real part data from the first real part register, reads the first imaginary part data from the first imaginary part register, and arranges the first real part data of the first sub-block together and the first imaginary part data together to generate the target complex elements of the first sub-block. Here, one first real part data and one first imaginary part data constitute one target complex element of the first sub-block, and the first sub-block includes multiple target complex elements.

[0073] In this embodiment, for complex matrix multiplication operations of CGEMM, the processor divides the first complex matrix into blocks and rearranges the real and imaginary parts of the first block. This allows for the use of instructions with higher throughput to complete data loading, more flexible modification of the complex multiplication assembly algorithm, reduction of pipeline congestion, and improvement of the computational efficiency of complex matrix multiplication. This, in turn, enhances computing power, meets the ever-increasing computing power requirements of the ARM architecture, and improves processor performance.

[0074] Figure 5 Flowchart of the data processing method provided in the embodiments of this application Figure 3 ,like Figure 5 As shown, in an optional implementation, step S103, in which the processor rearranges the second real part data and the second imaginary part data of the second sub-block according to a preset arrangement rule to generate each target complex element of the second sub-block, may include: S301, The processor loads the second real part data and the second imaginary part data from the memory address of the second complex matrix into the second real part register and the second imaginary part register, respectively.

[0075] The second complex matrix is ​​recursively divided by rows, meaning that data is divided into blocks row by row (from left to right). That is, each time, the complex element in row b is taken as a second sub-block. Since the complex matrix is ​​stored column-wise in the memory address space, to arrange the complex elements in the same row consecutively, it is necessary to skip n (the number of rows in the second complex matrix), i.e., 1+n.

[0076] The processor uses the assembly load instruction LD1 to load the second real part data from the memory address of the second complex matrix into the second real part register, and to load the second imaginary part data into the second imaginary part register, in order to complete the loading of complex elements.

[0077] The number of the second real part register and the second imaginary part register are the same, and the total number of the second real part register and the second imaginary part register is determined by the register loading mode of the assembly load instruction LD1. If the register loading mode is the dual register mode, the total number of the second real part register and the second imaginary part register is 2, and the number of each is 1.

[0078] For example, the assembly load instruction LD1 loads in dual-register mode with m=4, loading eight single-precision floating-point numbers (four first real parts and four first imaginary parts) from the memory address of the second complex matrix into vector registers V4 and V5. This contains all the real and imaginary parts of the four complex elements in a second sub-block of the second complex matrix. Each complex element consists of two single-precision floating-point numbers: the second real part and the second imaginary part. V4 stores [real 1, real 2, real 3, real 4, real 5, real 6, real 7, real 8, real 9, real 1 ... 1+n ,Reality 1+2n ,Reality 1+3n V5 stores [virtual 1, virtual 2] 1+n , false 1+2n , false 1+3n V4 is the second real part register, and V5 is the second imaginary part register.

[0079] Figure 6 A schematic diagram of the second complex matrix provided in the embodiments of this application, as shown below. Figure 6 As shown, taking n=4 as an example, the 4 columns before optimization represent taking the complex elements (real 1, imaginary 1, real 1, imaginary 1, real 1) from the 1st row and 4th column of the second complex matrix. 1+n , false 1+n ,Reality 1+2n , false 1+2n ,Reality 1+3n , false 1+3n If the assembly load instruction LD1 loads in dual-register mode, then after 4-column optimization, [real 1, real 2] will be loaded. 1+n ,Reality 1+2n ,Reality 1+3n Store in V4, and store [virtual 1, virtual 2] 1+n , false 1+2n , false 1+3n Save to V5.

[0080] Continue to refer to Figure 6 Taking n=2 as an example, the two columns before optimization represent taking the complex elements (real 1, imaginary 1, real 1, real 1) from the 1st row and 2nd column of the second complex matrix. 1+n , false 1+n If the assembly load instruction LD1 loads in dual-register mode, then after optimization of the two columns, [real 1, real 2] will be loaded. 1+n Store in V4, and store [virtual 1, virtual 2] 1+n Save to V5.

[0081] S302, The processor reads the second real part data and the second imaginary part data from the second real part register and the second imaginary part register, respectively.

[0082] S303, The processor rearranges the second real part data and the second imaginary part data to generate the target complex elements of the second sub-block.

[0083] The processor reads the second real part data from the second real part register, reads the second imaginary part data from the second imaginary part register, and arranges the second real part data of the second sub-block together and the second imaginary part data together to generate the target complex elements of the second sub-block. Here, one second real part data and one second imaginary part data constitute one target complex element of the second sub-block, and the second sub-block includes multiple target complex elements.

[0084] For example, if a×b is 8×4, then for the first complex matrix, [real1, real2, real3, real4] are stored in V0, [imaginary1, imaginary2, imaginary3, imaginary4] are stored in V1, [real5, real6, real7, real8] are stored in V2, and [imaginary5, imaginary6, imaginary7, imaginary8] are stored in V3. For the second complex matrix, [real1, real2, real3, real4] are stored in V0, [imaginary1, real2, real3, imaginary4] are stored in V1, [real5, real6, real7, real8] are stored in V2, and [imaginary5, imaginary6, imaginary7, imaginary8] are stored in V3. 1+n ,Reality 1+2n ,Reality 1+3n Store in V4, and store [virtual 1, virtual 2] 1+n , false 1+2n , false 1+3n Stored in V5. The following explains the complex matrix multiplication process in CGEMM: First, perform the first set of complex number operations: using the first target complex number element of the second sub-block (real part located in V4.S[0], imaginary part located in V5.S[0]), perform complex multiplication and accumulation with the 8 target complex number elements of the first sub-block. Specifically, calculate and accumulate the real part data (stored in vector registers V6 and V7) and imaginary part data (stored in vector registers V8 and V9) of the 8 complex number results in the first column of the target output matrix C. V4.S[0] represents the first single-precision floating-point number in register V4, and so on.

[0085] Then, the second set of complex number operations is performed: using the second target complex number element of the second sub-block (located in V4.S[1] and V5.S[1]), complex number multiplication and accumulation are performed with the 8 target complex number elements of the first sub-block. Specifically, the real part data (stored in vector registers V10 and V12) and imaginary part data (stored in vector registers V12 and V13) of the 8 complex number results in the second column of the target output matrix C are calculated and accumulated respectively.

[0086] Then perform the third set of complex number operations: using the third target complex number element of the second sub-block (located in V4.S[2] and V5.S[2]), perform complex multiplication and accumulation with the 8 target complex number elements of the first sub-block. Specifically, calculate and accumulate the real part data (stored in vector registers V14 and V15) and imaginary part data (stored in vector registers V16 and V17) of the 8 complex number results in the third column of the target output matrix C respectively.

[0087] Finally, the fourth set of complex number operations is performed: using the fourth target complex number element of the second sub-block (located in V4.S[3] and V5.S[3]), complex number multiplication and accumulation are performed with the 8 target complex number elements of the first sub-block. Specifically, the real part data (stored in vector registers V18 and V19) and imaginary part data (stored in vector registers V20 and V21) of the 8 complex number results in the fourth column of the target output matrix C are calculated and accumulated respectively.

[0088] It should be noted that the first and second sub-blocks are in one-to-one correspondence. A group of sub-blocks includes one first sub-block and one second sub-block. Before calculation, the results stored in V6 to V20 are cleared to zero. Calculating and accumulating the real part (stored in vector registers V6 and V7) and imaginary part (stored in vector registers V8 and V9) of the eight complex numbers in the first column of the target output matrix C for the current group of sub-blocks means that after calculating the real and imaginary parts of the eight complex numbers in the first column of the target output matrix C calculated for the previous group of sub-blocks, it is necessary to accumulate the real and imaginary parts of the eight complex numbers in the first column of the target output matrix C calculated for the previous group of sub-blocks. The accumulated real parts of the eight complex numbers in the first column of the target output matrix C are then stored in V6 and V7, and the imaginary parts are stored in V8 and V9. The accumulation process for other registers is similar and will not be described in detail here.

[0089] In this embodiment, for complex matrix multiplication operations of CGEMM, the processor divides the second complex matrix into blocks and rearranges the real and imaginary data of the second blocks. This allows for the use of instructions with higher throughput to complete data loading, more flexible modification of the complex multiplication assembly algorithm, reduction of pipeline congestion, and improvement of the computational efficiency of complex matrix multiplication. This, in turn, enhances computing power, meets the ever-increasing computing power requirements of the ARM architecture, and improves processor performance.

[0090] The following is combined with Figures 7 to 12 The examples illustrate the optimization method for complex matrix multiplication in ZGEMM.

[0091] Figure 7 Flowchart of the data processing method provided in the embodiments of this application Figure 4 In this embodiment, the execution entity can be a processor, such as an ARM-based processor. In this embodiment, the processor includes memory, which can store the data to be processed. Furthermore, based on the complex multiplication operation to be processed, the processor also includes multiple registers, including real part registers, imaginary part registers, etc.

[0092] like Figure 7 As shown, the method may include: S401. The processor responds to the application instruction by calling the preset assembly kernel function to divide the first complex matrix and the second complex matrix of the complex matrix multiplication operation into blocks, resulting in each first sub-block and each second sub-block.

[0093] The complex matrix algorithm in this embodiment is an algorithm called from the algorithm library at runtime. Generally, during application runtime, the processor will call the required algorithm from the algorithm library. For example, when performing tasks related to complex matrices, the complex matrix algorithm may be called.

[0094] The complex matrix multiplication operation can be ZGEMM, and the first and second complex matrices can be double-precision complex matrices, for example... Figure 1 In the matrix, there are matrices A and B. The first and second complex matrices are the original matrices, meaning that when participating in matrix multiplication, the original form of the matrix is ​​used directly without swapping (transposing) or conjugate transposing the rows and columns.

[0095] It should be noted that the elements in a double-precision complex matrix are called double-precision complex elements, which include a real part and an imaginary part, and the real part and the imaginary part are each a double-precision floating-point number.

[0096] Preset assembly kernel functions refer to low-level subroutines written in assembly language for the instruction set of a computing platform (such as the ARM platform), which execute the core computing logic. A preset assembly kernel function can be an a×b assembly kernel function, representing the process of retrieving a rows (the number of columns can be set according to actual needs, such as 1 column) from the first complex matrix and b columns (the number of rows can be set according to actual needs, such as 1 row) from the second complex matrix. For example, a×b could be 8×4 or 4×4.

[0097] Each time, the processor takes the complex elements of row a from the first complex matrix as the first sub-block to divide the first complex matrix into blocks, thus obtaining each first sub-block of the first complex matrix. Similarly, each time, it takes the complex elements of column b from the second complex matrix as the second sub-block to divide the second complex matrix into blocks, thus obtaining each second sub-block of the second complex matrix.

[0098] Since complex matrices are stored column-wise in memory address space, meaning that different rows of the same column are contiguous in memory address space, retrieving data column by column is relatively fast because the memory address space is contiguous. However, if data is retrieved row by row, different columns of the same row are skipped in memory address space (the distance of the entire column must be skipped), which is relatively slow.

[0099] The recursive traversal directions of the first and second complex matrices are different. The first complex matrix is ​​recursively traversed column-wise, meaning it is divided into blocks column by column. That is, each time, a row of 'a' and column 1 complex elements are taken from the first complex matrix as a first sub-block (dimension a×1). Since complex matrices are stored column-wise in memory, the complex elements in row 'a' and column 1 are contiguous in memory address space. The second complex matrix is ​​recursively traversed row-wise, meaning it is divided into blocks row by row. That is, each time, a row of '1' and column 1 b complex elements are taken from the first complex matrix as a second sub-block (dimension 1×b). Since complex matrices are stored column-wise in memory, the complex elements in row 1 and column 1 b are not contiguous in memory address space.

[0100] For example, if a×b is 4×4, each time a complex element in row 4 and column 1 is taken from the first complex matrix as a first sub-block, and a complex element in row 1 and column 4 is taken from the second complex matrix as a second sub-block.

[0101] Figure 8 This is a schematic diagram of the original complex matrix provided in an embodiment of this application. Figure 9 This is a schematic diagram of a column-recursive matrix provided in an embodiment of this application. Figure 10 This is a schematic diagram of a row-recursive matrix provided for an embodiment of this application.

[0102] like Figures 8 to 10 As shown, after recursion by column, the original complex matrix has a block of elements in the order of [1,3,5,7,2,4,6,8,3,5,7,9,4,6,8,0]. After recursion by row, the original complex matrix has a block of elements in the order of [1,2,3,4,3,4,5,6,5,6,7,8,7,8,9,0].

[0103] As can be seen, similar to CGEMM, the recursion methods for the first and second complex matrices are different.

[0104] In some embodiments, since the number of rows in the first complex matrix may not be an integer multiple of m, the first sub-block of complex elements in rows a and columns 1 can be selected from the first complex matrix each time according to m. When the number of remaining rows is less than an integer multiple of m, a preset selection strategy can be adopted to select the complex elements in the first row and / or the second row as the first sub-block in turn. For example, when m is 8, the number of the first row is 4 and the number of the second row is 2, which means that the complex elements in rows 8 and columns 1 are selected as the first sub-block in advance. When the number of remaining rows is 6 and less than an integer multiple of 8, the complex elements in rows 4 and columns 1 are selected as the first sub-block and the complex elements in rows 2 and columns 1 are selected as the first sub-block.

[0105] In some embodiments, since the number of columns in the second complex matrix may not be an integer multiple of n, the second sub-block of complex elements in row 1 and column b can be selected first, with n as the priority. When the number of remaining columns is less than an integer multiple of n, a preset selection strategy can be adopted to select the complex elements in the first column as the second sub-block in turn. For example, when n is 4, the number of the first column is 2, which means that the complex elements in row 1 and column 4 are selected first as the second sub-block. When the number of remaining columns is less than an integer multiple of 4, the complex elements in row 1 and column 2 are selected as the second sub-block.

[0106] In some embodiments, since the number of rows in the first complex matrix may not be an integer multiple of m, the first sub-block of complex elements in rows a and columns 1 can be selected from the first complex matrix each time according to m. When the number of remaining rows is less than an integer multiple of m, a preset selection strategy can be adopted to select the complex elements in the first row and / or the second row as the first sub-block in turn. For example, when m is 8, the number of the first row is 4 and the number of the second row is 2, which means that the complex elements in rows 8 and columns 1 are selected as the first sub-block in advance. When the number of remaining rows is 6 and less than an integer multiple of 8, the complex elements in rows 4 and columns 1 are selected as the first sub-block and the complex elements in rows 2 and columns 1 are selected as the first sub-block.

[0107] In some embodiments, since the number of columns in the second complex matrix may not be an integer multiple of n, the second sub-block of complex elements in row 1 and column b can be selected first, with n as the priority. When the number of remaining columns is less than an integer multiple of n, a preset selection strategy can be adopted to select the complex elements in the first column as the second sub-block in turn. For example, when n is 4, the number of the first column is 2, which means that the complex elements in row 1 and column 4 are selected first as the second sub-block. When the number of remaining columns is less than an integer multiple of 4, the complex elements in row 1 and column 2 are selected as the second sub-block.

[0108] In other words, for the first and second complex matrices, the complex matrices are first divided into blocks according to the maximum sub-block size (rows and columns) corresponding to the preset assembly kernel function.

[0109] S402. The processor obtains each initial complex element of the first sub-block based on the first real part data and the first imaginary part data of the first sub-block, and performs imaginary part swapping to obtain each target complex element of the first sub-block.

[0110] The real part and imaginary part of the first sub-block are respectively the first real part and the first imaginary part, and there are multiple first real parts and multiple first imaginary parts. One first real part and one corresponding first imaginary part constitute the initial complex element of the first sub-block. Therefore, based on multiple first real parts and multiple second real parts, multiple initial complex elements of the first sub-block can be obtained.

[0111] For the initial complex elements of the first sub-block, the processor determines the complex element to be swapped from multiple initial complex elements of the first sub-block, and performs an imaginary part swap on the initial complex element and the complex element to be swapped to obtain the target complex elements of the first sub-block. This method can obtain multiple target complex elements of the first sub-block by performing an imaginary part swap on all multiple initial complex elements of the first sub-block.

[0112] For example, the imaginary part of the initial complex element of the first sub-block is swapped with the imaginary part of the complex element to be swapped. The initial complex element of the first sub-block after the swap is used as the target complex element of the first sub-block. That is, the imaginary part of the complex element to be swapped is used as the imaginary part of the target complex element of the first sub-block, and the real part of the initial complex element of the first sub-block is used as the real part of the target complex element. Thus, a target complex element can be obtained.

[0113] S403. The processor obtains each initial complex element of the second sub-block based on the second real part data and the second imaginary part data of the second sub-block, and performs real-imaginary part swapping to obtain each target complex element of the second sub-block.

[0114] The real part and imaginary part of the second sub-block are the second real part and the second imaginary part, respectively, and there are multiple instances of both. One second real part and one corresponding second imaginary part constitute the initial complex element of the second sub-block. Therefore, based on multiple second real parts and multiple second imaginary parts, multiple initial complex elements of the second sub-block can be obtained.

[0115] For each initial complex element of the second sub-block, the processor determines the complex element to be swapped from the other initial complex elements in the second sub-block, excluding the initial complex element itself, and performs a real-imaginary part swap on the initial complex element and the complex element to be swapped to obtain the target complex element of the second sub-block. In this way, by performing real-imaginary part swaps on multiple initial complex elements of the second sub-block, multiple target complex elements of the second sub-block can be obtained.

[0116] For example, by swapping the imaginary part of the initial complex element of the second sub-block with the real part of the complex element to be swapped, two target complex elements of the second sub-block are obtained. That is, the imaginary part of the complex element to be swapped is used as the imaginary part of one target complex element of the second sub-block, and the real part of the initial complex element of the second sub-block is used as the real part of the target complex element. The real part of the complex element to be swapped is used as the imaginary part of one target complex element of the second sub-block, and the imaginary part of the initial complex element of the second sub-block is used as the real part of the target complex element.

[0117] S404. The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the target output matrix.

[0118] The processor uses each target complex element of the second sub-block and performs complex multiplication operations with each target complex element of the first sub-block, and accumulates them to obtain the output matrix of a set of sub-blocks. A set of sub-blocks includes a first sub-block and a second sub-block, and the first sub-block and the second sub-block have a one-to-one correspondence. Then, the output matrices of all sets of sub-blocks are accumulated to obtain the target output matrix of the first complex matrix and the second complex matrix.

[0119] The target output matrix can be the result of executing an application instruction. The entire process improves the efficiency of complex matrix multiplication, thereby increasing computing power and accelerating applications. This meets the ever-growing computing power requirements of the ARM architecture and improves processor performance.

[0120] In an optional implementation, step S404 above, in which the processor performs complex multiplication operations based on the target complex elements of the first sub-block and the second sub-block to obtain the target output matrix, may include: The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the complex operation result; the processor accumulates the complex operation result to obtain the target output matrix.

[0121] The processor uses the first target complex element of the second sub-block and performs complex multiplication operations with all target complex elements of the first sub-block to obtain the first complex operation result of a set of sub-blocks. The number of the first complex operation results is the same as the number of target complex elements of the first sub-block.

[0122] The processor uses the second target complex element of the second sub-block and performs complex multiplication operations with all target complex elements of the first sub-block to obtain the second complex operation result of a set of sub-blocks. The number of the second complex operation results is the same as the number of target complex elements of the first sub-block. This process is repeated until the last target complex element of the second sub-block is used and performs complex multiplication operations with all target complex elements of the first sub-block to obtain the final complex operation result of a set of sub-blocks. The number of the final complex operation results is the same as the number of target complex elements of the first sub-block.

[0123] Then the processor calculates the sum of the first complex number operation results corresponding to all sub-blocks, the sum of the second complex number operation results corresponding to all sub-blocks, and so on, until the sum of the last complex number operation results corresponding to all sub-blocks is calculated, and then arranges them in columns to obtain the target output matrix.

[0124] For example, if the number of target complex elements in the first sub-block is 2, then the sum of the results of the first complex operations corresponding to all sub-blocks is used as the first and second columns of the target output matrix, respectively. The sum of the results of the second complex operations corresponding to all sub-blocks is used as the third and fourth columns of the target output matrix, respectively. And so on, the sum of the results of the last complex operations corresponding to all sub-blocks is used as the penultimate and penultimate columns of the target output matrix, respectively.

[0125] It should be noted that complex matrix multiplication can be performed using the complex multiplication formula (a+bi)×(c+di) =(ac-bd)+(ad+bc)i. In the underlying assembly language, the combination of the two instructions fmla and fmls can be used to efficiently complete the complex multiplication operation. The fmla instruction is for multiplication and addition, and the fmls instruction is for multiplication and subtraction.

[0126] In this embodiment, for complex matrix multiplication operations in ZGEMM, the complex matrix is ​​divided into blocks, and the real and imaginary parts of each sub-block are rearranged to improve the efficiency of complex matrix multiplication, such as giga-floating-point operations per second (GFLOPS). Since the algorithm's efficiency is improved, the application execution efficiency is also higher, thereby accelerating the application and further improving the processor's performance.

[0127] Figure 11 Flowchart of the data processing method provided in the embodiments of this application Figure 5 ,like Figure 11 As shown, in an optional implementation, step S402, in which the processor obtains each initial complex element of the first sub-block based on the first real part data and the first imaginary part data of the first sub-block, and performs imaginary part swapping to obtain each target complex element of the first sub-block, may include: S501, The processor loads the first real part data and the first imaginary part data from the memory address of the first complex matrix, obtains each initial complex element of the first sub-block, and loads them into the third register.

[0128] Since complex matrices are stored column-wise in memory address space, meaning different rows of the same column are contiguous in memory address space, and the first complex matrix is ​​recursively divided column-wise (meaning it is divided into blocks one by one), each time a complex element in row a, column 1 is taken from the first complex matrix as the first sub-block, the a-row, column 1 complex element taken each time is contiguous in memory address space. The processor can use the assembly load instruction LD1 to load the first real part and the first imaginary part of the first complex matrix from its memory address, obtain and load each initial complex element of the first sub-block into the third register, thus completing the complex element loading. The third register simultaneously stores the real and imaginary parts of the initial complex elements of the first sub-block.

[0129] The number of third registers is determined by the register loading mode of the assembly load instruction LD1. If the register loading mode is four-register mode, the number of third registers is 4; if the register loading mode is two-register mode, the number of third registers is 2.

[0130] For example, the assembly load instruction LD1 loads in four-register mode with m = 4. The first sub-block of four complex numbers is stored as [0, 2, 1, 3, 4, 6, 5, 7]. Eight double-precision floating-point numbers (four first real parts and four first imaginary parts) are loaded from the memory address of the first complex number matrix into vector registers V0, V1, V2, and V3. V0 is [0, 2], V1 is [1, 3], V2 is [4, 6], and V3 is [5, 7]. This means that the first real part 0 and the first imaginary part 2 are stored in V0, the first real part 1 and the first imaginary part 3 are stored in V1, the first real part 4 and the first imaginary part 6 are stored in V2, and the first real part 5 and the first imaginary part 7 are stored in V3. Each register contains two double-precision numbers (32 bytes in total), which contain the real and imaginary parts of the four complex number elements of the first sub-block.

[0131] S502, The processor reads each initial complex element of the first sub-block from the third register and performs imaginary part swapping to obtain each target complex element of the first sub-block.

[0132] The processor reads each initial complex element of the first sub-block from the third register, determines the complex element to be swapped from the multiple initial complex elements of the first sub-block, and performs an imaginary part swap on the initial complex element and the complex element to be swapped to obtain the target complex element of the first sub-block. By performing an imaginary part swap on all the multiple initial complex elements of the first sub-block in this way, multiple target complex elements of the first sub-block can be obtained.

[0133] In an optional implementation, step S502 above, in which the processor reads each initial complex element of the first sub-block from the third register and performs imaginary part swapping to obtain each target complex element of the first sub-block, may include: The processor reads the initial complex elements of the first sub-block from the third register; The processor groups the initial complex elements of the first sub-block to obtain the initial complex element groups of the first sub-block; The processor swaps the imaginary parts of each initial complex element group in the first sub-block to obtain each target complex element of the first sub-block.

[0134] The processor reads each initial complex element of the first sub-block from the third register and groups each initial complex element of the first sub-block to obtain each initial complex element group of the first sub-block. Each group includes at least two initial complex elements of the first sub-block, and each initial complex element group corresponds to a target complex element.

[0135] For example, the initial complex elements stored in V0 and V1 can be used as one initial complex element group, and the initial complex elements stored in V2 and V3 can be used as another initial complex element group. In this way, when the assembly load instruction LD1 loads the four registers mode and m is 4, it can be divided into two initial complex element groups, with each group containing two initial complex elements.

[0136] For the initial complex element group of the first sub-block, the processor uses the initial complex element group of the first sub-block as the exchange unit to perform imaginary part exchange on the initial complex elements of the first sub-block within the group to obtain the target complex element of the first sub-block. For example, the imaginary part data of the initial complex element stored in V0 is exchanged with the imaginary part data of the initial complex element stored in V1. The initial complex element stored in V0 after the exchange is the target complex element. That is, V0 (real part) and V1 (imaginary part) constitute one target complex element of the first sub-block. Similarly, V2 (real part) and V3 (imaginary part) constitute another target complex element of the first sub-block.

[0137] In this embodiment, for complex matrix multiplication operations of ZGEMM, the processor divides the first complex matrix into blocks and swaps the imaginary parts of the first blocks. This allows for the use of instructions with higher throughput to complete data loading, more flexible modification of the complex multiplication assembly algorithm, reduction of pipeline congestion, and improvement of the computational efficiency of complex matrix multiplication. This, in turn, enhances computing power, meets the ever-increasing computing power requirements of the ARM architecture, and improves processor performance.

[0138] Figure 12 Flowchart of the data processing method provided in the embodiments of this application Figure 6 ,like Figure 12As shown, in an optional implementation, step S403, in which the processor obtains each initial complex element of the second sub-block based on the second real part data and the second imaginary part data of the second sub-block, and performs real-imaginary part swapping to obtain each target complex element of the second sub-block, may include: S601. The processor loads the second real part data and the second imaginary part data from the memory address of the second complex matrix, obtains the initial complex elements of the second sub-block, and loads them into the fourth register.

[0139] The processor uses the assembly load instruction LD1 to load the second real part and the second imaginary part of the second complex matrix from its memory address, and then retrieves and loads the initial complex elements of the second sub-block into the fourth register to complete the loading of the complex elements. The fourth register simultaneously stores the real and imaginary parts of the initial complex elements of the first sub-block.

[0140] The number of fourth registers is determined by the register loading mode of the assembly load instruction LD1. If the register loading mode is four-register mode, the number of fourth registers is 4; if the register loading mode is two-register mode, the number of fourth registers is 2.

[0141] For example, the assembly load instruction LD1 loads in four-register mode with n = 4. The four complex elements of the second sub-block are stored as [8, 10, 9, 11, 12, 14, 13, 15]. Eight double-precision floating-point numbers (four second real parts and four second imaginary parts) are loaded from the memory address of the second complex matrix into vector registers V4, V5, V6, and V7. V4 is [8, 10], V5 is [9, 11], V6 is [12, 14], and V7 is [13, 15]. This means that the second real part 8 and the second imaginary part 10 are stored in V4, the second real part 9 and the second imaginary part 11 are stored in V5, the second real part 12 and the second imaginary part 14 are stored in V6, and the second real part 13 and the second imaginary part 15 are stored in V7. Each register contains two double-precision numbers (32 bytes in total), which contain the real and imaginary parts of the four complex elements of the second sub-block.

[0142] S602. The processor reads each initial complex element of the second sub-block from the fourth register and swaps the real and imaginary parts to obtain each target complex element of the second sub-block.

[0143] The processor reads each initial complex element of the second sub-block from the fourth register, determines the complex element to be swapped from the multiple initial complex elements of the second sub-block, and swaps the real and imaginary parts of the initial complex elements and the complex element to be swapped to obtain the target complex elements of the second sub-block. By performing imaginary part swapping on all the multiple initial complex elements of the second sub-block in this way, multiple target complex elements of the second sub-block can be obtained.

[0144] In an optional implementation, step S602 above, in which the processor reads each initial complex element of the second sub-block from the fourth register and performs a real-imaginary part swap to obtain each target complex element of the second sub-block, may include: The processor reads the initial complex elements of the second sub-block from the fourth register; The processor groups the initial complex elements of the second sub-block to obtain the initial complex element groups of the second sub-block; The processor swaps the real and imaginary parts of each initial complex element group in the second sub-block to obtain each target complex element of the second sub-block.

[0145] The processor reads each initial complex element of the second sub-block from the fourth register and groups each initial complex element of the second sub-block to obtain each initial complex element group of the second sub-block. Each group includes at least two initial complex elements of the second sub-block. The number of target complex elements corresponding to an initial complex element group is the same as the number of initial complex elements included in the group.

[0146] For example, the initial complex elements stored in V4 and V5 can be used as one initial complex element group, and the initial complex elements stored in V6 and V7 can be used as another initial complex element group. In this way, when the assembly load instruction LD1 loads the four registers mode and n is 4, it can be divided into two initial complex element groups. Each group contains two initial complex elements, which correspond to two target complex elements.

[0147] For the initial complex element group of the second sub-block, the processor uses the initial complex element group of the second sub-block as the exchange granularity to perform real and imaginary part exchange on the initial complex elements of the second sub-block within the group to obtain the target complex element of the second sub-block. For example, the imaginary part data of the initial complex element stored in V4 and the real part data of the initial complex element stored in V5 are exchanged. That is, the real part data located in V4.D[0] and the real part data located in V5.D[0] constitute one target complex element of the second sub-block, and the imaginary part data located in V4.D[1] and the imaginary part data located in V5.D[1] constitute another target complex element of the second sub-block. Among them, the imaginary part data located in V4.D[1] becomes the real part data of the other target complex element.

[0148] Wherein, V4.D[0] represents the first double-precision floating-point number in the V4 register, and V4.D[1] represents the second double-precision floating-point number in the V4 register. V4 includes two double-precision floating-point numbers. The first double-precision floating-point number is the real part of the initial complex element stored in V4, and the second double-precision floating-point number is the imaginary part of the initial complex element stored in V4. The others follow the same pattern.

[0149] For example, if a×b is 8×4, then for the first complex matrix, [0,2] is stored in V0, [1,3] in V1, [4,6] in V2, and [5,7] in V3. For the second complex matrix, [8,10] is stored in V4, [9,11] in V5, [12,14] in V6, and [13,15] in V7. The following explains the complex matrix multiplication process of ZGEMM: First, perform the first set of complex number operations: use the first target complex number element of the second sub-block (real part located in V4.D[0], imaginary part located in V5.D[0], denoted as [8,9]) to perform complex multiplication and accumulation with the first target complex number element of the first sub-block (V0 (real part), V1 (imaginary part), denoted as [0,3]). The real part of the calculation result is stored in vector register V8 and the imaginary part is stored in vector register V9. At the same time, use the first target complex number element of the second sub-block (real part located in V4.D[0], imaginary part located in V5.D[0], denoted as [8,9]) to perform complex multiplication and accumulation with the second target complex number element of the first sub-block (V2 (real part), V3 (imaginary part), denoted as [4,7]). The real part of the calculation result is stored in vector register V10 and the imaginary part is stored in vector register V11.

[0150] Then, the second set of complex number operations is performed: the second target complex number element of the second sub-block (real part located in V4.D[1], imaginary part located in V5.D[1], denoted as [10,11]) is multiplied and accumulated with the first target complex number element of the first sub-block (V0 (real part), V1 (imaginary part), denoted as [0,3]). The real part of the result is stored in vector register V12 and the imaginary part is stored in vector register V13. At the same time, the second target complex number element of the second sub-block (real part located in V4.D[1], imaginary part located in V5.D[1], denoted as [10,11]) is multiplied and accumulated with the second target complex number element of the first sub-block (V2 (real part), V3 (imaginary part), denoted as [4,7]). The real part of the result is stored in vector register V14 and the imaginary part is stored in vector register V15.

[0151] Then perform the third set of complex number operations: using the third target complex number element of the second sub-block (real part located in V6.D[0], imaginary part located in V7.D[0], denoted as [12,13]), perform complex multiplication and accumulation with the first target complex number element of the first sub-block (V0 (real part), V1 (imaginary part), denoted as [0,3]), and store the real part of the calculation result in vector register V16 and the imaginary part in vector register V17. At the same time, using the third target complex number element of the second sub-block (real part located in V6.D[0], imaginary part located in V7.D[0], denoted as [12,13]), perform complex multiplication and accumulation with the second target complex number element of the first sub-block (V2 (real part), V3 (imaginary part), denoted as [4,7]), and store the real part of the calculation result in vector register V18 and the imaginary part in vector register V19.

[0152] Then perform the fourth set of complex number operations: use the fourth target complex number element of the second sub-block (real part located in V6.D[1], imaginary part located in V7.D[1], denoted as [14,15]) to perform complex multiplication and accumulation with the first target complex number element of the first sub-block (V0 (real part), V1 (imaginary part), denoted as [0,3]). The real part of the calculation result is stored in vector register V20 and the imaginary part is stored in vector register V21. At the same time, use the fourth target complex number element of the second sub-block (real part located in V6.D[1], imaginary part located in V7.D[1], denoted as [14,15]) to perform complex multiplication and accumulation with the second target complex number element of the first sub-block (V2 (real part), V3 (imaginary part), denoted as [4,7]). The real part of the calculation result is stored in vector register V22 and the imaginary part is stored in vector register V23.

[0153] It should be noted that the first and second sub-blocks are in one-to-one correspondence. A group of sub-blocks includes one first sub-block and one second sub-block. Before calculation, the results stored in V8 to V23 are cleared to zero. The calculation and accumulation of the real part (stored in vector register V8) and imaginary part (stored in vector register V9) of the first column of the complex elements of the target output matrix C for the current group of sub-blocks means that after calculating the first column of the complex elements of the target output matrix C, the first column of the complex elements of the target output matrix C calculated for the previous group of sub-blocks needs to be accumulated (adding the real parts and the imaginary parts). This process is repeated until the finally accumulated real part is stored in V8 and the imaginary part is stored in V9, which is then used as the first column of the complex elements of the target output matrix C. The accumulation process of other registers is similar and will not be described in detail here.

[0154] Specifically, the complex elements whose real parts are stored in V8 and imaginary parts in V9 are used as the first column of the final target output matrix C. The complex elements whose real parts are stored in V10 and imaginary parts in V11 are used as the second column of the final target output matrix C. The complex elements whose real parts are stored in V12 and imaginary parts in V13 are used as the third column of the final target output matrix C. The complex elements whose real parts are stored in V14 and imaginary parts in V15 are used as the fourth column of the final target output matrix C. The accumulated real part is stored in V16 and the imaginary part is stored in V17 as the fifth column of the final target output matrix C. The accumulated real part is stored in V18 and the imaginary part is stored in V19 as the sixth column of the final target output matrix C. The accumulated real part is stored in V20 and the imaginary part is stored in V21 as the sixth column of the final target output matrix C. The accumulated real part is stored in V22 and the imaginary part is stored in V23 as the seventh column of the final target output matrix C.

[0155] In this embodiment, for complex matrix multiplication operations of ZGEMM, the processor divides the second complex matrix into blocks and swaps the real and imaginary parts of the second blocks. This allows for the use of instructions with higher throughput to complete data loading, more flexible modification of the complex multiplication assembly algorithm, reduction of pipeline congestion, and improvement of the computational efficiency of complex matrix multiplication. This, in turn, enhances computing power, meets the ever-increasing computing power requirements of the ARM architecture, and improves processor performance.

[0156] It should be noted that this scheme, through similar transformation logic, can perform general complex matrix multiplication CGEMM and ZGEMM in TN (A is a pure transpose matrix, B is unchanged), NT (A is unchanged, B is a pure transpose matrix), NN (both A and B are unchanged), TT (both A and B are pure transpose matrices), RR (both A and B are pure conjugate matrices), TR (A is a pure transpose matrix, B is a pure conjugate matrix), NR (A is unchanged, B is a pure conjugate matrix), and RN (A is a pure conjugate matrix, B is unchanged). Complex matrix multiplication operations are performed under the following 16 modes: RT (A is a pure conjugate matrix, B is a pure transpose matrix), TC (A is a pure transpose matrix, B is a conjugate transpose matrix), NC (A is unchanged, B is a conjugate transpose matrix), RC (A is a pure conjugate matrix, B is a conjugate transpose matrix), CC (A and B are both conjugate transpose matrices), CT (A is a conjugate transpose matrix, B is a pure transpose matrix), CN (A is a conjugate transpose matrix, B is unchanged), and CR (A is a conjugate transpose matrix, B is a pure conjugate matrix).

[0157] Special single-precision complex matrix multiplication methods such as CHEMM, CHER2K, CHERK, CSYMM, CSYRK, CSYR2K, and CTRMM call the assembly kernel function of CGEMM to complete the calculation, while special double-precision complex matrix multiplication methods such as ZHEMM, ZHER2K, ZHERK, ZSYMM, ZSYRK, ZSYR2K, and ZTRMM call the assembly kernel function of ZGEMM to complete the calculation. Therefore, by modifying the corresponding packing functions of CHEMM, CHER2K, CHERK, CSYMM, CSYRK, CSYR2K, CTRMM, ZHEMM, ZHER2K, ZHERK, ZSYMM, ZSYRK, ZSYR2K, and ZTRMM, and then calling the optimized assembly kernel functions of CGEMM and ZGEMM, the complex matrix multiplication operations of these 14 functions in the above 16 modes can be implemented simultaneously.

[0158] In some embodiments, the test dimension is 4096 to 16384. A test dimension of 4096 means that the dimensions of matrices A, B, and C are all 4096×4096, and a test dimension of 4096 means that the dimensions of matrices A, B, and C are all 16384×16384. Within the above test dimension range, for the number of threads 1, 16, 32, and 64, the speedup ratio of single-precision complex matrix multiplication and the speedup ratio of double-precision complex matrix multiplication before and after optimization are as follows: Figures 13 to 16 As shown.

[0159] Figure 13 This is a schematic diagram illustrating the speedup ratio of single-threaded single-precision complex matrix multiplication in an embodiment of this application. Figure 14 This is a schematic diagram illustrating the speedup ratio of multi-threaded single-precision complex matrix multiplication provided in an embodiment of this application. Figure 15 This diagram illustrates the speedup ratio of double-precision complex matrix multiplication in a single-threaded environment, as provided in an embodiment of this application. Figure 16 This is a schematic diagram illustrating the speedup of double-precision complex matrix multiplication under multithreading in an embodiment of this application.

[0160] like Figures 13 to 16 As shown, the horizontal axis represents the eight single-precision complex matrix multiplication functions (CGEMM, CHEMM, CHER2K, CHERK, CSYMM, CSYRK, CSYR2K, CTRMM), and the vertical axis represents the speedup ratio (performance after optimization / performance before optimization).

[0161] As can be seen, the speedup ratio of single-precision complex matrix multiplication and double-precision complex matrix multiplication is improved under both single-threaded and multi-threaded scenarios after adopting this solution. Therefore, this solution can simultaneously achieve efficient optimization of general and special complex matrix operations, and has stability in both single-threaded and multi-threaded scenarios.

[0162] Figure 17 Schematic diagram of the data processing apparatus provided in the embodiments of this application Figure 1 This device can be integrated into the processor.

[0163] like Figure 17 As shown, the device may include: Block module 701 is used to respond to application instructions, call preset assembly kernel functions, and divide the first complex matrix and the second complex matrix of complex matrix multiplication into blocks respectively to obtain each first sub-block and each second sub-block; The arrangement module 702 is used to rearrange the first real part data and the first imaginary part data of the first sub-block according to the preset arrangement rules to generate each target complex element of the first sub-block, wherein the real part data of each target complex element of the first sub-block are arranged together and the imaginary part data are arranged together. The arrangement module 702 is also used to rearrange the second real part data and the second imaginary part data of the second sub-block according to the preset arrangement rules to generate each target complex element of the second sub-block, wherein the real part data of each target complex element of the second sub-block are arranged together and the imaginary part data are arranged together. The operation module 703 is used to perform complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the target output matrix.

[0164] In an optional implementation, the orchestration module 702 is specifically used for: Load the first real part data and the first imaginary part data from the memory address of the first complex matrix into the first real part register and the first imaginary part register, respectively; Read the first real part data and the first imaginary part data from the first real part register and the first imaginary part register, respectively; The first real part data and the first imaginary part data are rearranged to generate the target complex number elements of the first sub-block.

[0165] In an optional implementation, the orchestration module 702 is specifically used for: Load the second real part data and the second imaginary part data from the memory address of the second complex matrix into the second real part register and the second imaginary part register, respectively; Read the second real part data and the second imaginary part data from the second real part register and the second imaginary part register, respectively; The second real part data and the second imaginary part data are rearranged to generate the target complex number elements of the second sub-block.

[0166] In an optional implementation, the arithmetic module 703 is specifically used for: Complex number multiplication is performed on each target complex number element of the first sub-block and each target complex number element of the second sub-block to obtain the complex number operation result; The target output matrix is ​​obtained by summing the results of complex number operations.

[0167] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.

[0168] Figure 18 Schematic diagram of the data processing apparatus provided in the embodiments of this application Figure 2 This device can be integrated into the processor.

[0169] like Figure 18 As shown, the device may include: Block module 801 is used to respond to application instructions, call preset assembly kernel functions, and divide the first complex matrix and the second complex matrix of complex matrix multiplication into blocks respectively to obtain each first sub-block and each second sub-block; The exchange module 802 is used to obtain each initial complex element of the first sub-block based on the first real part data and the first imaginary part data of the first sub-block, and to perform imaginary part exchange to obtain each target complex element of the first sub-block. The exchange module 802 is also used to obtain each initial complex element of the second sub-block based on the second real part data and the second imaginary part data of the second sub-block, and to exchange the real and imaginary parts to obtain each target complex element of the second sub-block; The operation module 803 is used to perform complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the target output matrix.

[0170] In an optional implementation, the switching module 802 is specifically used for: Load the first real part data and the first imaginary part data from the memory address of the first complex matrix respectively, obtain the initial complex elements of the first sub-block, and load them into the third register; Read the initial complex elements of the first sub-block from the third register and swap their imaginary parts to obtain the target complex elements of the first sub-block.

[0171] In an optional implementation, the switching module 802 is specifically used for: Read the initial complex elements of the first sub-block from the third register; Group the initial complex elements of the first sub-block to obtain the initial complex element groups of the first sub-block; The imaginary parts of each initial complex element group in the first sub-block are swapped to obtain each target complex element in the first sub-block.

[0172] In an optional implementation, the switching module 802 is specifically used for: Load the second real part data and the second imaginary part data from the memory address of the second complex matrix respectively, obtain the initial complex elements of the second sub-block, and load them into the fourth register; Read the initial complex elements of the second sub-block from the fourth register and swap the real and imaginary parts to obtain the target complex elements of the second sub-block.

[0173] In an optional implementation, the switching module 802 is specifically used for: Read the initial complex elements of the second sub-block from the fourth register; Group the initial complex elements of the second sub-block to obtain the initial complex element groups of the second sub-block; The real and imaginary parts of each initial complex element group in the second sub-block are swapped to obtain each target complex element of the second sub-block.

[0174] In an optional implementation, the arithmetic module 803 is specifically used for: Complex number multiplication is performed on each target complex number element of the first sub-block and each target complex number element of the second sub-block to obtain the complex number operation result; The target output matrix is ​​obtained by summing the results of complex number operations.

[0175] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.

[0176] Figure 19 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application, such as... Figure 19 As shown, the device may include a processor 901 and a memory 902. The memory 902 stores machine-readable instructions that can be executed by the processor 901. When the electronic device is running, the processor 901 communicates with the memory 902 and executes the machine-readable instructions to perform the above-described method.

[0177] This application also provides a computer-readable storage medium storing a computer program, which is executed by a processor to perform the above-described method.

[0178] In this embodiment, the computer program, when run by the processor, can also execute other machine-readable instructions to perform other methods as described in the embodiments. For details on the specific execution steps and principles, please refer to the description of the embodiments, which will not be repeated here.

[0179] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0180] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application. All should be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.

Claims

1. A data processing method, characterized in that, include: In response to the application instruction, the processor calls the preset assembly kernel function to divide the first complex matrix and the second complex matrix of the complex matrix multiplication operation into blocks, resulting in each first sub-block and each second sub-block; The processor rearranges the first real part data and the first imaginary part data of the first sub-block according to a preset arrangement rule to generate each target complex element of the first sub-block, wherein the real part data of each target complex element of the first sub-block is arranged together and the imaginary part data is arranged together. The processor rearranges the second real part data and the second imaginary part data of the second sub-block according to the preset arrangement rules to generate each target complex element of the second sub-block, wherein the real part data of each target complex element of the second sub-block are arranged together and the imaginary part data are arranged together. The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the target output matrix.

2. The method of claim 1, wherein, The processor rearranges the first real part data and the first imaginary part data of the first sub-block according to a preset arrangement rule to generate each target complex element of the first sub-block, including: The processor loads the first real part data and the first imaginary part data from the memory address of the first complex matrix into the first real part register and the first imaginary part register, respectively; The processor reads the first real part data and the first imaginary part data from the first real part register and the first imaginary part register, respectively; The processor rearranges the first real part data and the first imaginary part data to generate the target complex elements of the first sub-block.

3. The method of claim 1, wherein, The processor rearranges the second real part and the second imaginary part of the second sub-block according to the preset arrangement rules to generate the target complex elements of the second sub-block, including: The processor loads the second real part data and the second imaginary part data from the memory address of the second complex matrix into the second real part register and the second imaginary part register, respectively; The processor reads the second real part data and the second imaginary part data from the second real part register and the second imaginary part register, respectively; The processor rearranges the second real part data and the second imaginary part data to generate the target complex elements of the second sub-block.

4. The method of claim 1, wherein, The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain a target output matrix, including: The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the complex number operation result; The processor accumulates the results of the complex number operations to obtain the target output matrix.

5. A data processing method, characterized by, include: In response to the application instruction, the processor calls the preset assembly kernel function to divide the first complex matrix and the second complex matrix of the complex matrix multiplication operation into blocks, resulting in each first sub-block and each second sub-block; The processor obtains each initial complex element of the first sub-block based on the first real part data and the first imaginary part data of the first sub-block, and performs imaginary part swapping to obtain each target complex element of the first sub-block. The processor obtains each initial complex element of the second sub-block based on the second real part data and the second imaginary part data of the second sub-block, and performs real-imaginary part swapping to obtain each target complex element of the second sub-block; The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the target output matrix.

6. The method of claim 5, wherein, The processor obtains each initial complex element of the first sub-block based on the first real part data and the first imaginary part data of the first sub-block, and performs imaginary part swapping to obtain each target complex element of the first sub-block, including: The processor loads the first real part data and the first imaginary part data from the memory address of the first complex matrix, obtains each initial complex element of the first sub-block, and loads them into the third register. The processor reads each initial complex element of the first sub-block from the third register and performs imaginary part swapping to obtain each target complex element of the first sub-block.

7. The method of claim 6, wherein, The processor reads each initial complex element of the first sub-block from the third register and performs imaginary part swapping to obtain each target complex element of the first sub-block, including: The processor reads each initial complex element of the first sub-block from the third register; The processor groups the initial complex elements of the first sub-block to obtain the initial complex element groups of the first sub-block; The processor performs imaginary part swapping on each initial complex element group of the first sub-block to obtain each target complex element of the first sub-block.

8. The method according to claim 5, characterized in that, The processor obtains each initial complex element of the second sub-block based on the second real part data and the second imaginary part data of the second sub-block, and performs real-imaginary part swapping to obtain each target complex element of the second sub-block, including: The processor loads the second real part data and the second imaginary part data from the memory address of the second complex matrix, obtains each initial complex element of the second sub-block, and loads them into the fourth register; The processor reads each initial complex element of the second sub-block from the fourth register and swaps the real and imaginary parts to obtain each target complex element of the second sub-block.

9. The method of claim 8, wherein, The processor reads each initial complex element of the second sub-block from the fourth register and swaps its real and imaginary parts to obtain each target complex element of the second sub-block, including: The processor reads each initial complex element of the second sub-block from the fourth register; The processor groups the initial complex elements of the second sub-block to obtain the initial complex element groups of the second sub-block; The processor swaps the real and imaginary parts of each initial complex element group in the second sub-block to obtain each target complex element of the second sub-block.

10. The method of claim 5, wherein, The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain a target output matrix, including: The processor performs complex multiplication operations on each target complex element of the first sub-block and each target complex element of the second sub-block to obtain the complex number operation result; The processor accumulates the results of the complex number operations to obtain the target output matrix.

11. An electronic device, comprising: include: A processor and a memory, the memory storing machine-readable instructions executable by the processor, wherein when the electronic device is running, the processor communicates with the memory and executes the machine-readable instructions to perform the method according to any one of claims 1 to 10.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the method according to any one of claims 1 to 10.