Abstract:
The invention relates to a processor comprising, in its instruction set, a bit matrix multiplication instruction (sbmm) having a first double precision operand (A) representing a first matrix to multiply, a second operand (B) explicitly designating any two single precision registers whose joint contents represent a second matrix to multiply, and a destination parameter (C) explicitly designating any two single precision registers for jointly containing a matrix representing the result of the multiplication.

Description:
FIELD 
       [0001]    The invention relates to a processor having data reorganization functionality, in particular using a bit matrix multiplication unit. 
       BACKGROUND 
       [0002]    A bit matrix multiplication unit (BMM) allows a reorganization of data in a single instruction cycle. Many types of reorganization are possible, up to a reorganization of the individual bits of the processed data. The article [Yedidya Hilewitz et al. “Bit Matrix Multiplication in Commodity Processors”, IEEE International Conference on Application-Specific Systems, Architectures and Processors, 2008] describes applications of BMM units. 
         [0003]    In practice, a BMM operator is used with one of its operands at a constant value selected to define a particular operation on the contents of the other operand. Constants chosen for the first operand may define permutations of the rows of the matrix assigned to the second operand, i.e. permutations of words represented by the rows. Constants chosen for the second operand may define permutations of the columns of the matrix assigned to the first operand, i.e. permutations of bits according to a same pattern applied to all the rows of the matrix. 
         [0004]    However, a BMM unit finds limits in terms of efficiency when the reorganizations mix data from multiple matrices. 
       SUMMARY 
       [0005]    A processor is generally provided, comprising, in its instruction set, a bit matrix multiplication instruction having a first double precision operand representing a first matrix to multiply, a second operand explicitly designating any two single precision registers whose joint contents represent a second matrix to multiply, and a destination parameter explicitly designating any two single precision registers for jointly containing a matrix representing the result of the multiplication. 
         [0006]    The processor may comprise a register file of single precision registers configured for, upon reading, joining the contents of two individually selected registers in an output word of double precision, and, upon writing, splitting an input double precision word into two individually selected registers; a bit matrix multiplication unit configured for receiving two multiplicand matrices in the form of double precision words and writing a result matrix in the form of a double precision word in the register file; an instruction processing unit configured for, upon execution of a bit matrix multiplication instruction:
       providing the first operand directly as a first of the two multiplicands of the bit matrix multiplication unit,   using the second operand to read in the register file the second multiplicand of the matrix multiplication unit, and   using the destination parameter to write in the register file the result provided by the bit matrix multiplication unit.       
 
         [0010]    The bit matrix multiplication unit may further be configured to respond to a variant of the bit matrix multiplication instruction by providing a double precision result corresponding to the transposed matrix of the result of the multiplication. 
         [0011]    A bit matrix multiplication method may be provided, comprising the steps of representing bit-matrices by double precision words; reading two individually selected registers from a register file of single precision registers; joining the contents of the two read registers to form a first multiplicand matrix; multiplying the first multiplicand matrix by a second multiplicand matrix; splitting the multiplication result into two single precision words; and writing the two single precision words in two individually selected registers of the register file. 
         [0012]    The method may comprise the further steps of defining the second multiplicand matrix directly in a first operand of a bit matrix multiplication instruction; defining the registers for forming the first multiplicand matrix in a second operand of the bit matrix multiplication instruction; and defining the registers for holding the multiplication result in a destination parameter of the bit matrix multiplication instruction. 
     
    
     
       BRIEF DESCRIPTION OF DRAWINGS 
         [0013]    Other advantages and features will become more clearly apparent from the following description of particular embodiments of the invention provided for exemplary purposes only and represented in the appended drawings, in which: 
           [0014]      FIG. 1  is a block diagram of a BMM unit designed to handle 8×8-bit matrices; 
           [0015]      FIG. 2  illustrates the operation of a BMM unit; 
           [0016]      FIG. 3  is a block diagram of a BMM unit associated with a processor register file of particular structure; 
           [0017]      FIG. 4  illustrates an operation for interleaving words from two packets; 
           [0018]      FIGS. 5A to 5C  illustrate data in various phases of the execution of a particular BMM instruction used in processing the reorganization of  FIG. 4 ; 
           [0019]      FIG. 6  illustrates a bit interleaving operation on two packets; and 
           [0020]      FIGS. 7A to 7D  illustrate data in various phases of the execution of two particular BMM instructions used in processing the reorganization of  FIG. 6 . 
       
    
    
     DESCRIPTION OF EMBODIMENTS 
       [0021]      FIG. 1  is a block diagram of a BMM unit. The size of the manipulated matrices is generally square and conforms to one of the precision formats supported by the processor. 
         [0022]    A 32-bit processor is considered below as an example, supporting a “single” precision of 32-bits and a “double” precision of 64 bits. In this context, the matrices are 8×8-bit matrices, each of which can be represented by a double precision word (64 bits). 
         [0023]    The BMM unit thus receives two 64-bit words A and B representing two multiplicand matrices of 8×8 bits MATa and MATb. The matrices MATa and MATb may be multiplied by a hard-wired circuit MMULT to produce a result matrix MATc of 8×8 bits. This matrix MATc is provided by the BMM unit in the form of a 64-bit word C. 
         [0024]    In the following it is considered that the bytes forming a 64-bit word representing a matrix are sorted by increasing weight from the first row to the eighth row of the matrix, and that the bits of each byte are sorted by decreasing weights from the first column to the eighth column of the matrix. Thus, if b ij  designates the bit of weight j of the byte of weight i of a 64-bit word, the corresponding matrix is expressed as: 
         [0000]    
       
         
           
               
             
               [ 
               
                 
                   
                     
                       b 
                       07 
                     
                   
                   
                     
                       b 
                       06 
                     
                   
                   
                     
                       b 
                       05 
                     
                   
                   
                     
                       b 
                       04 
                     
                   
                   
                     
                       b 
                       03 
                     
                   
                   
                     
                       b 
                       02 
                     
                   
                   
                     
                       b 
                       01 
                     
                   
                   
                     
                       b 
                       00 
                     
                   
                 
                 
                   
                     
                       b 
                       17 
                     
                   
                   
                     
                       b 
                       16 
                     
                   
                   
                     
                       b 
                       15 
                     
                   
                   
                     
                       b 
                       14 
                     
                   
                   
                     
                       b 
                       13 
                     
                   
                   
                     
                       b 
                       12 
                     
                   
                   
                     
                       b 
                       11 
                     
                   
                   
                     
                       b 
                       10 
                     
                   
                 
                 
                   
                     
                       b 
                       27 
                     
                   
                   
                     
                       b 
                       26 
                     
                   
                   
                     
                       b 
                       25 
                     
                   
                   
                     
                       b 
                       24 
                     
                   
                   
                     
                       b 
                       23 
                     
                   
                   
                     
                       b 
                       22 
                     
                   
                   
                     
                       b 
                       21 
                     
                   
                   
                     
                       b 
                       20 
                     
                   
                 
                 
                   
                     
                       b 
                       37 
                     
                   
                   
                     
                       b 
                       36 
                     
                   
                   
                     
                       b 
                       35 
                     
                   
                   
                     
                       b 
                       34 
                     
                   
                   
                     
                       b 
                       33 
                     
                   
                   
                     
                       b 
                       32 
                     
                   
                   
                     
                       b 
                       31 
                     
                   
                   
                     
                       b 
                       30 
                     
                   
                 
                 
                   
                     
                       b 
                       47 
                     
                   
                   
                     
                       b 
                       46 
                     
                   
                   
                     
                       b 
                       45 
                     
                   
                   
                     
                       b 
                       44 
                     
                   
                   
                     
                       b 
                       43 
                     
                   
                   
                     
                       b 
                       42 
                     
                   
                   
                     
                       b 
                       41 
                     
                   
                   
                     
                       b 
                       40 
                     
                   
                 
                 
                   
                     
                       b 
                       57 
                     
                   
                   
                     
                       b 
                       56 
                     
                   
                   
                     
                       b 
                       55 
                     
                   
                   
                     
                       b 
                       54 
                     
                   
                   
                     
                       b 
                       53 
                     
                   
                   
                     
                       b 
                       52 
                     
                   
                   
                     
                       b 
                       51 
                     
                   
                   
                     
                       b 
                       50 
                     
                   
                 
                 
                   
                     
                       b 
                       67 
                     
                   
                   
                     
                       b 
                       66 
                     
                   
                   
                     
                       b 
                       65 
                     
                   
                   
                     
                       b 
                       64 
                     
                   
                   
                     
                       b 
                       63 
                     
                   
                   
                     
                       b 
                       62 
                     
                   
                   
                     
                       b 
                       61 
                     
                   
                   
                     
                       b 
                       60 
                     
                   
                 
                 
                   
                     
                       b 
                       77 
                     
                   
                   
                     
                       b 
                       76 
                     
                   
                   
                     
                       b 
                       75 
                     
                   
                   
                     
                       b 
                       74 
                     
                   
                   
                     
                       b 
                       73 
                     
                   
                   
                     
                       b 
                       72 
                     
                   
                   
                     
                       b 
                       71 
                     
                   
                   
                     
                       b 
                       70 
                     
                   
                 
               
               ] 
             
           
         
       
     
         [0025]    As previously indicated, one of the operands receives a constant which defines the reorganization to operate in the other, variable operand. If the BMM unit performs the multiplication A×B, by choosing a constant for the operand A, a reorganization is defined among the rows of the matrix conveyed in operand B, i.e. among the bytes of operand B. By choosing a constant for the operand B, a corresponding reorganization is defined among the columns of the matrix conveyed by the operand A. The cases considered below by way of example can be processed using constants for the operand A. 
         [0026]    A particular constant is that associated with the identity matrix, comprising 1s only in the first diagonal. For an 8×8 matrix representing 64-bit operands B, the identity matrix is expressed in hexadecimal by: 
         [0027]    MID=0x80 40 20 10 08 04 02 01 
         [0028]    Each pair of digits of a constant represents a byte or row of the matrix, the least significant byte (0x01) corresponding to the first row of the matrix. 
         [0029]    From this constant MID, a hexadecimal constant MOP may be built defining an arbitrary byte permutation operation. It is considered that the weights of the bytes of the operands and of the results increase from right to left from the value 0. Then, if the position i of the constant MOP contains the value 0xXY, where 0xXY is the content at position j of the constant MID, the operation produces a result C whose byte at position i receives the byte at position j of the second operand B. 
         [0030]      FIG. 2  illustrates this functionality with an example. The first operand A receives a constant MOP whose byte of weight  2  contains the value 0x20, for instance. The operand B receives eight bytes B 0  to B 7 . The byte of value 0x20 in constant MOP identifies weight  5  in the identity matrix MID. In those circumstances, the byte of weight  5 , B 5 , of operand B is placed as weight  2  in the result C. 
         [0031]    According to this technique, several useful constants may be defined, for example: 
         [0032]    0x01 02 04 08 10 20 40 80: reverse the byte order in the second operand B, 
         [0033]    0x80 40 08 04 20 10 02 01: interleaving the 16-bit words of the two 32-bit words forming the operand B, 
         [0034]    0x80 08 40 04 20 02 10 01: interleaving the bytes of the two 32-bit words forming the operand B, etc. 
         [0035]    Any reorganization of bytes within a same operand B is thus possible by suitably building a constant MOP for operand A. However, there are situations where it is desired to reorganize data of a data sequence that does not fit in a matrix processed by the BMM unit. The data sequence may then be divided into several packets of the size of a matrix, and each packet may be processed in turn by the BMM unit. If the data of two consecutive packets should be mixed in a single multiplication result C, it may be necessary in conventional architectures to effect several transfers between registers to prepare the operands before they can be provided to the BMM unit. 
         [0036]      FIG. 3  is a partial block diagram of an embodiment of a processor with a BMM unit achieving reduction of the number of instruction cycles necessary to mix data from several packets, by using specific BMM instructions. 
         [0037]    The processor includes a register file REGS. The size of the registers is adapted to the processor architecture. In the context of a 32-bit processor, the registers also have a size of 32 bits, corresponding to single precision. The BMM unit is however designed to process words of double precision (64 bits). The register file is associated with a control circuit CTRL, which may be designed to provide simultaneously the contents of a register pair as a 64-bit multiplicand to the BMM unit. The control circuit may also be designed to write the result of the multiplication, of double precision, in a pair of registers. 
         [0038]    In a conventional processor architecture designed for thus using a pair of registers to handle double precision data, the instructions only identify the first register in the pair. The second register of the pair is implicitly the next register in the addressing system of the register file. Thus, the instructions manipulating double precision data can only identify even-numbered registers, knowing that the odd-numbered registers are reserved for forming implicit pairs with the registers identified in the instructions. 
         [0039]    The architecture of  FIG. 3  is designed so that instructions can explicitly identify any two registers to form a pair for holding a double precision word. In particular, a BMM instruction is provided to explicitly identify each of the two registers that together contain an operand, and each of the two registers that together receive the result. 
         [0040]    More specifically, to perform a matrix multiplication of the type C=MOPxB, the following BMM instruction may be provided: 
         [0041]    bmm $rx:$ry, MOP, $ri:$rj 
         [0042]    Where “$rx:$ry” designates the addresses of the two registers to use for receiving the result C, and “$ri:$rj” designates the addresses of the two registers that contain the multiplicand B. The notations without the sign “$” designate the contents of registers. The notation “MOP” designates an immediate double precision constant conveyed in the instruction, which is provided directly as multiplicand A to the BMM unit. It is assumed that the first register of the register pairs contains the least significant bytes and the second register the most significant bytes. The constant MOP is then expressed in the same format—for example, if the constant MOP is chosen equal to the identity matrix MID, it would be expressed in the form: 
         [0043]    MOP=0x08040201:0x80402010. 
         [0044]    An instruction register  30  is designed to provide in parallel the register addresses ($ri, $rj, $rx, $ry) conveyed by the bmm instruction to the control circuit CTRL, and the operand MOP as multiplicand A to the BMM unit. The control circuit is designed to join the contents of registers $ri and $rj to form the multiplicand B of the BMM unit, and to split the result C of the multiplication into the two registers $rx and $ry (the lower weight bytes being assigned to the first registers of the pairs). 
         [0045]    In some architectures, the operand A of the bmm instruction may also be of register type and, like the operand B, identify a pair of explicit registers $ru:$rv. 
         [0046]    In fact, in many processor architectures, immediate values conveyed in the instructions are used as the last parameter. Then it is preferred to use an instruction like: 
         [0047]    sbmm $rx:$ry, $ri:$rj, MOP 
         [0048]    Where 
         [0049]    sbmm C, B, A 
         [0050]    Produces the same result as 
         [0051]    bmm C, A, B 
         [0052]    The BMM unit is not changed—the prefix “s” (for “swapped”) of the sbmm instruction simply means that the operands of the instruction are swapped in wiring relative to the multiplicands of the BMM unit. 
         [0053]      FIG. 4  illustrates a first example of data reorganization consisting of interleaving 16-bit words of two packets of four 16-bit words. Such a type of reorganization may be useful for Single Instruction, Multiple Data (SIMD) processors. In a SIMD processor, a single instruction is provided simultaneously to several similar processing units that simultaneously process respective data lanes. In many situations, it is desired at certain processing stages to switch data to different lanes. 
         [0054]    The words of the first packet WA are designated wa 0  to wa 7  and the words of the second packet WB by wb 0  to wb 7 . The interleaving operation produces a sequence of eight 16-bit words WC where each word taken in packet WA is followed by the word of same weight of packet WB, as shown. 
         [0055]    With the architecture of  FIG. 3 , such an operation can be performed using only two sbmm instructions. For example, assuming that the two packets are initially contained in registers $r 0  to $r 3 : 
         [0056]    sbmm $r 10 :$r 11 , $r 0 :$r 2 , 0x20100201:0x80400804 
         [0057]    sbmm $r 12 :$r 13 , $r 1 :$r 3 , 0x20100201:0x80400804 
         [0058]      FIGS. 5A-5C  illustrate in more detail the operation of these instructions. 
         [0059]      FIG. 5A  shows the initial contents of registers $r 0  to $r 3 , in the form of 8×8 bit matrices in the previously specified format. The cells of the matrices simply indicate the indices ij of the bits. The pair of registers $r 0 :$r 1  contains the packet of words WA, and the indices are indicated in bold. The pair of registers $r 2 :$r 3  contains the packet WB, and the indices are indicated in italics. Each word, of 16 bits, occupies two consecutive rows of the corresponding matrix. The contents of the first registers of the pairs, associated with the lower weight words, are located in the upper half of the matrices. 
         [0060]    It shall be noted that each operand B of the sbmm instructions above designates a pair of registers that do not correspond to a same matrix of  FIG. 5A . In fact, each operand B designates a matrix constructed from one half of each of the two matrices of  FIG. 5A . 
         [0061]      FIG. 5B  shows the matrices used as operands B by the sbmm instructions. The ability to freely select the two registers used for forming the operand B allows, at no extra cost in instruction cycles, performing a preliminary reorganization, especially a reorganization involving the two packets WA and WB. More specifically, in  FIG. 5B , the operand B of the first sbmm instruction includes the first two words of the packet WA, taken in the register $r 0 , and the first two words of the packet WB, taken in register $r 2 . The operand B of the second sbmm instruction includes the last two words of the packet WA, taken in the register $r 1 , and the last two words of the packet WB, taken in the register $r 3 . 
         [0062]    The constant MID is shown to the right of the matrices in correspondence with the rows of the matrices. 
         [0063]    In  FIG. 5C , both sbmm instructions have been executed and the results have been written in the register pairs $r 10 :$r 11  and $r 12 :$r 13 , respectively. The resulting reorganization left the first two rows and the last two rows of each matrix unchanged and exchanged the last two rows of the first register with the first two rows of the second register. 
         [0064]    The value of the constant MOP is indicated to the right in correspondence with the rows of the matrices. It shall be noted that the pairs of digits of the constant MID in  FIG. 5B  have “followed” their respective rows in  FIG. 5C  to form the constant MOP. 
         [0065]    In a conventional architecture using pairs of implicit registers to convey double precision data, none of the matrices of  FIG. 5B  is usable directly as an operand B of a BMM instruction. Indeed, the registers of the pairs do not have consecutive addresses. It would first be necessary to exchange the contents of registers $r 1  and $r 2  of  FIG. 5A , which implies the execution of three register to register write instructions using a temporary register. In other words, the same operation would require five instructions for processing the two packets instead of two. 
         [0066]    To extend the capabilities of the processor, an instruction designated by sbmmt may be added for performing both a BMM operation and a transposition of the result matrix C. In other words, the execution of the instruction: 
         [0067]    sbmmt C, B, MOP 
         [0068]    Provides a result C that is the transposed of the matrix C produced by the instruction 
         [0069]    sbmm C, B, MOP 
         [0070]    Such an instruction sbmmt may use the same BMM unit as the sbmm instruction. The transposition may be achieved simply through the wiring of the output of the BMM unit. The instruction may be used to perform a simple transposition when the operand MOP is equal to the identity matrix MID. 
         [0071]      FIG. 6  illustrates a reorganization example where the sbmmt instruction is useful. This is a so-called “bit-slicing” operation performed by way of example on a sequence of 16 bytes b 0  to b 15  to produce eight 16-bit words w 0  to w 7 . The operation involves grouping in a word w i  the bits of weight i of the 16 bytes, the bytes being used per increasing weight. Such an operation may be performed using only two sbmmt instructions and two sbmm instructions. For example, assuming that the 16 bytes are initially contained in the registers $r 0  to $r 3  by increasing weights: 
         [0072]    sbmmt $r 0 :$r 1 , $r 0 :$r 1 , 0x08040201:0x80402010 
         [0073]    sbmmt $r 2 :$r 3 , $r 2 :$r 3 , 0x08040201:0x80402010 
         [0074]    sbmm $r 10 :$r 11 , $r 0 :$r 2 , 0x20021001:0x80084004 
         [0075]    sbmm $r 12 :$r 13 , $r 1 :$r 3 , 0x20021001:0x80084004 
         [0076]      FIGS. 7A-7D  illustrate in more detail the operation of these instructions in the same format as  FIGS. 5A to 5C . The constant MOP of the first two sbmmt instructions is the identity matrix MID. The result is that these instructions perform a simple transposition. 
         [0077]      FIG. 7A  shows the initial contents of the registers $r 0  to $r 3 , the pair of registers $r 0 :$r 1  containing bytes b 0 -b 7  of the sequence, and the pair of registers $r 2 :$r 3  containing bytes b 8 -b 15 . 
         [0078]      FIG. 7B  illustrates the results of the sbmmt instructions, results that are overwritten in registers $r 0  to $r 3 . The matrices of  FIG. 7A  have been transposed. 
         [0079]    The sbmmt instructions thus classify the bits of same weight of each byte in the same row, and the bits of a same byte in the same column. The weights of the bytes increase from right to left, and the weights of the bits increase from top to bottom. 
         [0080]      FIG. 7C  shows the matrices used as operands B by the sbmm instructions. More specifically, the operand B of the first sbmm instruction is formed by the contents of the register pair $r 0 :$r 2 , and the operand B of the second sbmm instruction is formed by the contents of the register pair $r 1 :$r 3 . 
         [0081]    The identity constant MID is illustrated to the right of the matrices in correspondence with the rows of the matrices. 
         [0082]    In  FIG. 7D , the two sbmm instructions have been executed and the results have been written in the register pairs $r 10 :$r 11  and $r 12 :$r 13 , respectively. 
         [0083]    The value of the constant MOP is indicated to the right in correspondence with the rows of the matrices. It shall be noted that the digit pairs of the constant MID of  FIG. 7C  have “followed” their respective rows in  FIG. 7D  to form the constant MOP. This constant is among those indicated above, operating the byte interleaving of the two 32-bit words of the operand B. 
         [0084]    In a conventional architecture using pairs of implicit registers to convey double precision data, none of the matrices of  FIG. 7C  is usable directly for operand B of a BMM instruction. Indeed, the registers of the pairs do not have consecutive addresses. It would first be required to exchange the contents of registers $r 1  and $r 2  of  FIG. 7B , which implies the execution of three register to register write instructions using a temporary register. In other words, the same operation would require seven instructions for processing the two packets instead of four. 
         [0085]    In certain processor architectures dedicated to cryptography, a specific processing unit may be provided for “bit-slicing”, which has a surface area that may be greater than that of a BMM unit. The processor architecture described herein provides, with a single BMM unit, and a set of instructions that can explicitly identify the registers to be used for double precision data, generic and flexible data reorganizing functions that are not restricted to specific technical areas.