WO2022130883A1 - コンパイル装置、コンパイル方法、及びコンパイルプログラム記録媒体 - Google Patents

コンパイル装置、コンパイル方法、及びコンパイルプログラム記録媒体 Download PDF

Info

Publication number
WO2022130883A1
WO2022130883A1 PCT/JP2021/042164 JP2021042164W WO2022130883A1 WO 2022130883 A1 WO2022130883 A1 WO 2022130883A1 JP 2021042164 W JP2021042164 W JP 2021042164W WO 2022130883 A1 WO2022130883 A1 WO 2022130883A1
Authority
WO
WIPO (PCT)
Prior art keywords
vector
loop
vector register
data
register
Prior art date
Application number
PCT/JP2021/042164
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 US18/265,300 priority Critical patent/US20240053969A1/en
Publication of WO2022130883A1 publication Critical patent/WO2022130883A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/45Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions
    • G06F8/451Code distribution
    • G06F8/452Loops
    • 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

Definitions

  • the present invention relates to a compiling device, a compiling method, and a compiling program recording medium, and particularly to speeding up a program.
  • the access time from the arithmetic unit of the computer to the main memory is longer than the arithmetic time of the arithmetic unit, and the data transfer performance between the main memory and the arithmetic unit is insufficient.
  • a scalar computer shortens the access time to the main memory by providing a high-speed cache memory between the arithmetic unit and the main memory.
  • the access time to the main memory is shortened by transferring a large amount of data at once by a vector instruction.
  • the memory access time per piece of data can be regarded as one-third of the number of data transferred at the same time. The maximum value of this number is determined by the vector length of the vector computer, and when the value of the vector length is 256, the memory access time is 1/256, which is a small value.
  • the vector computer loads the data stored in the main memory onto the vector register and realizes high-speed calculation via the vector register. Therefore, how to efficiently bring the data in the main memory to the register is important for speeding up.
  • Patent Document 1 relates to a vector computer, and it is proposed to reduce duplicate memory access and improve execution performance when adjacent memory access instructions exist.
  • Patent Document 2 relates to a compilation method used in a computer, and it is proposed to extract an array in a source program and allocate it to a main memory or a temporary storage device according to the number of accesses.
  • each array element A (I) is processed as shown in FIG. 17 (b). It is common to issue vector load instructions for each of ⁇ A (I + 4).
  • Patent Document 1 vector load instructions are reduced by element-shifting adjacent data.
  • the data at the end of the vector register is insufficient due to the element shift, but the missing data is handled by changing the vector length so that the processing is executed by the scalar operation or the operation is not executed by the mask.
  • An object of the present invention is to provide a compiling device, a compiling method, and a compiling program that can speed up a program when a loop in the program includes access to adjacent data.
  • the compiling device is When the loop of the source program contains access to adjacent data, a loop analysis unit that determines whether the loop can be vectorized, and a loop analysis unit.
  • a vectorization execution unit that generates an instruction to read an element required for an operation from a memory to a vector register when access to the adjacent data is included and the loop can be vectorized. include.
  • the compilation method according to the present invention is If a loop in the source program contains access to adjacent data, determine if the loop is vectorizable and determine if the loop is vectorizable. When the access to the adjacent data is included and the loop is vectorizable, a vector load instruction is generated to read the elements required for the operation from the memory to the vector register. Generate a vector element shift instruction that generates vector data obtained by element-shifting the elements read into the above vector register. Generate vector operation instructions to perform operations, Generate a vector store instruction to write the operation result from the vector register to the memory.
  • the compilation program recording medium is Computer, When the loop of the source program contains access to adjacent data, a loop analysis means for determining whether the loop can be vectorized, and As a vectorization execution means that generates an instruction for reading an element required for an operation from a memory to a vector register when the access to the adjacent data is included and the loop can be vectorized. Record the compilation program that works.
  • a compiling device a compiling method, and a compiling program that can speed up a program when a loop in the program includes access to adjacent data.
  • the vector load instruction for loading the adjacent data is changed to the vector element shift instruction shown in FIG. 1 without memory access. Speed up the program by replacing it.
  • the data required for the operation is loaded into the vector register by the vector load instruction. Then, by shifting the elements of the vector register loaded with the data by the vector element shift instruction as shown in FIG. 6, adjacent data elements are generated.
  • the compiling device, compiling method, and compiling program of the embodiment of the present invention are used as a computer for executing the target program (object program).
  • a calculator is the calculator 150 shown in FIG. 2B, and includes an arithmetic unit 151, a main memory 152, and a temporary storage device 153.
  • the calculator 150 is a computer, which is a vector calculator capable of performing vector operations. A computer having such a configuration is proposed in Patent Document 2.
  • the arithmetic unit 151 of FIG. 2B is an apparatus for the calculator 150 to execute an arithmetic based on a program.
  • the arithmetic unit 151 is specifically an arithmetic unit in a processor such as a CPU (Central Processing Unit) or GPU (Graphics Processing Unit) of the computer, and is configured by, for example, an ALU (Arithmetic Logic Unit) in the CPU.
  • the arithmetic unit 151 acquires data from the main memory 152 or the temporary storage device 153 and executes an operation accordingly.
  • the main memory 152 in FIG. 2B is a main storage device accessible to the arithmetic unit 151 in the calculator 150.
  • the main memory 152 can hold data necessary for the arithmetic unit 151 to execute the arithmetic and data as a result of executing the arithmetic.
  • the temporary storage device 153 in FIG. 2B is a storage device that the arithmetic unit 151 can access at a higher speed than the main memory 152, and corresponds to, for example, a register.
  • the arithmetic unit 151 and the temporary storage device 153 constitute a CPU
  • the arithmetic unit 151 is an ALU in the CPU
  • the temporary storage device 153 is a register in the CPU.
  • the compile device of the embodiment of the present invention is a compiler that generates a target program executed by the computer 150 based on a primitive program (source program).
  • the compiler generates object code by compiling the source program, and generates the target program (object program).
  • FIG. 2A is a block diagram for explaining a compilation device according to the present embodiment.
  • the compiling device of FIG. 2A is a compiler 100 that compiles a source program and generates an object code.
  • the compiler 100 of FIG. 2A is based on the loop analysis unit 10 that analyzes the source program as a program and analyzes whether the loop in the program includes access to adjacent data and can be vectorized, and the analysis result.
  • a vectorization execution unit 20 for vectorizing a loop is included.
  • the compiling device according to this embodiment is used in the above-mentioned computer and is a function incorporated in the compiler.
  • the loop analysis unit 10 determines whether the adjacent data recognition means 11 for recognizing whether the loop includes access to the adjacent data and the loop including the access to the adjacent data can be vectorized.
  • the determination means 12 is included.
  • the vectorization execution unit 20 includes a vector load instruction generation means 21 for reading the elements required for the operation from the memory to the vector register. Further, the vectorization execution unit 20 is a vector element shift instruction generation means 22 for generating an instruction (vector element shift instruction) for calculating vector data obtained by element-shifting the element read into the vector register, and a vector for executing an operation. The arithmetic instruction generation means 23 is included. Further, the vectorization execution unit 20 includes a vector store instruction generation means 24 for writing the operation result from the vector register to the memory.
  • the computer used by the compiler is a vector computer capable of vector operation and includes a vector element shift instruction.
  • the vector element shift is 1.
  • the elements of the vector register specified by Vy are shifted to the left by one element and stored in the vector register specified by Vx.
  • the first element of the vector register specified by Vz is stored in the last element of the vector register specified by Vx. In this way, the compiler 100 generates the vector element shift in the vector element shift instruction generation means 22.
  • FIG. 3 is a flowchart for explaining a compilation method according to the first embodiment of the present invention.
  • FIG. 4 is an example of a source program targeted by the first embodiment of the present invention.
  • FIG. 5 is a conceptual diagram for explaining an operation of loading an element required for an operation from a memory by vector loading in the compilation method according to the first embodiment of the present invention.
  • FIG. 6 is a conceptual diagram for explaining an operation of generating adjacent data A (I + 1) by vector element shift in the compilation method according to the first embodiment of the present invention.
  • FIG. 7 is a conceptual diagram for explaining an operation of generating adjacent data A (I + 2) by vector element shift in the compilation method according to the first embodiment of the present invention.
  • FIG. 8 is a conceptual diagram for explaining an operation of generating adjacent data A (I + 3) by vector element shift in the compilation method according to the first embodiment of the present invention.
  • FIG. 9 is a conceptual diagram for explaining an operation of generating adjacent data A (I + 4) by vector element shift in the compilation method according to the first embodiment of the present invention.
  • FIG. 10 is a conceptual diagram for explaining the operation of the vector operation in the compilation method according to the first embodiment of the present invention.
  • FIG. 11 is a conceptual diagram for explaining the operation of storing the operation result by the vector store in the memory in the compilation method according to the first embodiment of the present invention.
  • FIG. 4 is a Fortran program having operations on adjacent data.
  • the program of FIG. 4 is an operation using array elements A (I) to A (I + 4), and the difference between the values of the subscript expressions of adjacent array elements is 1.
  • the program to which the present invention can be applied is not limited to the program in which the difference between the values of the subscript expressions of the adjacent array elements is 1.
  • step S1 Analyze the target source program.
  • the adjacency data recognition means 11 recognizes whether the source program includes an adjoining data access in a loop as shown in FIG. In other words, the adjacency data recognition means 11 determines whether or not the loop in the source program includes access to the adjoining data (step S2). When the loop in the source program does not include access to adjacent data (NO in step S2), the process proceeds to step S8.
  • step S3 When the loop in the source program includes access to adjacent data (YES in step S2), the process proceeds to step S3, and whether or not vectorization is possible in the loop including the adjacent data access by the vectorization determination means 12. Is determined (step S3).
  • the condition that can be vectorized is that there is no dependency that hinders vectorization in the definition / reference relationship of arrays and variables.
  • step S8 When vectorization is not possible (NO in step S3), the process proceeds to step S8.
  • step S3 When vectorization is possible (YES in step S3), the process proceeds to step S4, and the loop that includes adjacent data access and is vectorizable is vectorized by the vectorization execution unit 20.
  • the vectorization execution unit 20 generates an instruction sequence from the source program of FIG. 4 according to the procedure of FIGS. 5 to 11.
  • the vectorization execution unit 20 generates a vector load instruction by the vector load instruction generation means 21 in order to load the data required for the operation from the memory into the vector register.
  • the maximum index expression of the array is I + 4. Therefore, the number of data elements used in one vector operation is the vector length + 4. Since the vector length of the loop in FIG. 4 is 256, the 1st to 256th elements of the array A are loaded into vreg1 and the 257th to 260th elements of the array A are loaded into vreg2 as shown in FIG. vreg1 is a vector register having an element corresponding to A (I).
  • the vector element shift instruction generation means 22 After loading the data into the vector register, the vector element shift instruction generation means 22 generates a vector register having adjacent data elements.
  • a vector register having adjacent data elements is generated by the vector element shift instruction of FIG.
  • the vector register having the element corresponding to A (I + 1) can be generated as shown in (1) and (2) of FIG. 6 by inputting vreg1 and vreg2 to the vector element shift instruction.
  • vreg3 is a vector register having an element corresponding to A (I + 1).
  • a vector register having an element corresponding to A (I + 2) To generate a vector register having an element corresponding to A (I + 2), first generate vreg4 whose first element is 258 from vreg2 by the vector element shift instruction as shown in (1) of FIG. Then, by using the previously generated vreg3 and vreg4 as the input of the vector element shift instruction, a vector register having an element corresponding to A (I + 2) is generated as shown in (2) of FIG. 7 and (3) of FIG. can.
  • vreg5 is a vector register having an element corresponding to A (I + 2).
  • two vector element shift instructions are executed in the same procedure as for A (I + 2), respectively, to execute two vector element shift instructions from (1) to (3) in FIG. ), Can be generated as shown in (1) to (3) of FIG.
  • the vector operation instruction generation means 23 generates an operation instruction as shown in FIG. 10 (step S6).
  • the vector store instruction generation means 24 generates a vector store instruction as shown in FIG. 11 (step S7).
  • the target program is generated by integrating the determination result in step S2, the determination result in step S3, and the instructions generated in steps S4 to S7 (step S8).
  • FIG. 12A is an instruction sequence generated by the background technique
  • FIG. 12B is an instruction sequence generated by the embodiment of the present invention.
  • the background technology compilation method when performing a vector operation on adjacent data, a vector load instruction is issued for each array element A (I) to A (I + 4), and all the data used in the operation is shown in the figure. It was read into the vector register by the vector load instruction like 12A.
  • the vector load instruction is replaced with the vector element shift instruction without memory access in the vector operation for the adjacent data.
  • the number of vector load instructions executed can be reduced by generating the vector element shift instruction as shown in FIG. 12B. By reducing the number of vector load instructions executed, access to memory can be reduced and the program can be speeded up.
  • the compile device the compile method, and the compile program of the present embodiment, it is possible to generate adjacent data elements by the vector element shift instruction and execute the operation without changing the vector length. As a result, the operation can be efficiently executed without reducing the vector length. It should be noted that the same effect as described above can be obtained even on the program recording medium in which the compiled program is recorded.
  • FIG. 13 is an example of a source program targeted by the second embodiment of the present invention.
  • FIG. 14 is a conceptual diagram for explaining a compilation method according to the second embodiment of the present invention.
  • the program of FIG. 13 is an operation using array elements A (I), A (I + 3), A (I + 4), A (I + 7), and A (I + 10), and is a difference between the values of the subscript expressions of adjacent array elements.
  • Is a program using an array element in which is 2 or more. In this embodiment, 1.
  • the elements of the vector register specified by Vy are shifted to the left by the value of the register specified by Sx and stored in the vector register specified by Vx.
  • the first element Sx of the vector register specified by Vz is stored in the last element of the vector register specified by Vx.
  • the compiling device, the compiling method, and the compiling program according to the present embodiment can be applied as long as the vector computer capable of vector operation has a vector element shift instruction capable of shifting multiple elements as shown in FIG. Further, even if the vector computer does not have such an instruction, it can be applied by generating a plurality of vector element shift instructions.
  • the compile device includes a vector load instruction for loading adjacent data
  • the vector load instruction is stored in the memory.
  • Replace with a vector element shift instruction without access Instructions without memory access are faster than instructions with memory access, such as vector load instructions.
  • this vector load instruction By replacing this vector load instruction with a vector element shift instruction that does not involve memory access, the number of executions of the vector load instruction can be reduced. As a result, the program can be speeded up as in the first embodiment.
  • the compile device the compile method, and the compile program of the present embodiment, it is possible to generate adjacent data elements by the vector element shift instruction and execute the operation without changing the vector length. As a result, the operation can be efficiently executed without reducing the vector length.
  • the source program includes a vector load instruction for loading adjacent data
  • this vector load instruction is used.
  • FIG. 15 is an example of a source program targeted by the third embodiment of the present invention.
  • FIG. 16 is a conceptual diagram for explaining a compilation method according to the third embodiment of the present invention.
  • the program of FIG. 15 is an operation using array elements A (I), A (I-1), A (I-2), A (I-3), and A (I-4), and is an adjacent array. It is a program that uses an array element that reduces the value of the subscript expression of the element. In this embodiment, 1.
  • the elements of the vector register specified by Vy are shifted to the right by one element and stored in the vector register specified by Vx.
  • the first element of the vector register specified by Vz is combined with the first element of Vx.
  • the vector register specified by Vy is shifted to the right by one element and assigned to Vx. Furthermore, the first element of the vector register specified by Vz is combined with the first element of Vx. Similarly, by shifting to the right and assigning to Vx and combining the first element of the vector register specified by Vz with the first element of Vx, A (I-2), A (I-3), A ( Data can be loaded in the same manner for I-4).
  • the compiling device, the compiling method, and the compiling program according to the present embodiment apply the vector element shift instruction as shown in FIG. 16 whose shift direction is opposite to that of FIG. 1 if the vector computer capable of vector operation has. can. Further, even if a vector computer capable of vector operation does not have such an instruction, it can be applied by loading data from the array element A (I-4) instead of the array element A (I).
  • the compile device includes a vector load instruction for loading adjacent data
  • the vector load instruction is stored in the memory.
  • Replace with a vector element shift instruction without access Instructions without memory access are faster than instructions with memory access, such as vector load instructions.
  • this vector load instruction By replacing this vector load instruction with a vector element shift instruction that does not involve memory access, the number of executions of the vector load instruction can be reduced. As a result, the program can be speeded up as in the first embodiment.
  • the compile device the compile method, and the compile program of the present embodiment, it is possible to generate adjacent data elements by the vector element shift instruction and execute the operation without changing the vector length. As a result, the operation can be efficiently executed without reducing the vector length.
  • the source program includes a vector load instruction for loading the adjacent data, this is the case.
  • the vector load instruction can be replaced with a vector element shift instruction without memory access. This makes it possible to expand the range of target programs that can be speeded up. It should be noted that the same effect as described above can be obtained even on the program recording medium in which the compiled program is recorded.
  • the vectorization execution unit is A vector load instruction generation means for generating an instruction for reading an element required for an operation from a memory into the vector register, and a vector load instruction generation means.
  • a vector element shift instruction generation means for generating vector data obtained by element-shifting the elements read into the vector register, and Vector operation instruction generation means that generates operation instructions to execute operations
  • a vector store instruction generation means for generating a vector store instruction for writing an operation result from the vector register to a memory, and the like.
  • the compiling device according to Appendix 1. (Appendix 3) When the value of the subscript expression of the adjacent array element increases, the vector element shift instruction generation means shifts the data of the specified first vector register to the left by the increase number of the value and assigns it to the second vector register. Then, from the first element of the next vector register, the same number as the increase number is connected to the end.
  • the vector element shift instruction generation means shifts the data of the specified first vector register to the right by the decrease number of the value and assigns it to the second vector register. Then, from the first element of the next vector register, the same number as the decrease number is connected to the first element.
  • the compiling device described in Appendix 2. (Appendix 5)
  • the loop analysis unit Adjacent data recognition means that recognize whether the loop contains access to adjacent data, A vectorization determination means for determining whether a loop containing access to adjacent data can be vectorized, and the like.
  • the compiling device according to any one of Supplementary note 1 to Supplementary note 4.
  • a loop in the source program contains access to adjacent data, determine if the loop is vectorizable and determine if the loop is vectorizable.
  • a vector load instruction is generated to read the elements required for the operation from the memory to the vector register.
  • Generate a vector element shift instruction to generate vector data obtained by element-shifting the elements read into the vector register.
  • Generate vector operation instructions to perform operations Generate a vector store instruction to write the operation result from the vector register to the memory. How to compile.
  • the vectorization execution means is A vector load instruction generation means for generating an instruction for reading an element required for an operation from a memory into the vector register, and a vector load instruction generation means.
  • a vector element shift instruction generation means for generating vector data obtained by element-shifting the elements read into the vector register, and Vector operation instruction generation means that generates operation instructions to execute operations
  • a vector store instruction generation means for generating a vector store instruction for writing an operation result from the vector register to a memory, and the like.
  • the compilation program described in Appendix 9. (Appendix 11) When the value of the subscript expression of the adjacent array element increases, the vector element shift instruction generation means shifts the data of the specified first vector register to the left by the increase number of the value and assigns it to the second vector register. Then, from the first element of the next vector register, the same number as the increase number is connected to the end.
  • the vector element shift instruction generation means shifts the data of the specified first vector register to the right by the decrease number of the value and assigns it to the second vector register. Then, from the first element of the next vector register, the same number as the decrease number is connected to the first element.
  • the compilation program described in Appendix 10. (Appendix 13)
  • the loop analysis means is Adjacent data recognition means that recognize whether the loop contains access to adjacent data, A vectorization determination means for determining whether a loop containing access to adjacent data can be vectorized, and the like.
  • the compilation program according to any one of Supplementary note 9 to Supplementary note 12.
  • Loop analysis unit 11 Adjacent data recognition means 12
  • Vectorization judgment means 20 Vectorization execution unit 21
  • Vector operation instruction generation means 24 Vector store instruction generation means 100 Compiler

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Devices For Executing Special Programs (AREA)
  • Complex Calculations (AREA)

Abstract

プログラム中のループが隣接するデータへのアクセスを含んでいる場合にプログラムを高速化することができる、コンパイル装置、コンパイル方法、及びコンパイルプログラムを提供する。コンパイル装置は、ソースプログラムのループ中に隣接するデータへのアクセスが含まれる場合に、そのループがベクトル化可能であるかを判定するループ解析部と、上記隣接するデータへのアクセスが含まれ、かつ、そのループがベクトル化可能である場合に、演算に必要となる要素をメモリからベクトルレジスタへ読み込むための命令を生成するベクトル化実行部と、を含む。

Description

コンパイル装置、コンパイル方法、及びコンパイルプログラム記録媒体
 本発明は、コンパイル装置、コンパイル方法、及びコンパイルプログラム記録媒体に関し、特にプログラムの高速化に関する。
 計算機の演算装置からメインメモリへのアクセス時間は、演算装置の演算時間と比べると大きく、メインメモリと演算装置との間のデータ転送性能は不足している。この広がる性能差を埋めるために、一般にスカラ計算機では、演算装置とメインメモリ間に高速なキャッシュメモリを設けることにより、メインメモリへのアクセス時間を短縮している。一方、ベクトル計算機では、ベクトル命令により一度に多くのデータをまとめて転送することにより、メインメモリへのアクセス時間を短縮している。データ1個あたりのメモリアクセス時間は、同時に転送されたデータの個数分の1とみなすことができる。この個数の最大値はベクトル計算機のベクトル長で決まり、ベクトル長の値が256の場合は、メモリアクセス時間は256分の1と、小さい値になる。
 またベクトル計算機では、メインメモリに配置されているデータをベクトルレジスタ上にロードしてそのベクトルレジスタを介して、高速な演算を実現している。このため、メインメモリ上のデータをいかに効率良くレジスタ上に持ってくるかということが、高速化のために重要である。
 特許文献1は、ベクトル計算機に関するものであり、隣接するメモリアクセス命令が存在するときに重複したメモリアクセスを削減して実行性能を向上させることが提案されている。
 特許文献2は、計算機で用いられるコンパイル方法に関するものであり、ソースプログラムにおける配列を抽出し、アクセス回数に応じてメインメモリ又は一時記憶装置に割り当てることが提案されている。
特開2000-048009号公報 特開2013-182293号公報
 しかしながら、上述した背景技術のコンパイル方法には以下のような課題がある。背景技術のコンパイル方法では、図17の(a)に示すプログラムのように隣接するデータに対する演算をベクトル命令で処理する際には、図17の(b)のように各配列要素A(I)~A(I+4)に対してベクトルロード命令をそれぞれ発行するのが一般的である。
 しかしながら、図17の(b)のように各配列要素に対してベクトルロード命令をそれぞれ発行すると、ベクトルロード命令実行数が増大する。また図17の(b)では、各ベクトルロード命令間において重複した要素をロードしている状態にある。ベクトルロード命令のようにメモリアクセスを伴う命令は、メモリアクセスを伴わない命令に比べて低速であり、重複した要素のロードはプログラムを低速にする。
 特許文献1では、隣接するデータを要素シフトすることでベクトルロード命令を削減している。特許文献1では、要素シフトすることでベクトルレジスタの末尾のデータが不足するが、ベクトル長を変更して不足したデータについてはスカラ演算により処理を実行する、もしくはマスクにより演算を実行しないように取り扱うことが提案されている。このため、ベクトル長を変更して不足したデータについてはスカラ演算により処理を実行する、もしくはマスクにより演算を実行しない、といった取り扱いが必要であり、演算実行の効率性が低下するという課題がある。
 本発明の目的は、プログラム中のループが隣接するデータへのアクセスを含んでいる場合にプログラムを高速化することができる、コンパイル装置、コンパイル方法、及びコンパイルプログラムを提供することにある。
 前記目的を達成するため、本発明に係るコンパイル装置は、
 ソースプログラムのループ中に隣接するデータへのアクセスが含まれる場合に、そのループがベクトル化可能であるかを判定するループ解析部と、
 上記隣接するデータへのアクセスが含まれ、かつ、そのループがベクトル化可能である場合に、演算に必要となる要素をメモリからベクトルレジスタへ読み込むための命令を生成するベクトル化実行部と、を含む。
 本発明に係るコンパイル方法は、
 ソースプログラムのループ中に隣接するデータへのアクセスが含まれる場合に、そのループがベクトル化可能であるかを判定し、
 上記隣接するデータへのアクセスが含まれ、かつ、そのループがベクトル化可能である場合に、演算に必要となる要素をメモリからベクトルレジスタへ読み込むためのベクトルロード命令を生成し、
 上記ベクトルレジスタへ読み込んだ要素を要素シフトしたベクトルデータを生成するベクトル要素シフト命令を生成し、
 演算を実行するためのベクトル演算命令を生成し、
 演算結果を上記ベクトルレジスタからメモリへ書き込むためのベクトルストア命令を生成する。
 本発明に係るコンパイルプログラム記録媒体は、
 コンピュータを、
 ソースプログラムのループ中に隣接するデータへのアクセスが含まれる場合に、そのループがベクトル化可能であるかを判定するループ解析手段と、
 上記隣接するデータへのアクセスが含まれ、かつ、そのループがベクトル化可能である場合に、演算に必要となる要素をメモリからベクトルレジスタへ読み込むための命令を生成するベクトル化実行手段と、して機能させるコンパイルプログラムを記録する。
 本発明によれば、プログラム中のループが隣接するデータへのアクセスを含んでいる場合にプログラムを高速化することができる、コンパイル装置、コンパイル方法、及びコンパイルプログラムを提供することができる。
本発明の実施形態のコンパイル方法を説明するための概念図である。 本発明の第1実施形態によるコンパイラを説明するためのブロック図である。 本発明の実施形態のコンパイル装置、コンパイル方法、及びコンパイルプログラムに関して、目的プログラムを実行する計算機の構成を説明するためのブロック図である。 本発明の第1実施形態によるコンパイル方法を説明するためのフローチャートである。 本発明の第1実施形態が対象とするソースプログラムの一例である。 本発明の第1実施形態によるコンパイル方法のうち、ベクトルロードにより演算に必要となる要素をメモリからロードする動作を説明するための概念図である。 本発明の第1実施形態によるコンパイル方法のうち、ベクトル要素シフトにより隣接データA(I+1)を生成する動作を説明するための概念図である。 本発明の第1実施形態によるコンパイル方法のうち、ベクトル要素シフトにより隣接データA(I+2)を生成する動作を説明するための概念図である。 本発明の第1実施形態によるコンパイル方法のうち、ベクトル要素シフトにより隣接データA(I+3)を生成する動作を説明するための概念図である。 本発明の第1実施形態によるコンパイル方法のうち、ベクトル要素シフトにより隣接データA(I+4)を生成する動作を説明するための概念図である。 本発明の第1実施形態によるコンパイル方法のうち、ベクトル演算の動作を説明するための概念図である。 本発明の第1実施形態によるコンパイル方法のうち、ベクトルストアによる演算結果をメモリへストアする動作を説明するための概念図である。 背景技術により生成される命令列である。 本発明の実施形態により生成される命令列である。 本発明の第2実施形態が対象とするソースプログラムの一例である。 本発明の第2実施形態によるコンパイル方法を説明するための概念図である。 本発明の第3実施形態が対象とするソースプログラムの一例である。 本発明の第3実施形態によるコンパイル方法を説明するための概念図である。 (a)は隣接アクセスを伴う演算のソースプログラムであり、(b)は背景技術のコンパイル方法で生成される命令列である。
 本発明の具体的な実施形態について説明する前に、実施形態の概要について説明する。
 本発明の実施形態では、隣接するデータをロードするベクトルロード命令がソースプログラムに含まれる場合、この隣接するデータをロードするベクトルロード命令を、メモリアクセスを伴わない図1に示すベクトル要素シフト命令に置き換えることでプログラムを高速化する。
 図5のように、演算に必要となるデータをベクトルロード命令により、ベクトルレジスタにロードをする。そして、データをロードしたベクトルレジスタの要素をベクトル要素シフト命令により図6のようにシフトすることで、隣接するデータ要素を生成する。
 ベクトル要素シフト命令により隣接するデータ要素を生成することで、重複するデータのロードを無くすことできるためベクトルロード命令実行数を削減できプログラムを高速化できる。
 本発明の実施形態のコンパイル装置、コンパイル方法、及びコンパイルプログラムは、目的プログラム(オブジェクトプログラム)を実行する計算機に用いられる。このような計算機は、図2Bに示される計算機150であり、演算装置151、メインメモリ152、及び一時記憶装置153を含んで構成される。計算機150はコンピュータであり、ベクトル演算が可能なベクトル計算機である。このような構成の計算機は、特許文献2で提案されている。
 図2Bの演算装置151は、プログラムに基づいて計算機150が演算を実行するための装置である。演算装置151は、具体的には計算機のCPU(Central Processing Unit)、GPU(Graphics Processing Unit)といったプロセッサ内の演算装置であり、例えばCPUにおけるALU(Arithmetic Logic Unit)により構成される。演算装置151は、メインメモリ152又は一時記憶装置153からデータを取得し、それに応じて演算を実行する。
 図2Bのメインメモリ152は、計算機150において演算装置151がアクセス可能な主記憶装置である。メインメモリ152は、演算装置151が演算を実行するために必要なデータ及び演算を実行した結果のデータを保持することができる。
 図2Bの一時記憶装置153は、演算装置151がメインメモリ152よりも高速にアクセス可能な記憶装置であり、例えばレジスタが該当する。例えば、演算装置151及び一時記憶装置153がCPUを構成する場合には、演算装置151はCPU内のALU、一時記憶装置153はCPU内のレジスタである。
 本発明の実施形態のコンパイル装置は、上記計算機150が実行する目的プログラムを、原始プログラム(ソースプログラム)に基づいて生成するコンパイラである。コンパイラは、ソースプログラムをコンパイルすることにより、オブジェクトコードを生成し、目的プログラム(オブジェクトプログラム)を生成する。以下、本発明の具体的な実施形態について、図面を参照しながら詳細に説明する。
 〔第1実施形態〕
 初めに、本発明の第1実施形態によるコンパイル装置、コンパイル方法、及びコンパイルプログラムについて、説明する。
 (実施形態の構成)
 図2Aは、本実施形態によるコンパイル装置を説明するためのブロック図である。図2Aのコンパイル装置は、ソースプログラムをコンパイルしてオブジェクトコードを生成するコンパイラ100である。図2Aのコンパイラ100は、プログラムとしてのソースプログラムを解析してプログラム中のループが隣接するデータへのアクセスを含んでおりベクトル化可能であるかを解析するループ解析部10、及び解析結果に基づきループをベクトル化するベクトル化実行部20を含む。本実施形態によるコンパイル装置は、上述した計算機に用いられ、コンパイラに組み込まれる一機能である。
 ループ解析部10は、ループ中に隣接するデータへのアクセスが含まれているか認識する隣接データ認識手段11、及び隣接するデータへのアクセスを含むループがベクトル化可能であるかを判断するベクトル化判定手段12を含む。
 ベクトル化実行部20は、演算に必要となる要素をメモリからベクトルレジスタへ読込むためのベクトルロード命令生成手段21を含む。さらにベクトル化実行部20は、ベクトルレジスタへ読み込んだ要素を要素シフトしたベクトルデータを計算する命令(ベクトル要素シフト命令)を生成するためのベクトル要素シフト命令生成手段22、演算を実行するためのベクトル演算命令生成手段23を含む。さらにベクトル化実行部20は、演算結果をベクトルレジスタからメモリへ書込むためのベクトルストア命令生成手段24を含む。
 本発明の実施形態において、コンパイラが用いられる計算機はベクトル演算が可能なベクトル計算機であり、ベクトル要素シフト命令を備えているものとする。ベクトル要素シフトは、図1の1.に示すようにVyで指定されたベクトルレジスタの要素を1要素左へシフトしてVxで指定されたベクトルレジスタに格納し、図1の2.に示すようにVzで指定されたベクトルレジスタの先頭要素をVxで指定されたベクトルレジスタの最後尾の要素に格納する。こうしてコンパイラ100は、ベクトル要素シフト命令生成手段22においてベクトル要素シフトを生成する。
 (実施形態の動作)
 次に、図3~11を用いて動作について説明する。図3は、本発明の第1実施形態によるコンパイル方法を説明するためのフローチャートである。図4は、本発明の第1実施形態が対象とするソースプログラムの一例である。図5は、本発明の第1実施形態によるコンパイル方法のうち、ベクトルロードにより演算に必要となる要素をメモリからロードする動作を説明するための概念図である。図6は、本発明の第1実施形態によるコンパイル方法のうち、ベクトル要素シフトにより隣接データA(I+1)を生成する動作を説明するための概念図である。図7は、本発明の第1実施形態によるコンパイル方法のうち、ベクトル要素シフトにより隣接データA(I+2)を生成する動作を説明するための概念図である。図8は、本発明の第1実施形態によるコンパイル方法のうち、ベクトル要素シフトにより隣接データA(I+3)を生成する動作を説明するための概念図である。図9は、本発明の第1実施形態によるコンパイル方法のうち、ベクトル要素シフトにより隣接データA(I+4)を生成する動作を説明するための概念図である。図10は、本発明の第1実施形態によるコンパイル方法のうち、ベクトル演算の動作を説明するための概念図である。図11は、本発明の第1実施形態によるコンパイル方法のうち、ベクトルストアによる演算結果をメモリへストアする動作を説明するための概念図である。
 本説明においては、1つのベクトルレジスタの要素数は256とする。図4は、隣接するデータに対する演算を有するFortranプログラムとなっている。図4のプログラムは、配列要素A(I)~A(I+4)を用いた演算であり、隣接する配列要素の添字式の値の差が1のプログラムである。なお後述するように、本発明が適用できるプログラムは隣接する配列要素の添字式の値の差が1のプログラムに限られない。
 対象のソースプログラムを解析する(ステップS1)。隣接データ認識手段11は、ソースプログラムに図4のようなループが隣接するデータアクセスを含むかを認識する。言い換えると、隣接データ認識手段11は、ソースプログラム中のループが隣接するデータへのアクセスを含んでいるか否かを判断する(ステップS2)。ソースプログラム中のループが隣接するデータへのアクセスを含んでいないとき(ステップS2のNO)は、ステップS8に進む。
 ソースプログラム中のループが隣接するデータへのアクセスを含んでいるとき(ステップS2のYES)はステップS3に進み、ベクトル化判定手段12が隣接するデータアクセスを含むループにおいてベクトル化が可能か否かを判定する(ステップS3)。ベクトル化できる条件としては、配列や変数の定義・参照関係にベクトル化を阻害する依存関係がないことが挙げられる。ベクトル化が可能でないとき(ステップS3のNO)は、ステップS8に進む。
 ベクトル化が可能なとき(ステップS3のYES)はステップS4に進み、隣接するデータアクセスを含みかつベクトル化可能であるループをベクトル化実行部20でベクトル化する。ベクトル化実行部20では、図5~11の手順により図4のソースプログラムから命令列を生成する。
 ベクトル化実行部20では、演算に必要となるデータをベクトルレジスタへメモリからロードするためにベクトルロード命令生成手段21によりベクトルロード命令を生成する。図4のソースプログラムでは配列の添字式の最大はI+4となる。そのため、1回のベクトル演算において使用するデータの要素数はベクトル長+4個となる。図4のループのベクトル長は256となるため、図5のようにvreg1に配列Aの1~256番目の要素、vreg2に配列Aの257~260番目の要素をロードすることになる。vreg1がA(I)に該当する要素を持つベクトルレジスタとなる。
 ベクトルレジスタへデータをロードしたのち、ベクトル要素シフト命令生成手段22が隣接するデータ要素を持つベクトルレジスタを生成する。隣接するデータ要素を持つベクトルレジスタは、図1のベクトル要素シフト命令により生成する。
 本実施形態ではA(I+1)に該当する要素を持つベクトルレジスタは、vreg1とvreg2をベクトル要素シフト命令の入力とすることで、図6の(1)及び(2)に示すよう生成することができる。vreg3が、A(I+1)に該当する要素を持つベクトルレジスタとなる。
 A(I+2)に該当する要素を持つベクトルレジスタを生成するには、図7の(1)のようにベクトル要素シフト命令によりvreg2から先頭要素が258となるvreg4を先に生成する。そして、先に生成したvreg3とvreg4をベクトル要素シフト命令の入力とすることで図7の(2)、図7の(3)のようにA(I+2)に該当する要素を持つベクトルレジスタを生成できる。vreg5が、A(I+2)に該当する要素を持つベクトルレジスタとなる。A(I+3)、A(I+4)に該当する要素を持つベクトルレジスタについても、A(I+2)と同様の手順によりそれぞれベクトル要素シフト命令を2命令実行することで図8の(1)~(3)、図9の(1)~(3)のように生成することができる。
 隣接する要素を持つベクトルレジスタを生成できたら、生成したベクトルレジスタを入力として演算を実行する。ベクトル演算命令生成手段23により、図10のような演算命令を生成する(ステップS6)。
 最後に、ベクトルストアにより演算結果をメモリへストアする。ベクトルストア命令生成手段24により図11のようなベクトルストア命令を生成する(ステップS7)。ステップS2での判定結果、ステップS3での判定結果、及びステップS4からステップS7で生成された命令を総合して、目的プログラムを生成する(ステップS8)。
 (実施形態の効果)
 本実施形態のコンパイル装置、コンパイル方法、及びコンパイルプログラムによれば、隣接するデータをロードするベクトルロード命令がソースプログラムに含まれる場合にはこのベクトルロード命令を、メモリアクセスを伴わないベクトル要素シフト命令に置き換える。メモリアクセスを伴わない命令は、ベクトルロード命令のようにメモリアクセスを伴う命令に比べて高速である。このベクトルロード命令の、メモリアクセスを伴わないベクトル要素シフト命令への置き換えによって、ベクトルロード命令の実行数を削減することができる。これにより、プログラムを高速化することができる。
 図12Aは、背景技術により生成される命令列であり、図12Bは、本発明の実施形態により生成される命令列である。背景技術のコンパイル方法では、隣接するデータに対するベクトル演算の際には、各配列要素A(I)~A(I+4)に対してベクトルロード命令をそれぞれ発行し、演算で使用するすべてのデータを図12Aのようにベクトルロード命令によりベクトルレジスタへ読み込んでいた。これに対して、本発明の実施形態のコンパイル方法では、隣接するデータに対するベクトル演算の際にベクトルロード命令を、メモリアクセスを伴わないベクトル要素シフト命令に置き換える。これにより、図12Bのようにベクトル要素シフト命令を生成することで、ベクトルロード命令の実行数を減らすことができる。ベクトルロード命令実行数を減らすことでメモリへのアクセスを減らすことができ、プログラムを高速化できる。
 さらに本実施形態のコンパイル装置、コンパイル方法、及びコンパイルプログラムによれば、ベクトル要素シフト命令により隣接するデータ要素を生成して、ベクトル長を変更することなく演算を実行することができる。これにより、ベクトル長を削減することなく効率的に演算を実行することができる。なお、コンパイルプログラムを記録したプログラム記録媒体においても、上述した効果と同様の効果を奏することができる。
 〔第2実施形態〕
 次に、本発明の第2実施形態によるコンパイル装置、コンパイル方法、及びコンパイルプログラムについて、説明する。本実施形態によるコンパイル装置、コンパイル方法、及びコンパイルプログラムについて、上述した第1実施形態と同様な内容についてはその詳細な説明を省略して、相違点について説明する。上述した第1実施形態では、隣接する配列要素の添字式の値の差が1のプログラムを例に説明したが、本発明はこれに限られない。例えば、各添字式の値の差が1より大きいプログラムにおいても適用できる。
 図13は、本発明の第2実施形態が対象とするソースプログラムの一例である。図14は、本発明の第2実施形態によるコンパイル方法を説明するための概念図である。図13のプログラムは、配列要素A(I)、A(I+3)、A(I+4)、A(I+7)、A(I+10)を用いた演算であり、隣接する配列要素の添字式の値の差が2以上である配列要素を用いたプログラムである。本実施形態では、図14の1.に示すようにVyで指定されたベクトルレジスタの要素をSxで指定されたレジスタの値だけ左へシフトしてVxで指定されたベクトルレジスタに格納し、図14の2.に示すようにVzで指定されたベクトルレジスタの先頭要素Sx個をVxで指定されたベクトルレジスタの最後尾の要素に格納する。
 図14では、Sx=2の場合を示している。図14では、Vyで指定されたベクトルレジスタをSxで指定されたレジスタの値(Sx=2)だけ左シフトしてVxに代入している。さらにVxの最後尾の要素にVzで指定されたベクトルレジスタの先頭要素Sx個(Sx=2)を結合している。
 例えば配列要素A(I)から配列要素A(I+3)を生成するときには、Vyで指定されたベクトルレジスタをSxで指定されたレジスタの値(Sx=3)だけ左シフトしてVxに代入する。さらにVxの最後尾の要素にVzで指定されたベクトルレジスタの先頭要素Sx個(Sx=3)を結合する。以下同様に、添字式の値の差に対応する、Sxで指定されたレジスタの値だけ左シフトしてVxに代入し、Vxの最後尾の要素にVzで指定されたベクトルレジスタの先頭要素Sx個を結合する。このように、添字式の値の差に対応する、Sxで指定されたレジスタの値だけ左シフトしてVxに代入し、Vxの最後尾の要素にVzで指定されたベクトルレジスタの先頭要素Sx個を結合することで、A(I+4)、A(I+7)やA(I+10)についても同様にデータをロードすることができる。
 本実施形態によるコンパイル装置、コンパイル方法、及びコンパイルプログラムは、図14に示すような複数要素シフト可能であるベクトル要素シフト命令を、ベクトル演算が可能なベクトル計算機が有していれば適用できる。また、ベクトル計算機がそのような命令を有していなくても、複数ベクトル要素シフト命令を生成することでも適用できる。
 (実施形態の効果)
 本実施形態のコンパイル装置、コンパイル方法、及びコンパイルプログラムによれば、第1実施形態と同様に、隣接するデータをロードするベクトルロード命令がソースプログラムに含まれる場合にはこのベクトルロード命令を、メモリアクセスを伴わないベクトル要素シフト命令に置き換える。メモリアクセスを伴わない命令は、ベクトルロード命令のようにメモリアクセスを伴う命令に比べて高速である。このベクトルロード命令の、メモリアクセスを伴わないベクトル要素シフト命令への置き換えによって、ベクトルロード命令の実行数を削減することができる。これにより、第1実施形態と同様に、プログラムを高速化することができる。
 さらに本実施形態のコンパイル装置、コンパイル方法、及びコンパイルプログラムによれば、ベクトル要素シフト命令により隣接するデータ要素を生成して、ベクトル長を変更することなく演算を実行することができる。これにより、ベクトル長を削減することなく効率的に演算を実行することができる。
 さらに本実施形態によれば、隣接する配列要素の添字式の値の差が2以上のプログラムにおいても、隣接するデータをロードするベクトルロード命令がソースプログラムに含まれる場合にはこのベクトルロード命令を、メモリアクセスを伴わないベクトル要素シフト命令に置き換えることができる。これにより、高速化が可能な対象プログラムの範囲を拡げることができる。なお、コンパイルプログラムを記録したプログラム記録媒体においても、上述した効果と同様の効果を奏することができる。
 〔第3実施形態〕
 次に、本発明の第3実施形態によるコンパイル装置、コンパイル方法、及びコンパイルプログラムについて、説明する。本実施形態によるコンパイル装置、コンパイル方法、及びコンパイルプログラムについて、上述した第1実施形態と同様な内容についてはその詳細な説明を省略して、相違点について説明する。上述した第1実施形態では、隣接する配列要素の添字式の値の差が1で値が増加するプログラムを例に説明したが、本発明はこれに限られない。例えば、添字式の値が減少するような場合においても適用できる。
 図15は、本発明の第3実施形態が対象とするソースプログラムの一例である。図16は、本発明の第3実施形態によるコンパイル方法を説明するための概念図である。図15のプログラムは、配列要素A(I)、A(I-1)、A(I-2)、A(I-3)、A(I-4)を用いた演算であり、隣接する配列要素の添字式の値が減少するような配列要素を用いたプログラムである。本実施形態では、図16の1.に示すようにVyで指定されたベクトルレジスタの要素を1要素右へシフトしてVxで指定されたベクトルレジスタに格納し、図16の2.に示すようにVxの先頭要素にVzで指定されたベクトルレジスタの先頭要素を結合する。
 例えば配列要素A(I)から配列要素A(I-1)を生成するときには、Vyで指定されたベクトルレジスタを1要素右シフトしてVxに代入する。さらにVxの先頭要素にVzで指定されたベクトルレジスタの先頭要素を結合する。以下同様に、右シフトしてVxに代入し、Vxの先頭要素にVzで指定されたベクトルレジスタの先頭要素を結合することで、A(I-2)、A(I-3)、A(I-4)についても同様にデータをロードすることができる。
 本実施形態によるコンパイル装置、コンパイル方法、及びコンパイルプログラムは、図1とはシフト方向が逆となる図16のようなベクトル要素シフト命令を、ベクトル演算が可能なベクトル計算機が有していれば適用できる。またベクトル演算が可能なベクトル計算機がそのような命令を有していなくても、配列要素A(I)ではなく配列要素A(I-4)を基点としてデータをロードすることでも適用できる。
 (実施形態の効果)
 本実施形態のコンパイル装置、コンパイル方法、及びコンパイルプログラムによれば、第1実施形態と同様に、隣接するデータをロードするベクトルロード命令がソースプログラムに含まれる場合にはこのベクトルロード命令を、メモリアクセスを伴わないベクトル要素シフト命令に置き換える。メモリアクセスを伴わない命令は、ベクトルロード命令のようにメモリアクセスを伴う命令に比べて高速である。このベクトルロード命令の、メモリアクセスを伴わないベクトル要素シフト命令への置き換えによって、ベクトルロード命令の実行数を削減することができる。これにより、第1実施形態と同様に、プログラムを高速化することができる。
 さらに本実施形態のコンパイル装置、コンパイル方法、及びコンパイルプログラムによれば、ベクトル要素シフト命令により隣接するデータ要素を生成して、ベクトル長を変更することなく演算を実行することができる。これにより、ベクトル長を削減することなく効率的に演算を実行することができる。
 さらに本実施形態によれば、隣接する配列要素の添字式の値が減少するような配列要素を用いたプログラムにおいても、隣接するデータをロードするベクトルロード命令がソースプログラムに含まれる場合にはこのベクトルロード命令を、メモリアクセスを伴わないベクトル要素シフト命令に置き換えることができる。これにより、高速化が可能な対象プログラムの範囲を拡げることができる。なお、コンパイルプログラムを記録したプログラム記録媒体においても、上述した効果と同様の効果を奏することができる。
 上記の実施形態の一部又は全部は、以下の付記のようにも記載されうるが、以下には限られない。
(付記1)
ソースプログラムのループ中に隣接するデータへのアクセスが含まれる場合に、そのループがベクトル化可能であるかを判定するループ解析部と、
前記隣接するデータへのアクセスが含まれ、かつ、そのループがベクトル化可能である場合に、演算に必要となる要素をメモリからベクトルレジスタへ読み込むための命令を生成するベクトル化実行部と、を含む、
コンパイル装置。
(付記2)
前記ベクトル化実行部は、
演算に必要となる要素をメモリから前記ベクトルレジスタへ読み込むための命令を生成するベクトルロード命令生成手段と、
前記ベクトルレジスタへ読み込んだ要素を要素シフトしたベクトルデータを生成するベクトル要素シフト命令生成手段と、
演算を実行するための演算命令を生成するベクトル演算命令生成手段と、
演算結果を前記ベクトルレジスタからメモリへ書き込むためのベクトルストア命令を生成するベクトルストア命令生成手段と、を含む、
付記1に記載のコンパイル装置。
(付記3)
前記ベクトル要素シフト命令生成手段は、隣接する配列要素の添字式の値が増加する場合、指定された第1のベクトルレジスタのデータを値の増加数だけ左シフトして第2のベクトルレジスタに代入し、さらに次のベクトルレジスタの先頭要素から前記増加数と同数だけ最後尾に結合する、
付記2に記載のコンパイル装置。
(付記4)
前記ベクトル要素シフト命令生成手段は、隣接する配列要素の添字式の値が減少する場合、指定された第1のベクトルレジスタのデータを値の減少数だけ右シフトして第2のベクトルレジスタに代入し、さらに次のベクトルレジスタの先頭要素から前記減少数と同数だけ先頭要素に結合する、
付記2に記載のコンパイル装置。
(付記5)
前記ループ解析部は、
ループ中に隣接するデータへのアクセスが含まれているか認識する隣接データ認識手段と、
隣接するデータへのアクセスを含むループがベクトル化可能であるかを判定するベクトル化判定手段と、を含む、
付記1乃至付記4のいずれか一つに記載のコンパイル装置。
(付記6)
ソースプログラムのループ中に隣接するデータへのアクセスが含まれる場合に、そのループがベクトル化可能であるかを判定し、
前記隣接するデータへのアクセスが含まれ、かつ、そのループがベクトル化可能である場合に、演算に必要となる要素をメモリからベクトルレジスタへ読み込むためのベクトルロード命令を生成し、
前記ベクトルレジスタへ読み込んだ要素を要素シフトしたベクトルデータを生成するベクトル要素シフト命令を生成し、
演算を実行するためのベクトル演算命令を生成し、
演算結果を前記ベクトルレジスタからメモリへ書き込むためのベクトルストア命令を生成する、
コンパイル方法。
(付記7)
前記ベクトル要素シフト命令は、隣接する配列要素の添字式の値が増加する場合、指定された第1のベクトルレジスタのデータを値の増加数だけ左シフトして第2のベクトルレジスタに代入し、さらに次のベクトルレジスタの先頭要素から前記増加数と同数だけ最後尾に結合する、
付記6に記載のコンパイル方法。
(付記8)
前記ベクトル要素シフト命令は、隣接する配列要素の添字式の値が減少する場合、指定された第1のベクトルレジスタのデータを値の減少数だけ右シフトして第2のベクトルレジスタに代入し、さらに次のベクトルレジスタの先頭要素から前記減少数と同数だけ先頭要素に結合する、
付記6に記載のコンパイル方法。
(付記9)
コンピュータを、
ソースプログラムのループ中に隣接するデータへのアクセスが含まれる場合に、そのループがベクトル化可能であるかを判定するループ解析手段と、
前記隣接するデータへのアクセスが含まれ、かつ、そのループがベクトル化可能である場合に、演算に必要となる要素をメモリからベクトルレジスタへ読み込むための命令を生成するベクトル化実行手段と、して機能させる、
コンパイルプログラム。
(付記10)
前記ベクトル化実行手段は、
演算に必要となる要素をメモリから前記ベクトルレジスタへ読み込むための命令を生成するベクトルロード命令生成手段と、
前記ベクトルレジスタへ読み込んだ要素を要素シフトしたベクトルデータを生成するベクトル要素シフト命令生成手段と、
演算を実行するための演算命令を生成するベクトル演算命令生成手段と、
演算結果を前記ベクトルレジスタからメモリへ書き込むためのベクトルストア命令を生成するベクトルストア命令生成手段と、を含む、
付記9に記載のコンパイルプログラム。
(付記11)
前記ベクトル要素シフト命令生成手段は、隣接する配列要素の添字式の値が増加する場合、指定された第1のベクトルレジスタのデータを値の増加数だけ左シフトして第2のベクトルレジスタに代入し、さらに次のベクトルレジスタの先頭要素から前記増加数と同数だけ最後尾に結合する、
付記10に記載のコンパイルプログラム。
(付記12)
前記ベクトル要素シフト命令生成手段は、隣接する配列要素の添字式の値が減少する場合、指定された第1のベクトルレジスタのデータを値の減少数だけ右シフトして第2のベクトルレジスタに代入し、さらに次のベクトルレジスタの先頭要素から前記減少数と同数だけ先頭要素に結合する、
付記10に記載のコンパイルプログラム。
(付記13)
前記ループ解析手段は、
ループ中に隣接するデータへのアクセスが含まれているか認識する隣接データ認識手段と、
隣接するデータへのアクセスを含むループがベクトル化可能であるかを判定するベクトル化判定手段と、を含む、
付記9乃至付記12のいずれか一つに記載のコンパイルプログラム。
 以上、上述した実施形態を模範的な例として本発明を説明した。しかしながら、本発明は、上述した実施形態には限定されない。即ち、本発明は、本発明のスコープ内において、当業者が理解し得る様々な態様を適用することができる。
 この出願は、2020年12月14日に出願された日本出願特願2020-206419を基礎とする優先権を主張し、その開示の全てをここに取り込む。
 10  ループ解析部
 11  隣接データ認識手段
 12  ベクトル化判定手段
 20  ベクトル化実行部
 21  ベクトルロード命令生成手段
 22  ベクトル要素シフト命令生成手段
 23  ベクトル演算命令生成手段
 24  ベクトルストア命令生成手段
 100  コンパイラ

Claims (13)

  1.  ソースプログラムのループ中に隣接するデータへのアクセスが含まれる場合に、そのループがベクトル化可能であるかを判定するループ解析手段と、
     前記隣接するデータへのアクセスが含まれ、かつ、そのループがベクトル化可能である場合に、演算に必要となる要素をメモリからベクトルレジスタへ読み込むための命令を生成するベクトル化実行手段と、を含む、
    コンパイル装置。
  2.  前記ベクトル化実行手段は、
     演算に必要となる要素をメモリから前記ベクトルレジスタへ読み込むための命令を生成するベクトルロード命令生成手段と、
     前記ベクトルレジスタへ読み込んだ要素を要素シフトしたベクトルデータを生成するベクトル要素シフト命令生成手段と、
     演算を実行するための演算命令を生成するベクトル演算命令生成手段と、
     演算結果を前記ベクトルレジスタからメモリへ書き込むためのベクトルストア命令を生成するベクトルストア命令生成手段と、を含む、
    請求項1に記載のコンパイル装置。
  3.  前記ベクトル要素シフト命令生成手段は、隣接する配列要素の添字式の値が増加する場合、指定された第1のベクトルレジスタのデータを値の増加数だけ左シフトして第2のベクトルレジスタに代入し、さらにベクトル次のレジスタの先頭要素から前記増加数と同数だけ最後尾に結合する、
    請求項2に記載のコンパイル装置。
  4.  前記ベクトル要素シフト命令生成手段は、隣接する配列要素の添字式の値が減少する場合、指定された第1のベクトルレジスタのデータを値の減少数だけ右シフトして第2のベクトルレジスタに代入し、さらに次のベクトルレジスタの先頭要素から前記減少数と同数だけ先頭要素に結合する、
    請求項2に記載のコンパイル装置。
  5.  前記ループ解析手段は、
     ループ中に隣接するデータへのアクセスが含まれているか認識する隣接データ認識手段と、
     隣接するデータへのアクセスを含むループがベクトル化可能であるかを判定するベクトル化判定手段と、を含む、
    請求項1乃至請求項4のいずれか一項に記載のコンパイル装置。
  6.  ソースプログラムのループ中に隣接するデータへのアクセスが含まれる場合に、そのループがベクトル化可能であるかを判定し、
     前記隣接するデータへのアクセスが含まれ、かつ、そのループがベクトル化可能である場合に、演算に必要となる要素をメモリからベクトルレジスタへ読み込むためのベクトルロード命令を生成し、
     前記ベクトルレジスタへ読み込んだ要素を要素シフトしたベクトルデータを生成するベクトル要素シフト命令を生成し、
     演算を実行するためのベクトル演算命令を生成し、
     演算結果を前記ベクトルレジスタからメモリへ書き込むためのベクトルストア命令を生成する、
    コンパイル方法。
  7.  前記ベクトル要素シフト命令は、隣接する配列要素の添字式の値が増加する場合、指定された第1のベクトルレジスタのデータを値の増加数だけ左シフトして第2のベクトルレジスタに代入し、さらに次のベクトルレジスタの先頭要素から前記増加数と同数だけ最後尾に結合する、
    請求項6に記載のコンパイル方法。
  8.  前記ベクトル要素シフト命令は、隣接する配列要素の添字式の値が減少する場合、指定された第1のベクトルレジスタのデータを値の減少数だけ右シフトして第2のベクトルレジスタに代入し、さらに次のベクトルレジスタの先頭要素から前記減少数と同数だけ先頭要素に結合する、
    請求項6に記載のコンパイル方法。
  9.  コンピュータを、
     ソースプログラムのループ中に隣接するデータへのアクセスが含まれる場合に、そのループがベクトル化可能であるかを判定するループ解析手段と、
     前記隣接するデータへのアクセスが含まれ、かつ、そのループがベクトル化可能である場合に、演算に必要となる要素をメモリからベクトルレジスタへ読み込むための命令を生成するベクトル化実行手段と、して機能させる、
    コンパイルプログラムを記録したプログラム記録媒体。
  10.  前記ベクトル化実行手段は、
     演算に必要となる要素をメモリから前記ベクトルレジスタへ読み込むための命令を生成するベクトルロード命令生成手段と、
     前記ベクトルレジスタへ読み込んだ要素を要素シフトしたベクトルデータを生成するベクトル要素シフト命令生成手段と、
     演算を実行するための演算命令を生成するベクトル演算命令生成手段と、
     演算結果を前記ベクトルレジスタからメモリへ書き込むためのベクトルストア命令を生成するベクトルストア命令生成手段と、を含む、
    請求項9に記載のコンパイルプログラムを記録したプログラム記録媒体。
  11.  前記ベクトル要素シフト命令生成手段は、隣接する配列要素の添字式の値が増加する場合、指定された第1のベクトルレジスタのデータを値の増加数だけ左シフトして第2のベクトルレジスタに代入し、さらに次のベクトルレジスタの先頭要素から前記増加数と同数だけ最後尾に結合する、
    請求項10に記載のコンパイルプログラムを記録したプログラム記録媒体。
  12.  前記ベクトル要素シフト命令生成手段は、隣接する配列要素の添字式の値が減少する場合、指定された第1のベクトルレジスタのデータを値の減少数だけ右シフトして第2のベクトルレジスタに代入し、さらに次のベクトルレジスタの先頭要素から前記減少数と同数だけ先頭要素に結合する、
    請求項10に記載のコンパイルプログラムを記録したプログラム記録媒体。
  13.  前記ループ解析手段は、
     ループ中に隣接するデータへのアクセスが含まれているか認識する隣接データ認識手段と、
     隣接するデータへのアクセスを含むループがベクトル化可能であるかを判定するベクトル化判定手段と、を含む、
    請求項9乃至請求項12のいずれか一項に記載のコンパイルプログラムを記録したプログラム記録媒体。
PCT/JP2021/042164 2020-12-14 2021-11-17 コンパイル装置、コンパイル方法、及びコンパイルプログラム記録媒体 WO2022130883A1 (ja)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/265,300 US20240053969A1 (en) 2020-12-14 2021-11-17 Compiling device, compiling method, and compiling program recording medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2020-206419 2020-12-14
JP2020206419A JP7088276B1 (ja) 2020-12-14 2020-12-14 コンパイル装置、コンパイル方法、及びコンパイルプログラム

Publications (1)

Publication Number Publication Date
WO2022130883A1 true WO2022130883A1 (ja) 2022-06-23

Family

ID=82059761

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2021/042164 WO2022130883A1 (ja) 2020-12-14 2021-11-17 コンパイル装置、コンパイル方法、及びコンパイルプログラム記録媒体

Country Status (3)

Country Link
US (1) US20240053969A1 (ja)
JP (1) JP7088276B1 (ja)
WO (1) WO2022130883A1 (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 リストベクトル処理装置
JPH1166046A (ja) * 1997-08-12 1999-03-09 Fujitsu Ltd ベクトル処理装置
JP2000048009A (ja) * 1998-07-28 2000-02-18 Fujitsu Ltd メモリアクセス処理装置および記録媒体
JP2009104494A (ja) * 2007-10-25 2009-05-14 Nec Computertechno Ltd ベクトル処理装置

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 リストベクトル処理装置
JPH1166046A (ja) * 1997-08-12 1999-03-09 Fujitsu Ltd ベクトル処理装置
JP2000048009A (ja) * 1998-07-28 2000-02-18 Fujitsu Ltd メモリアクセス処理装置および記録媒体
JP2009104494A (ja) * 2007-10-25 2009-05-14 Nec Computertechno Ltd ベクトル処理装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
KITAWAKI, SHIGEMUNE ET AL.: "Language Processors and Support Tools for the SX-3 Series", NEC TECHNICAL JOURNAL, vol. 45, no. 2, 28 February 1992 (1992-02-28), JP , pages 59 - 70, XP009537656, ISSN: 0285-4139 *

Also Published As

Publication number Publication date
US20240053969A1 (en) 2024-02-15
JP2022096010A (ja) 2022-06-29
JP7088276B1 (ja) 2022-06-21

Similar Documents

Publication Publication Date Title
CN110766147B (zh) 神经网络编译器架构及编译方法
US6113650A (en) Compiler for optimization in generating instruction sequence and compiling method
EP2710467B1 (en) Automatic kernel migration for heterogeneous cores
JP4339907B2 (ja) マルチプロセッサ向け最適コード生成方法及びコンパイル装置
CN110764744A (zh) 用于神经网络计算的中间表示生成方法和装置
US5247696A (en) Method for compiling loops having recursive equations by detecting and correcting recurring data points before storing the result to memory
JP2002149416A (ja) プログラムの最適化方法及びこれを用いたコンパイラ
CN113748399B (zh) 在异构计算资源上调度计算图的方法、装置及可读介质
KR20150112017A (ko) 병렬 파이프라인에서의 분기에 대한 하드웨어 및 소프트웨어 해법
Falch et al. Register caching for stencil computations on GPUs
US20170269931A1 (en) Method and Computing System for Handling Instruction Execution Using Affine Register File on Graphic Processing Unit
US11915056B2 (en) Combination of multiple data processing and machine learning frameworks for a target hardware
WO2022130883A1 (ja) コンパイル装置、コンパイル方法、及びコンパイルプログラム記録媒体
WO2022267638A1 (en) Method and apparatus for functional unit balancing at program compile time
JP7115563B2 (ja) コンパイル装置、コンパイル方法、及び制御プログラム
JP2022098645A (ja) コンパイル装置、コンパイル方法、及びコンパイルプログラム
Bernstein et al. Usable assembly language for GPUs: a success story
Afonso et al. Automatic acceleration of stencil codes in android devices
JP3730675B2 (ja) 処理装置
US20220197614A1 (en) Method and apparatus for retaining optimal width vector operations in arbitrary/flexible vector width architecture
JP2018049461A (ja) コンパイル装置、コンパイル方法、および、コンパイルプログラム
Yu et al. Case Study: Optimization Methods with TVM Hybrid-OP on RISC-V Packed SIMD
JP6600888B2 (ja) 並列化コンパイラ、並列化コンパイル装置、及び並列プログラムの生成方法
US10387128B2 (en) Method and apparatus for compiling computer-readable computer programs using extended isomorphism
JP2024030940A (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: 21906247

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 18265300

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21906247

Country of ref document: EP

Kind code of ref document: A1