WO2020116025A1 - コンパイル装置、コンパイル方法、及び非一時的なコンピュータ可読媒体 - Google Patents

コンパイル装置、コンパイル方法、及び非一時的なコンピュータ可読媒体 Download PDF

Info

Publication number
WO2020116025A1
WO2020116025A1 PCT/JP2019/040150 JP2019040150W WO2020116025A1 WO 2020116025 A1 WO2020116025 A1 WO 2020116025A1 JP 2019040150 W JP2019040150 W JP 2019040150W WO 2020116025 A1 WO2020116025 A1 WO 2020116025A1
Authority
WO
WIPO (PCT)
Prior art keywords
vector
data
word
instruction
register
Prior art date
Application number
PCT/JP2019/040150
Other languages
English (en)
French (fr)
Inventor
晃一 増田
Original Assignee
日本電気株式会社
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 日本電気株式会社 filed Critical 日本電気株式会社
Priority to JP2020559760A priority Critical patent/JP7115563B2/ja
Priority to US17/299,039 priority patent/US11829754B2/en
Publication of WO2020116025A1 publication Critical patent/WO2020116025A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/30007Arrangements for executing specific machine instructions to perform operations on data operands
    • G06F9/3001Arithmetic instructions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/30007Arrangements for executing specific machine instructions to perform operations on data operands
    • G06F9/30032Movement instructions, e.g. MOVE, SHIFT, ROTATE, SHUFFLE
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/16Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation
    • G06F8/4441Reducing the execution time required by the program code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/30007Arrangements for executing specific machine instructions to perform operations on data operands
    • G06F9/30036Instructions to perform operations on packed data, e.g. vector, tile or matrix operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/30076Arrangements for executing specific machine instructions to perform miscellaneous control operations, e.g. NOP
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30098Register arrangements

Definitions

  • the present disclosure relates to a compiling device, a compiling method, and a control program.
  • a compiling device has been proposed which improves the execution performance of a vector computer by converting an overlapping memory access into an object code with reduced memory access instructions when adjacent memory access instructions exist in the source program (for example, Patent Document 1). 1).
  • the compiling device disclosed in Patent Document 1 converts adjacent memory access instructions into one memory access instruction. Further, the compiling device generates an instruction to slide the data of the first vector register loaded by the one memory access instruction and store the data in the second vector register. Then, the compiling device generates an instruction for performing an operation on the data of the first vector register and the data of the second vector register.
  • Patent Document 1 since the compiler device of Patent Document 1 generates an instruction to slide the data of the first vector register and store it in the second vector register, there is a possibility that the elements used for the operation will be insufficient (Patent Document 1). Figure 4). In this case, the compiler device of Patent Document 1 needs to generate an additional vector instruction for load/store or operation in order to compensate for the lacking element, or a scalar instruction. That is, the compiler device of Patent Document 1 may not be able to sufficiently speed up the program because the source program is not optimized enough.
  • An object of the present disclosure is to provide a compiling device, a compiling method, and a control program that can realize speeding up of the program.
  • the compiling device is an arithmetic unit that includes, as operands, an element A[i], an element A[i+1], and an element [i+2 k ] of a (1/2) k word type (k is a natural number) array A.
  • a compilation processing unit is provided for converting a source program for repeatedly executing calculation processing for executing calculation while shifting the value of the subscript i (i is an integer of 0 or more) one by one. In the state where the first data unit group, which is used as the element A[i] in the repeated calculation process and each data unit is (1/2) k words, is packed from the memory in 1-word units.
  • a vector load instruction generation unit that generates a second vector load instruction for loading the second vector register as the second vector data in a state of being packed by the above, and a series of data strings of the first vector data and the second vector data.
  • a vector shift instruction generation unit that generates a first vector shift double instruction to be stored.
  • the compiling method includes an element A[i], an element A[i+1], and an element A[i+2 k ] of an array A of (1/2) k word type (k is a natural number) as operands.
  • a first vector load instruction for loading as vector data, and a second data unit group used as the element A[i+2 k ] in the repeated calculation processing are packed from the memory in units of one word.
  • Generating a second vector load instruction for loading the second vector register as the second vector data, and (1/2) k words as a series of the first vector data and the second vector data A first vector shift double instruction for storing a part of the data string obtained by the shift as third vector data corresponding to the element A[i+1] in a third vector register in a state of being packed in a unit of one word Generating.
  • the control program includes the element A[i], the element A[i+1], and the element A[i+2 k ] of the (1/2) k word type (k is a natural number) array A as operands.
  • the compiling process uses a first data unit group, which is used as the element A[i] in the repeated calculation process and each data unit is (1/2) k words, from the memory in one word.
  • a part of the data string obtained by shifting by (1/2) k words as a series of data strings is packed in 1-word units as the third vector data corresponding to the element A[i+1].
  • FIG. 9 is a flowchart illustrating an example of an analysis process by the compiling device according to the second embodiment regarding whether or not a vectorization technique is applicable. It is a flow chart which shows an example of a vectorization technique by a compilation device of a 2nd embodiment. It is a figure which shows an example of the object code produced
  • FIG. 11 is a diagram for explaining a vector load instruction generated by the vectorization technique of the second embodiment.
  • FIG. 11 is a diagram for explaining a vector shift double instruction generated by the vectorization technique of the second embodiment.
  • FIG. 10 is a diagram for explaining packed vector operation instructions generated by the vectorization technique of the second embodiment. It is a figure which shows an example of the object code produced
  • FIG. 13 is a diagram for explaining a vector load instruction generated by the vectorization technique of the second embodiment in the case of the 1/4 word type.
  • FIG. 10 is a diagram provided for explaining a vector shift double instruction generated by the vectorization technique of the second embodiment in the case of the 1/4 word type.
  • FIG. 10 is a diagram for explaining packed vector operation instructions generated by the vectorization technique of the second embodiment in the case of the 1/4 word type. It is a figure which shows the hardware structural example of a compiling apparatus.
  • FIG. 1 is a block diagram showing an example of a compiling device according to the first embodiment.
  • the compiling device 10 has a compiling processing unit 11.
  • the compile processing unit 11 converts a source program (source program) into object code.
  • This source program executes a “calculation process” that executes an arithmetic calculation that includes, as operands, an element a[i], an element a[i+1], and an element a[i+2 k ] of a (1/2) k word type array a.
  • It is a program for repeatedly executing the value of the subscript i while shifting the value one by one.
  • k is a natural number
  • the subscript i is an integer of 0 or more.
  • the above-described arithmetic calculation includes the "adjacent element calculation" of the array because the element a[i] and the element a[i+1] are adjacent to each other in the array.
  • the above-mentioned calculation process that is repeatedly executed may be referred to as “repetition calculation process”.
  • the compile processing unit 11 executes the “vectorization technique” of the first embodiment.
  • the compilation processing unit 11 includes a vector load instruction generation unit 12 and a vector shift double instruction generation unit 13.
  • the vector load instruction generation unit 12 loads the "first data unit group” used as the element a[i] in the iterative calculation processing from the memory (not shown) in the unit of one word in the first vector register. To generate a first vector load instruction. Each data unit is (1/2) k words. Further, the vector load instruction generation unit 12 loads the second data unit group used as the element [i+2 k ] in the iterative calculation processing from the memory (not shown) in the unit of one word in the second vector register. To generate a second vector load instruction.
  • first data unit group and “second data unit group” may be referred to as “first vector data” and "second vector data”, respectively.
  • the vector shift double instruction generation unit 13 packs a part of a data string obtained by shifting the first vector data and the second vector data as a series of data strings by (1/2) k words in units of one word. In this state, a vector shift double instruction to be stored in the third vector register is generated. A part of the data string stored in the third vector register is “third vector data” corresponding to the element a[i+1].
  • the compiling device 10 has the compiling processing unit 11.
  • the vector load instruction generation unit 12 packs the “first data unit group” used as the element a[i] in the iterative calculation processing from the memory (not shown) in units of one word. Generate a first vector load instruction for loading the first vector register. Each data unit is (1/2) k words. Further, the vector load instruction generation unit 12 loads the second data unit group used as the element [i+2 k ] in the iterative calculation processing from the memory (not shown) in the unit of one word in the second vector register. To generate a second vector load instruction.
  • each word-unit register area in the first vector register and the second vector register can be filled with two packed data units, so that the resource utilization efficiency of the register is improved.
  • the vector shift double instruction generation unit 13 in the compilation processing unit 11 shifts the first vector data and the second vector data as a series of data strings by (1/2) k words to obtain one of the data strings.
  • a vector shift double instruction for storing a copy in units of one word in the third vector register is generated.
  • the compiling device 10 With the configuration of the compiling device 10, it is possible to generate the third vector data including the same number of data units as the data units included in each of the first vector data and the second vector data. Accordingly, in the first vector data, the second vector data, and the third vector data, there will be no shortage of elements used for the calculation. Therefore, it is not necessary to generate the instruction for loading the insufficient element and the scalar instruction for operating the data loaded by the instruction as in the above-mentioned Patent Document 1. As a result, speeding up of the program can be realized.
  • the second embodiment relates to a more specific embodiment.
  • FIG. 2 is a block diagram showing an example of a compiling device according to the second embodiment.
  • the compiling device 20 has a compiling processing unit 21.
  • the compile processing unit 21 converts the source program (source program) into an object code, similarly to the compile processing unit 11 of the first embodiment.
  • the compilation processing unit 11 includes an analysis unit 22 and a vectorization execution unit 23.
  • the analysis unit 22 includes a loop detection unit 22A, a vectorization availability determination unit 22B, and an optimization application availability determination unit 22C.
  • the loop detection unit 22A detects a loop in the source program and determines whether or not the above-described "calculation process" is included in the detected loop.
  • the vectorization propriety determination unit 22B determines whether the loop can be vectorized when the above-described "calculation process" is included in the loop detected by the loop detection unit 22A.
  • the “vectorizable condition” for example, a conventional condition, that is, “definition and reference relationship regarding an array and a variable in a loop have no dependency that hinders vectorization” can be used.
  • the optimization applicability determination unit 22C determines whether the “vectorization technique” of the second embodiment can be applied to the above “calculation process”. For example, the optimization applicability determination unit 22C, when all of the following first condition, second condition, and third condition are satisfied, responds to the above “calculation process” by the “vectorization technique” of the second embodiment. Is applicable.
  • First condition The array must be (1/2) k- word type.
  • Second condition In one iteration, that is, in the "calculation process”, all array elements to be calculated are adjacent.
  • (Third condition) In one iteration, that is, in the "calculation process", the number of array elements used for calculation is "m ⁇ 2 k +1". However, m is an arbitrary natural number.
  • the determinations of the loop detection unit 22A and the vectorization propriety determination unit 22B are affirmative.
  • FIG. 3 is a diagram showing an example of the source program of the second embodiment.
  • the vectorization execution unit 23 performs the “vectorization” of the second embodiment on the source program for which the loop detection unit 22A, the vectorization availability determination unit 22B, and the optimization application availability determination unit 22C make positive determinations. Perform techniques.
  • the vectorization execution unit 23 includes a vector length calculation instruction generation unit 23A, a vector load instruction generation unit 12, a vector shift double instruction generation unit 13, a packed vector operation instruction generation unit 23B, and a vector store instruction generation unit 23C.
  • the vector length calculation command generation unit 23A generates an SRL (Shift Right Logical) command for acquiring the “loop length N” and calculating N ⁇ (1/2) k by a right logical shift operation. Further, the vector length calculation command generation unit 23A generates an SMVL (Store Max Vector Length) command for acquiring the "maximum vector length” allowed in the system. Further, the vector length calculation command generation unit 23A compares the value calculated by the SRL command with the "maximum vector length” and selects the smaller one, and the MIN (Minimum) command and the selected value are " An LVL (Load Vector Length) instruction for "vector length” is generated. In the case of the program of FIG. 3, the vector length calculation instruction generation unit 23A acquires the loop length n, compares n ⁇ (1/2) 1 with the maximum vector length, and selects the instruction group with the smaller one as the vector length. Will be generated.
  • SRL Send Right Logical
  • SMVL Store Max Vector Length
  • the vector load instruction generation unit 12 loads (m+1) VLD(Vector) to load 2 k data units (that is, 1-word data unit) as 1 packed vector into different vector registers respectively as 1 packed data. Load) command is generated.
  • These (m+1) VLD instructions have positions where the loading of data units from a memory (not shown), that is, "vector load start positions" are 2 k elements (that is, the number of elements for one word) with each other. It is deviating from each other.
  • the vector shift double instruction generation unit 13 performs (2k-1) VSRD (Vector Shift Double) for shifting by "a predetermined shift amount" for each pair of the data unit group having the closest "vector load start position". Right) Generate a command.
  • Each pair of data unit groups having the closest "vector load start position” is a pair of data unit groups in which the vector load start position is shifted by the number of elements for one word.
  • the “predetermined shift amount” for the (2k ⁇ 1) VSRD instructions is 1 ⁇ (1 ⁇ 2) k words (l is a natural number from 1 to (2k ⁇ 1)).
  • the VSRD instruction is the following instruction. "VSRD %v0,%v1,%v2,S"
  • %v0 means a 1-word vector register for writing the operation result.
  • %V1 and %v2 mean vector registers that are operands of operations.
  • S is a scalar value from 0 to (2 words-1) that specifies the shift amount. That is, according to the VSRD instruction, two vector registers, which are operands, are combined to form 2-word data (that is, a series of data strings), the 2-word data is right-shifted by S, and the lower order of the obtained 2-word data is calculated. The value of one word on the side is written in the vector register as the operation result.
  • the packed vector operation instruction generation unit 23B generates a PVOP (Packed Vector Operation) instruction for performing an operation on vector loaded vector data and vector data generated by vector shift double.
  • the generated PVOP instruction is an instruction according to the above-described arithmetic calculation mode.
  • the generated PVOP instruction is specifically a PVADD (Packed Vector ADD) instruction.
  • the vector store instruction generation unit 23C generates a VST (Vector Store) instruction for storing the operation result of the PVOP instruction as a 1-word vector store as packed data of 2 k elements.
  • VST Vector Store
  • FIG. 4 is a flowchart showing an example of an analysis process by the compiling device of the second embodiment as to whether or not the vectorization technique is applicable.
  • the analysis unit 22 determines whether or not a loop exists in the source program (step S101).
  • step S101 If the source program has a loop (YES in step S101), the analysis unit 22 determines whether the detected loop includes a calculation process (step S102).
  • the analysis unit 22 determines whether the loop can be vectorized (step S104).
  • the “condition that can be vectorized” it is possible to use, for example, a conventional condition, that is, “there is no dependency that hinders vectorization in the definitions and reference relationships for the arrays and variables in the loop”. it can.
  • the analysis unit 22 determines whether the array type of the calculation process is the (1/2) k word type (step S105).
  • the analysis unit 22 determines whether or not all the array elements to be calculated in the calculation process are adjacent (step S105). S106).
  • the analysis unit 22 determines whether the number of array elements used in the calculation in the calculation process is “m ⁇ 2 k +1”. It is determined whether or not (step S107).
  • the analysis unit 22 applies the vectorization technique of the second embodiment to the source program. Is determined (step S108).
  • step S109 the analysis unit 22 determines to apply the conventional optimization, for example (step S109).
  • FIG. 5 is a flow chart showing an example of a vectorization technique by the compiling device of the second embodiment. The processing flow of FIG. 5 starts when the analysis unit 22 determines to apply the vectorization technique of the second embodiment to the source program.
  • the vectorization executing unit 23 generates an SRL instruction for obtaining the loop length N and calculating N ⁇ (1/2) k by right logical shift operation (step S201).
  • the source program is the program shown in FIG. 3
  • the instruction shown in the first line of the part P6-1 of the object code shown in FIG. 6 is generated.
  • FIG. 6 is a diagram showing an example of an object code generated by the vectorization technique of the second embodiment.
  • the vectorization execution unit 23 generates an SMVL instruction for acquiring the “maximum vector length” permitted by the system (step S202).
  • the vectorization execution unit 23 compares the value calculated by the SRL instruction with the “maximum vector length” and selects the smaller one, and the MIN instruction and the selected value as the “vector length”. , LVL instruction is generated (step S203).
  • the source program is the program shown in FIG. 3, the part P6-1 of the object code shown in FIG. 6 is generated by steps S201 to S203.
  • the vectorization execution unit 23 generates (m+1) VLD instructions for loading 2 k data units as one packed data into different vector registers as one packed vector (step S204). These (m+1) VLD instructions are shifted from each other by 2 k elements (that is, the number of elements for one word) at the positions where the loading of the data unit from the memory (not shown) is started.
  • the source program is the program shown in FIG. 3, the object code portions P6-2 and P6-5 shown in FIG. 6 are generated.
  • the targets of the load instruction are a[i], a[i+2], and a[i+4], and the load start positions of these are shifted by two elements.
  • the processing as shown in FIG. 7 is executed. That is, by executing “VLD vreg1, a[i]”, the plurality of data units a[0] to a[11] have the vector load start position as a[0] and the two data units have 1 Loaded into the vector register vreg1.
  • FIG. 7 is a diagram for explaining a vector load instruction generated by the vectorization technique of the second embodiment.
  • the vectorization executing unit 23 shifts the number of (2k ⁇ 1) pieces for shifting the “vector load start position” by the “predetermined shift amount” for each pair of data unit groups closest to each other.
  • a VSRD instruction is generated (step S205).
  • the “predetermined shift amount” for the (2k ⁇ 1) VSRD instructions is 1 ⁇ (1 ⁇ 2) k words (l is a natural number from 1 to (2k ⁇ 1)).
  • the source program is the program shown in FIG. 3
  • the object code portions P6-3 and P6-6 shown in FIG. 6 are generated. That is, the part P6-3 is generated for the pair a[i] and a[i+2], and the part P6-6 is generated for the pair a[i+2] and a[i+4].
  • FIG. 8 is a diagram for explaining a vector shift double instruction generated by the vectorization technique of the second embodiment.
  • the vectorization executing unit 23 generates a PVOP instruction for performing an operation on vector data loaded by vector and vector data generated by vector shift double (step S206).
  • the source program is the program shown in FIG. 3
  • the object code portions P6-4 and P6-7 shown in FIG. 6 are generated. That is, since the calculation formula of the program shown in FIG. 3 includes four addition operators, four PVOP instructions are generated.
  • the parts P6-4 and P6-7 of the object code shown in FIG. 6 are executed, as shown in FIG. 9, the high order in each register area of the vector registers vreg1, vreg2, vreg3, vreg6, vreg7 in 1-word units.
  • the addition processing is performed separately for the area and the lower area.
  • FIG. 9 is a diagram for explaining packed vector operation instructions generated by the vectorization technique of the second embodiment.
  • the vectorization executing unit 23 generates a VST instruction for storing the operation result of the PVOP instruction as a 1-word vector as packed data of 2 k elements (step S207). Looking at the operation result by the PVOP instruction shown in FIG. 9, the calculation result obtained in each calculation process of the above-mentioned “repetitive calculation process” is held in each of the upper region and the lower region in each register region. I understand.
  • FIG. 10 is a diagram showing an example of an object code generated by the vectorization technique of the second embodiment in the case of the 1/4 word type.
  • the processing shown in FIG. 11 is executed. That is, by executing "VLD vreg1, a[i]", a plurality of data units a[0] to a[23] have the vector load start position a[0] and the four data units are 1 Loaded into the vector register vreg1.
  • FIG. 11 corresponds to a “register area” in units of one word, and each of the four columns in each row corresponds to a “partial area” corresponding to 1 ⁇ 4 word.
  • VLD vreg1, a[i+4] a plurality of data units a[4] to a[27] set the vector load start position to a[4] and the four data units are 1 Loaded into the vector register vreg2.
  • FIG. 11 is a diagram for explaining a vector load instruction generated by the vectorization technique of the second embodiment in the case of the 1/4 word type.
  • step S205 three VSRD instructions whose "predetermined shift amount” is 1/4 word, 2/4 word, and 3/4 word are generated for the pair of a[i] and a[i+4].
  • the vector register which is the operand of the VSRD instruction
  • the vreg1 and vreg2 are combined to form 2-word data.
  • the 2-word data is right-shifted by 3/4 word, and the value of the lower 1-word of the obtained 2-word data is written in the vector register vreg3.
  • the plurality of data units written in the vector register vreg3 correspond to a[i+1].
  • FIG. 12 is a diagram for explaining the vector shift double instruction generated by the vectorization technique of the second embodiment in the case of the 1/4 word type.
  • step S206 a PVOP instruction for performing an operation on the vector data vector-loaded and the vector data generated by the vector shift double is generated.
  • the vector addition operation of a[i] and a[i+4] is performed in the above-mentioned "partial area" unit as shown in FIG.
  • FIG. 13 is a diagram for explaining packed vector operation instructions generated by the vectorization technique of the second embodiment in the case of the 1/4 word type.
  • the vectorization execution unit 23 (vector shift double instruction generation unit 13), when the array a is a 1/4 word type, converts the series of data strings (that is, the 2 word data) into 3/4.
  • a first vector shift double instruction for storing a part of the data string obtained by shifting the word by the third vector register as the third vector data and the series of data strings obtained by shifting by 2/4 words
  • a second vector shift double instruction for storing a part of the obtained data string in the fourth vector register in the state of being packed in a unit of one word as the fourth vector data corresponding to the element A[i+2], and the above series of data.
  • a part of the data sequence obtained by shifting the column by 1/4 word is stored as a fourth vector data corresponding to the element A[i+3] in the fourth vector register in a state of being packed in 1-word units. 3 vector shift double instructions are generated.
  • the vector shift double instruction generation unit 13 shifts the series of data strings (that is, the above 2 word data) by 7/8 words and obtains the obtained data.
  • the second vector shift double instruction for storing in the fourth vector register in the state of being packed in a unit of one word, and the series of data strings are shifted by 5/8 words.
  • a third vector shift double instruction for storing a part of the obtained data string as fourth vector data corresponding to the element A[i+3] in the fourth vector register in a state of being packed in a unit of one word, and the above-mentioned series.
  • Part of the data string obtained by shifting the data string of 4 by 8/8 words is stored as the fifth vector data corresponding to the element A[i+4] in the fifth vector register while being packed in 1-word units.
  • the fourth vector shift double instruction to be performed, and a part of the data string obtained by shifting the above-mentioned series of data strings by 3/8 words are used as the sixth vector data corresponding to the element A[i+5] in 1-word units.
  • the fifth vector shift double instruction to store in the sixth vector register in the state packed with and the part of the data string obtained by shifting the above series of data strings by 2/8 word is stored in the element A[i+6].
  • FIG. 14 is a diagram illustrating a hardware configuration example of the compiling device.
  • the compiling device 100 has a processor 101 and a memory 102.
  • the compiling processing units 11 and 21 of the compiling devices 10 and 20 of the first and second embodiments may be realized by the processor 101 reading and executing a program stored in the memory 102.
  • the program can be stored using various types of non-transitory computer readable media and supplied to the compiling devices 10 and 20. Further, the program may be supplied to the compiling devices 10 and 20 by various types of transitory computer readable media.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Mathematical Analysis (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Algebra (AREA)
  • Databases & Information Systems (AREA)
  • Devices For Executing Special Programs (AREA)
  • Complex Calculations (AREA)
  • Advance Control (AREA)

Abstract

コンパイル装置(10)のベクトルロード命令生成部(12)は、繰り返し計算処理にて要素a[i]として用いられる「第1データユニット群」をメモリから1ワード単位でパックした状態で第1ベクトルレジスタにロードする命令を生成する。各データユニットは、(1/2)ワードである。ベクトルロード命令生成部(12)は、要素[i+2]として用いられる第2データユニット群を第2ベクトルレジスタにロードする命令を生成する。ベクトルシフトダブル命令生成部(13)は、第1ベクトルレジスタ及び第2ベクトルレジスタのデータを一連のデータ列として(1/2)ワード分シフトさせて得られたデータ列の一部を、1ワード単位でパックした状態で第3ベクトルレジスタにストアさせる命令を生成する。

Description

コンパイル装置、コンパイル方法、及び非一時的なコンピュータ可読媒体
 本開示は、コンパイル装置、コンパイル方法、及び制御プログラムに関する。
 ソースプログラム内に隣接するメモリアクセス命令が存在するときに重複したメモリアクセスを削減したオブジェクトコードに変換することによって、ベクトル計算機の実行性能を向上させる、コンパイル装置が提案されている(例えば、特許文献1)。特許文献1に開示されているコンパイル装置は、隣接するメモリアクセス命令を1つのメモリアクセス命令に変換する。さらに、該コンパイル装置は、該1つのメモリアクセス命令によってロードされた第1ベクトルレジスタのデータを、スライドさせて第2ベクトルレジスタに格納させる命令を生成する。そして、該コンパイル装置は、第1ベクトルレジスタのデータと第2のベクトルレジスタのデータとの演算を行う命令を生成する。
特開2000-48009号公報
 しかしながら、特許文献1のコンパイラ装置は、第1ベクトルレジスタのデータをスライドさせて第2ベクトルレジスタに格納させる命令を生成しているため、演算に用いる要素が不足する可能性がある(特許文献1の図4参照)。この場合、特許文献1のコンパイラ装置は、不足した要素を補うためロード/ストアや演算のための追加のベクトル命令、または、スカラ命令を生成する必要がある。すなわち、特許文献1のコンパイラ装置は、ソースプログラムの最適化が不十分であり、プログラムを十分に高速化できていない可能性がある。
 本開示の目的は、プログラムの高速化を実現することができる、コンパイル装置、コンパイル方法、及び制御プログラムを提供することにある。
 第1の態様にかかるコンパイル装置は、(1/2)ワード型(kは自然数)の配列Aの要素A[i]、要素A[i+1]、及び要素[i+2]をオペランドとして含む算術計算を実行する計算処理を添え字i(iは0以上の整数)の値を1つずつずらしながら繰り返し実行するための原始プログラムを、オブジェクトコードに変換するコンパイル処理部を具備し、前記コンパイル処理部は、前記繰り返される計算処理において前記要素A[i]として用いられ且つ各データユニットが(1/2)ワードである第1のデータユニット群をメモリから1ワード単位でパックした状態で第1ベクトルレジスタに第1ベクトルデータとしてロードするための第1ベクトルロード命令、及び、前記繰り返される計算処理において前記要素A[i+2]として用いられる第2のデータユニット群を前記メモリから1ワード単位でパックした状態で第2ベクトルレジスタに第2ベクトルデータとしてロードするための第2ベクトルロード命令を生成するベクトルロード命令生成部と、前記第1ベクトルデータ及び前記第2ベクトルデータを一連のデータ列として(1/2)ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+1]に対応する第3ベクトルデータとして、1ワード単位でパックした状態で第3ベクトルレジスタにストアさせる第1ベクトルシフトダブル命令を生成するベクトルシフト命令生成部と、を含む。
 第2の態様にかかるコンパイル方法は、(1/2)ワード型(kは自然数)の配列Aの要素A[i]、要素A[i+1]、及び要素A[i+2]をオペランドとして含む算術計算を実行する計算処理を添え字i(iは0以上の整数)の値を1つずつずらしながら繰り返し実行するための原始プログラムを、オブジェクトコードに変換するコンパイル方法であって、前記繰り返される計算処理において前記要素A[i]として用いられ且つ各データユニットが(1/2)ワードである第1のデータユニット群をメモリから1ワード単位でパックした状態で第1ベクトルレジスタに第1ベクトルデータとしてロードするための第1ベクトルロード命令、及び、前記繰り返される計算処理において前記要素A[i+2]として用いられる第2のデータユニット群を前記メモリから1ワード単位でパックした状態で第2ベクトルレジスタに第2ベクトルデータとしてロードするための第2ベクトルロード命令を生成すること、及び、前記第1ベクトルデータ及び前記第2ベクトルデータを一連のデータ列として(1/2)ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+1]に対応する第3ベクトルデータとして、1ワード単位でパックした状態で第3ベクトルレジスタにストアさせる第1ベクトルシフトダブル命令を生成すること、を含む。
 第3の態様にかかる制御プログラムは、(1/2)ワード型(kは自然数)の配列Aの要素A[i]、要素A[i+1]、及び要素A[i+2]をオペランドとして含む算術計算を実行する計算処理を添え字i(iは0以上の整数)の値を1つずつずらしながら繰り返し実行するための原始プログラムを、オブジェクトコードに変換するコンパイル処理をコンパイル装置に実行させる制御プログラムであって、前記コンパイル処理は、前記繰り返される計算処理において前記要素A[i]として用いられ且つ各データユニットが(1/2)ワードである第1のデータユニット群をメモリから1ワード単位でパックした状態で第1ベクトルレジスタに第1ベクトルデータとしてロードするための第1ベクトルロード命令、及び、前記繰り返される計算処理において前記要素A[i+2]として用いられる第2のデータユニット群を前記メモリから1ワード単位でパックした状態で第2ベクトルレジスタに第2ベクトルデータとしてロードするための第2ベクトルロード命令を生成すること、及び、前記第1ベクトルデータ及び前記第2ベクトルデータを一連のデータ列として(1/2)ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+1]に対応する第3ベクトルデータとして、1ワード単位でパックした状態で第3ベクトルレジスタにストアさせる第1ベクトルシフトダブル命令を生成すること、を含む。
 本開示により、プログラムの高速化を実現することができる、コンパイル装置、コンパイル方法、及び制御プログラムを提供することができる。
第1実施形態のコンパイル装置の一例を示すブロック図である。 第2実施形態のコンパイル装置の一例を示すブロック図である。 第2実施形態の原始プログラムの一例を示す図である。 第2実施形態のコンパイル装置による、ベクトル化技法を適用可能か否かについての解析処理の一例を示すフローチャートである。 第2実施形態のコンパイル装置によるベクトル化技法の一例を示すフローチャートである。 第2実施形態のベクトル化技法によって生成されるオブジェクトコードの一例を示す図である。 第2実施形態のベクトル化技法にて生成されるベクトルロード命令の説明に供する図である。 第2実施形態のベクトル化技法にて生成されるベクトルシフトダブル命令の説明に供する図である。 第2実施形態のベクトル化技法にて生成されるパックドベクトル演算命令の説明に供する図である。 1/4ワード型の場合に、第2実施形態のベクトル化技法によって生成されるオブジェクトコードの一例を示す図である。 1/4ワード型の場合に、第2実施形態のベクトル化技法にて生成されるベクトルロード命令の説明に供する図である。 1/4ワード型の場合に、第2実施形態のベクトル化技法にて生成されるベクトルシフトダブル命令の説明に供する図である。 1/4ワード型の場合に、第2実施形態のベクトル化技法にて生成されるパックドベクトル演算命令の説明に供する図である。 コンパイル装置のハードウェア構成例を示す図である。
 以下、図面を参照しつつ、実施形態について説明する。なお、実施形態において、同一又は同等の要素には、同一の符号を付し、重複する説明は省略される。
<第1実施形態>
 図1は、第1実施形態のコンパイル装置の一例を示すブロック図である。図1においてコンパイル装置10は、コンパイル処理部11を有している。コンパイル処理部11は、原始プログラム(ソースプログラム)を、オブジェクトコードに変換する。この原始プログラムは、(1/2)ワード型の配列aの要素a[i]、要素a[i+1]、及び要素a[i+2]をオペランドとして含む算術計算を実行する「計算処理」を添え字iの値を1つずつずらしながら繰り返し実行するためのプログラムである。kは自然数であり、添え字iは0以上の整数である。上記の算術計算は、要素a[i]と要素a[i+1]とが配列内で隣接しているので、配列の「隣接要素計算」を含んでいる。以下では、上記の繰り返し実行される計算処理を、「繰り返し計算処理」と呼ぶことがある。
 コンパイル処理部11は、第1実施形態の「ベクトル化技法」を実行する。コンパイル処理部11は、ベクトルロード命令生成部12と、ベクトルシフトダブル命令生成部13とを含む。
 ベクトルロード命令生成部12は、繰り返し計算処理にて要素a[i]として用いられる「第1データユニット群」をメモリ(図示せず)から1ワード単位でパックした状態で第1ベクトルレジスタにロードするための第1ベクトルロード命令を生成する。各データユニットは、(1/2)ワードである。さらに、ベクトルロード命令生成部12は、繰り返し計算処理にて要素[i+2]として用いられる第2データユニット群をメモリ(図示せず)から1ワード単位でパックした状態で第2ベクトルレジスタにロードするための第2ベクトルロード命令を生成する。以下では、上記の「第1データユニット群」及び「第2データユニット群」を、それぞれ、「第1ベクトルデータ」及び「第2ベクトルデータ」と呼ぶことがある。
 ベクトルシフトダブル命令生成部13は、第1ベクトルデータ及び第2ベクトルデータを一連のデータ列として(1/2)ワード分シフトさせて得られたデータ列の一部を、1ワード単位でパックした状態で第3ベクトルレジスタにストアさせるベクトルシフトダブル命令を生成する。第3ベクトルレジスタにストアされる上記データ列の一部は、要素a[i+1]に対応する「第3ベクトルデータ」である。
 以上のように第1実施形態によれば、コンパイル装置10は、コンパイル処理部11を有している。コンパイル処理部11にてベクトルロード命令生成部12は、繰り返し計算処理にて要素a[i]として用いられる「第1データユニット群」をメモリ(図示せず)から1ワード単位でパックした状態で第1ベクトルレジスタにロードするための第1ベクトルロード命令を生成する。各データユニットは、(1/2)ワードである。さらに、ベクトルロード命令生成部12は、繰り返し計算処理にて要素[i+2]として用いられる第2データユニット群をメモリ(図示せず)から1ワード単位でパックした状態で第2ベクトルレジスタにロードするための第2ベクトルロード命令を生成する。
 このコンパイル装置10の構成により、第1ベクトルレジスタ及び第2ベクトルレジスタにおける1ワード単位の各レジスタ領域を、パックされた2つのデータユニットによって埋めることができるので、レジスタのリソース利用効率を向上させることができる。
 また、コンパイル処理部11にてベクトルシフトダブル命令生成部13は、第1ベクトルデータ及び第2ベクトルデータを一連のデータ列として(1/2)ワード分シフトさせて得られたデータ列の一部を、1ワード単位でパックした状態で第3ベクトルレジスタにストアさせるベクトルシフトダブル命令を生成する。
 このコンパイル装置10の構成により、第1ベクトルデータ及び第2ベクトルデータのそれぞれに含まれるデータユニットと同数のデータユニットを含む第3ベクトルデータを生成することができる。これにより、第1ベクトルデータ、第2ベクトルデータ、及び第3ベクトルデータにおいて、演算に用いる要素に不足が生じることがない。このため、上記の特許文献1のような不足した要素をロードする命令及び該命令によってロードされたデータを演算するスカラ命令を生成する必要がない。この結果として、プログラムの高速化を実現することができる。
<第2実施形態>
 第2実施形態は、より具体的な実施形態に関する。
 <コンパイル装置の構成例>
 図2は、第2実施形態のコンパイル装置の一例を示すブロック図である。図2においてコンパイル装置20は、コンパイル処理部21を有する。コンパイル処理部21は、第1実施形態のコンパイル処理部11と同様に、原始プログラム(ソースプログラム)を、オブジェクトコードに変換する。コンパイル処理部11は、解析部22と、ベクトル化実行部23とを有している。
 解析部22は、ループ検出部22Aと、ベクトル化可否判定部22Bと、最適化適用可否判定部22Cとを有している。
 ループ検出部22Aは、原始プログラムにおけるループを検出し、検出されたループ内に上記の様な「計算処理」が含まれているか否かを判定する。
 ベクトル化可否判定部22Bは、ループ検出部22Aにて検出されたループ内に上記の様な「計算処理」が含まれる場合、ループをベクトル化できるか否かを判定する。「ベクトル化できる条件」としては、例えば、従来の条件、つまり、「ループ内の配列及び変数についての定義及び参照関係にベクトル化を阻害する依存関係がないこと」を用いることができる。
 最適化適用可否判定部22Cは、上記の「計算処理」に対して、第2実施形態の「ベクトル化技法」を適用できるか否かを判定する。例えば、最適化適用可否判定部22Cは、次の第1条件、第2条件、及び第3条件のすべてを満たす場合、上記の「計算処理」に対して、第2実施形態の「ベクトル化技法」を適用できると判定する。
 (第1条件)配列が(1/2)ワード型であること。
 (第2条件)1回の繰り返しにおいて、つまり、上記「計算処理」において、計算対象となる配列要素がすべて隣接していること。
 (第3条件)1回の繰り返しにおいて、つまり、上記「計算処理」において、計算に用いられる配列要素の数が「m×2+1」個であること。ただし、mは、任意の自然数である。
 原始プログラムが例えば図3に示すプログラムである場合には、ループ検出部22A及びベクトル化可否判定部22Bの判定は、肯定的な判定となる。さらに、原始プログラムが例えば図1に示すようなプログラムである場合には、最適化適用可否判定部22Cの判定も、肯定的な判定となる。すなわち、図3に示すプログラムは、配列が半ワード型(k=1)であり、計算対象である配列要素の添え字が、[i]、[i+1]、[i+2]、[i+3]、[i+4]と1つずつずれている。さらに、図3に示すプログラムは、1回の繰り返しにおいて計算に用いられる配列要素の数が5(=2×2+1)要素である。このため、図3に示すプログラムは、上記の第1条件、第2条件、及び第3条件のすべてを満たす。図3は、第2実施形態の原始プログラムの一例を示す図である。
 ベクトル化実行部23は、ループ検出部22A、ベクトル化可否判定部22B、及び最適化適用可否判定部22Cにて肯定的な判定がなされた原始プログラムに対して、第2実施形態の「ベクトル化技法」を実行する。
 ベクトル化実行部23は、ベクトル長算出命令生成部23Aと、ベクトルロード命令生成部12と、ベクトルシフトダブル命令生成部13と、パックドベクトル演算命令生成部23Bと、ベクトルストア命令生成部23Cとを有している。
 ベクトル長算出命令生成部23Aは、「ループ長N」を取得してN×(1/2)を右論理シフト演算によって計算するための、SRL(Shift Right Logical)命令を生成する。また、ベクトル長算出命令生成部23Aは、システムにて許容されている「最大ベクトル長」を取得するための、SMVL(Store Max Vector Length)命令を生成する。さらに、ベクトル長算出命令生成部23Aは、SRL命令によって計算した値と「最大ベクトル長」とを比較して小さい方を選択するための、MIN(Minimum)命令、及び、選択された値を「ベクトル長」とするための、LVL(Load Vector Length)命令を生成する。図3のプログラムの場合、ベクトル長算出命令生成部23Aは、ループ長nを取得し、n×(1/2)と最大ベクトル長とを比較して小さい方をベクトル長とする命令群を生成することになる。
 ベクトルロード命令生成部12は、2個のデータユニット(つまり、1ワードのデータユニット)を1つのパックドデータとしてそれぞれ異なるベクトルレジスタに1ワードベクトルロードするための、(m+1)個のVLD(Vector Load)命令を生成する。これらの(m+1)個のVLD命令は、メモリ(図示せず)からデータユニットのロードを開始する位置、つまり、「ベクトルロード開始位置」が互いに2要素(つまり、1ワード分の要素数)ずつずれている。
 ベクトルシフトダブル命令生成部13は、「ベクトルロード開始位置」が最も近いデータユニット群の各ペアに対して「所定シフト量」分シフトするための、(2k-1)個のVSRD(Vector Shift Double Right)命令を生成する。上記の「ベクトルロード開始位置」が最も近いデータユニット群の各ペアは、ベクトルロード開始位置が1ワード分の要素数だけずれた、データユニット群の各ペアである。(2k-1)個のVSRD命令についての「所定シフト量」は、それぞれ、l×(1/2)ワード(lは、1から(2k-1)までの自然数)である。
 VSRD命令は、次のような命令である。
   「VSRD %v0,%v1,%v2,S」
 ここで、%v0は、演算結果を書き込む1ワードベクトルレジスタを意味する。%v1,%v2は、演算のオペランドとなるベクトルレジスタを意味する。Sは、シフト量を指定する0から(2ワード-1)までのスカラ値である。すなわち、VSRD命令によれば、オペランドである2つのベクトルレジスタを合わせて2ワードデータ(つまり一連のデータ列)とし、該2ワードデータがSだけ右シフト演算され、得られた2ワードデータの下位側の1ワードの値が演算結果としてベクトルレジスタに書き込まれる。
 パックドベクトル演算命令生成部23Bは、ベクトルロードされたベクトルデータ及びベクトルシフトダブルによって生成されたベクトルデータに対して演算を行うための、PVOP(Packed Vector Operation)命令を生成する。ここで、具体的には、生成されるPVOP命令は、上記の算術計算の態様に応じた命令となる。例えば、図3に示す原始プログラムの例では、算術計算が要素間の加算であるので、生成されるPVOP命令は、具体的には、PVADD(Packed Vector ADD)命令となる。
 ベクトルストア命令生成部23Cは、PVOP命令による演算結果を、2要素のパックドデータとして1ワードベクトルストアするための、VST(Vector Store)命令を生成する。
 <コンパイル装置の動作例>
 以上の構成を有するコンパイル装置20の処理動作の一例について説明する。
 〈第2実施形態のベクトル化技法を適用可能か否かについての解析処理〉
 図4は、第2実施形態のコンパイル装置による、ベクトル化技法を適用可能か否かについての解析処理の一例を示すフローチャートである。
 コンパイル装置20において解析部22は、原始プログラムにループが存在するか否かを判定する(ステップS101)。
 原始プログラムにループが存在する場合(ステップS101YES)、解析部22は、検出したループ内に計算処理が含まれているか否かを判定する(ステップS102)。
 ループ内に計算処理が含まれている場合(ステップS103)、解析部22は、ループをベクトル化できるか否かを判定する(ステップS104)。上記の通り、「ベクトル化できる条件」としては、例えば、従来の条件、つまり、「ループ内の配列及び変数についての定義及び参照関係にベクトル化を阻害する依存関係がないこと」を用いることができる。
 ベクトル化ができると判定した場合(ステップS104YES)、解析部22は、計算処理の配列の型が(1/2)ワード型であるか否かを判定する(ステップS105)。
 計算処理の配列の型が(1/2)ワード型である場合(ステップS105YES)、解析部22は、計算処理において計算対象となる配列要素がすべて隣接しているか否かを判定する(ステップS106)。
 計算処理において計算対象となる配列要素がすべて隣接している場合(ステップS106YES)、解析部22は、計算処理において計算に用いられる配列要素の数が「m×2+1」個であるか否かを判定する(ステップS107)。
 計算処理において計算に用いられる配列要素の数が「m×2+1」個である場合(ステップS107YES)、解析部22は、原始プログラムに対して第2実施形態のベクトル化技法を適用することを決定する(ステップS108)。
 なお、ステップS101からステップS107のいずれかにおいて否定的な判定が為された場合、解析部22は、例えば従来の最適化を適用することを決定する(ステップS109)。
 〈第2実施形態のベクトル化技法〉
 図5は、第2実施形態のコンパイル装置によるベクトル化技法の一例を示すフローチャートである。図5の処理フローは、解析部22によって原始プログラムに対して第2実施形態のベクトル化技法を適用することを決定された場合にスタートする。
 コンパイル装置20においてベクトル化実行部23は、ループ長Nを取得してN×(1/2)を右論理シフト演算によって計算するための、SRL命令を生成する(ステップS201)。原始プログラムが図3に示すプログラムの場合、図6に示されるオブジェクトコードの部分P6-1の1行目に示される命令が生成されることになる。図6は、第2実施形態のベクトル化技法によって生成されるオブジェクトコードの一例を示す図である。
 ベクトル化実行部23は、システムにて許容されている「最大ベクトル長」を取得するための、SMVL命令を生成する(ステップS202)。
 ベクトル化実行部23は、SRL命令によって計算した値と「最大ベクトル長」とを比較して小さい方を選択するための、MIN命令、及び、選択された値を「ベクトル長」とするための、LVL命令を生成する(ステップS203)。原始プログラムが図3に示すプログラムの場合、ステップS201からステップS203によって、図6に示されるオブジェクトコードの部分P6-1が生成されることになる。
 ベクトル化実行部23は、2個のデータユニットを1つのパックドデータとしてそれぞれ異なるベクトルレジスタに1ワードベクトルロードするための、(m+1)個のVLD命令を生成する(ステップS204)。これらの(m+1)個のVLD命令は、メモリ(図示せず)からデータユニットのロードを開始する位置が互いに2要素(つまり、1ワード分の要素数)ずつずれている。原始プログラムが図3に示すプログラムの場合、図6に示されるオブジェクトコードの部分P6-2,P6-5が生成されることになる。図3に示すプログラムでは配列が半ワード型(つまり、k=1)であり且つ要素の数が5個(つまり、m=2)であるので、3つのVLD命令が生成されている。また、ロード命令の対象は、a[i]、a[i+2]、及びa[i+4]であり、これらのロード開始位置は互いに2要素ずつずれている。例えば、図6に示されるオブジェクトコードの部分P6-2が実行されると、図7に示されるような処理が実行されることになる。すなわち、「VLD vreg1,a[i]」が実行されることによって、複数のデータユニットa[0]~a[11]が、ベクトルロード開始位置をa[0]とし且つ2つのデータユニットが1つにパックされた状態で、ベクトルレジスタvreg1にロードされる。すなわち、ベクトルレジスタvreg1の1ワード単位の各レジスタ領域の上位領域(Upper領域)にデータユニットa[0],a[2],a[4],a[6],a[8],a[10]がロードされ、下位領域(Lower領域)にデータユニットa[1],a[3],a[5],a[7],a[9],a[11]がロードされている。また、「VLD vreg1,a[i+2]」が実行されることによって、複数のデータユニットa[2]~a[13]が、ベクトルロード開始位置をa[2]とし且つ2つのデータユニットが1つにパックされた状態で、ベクトルレジスタvreg2にロードされる。図7は、第2実施形態のベクトル化技法にて生成されるベクトルロード命令の説明に供する図である。
 図5の説明に戻り、ベクトル化実行部23は、「ベクトルロード開始位置」が最も近いデータユニット群の各ペアに対して「所定シフト量」分シフトするための、(2k-1)個のVSRD命令を生成する(ステップS205)。(2k-1)個のVSRD命令についての「所定シフト量」は、それぞれ、l×(1/2)ワード(lは、1から(2k-1)までの自然数)である。原始プログラムが図3に示すプログラムの場合、図6に示されるオブジェクトコードの部分P6-3,P6-6が生成されることになる。すなわち、a[i]及びa[i+2]のペアについて、部分P6-3が生成され、a[i+2]、及びa[i+4]のペアについて、部分P6-6が生成される。図3に示すプログラムでは配列が半ワード型(つまり、k=1)であるので、各ペアについて1つのVSRD命令が生成され、所定シフト量は1/2ワードとなる。例えば、図6に示されるオブジェクトコードの部分P6-3が実行されると、図8に示されるような処理が実行されることになる。すなわち、VSRD命令のオペランドであるベクトルレジスタvreg1,vreg2を合わせて2ワードデータとし、該2ワードデータが1/2ワードだけ右シフト演算され、得られた2ワードデータの下位側の1ワードの値がベクトルレジスタvreg3に書き込まれる。このベクトルレジスタvreg3に書き込まれた複数のデータユニットは、a[i+1]に相当する。図8は、第2実施形態のベクトル化技法にて生成されるベクトルシフトダブル命令の説明に供する図である。
 図5の説明に戻り、ベクトル化実行部23は、ベクトルロードされたベクトルデータ及びベクトルシフトダブルによって生成されたベクトルデータに対して演算を行うための、PVOP命令を生成する(ステップS206)。原始プログラムが図3に示すプログラムの場合、図6に示されるオブジェクトコードの部分P6-4,P6-7が生成されることになる。すなわち、図3に示すプログラムの計算式には加算演算子が4つ含まれるので、4つのPVOP命令が生成されている。図6に示されるオブジェクトコードの部分P6-4,P6-7が実行されると、図9に示すように、ベクトルレジスタvreg1,vreg2,vreg3,vreg6,vreg7の1ワード単位の各レジスタ領域における上位領域及び下位領域について別々に加算処理が行われる。図9は、第2実施形態のベクトル化技法にて生成されるパックドベクトル演算命令の説明に供する図である。
 図5の説明に戻り、ベクトル化実行部23は、PVOP命令による演算結果を、2要素のパックドデータとして1ワードベクトルストアするための、VST命令を生成する(ステップS207)。図9に示されたPVOP命令による演算結果を見ると、各レジスタ領域における上位領域及び下位領域のそれぞれには、上記の「繰り返し計算処理」の各計算処理において得られる計算結果が保持されることがわかる。
 なお、以上の説明では、1/2ワード型のケースを例にとって説明を行ったが、当然のことながらこれに限定されるものではなく、1/4ワード型、1/8ワード型についても同様に、上記の「ベクトル化技法」と適用することができる。
 例えば、1/4ワード型の場合、図3に示す原始プログラムは、図10に示すオブジェクトコードに変換される。図10は、1/4ワード型の場合に、第2実施形態のベクトル化技法によって生成されるオブジェクトコードの一例を示す図である。
 具体的には、ステップS204では、配列が1/4ワード型(つまり、k=2)であり且つ要素の数が5個(つまり、m=1)であるので、2つのVLD命令が生成される。そして、ロード命令の対象は、a[i]及びa[i+4]であり、これらのロード開始位置は互いに4要素ずれている。これらの2つのVLD命令が実行されると、図11に示されるような処理が実行されることになる。すなわち、「VLD vreg1,a[i]」が実行されることによって、複数のデータユニットa[0]~a[23]が、ベクトルロード開始位置をa[0]とし且つ4つのデータユニットが1つにパックされた状態で、ベクトルレジスタvreg1にロードされる。ここで、図11のベクトルレジスタvreg1における各行は、1ワード単位の「レジスタ領域」に対応し、各行における4つの列のそれぞれは1/4ワードに対応する「部分領域」に対応する。また、「VLD vreg1,a[i+4]」が実行されることによって、複数のデータユニットa[4]~a[27]が、ベクトルロード開始位置をa[4]とし且つ4つのデータユニットが1つにパックされた状態で、ベクトルレジスタvreg2にロードされる。図11は、1/4ワード型の場合に、第2実施形態のベクトル化技法にて生成されるベクトルロード命令の説明に供する図である。
 そして、ステップS205では、a[i]及びa[i+4]のペアについて、「所定シフト量」がそれぞれ1/4ワード、2/4ワード、3/4ワードである、3つのVSRD命令が生成される。a[i]及びa[i+4]のペアについて「所定シフト量」が3/4ワードであるVSRD命令「VSRD vreg3,vreg2,vreg1,48」が実行されると、VSRD命令のオペランドであるベクトルレジスタvreg1,vreg2を合わせて2ワードデータとされる。そして、該2ワードデータが3/4ワードだけ右シフト演算され、得られた2ワードデータの下位側の1ワードの値がベクトルレジスタvreg3に書き込まれる。このベクトルレジスタvreg3に書き込まれた複数のデータユニットは、a[i+1]に相当する。図12は、1/4ワード型の場合に、第2実施形態のベクトル化技法にて生成されるベクトルシフトダブル命令の説明に供する図である。
 そして、ステップS206では、ベクトルロードされたベクトルデータ及びベクトルシフトダブルによって生成されたベクトルデータに対して演算を行うための、PVOP命令が生成される。例えば、a[i]とa[i+4]とのベクトル加算演算は、図13に示すように、上記の「部分領域」単位で加算されることになる。図13は、1/4ワード型の場合に、第2実施形態のベクトル化技法にて生成されるパックドベクトル演算命令の説明に供する図である。
 このように、ベクトル化実行部23(ベクトルシフトダブル命令生成部13)は、配列aが1/4ワード型である場合、上記一連のデータ列(つまり、上記の2ワードデータ)を3/4ワード分シフトさせて得られたデータ列の一部を、第3ベクトルデータとして第3ベクトルレジスタにストアさせる第1ベクトルシフトダブル命令と、上記一連のデータ列を2/4ワード分シフトさせて得られたデータ列の一部を、要素A[i+2]に対応する第4ベクトルデータとして、1ワード単位でパックした状態で第4ベクトルレジスタにストアさせる第2ベクトルシフトダブル命令と、上記一連のデータ列を1/4ワード分シフトさせて得られたデータ列の一部を、要素A[i+3]に対応する第4ベクトルデータとして、1ワード単位でパックした状態で第4ベクトルレジスタにストアさせる第3ベクトルシフトダブル命令と、を生成している。
 配列aが1/8ワード型の場合も同様である。すなわち、ベクトルシフトダブル命令生成部13は、配列aが1/8ワード型である場合、上記一連のデータ列(つまり、上記の2ワードデータ)を7/8ワード分シフトさせて得られたデータ列の一部を、第3ベクトルデータとして第3ベクトルレジスタにストアさせる第1ベクトルシフトダブル命令と、上記一連のデータ列を6/8ワード分シフトさせて得られたデータ列の一部を、要素A[i+2]に対応する第4ベクトルデータとして、1ワード単位でパックした状態で第4ベクトルレジスタにストアさせる第2ベクトルシフトダブル命令と、上記一連のデータ列を5/8ワード分シフトさせて得られたデータ列の一部を、要素A[i+3]に対応する第4ベクトルデータとして、1ワード単位でパックした状態で第4ベクトルレジスタにストアさせる第3ベクトルシフトダブル命令と、上記一連のデータ列を4/8ワード分シフトさせて得られたデータ列の一部を、要素A[i+4]に対応する第5ベクトルデータとして、1ワード単位でパックした状態で第5ベクトルレジスタにストアさせる第4ベクトルシフトダブル命令と、上記一連のデータ列を3/8ワード分シフトさせて得られたデータ列の一部を、要素A[i+5]に対応する第6ベクトルデータとして、1ワード単位でパックした状態で第6ベクトルレジスタにストアさせる第5ベクトルシフトダブル命令と、上記一連のデータ列を2/8ワード分シフトさせて得られたデータ列の一部を、要素A[i+6]に対応する第7ベクトルデータとして、1ワード単位でパックした状態で第7ベクトルレジスタにストアさせる第6ベクトルシフトダブル命令と、上記一連のデータ列を1/8ワード分シフトさせて得られたデータ列の一部を、要素A[i+7]に対応する第8ベクトルデータとして、1ワード単位でパックした状態で第8ベクトルレジスタにストアさせる第7ベクトルシフトダブル命令と、を生成している。
 <他の実施形態>
 図14は、コンパイル装置のハードウェア構成例を示す図である。図14においてコンパイル装置100は、プロセッサ101と、メモリ102とを有している。第1実施形態及び第2実施形態のコンパイル装置10,20のコンパイル処理部11,21は、プロセッサ101がメモリ102に記憶されたプログラムを読み込んで実行することにより実現されてもよい。プログラムは、様々なタイプの非一時的なコンピュータ可読媒体(non-transitory computer readable medium)を用いて格納され、コンパイル装置10,20に供給することができる。また、プログラムは、様々なタイプの一時的なコンピュータ可読媒体(transitory computer readable medium)によってコンパイル装置10,20に供給されてもよい。
 以上、実施の形態を参照して本願発明を説明したが、本願発明は上記によって限定されるものではない。本願発明の構成や詳細には、発明のスコープ内で当業者が理解し得る様々な変更をすることができる。
 この出願は、2018年12月7日に出願された日本出願特願2018-229695を基礎とする優先権を主張し、その開示の全てをここに取り込む。
 10,20 コンパイル装置
 11,21 コンパイル処理部
 12 ベクトルロード命令生成部
 13 ベクトルシフトダブル命令生成部
 22 解析部
 22A ループ検出部
 22B ベクトル化可否判定部
 22C 最適化適用可否判定部
 23 ベクトル化実行部
 23A ベクトル長算出命令生成部
 23B パックドベクトル演算命令生成部
 23C ベクトルストア命令生成部

Claims (8)

  1.  (1/2)ワード型(kは自然数)の配列Aの要素A[i]、要素A[i+1]、及び要素[i+2]をオペランドとして含む算術計算を実行する計算処理を添え字i(iは0以上の整数)の値を1つずつずらしながら繰り返し実行するための原始プログラムを、オブジェクトコードに変換するコンパイル処理手段を具備し、
     前記コンパイル処理手段は、
     前記繰り返される計算処理において前記要素A[i]として用いられ且つ各データユニットが(1/2)ワードである第1のデータユニット群をメモリから1ワード単位でパックした状態で第1ベクトルレジスタに第1ベクトルデータとしてロードするための第1ベクトルロード命令、及び、前記繰り返される計算処理において前記要素A[i+2]として用いられる第2のデータユニット群を前記メモリから1ワード単位でパックした状態で第2ベクトルレジスタに第2ベクトルデータとしてロードするための第2ベクトルロード命令を生成するベクトルロード命令生成手段と、
     前記第1ベクトルデータ及び前記第2ベクトルデータを一連のデータ列として(1/2)ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+1]に対応する第3ベクトルデータとして、1ワード単位でパックした状態で第3ベクトルレジスタにストアさせる第1ベクトルシフトダブル命令を生成するベクトルシフト命令生成手段と、
     を含む、
     コンパイル装置。
  2.  前記コンパイル処理手段は、前記ベクトルロード命令生成手段が前記第1ベクトルロード命令及び前記第2ベクトルロード命令を生成する処理を開始し且つ前記ベクトルシフト命令生成手段が前記第1ベクトルシフトダブル命令を生成する処理を開始する条件が満たされているか否かを判定する条件判定手段をさらに含み、
     前記条件は、各計算処理において計算対象となるすべての要素の添え字が連続しているという条件を含む、
     請求項1記載のコンパイル装置。
  3.  前記コンパイル処理手段は、前記計算処理がN(Nは2以上の自然数)回繰り返される場合、前記N×(1/2)及びシステムにて許容されている最大ベクトル長のうちで小さい方をベクトル長として選択するためのベクトル長算出命令を生成するベクトル長算出命令生成手段をさらに具備し、
     前記ベクトルロード命令生成手段は、それぞれ前記ベクトル長を有する前記第1ベクトルデータ及び前記第2ベクトルデータをロードするための前記第1ベクトルロード命令及び前記第2ベクトルロード命令を生成する、
     請求項1又は2に記載のコンパイル装置。
  4.  前記ベクトルシフト命令生成手段は、前記配列Aが1/2ワード型である場合、前記一連のデータ列を1/2ワード分シフトさせて得られたデータ列の一部を、前記第3ベクトルデータとして前記第3ベクトルレジスタにストアさせる前記第1ベクトルシフトダブル命令を生成する、
     請求項1から3のいずれか1項に記載のコンパイル装置。
  5.  前記ベクトルシフト命令生成手段は、前記配列Aが1/4ワード型である場合、
     前記一連のデータ列を1/4ワード分シフトさせて得られたデータ列の一部を、前記第3ベクトルデータとして前記第3ベクトルレジスタにストアさせる前記第1ベクトルシフトダブル命令と、
     前記一連のデータ列を2/4ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+2]に対応する第4ベクトルデータとして、1ワード単位でパックした状態で第4ベクトルレジスタにストアさせる第2ベクトルシフトダブル命令と、
     前記一連のデータ列を1/4ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+3]に対応する第4ベクトルデータとして、1ワード単位でパックした状態で第4ベクトルレジスタにストアさせる第3ベクトルシフトダブル命令と、
     を生成する、
     請求項1から3のいずれか1項に記載のコンパイル装置。
  6.  前記ベクトルシフト命令生成手段は、前記配列Aが1/8ワード型である場合、
     前記一連のデータ列を7/8ワード分シフトさせて得られたデータ列の一部を、前記第3ベクトルデータとして前記第3ベクトルレジスタにストアさせる前記第1ベクトルシフトダブル命令と、
     前記一連のデータ列を6/8ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+2]に対応する第4ベクトルデータとして、1ワード単位でパックした状態で第4ベクトルレジスタにストアさせる第2ベクトルシフトダブル命令と、
     前記一連のデータ列を5/8ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+3]に対応する第4ベクトルデータとして、1ワード単位でパックした状態で第4ベクトルレジスタにストアさせる第3ベクトルシフトダブル命令と、
     前記一連のデータ列を4/8ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+4]に対応する第5ベクトルデータとして、1ワード単位でパックした状態で第5ベクトルレジスタにストアさせる第4ベクトルシフトダブル命令と、
     前記一連のデータ列を3/8ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+5]に対応する第6ベクトルデータとして、1ワード単位でパックした状態で第6ベクトルレジスタにストアさせる第5ベクトルシフトダブル命令と、
     前記一連のデータ列を2/8ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+6]に対応する第7ベクトルデータとして、1ワード単位でパックした状態で第7ベクトルレジスタにストアさせる第6ベクトルシフトダブル命令と、
     前記一連のデータ列を1/8ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+7]に対応する第8ベクトルデータとして、1ワード単位でパックした状態で第8ベクトルレジスタにストアさせる第7ベクトルシフトダブル命令と、
     を生成する、
     請求項1から3のいずれか1項に記載のコンパイル装置。
  7.  (1/2)ワード型(kは自然数)の配列Aの要素A[i]、要素A[i+1]、及び要素A[i+2]をオペランドとして含む算術計算を実行する計算処理を添え字i(iは0以上の整数)の値を1つずつずらしながら繰り返し実行するための原始プログラムを、オブジェクトコードに変換するコンパイル方法であって、
     前記繰り返される計算処理において前記要素A[i]として用いられ且つ各データユニットが(1/2)ワードである第1のデータユニット群をメモリから1ワード単位でパックした状態で第1ベクトルレジスタに第1ベクトルデータとしてロードするための第1ベクトルロード命令、及び、前記繰り返される計算処理において前記要素A[i+2]として用いられる第2のデータユニット群を前記メモリから1ワード単位でパックした状態で第2ベクトルレジスタに第2ベクトルデータとしてロードするための第2ベクトルロード命令を生成すること、及び、
     前記第1ベクトルデータ及び前記第2ベクトルデータを一連のデータ列として(1/2)ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+1]に対応する第3ベクトルデータとして、1ワード単位でパックした状態で第3ベクトルレジスタにストアさせる第1ベクトルシフトダブル命令を生成すること、を含む、
     コンパイル方法。
  8.  (1/2)ワード型(kは自然数)の配列Aの要素A[i]、要素A[i+1]、及び要素A[i+2]をオペランドとして含む算術計算を実行する計算処理を添え字i(iは0以上の整数)の値を1つずつずらしながら繰り返し実行するための原始プログラムを、オブジェクトコードに変換するコンパイル処理をコンパイル装置に実行させる制御プログラムであって、
     前記コンパイル処理は、
     前記繰り返される計算処理において前記要素A[i]として用いられ且つ各データユニットが(1/2)ワードである第1のデータユニット群をメモリから1ワード単位でパックした状態で第1ベクトルレジスタに第1ベクトルデータとしてロードするための第1ベクトルロード命令、及び、前記繰り返される計算処理において前記要素A[i+2]として用いられる第2のデータユニット群を前記メモリから1ワード単位でパックした状態で第2ベクトルレジスタに第2ベクトルデータとしてロードするための第2ベクトルロード命令を生成すること、及び、
     前記第1ベクトルデータ及び前記第2ベクトルデータを一連のデータ列として(1/2)ワード分シフトさせて得られたデータ列の一部を、前記要素A[i+1]に対応する第3ベクトルデータとして、1ワード単位でパックした状態で第3ベクトルレジスタにストアさせる第1ベクトルシフトダブル命令を生成すること、を含む、
     制御プログラムを格納する非一時的なコンピュータ可読媒体。
PCT/JP2019/040150 2018-12-07 2019-10-11 コンパイル装置、コンパイル方法、及び非一時的なコンピュータ可読媒体 WO2020116025A1 (ja)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2020559760A JP7115563B2 (ja) 2018-12-07 2019-10-11 コンパイル装置、コンパイル方法、及び制御プログラム
US17/299,039 US11829754B2 (en) 2018-12-07 2019-10-11 Compile device, compile method, and non-transitory computer readable medium for increasing a speed of a program

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2018-229695 2018-12-07
JP2018229695 2018-12-07

Publications (1)

Publication Number Publication Date
WO2020116025A1 true WO2020116025A1 (ja) 2020-06-11

Family

ID=70974646

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2019/040150 WO2020116025A1 (ja) 2018-12-07 2019-10-11 コンパイル装置、コンパイル方法、及び非一時的なコンピュータ可読媒体

Country Status (3)

Country Link
US (1) US11829754B2 (ja)
JP (1) JP7115563B2 (ja)
WO (1) WO2020116025A1 (ja)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0962654A (ja) * 1995-08-22 1997-03-07 Kofu Nippon Denki Kk リストベクトル処理装置
JP2012128790A (ja) * 2010-12-17 2012-07-05 Fujitsu Ltd 演算処理装置
JP2014526758A (ja) * 2011-09-26 2014-10-06 インテル・コーポレーション ストライド機能を有するベクトルロード演算/ストア演算を提供する命令及びロジック
JP2018049461A (ja) * 2016-09-21 2018-03-29 日本電気株式会社 コンパイル装置、コンパイル方法、および、コンパイルプログラム

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3817073B2 (ja) 1998-07-28 2006-08-30 富士通株式会社 メモリアクセス処理装置、メモリアクセス処理システム、および記録媒体
US10061746B2 (en) * 2014-09-26 2018-08-28 Intel Corporation Instruction and logic for a vector format for processing computations

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0962654A (ja) * 1995-08-22 1997-03-07 Kofu Nippon Denki Kk リストベクトル処理装置
JP2012128790A (ja) * 2010-12-17 2012-07-05 Fujitsu Ltd 演算処理装置
JP2014526758A (ja) * 2011-09-26 2014-10-06 インテル・コーポレーション ストライド機能を有するベクトルロード演算/ストア演算を提供する命令及びロジック
JP2018049461A (ja) * 2016-09-21 2018-03-29 日本電気株式会社 コンパイル装置、コンパイル方法、および、コンパイルプログラム

Also Published As

Publication number Publication date
JPWO2020116025A1 (ja) 2021-10-07
JP7115563B2 (ja) 2022-08-09
US20220027151A1 (en) 2022-01-27
US11829754B2 (en) 2023-11-28

Similar Documents

Publication Publication Date Title
JP4339907B2 (ja) マルチプロセッサ向け最適コード生成方法及びコンパイル装置
JP6245031B2 (ja) コンパイルプログラム、コンパイル方法およびコンパイル装置
JP5966509B2 (ja) プログラム、コード生成方法および情報処理装置
US8423979B2 (en) Code generation for complex arithmetic reduction for architectures lacking cross data-path support
JP6666554B2 (ja) 情報処理装置、変換プログラム、及び変換方法
JP2015201119A (ja) コンパイルプログラム、コンパイル方法およびコンパイル装置
US6993756B2 (en) Optimization apparatus that decreases delays in pipeline processing of loop and computer-readable storage medium storing optimization program
KR102062208B1 (ko) 멀티스레드 프로그램 코드의 변환 장치 및 방법
WO2020116025A1 (ja) コンパイル装置、コンパイル方法、及び非一時的なコンピュータ可読媒体
JPH04293150A (ja) コンパイル方法
JP6897213B2 (ja) コード生成装置、コード生成方法及びコード生成プログラム
JP2009265708A (ja) コンパイラ及びそのコード生成方法
JP6555005B2 (ja) 最適化装置、方法およびプログラム
WO2020066375A1 (ja) 情報処理装置、情報処理方法、プログラム
WO2022130883A1 (ja) コンパイル装置、コンパイル方法、及びコンパイルプログラム記録媒体
JP2018049461A (ja) コンパイル装置、コンパイル方法、および、コンパイルプログラム
JP2019185486A (ja) コード変換装置、コード変換方法、及びコード変換プログラム
JP2019067117A (ja) コード生成装置、コード生成方法及びコード生成プログラム
Bernstein et al. Usable assembly language for GPUs: a success story
US10572233B2 (en) Vectorization device, vectorization method, and recording medium on which vectorization program is stored
JP2003256214A (ja) 配列拡張によるループ変換方法
De Sutter et al. On the use of subword parallelism in medical image processing
JP3734658B2 (ja) コンパイラ装置およびコンパイラプログラムを記録したコンピュータ読取可能な記録媒体
JP2023002165A (ja) コンパイラ及びコンパイル方法
JP2009070070A (ja) コンパイラ及びコンパイル方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19892062

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020559760

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19892062

Country of ref document: EP

Kind code of ref document: A1