Code conversion device, code conversion method, and code conversion program
10 claims: 4 independent, 6 dependent
- 1複数の配列のデータ定義と、前記複数の配列に対する所定の演算と、前記所定の演算の演算結果を表す配列のデータ定義とを含む、第1コードを記憶する記憶部と、前記第1コードに含まれる前記複数の配列のデータ定義と前記演算結果を表す配列のデータ定義とを、構造体配列のデータ定義に変換し、前記第1コードに含まれる前記所定の演算を、前記構造体配列に対する演算に変換する変換部と、前記複数の配列各々の異なるデータに対して、前記構造体配列に対する演算を並列に実行する所定の命令を含む、第2コードを生成する生成部と、を備えることを特徴とするコード変換装置。
- 2前記所定の命令は、複数のレジスタそれぞれに格納された配列のデータに対して、前記構造体配列に対する演算を実行し、演算結果を表す配列のデータを所定のレジスタに書き込む命令であり、前記第2コードは、メモリに連続して格納された複数の構造体配列のデータを読み出して、各構造体配列のデータに含まれる前記複数の配列のデータを、前記複数のレジスタにそれぞれ書き込む命令と、前記所定のレジスタから前記演算結果を表す配列のデータを読み出して、前記メモリに格納された各構造体配列のデータに含まれる、前記演算結果を表す配列のデータの位置に書き込む命令と、をさらに含むことを特徴とする請求項1記載のコード変換装置。
- 3前記所定の命令は、複数のレジスタそれぞれに格納された配列のデータに対して、前記構造体配列に対する演算を実行し、演算結果を表す配列のデータを所定のレジスタに書き込む命令であり、前記第2コードは、メモリに連続して格納された複数の構造体配列のデータを読み出して、第1レジスタに連続して書き込む命令と、前記第1レジスタから、各構造体配列のデータに含まれる同じ配列のデータの位置を指定して、指定した位置のデータを読み出し、前記複数のレジスタのうち同じレジスタに連続して書き込む命令と、前記所定のレジスタから前記演算結果を表す配列のデータを読み出し、前記メモリに格納された各構造体配列のデータに含まれる、前記演算結果を表す配列のデータの位置を指定して、前記所定のレジスタから読み出したデータを前記メモリの指定した位置に書き込む命令と、をさらに含むことを特徴とする請求項1記載のコード変換装置。
- 4前記変換部は、データ定義の変換を示すコンパイラオプションに従って、前記第1コードに含まれる配列の中から、前記複数の配列と前記演算結果を表す配列とを選択することを特徴とする請求項1乃至3のいずれか1項に記載のコード変換装置。
- 5前記第1コードは、前記複数の配列と前記演算結果を表す配列とを指定する制御文を含み、前記変換部は、前記制御文に従って、前記第1コードに含まれる配列の中から、前記複数の配列と前記演算結果を表す配列とを選択することを特徴とする請求項1乃至3のいずれか1項に記載のコード変換装置。
- 6前記変換部は、前記第1コードに含まれる配列のアクセス頻度を示すプロファイル情報を用いて、前記第1コードに含まれる配列の中から、前記複数の配列と前記演算結果を表す配列とを選択することを特徴とする請求項1乃至3のいずれか1項に記載のコード変換装置。
- 7前記変換部は、前記第1コードに含まれるループ内における各配列の出現回数、又は前記ループ内で同じ添え字を有する配列のグループにおける各配列の出現回数のうち、少なくとも一方に基づいて、前記ループに含まれる配列の中から前記複数の配列を選択することを特徴とする請求項1乃至6のいずれか1項に記載のコード変換装置。
- 8前記第1コードに含まれる複数の配列のデータ定義は、配列構造体のデータ定義であることを特徴とする請求項1乃至7のいずれか1項に記載のコード変換装置。
- 9複数の配列のデータ定義と、前記複数の配列に対する所定の演算と、前記所定の演算の演算結果を表す配列のデータ定義とを含む、第1コードを記憶する記憶部を有するコンピュータが、前記第1コードに含まれる前記複数の配列のデータ定義と前記演算結果を表す配列のデータ定義とを、構造体配列のデータ定義に変換し、前記第1コードに含まれる前記所定の演算を、前記構造体配列に対する演算に変換し、前記複数の配列各々の異なるデータに対して、前記構造体配列に対する演算を並列に実行する所定の命令を含む、第2コードを生成することを特徴とするコード変換方法。
- 10複数の配列のデータ定義と、前記複数の配列に対する所定の演算と、前記所定の演算の演算結果を表す配列のデータ定義とを含む、第1コードを記憶する記憶部を有するコンピュータに、前記第1コードに含まれる前記複数の配列のデータ定義と前記演算結果を表す配列のデータ定義とを、構造体配列のデータ定義に変換させ、前記第1コードに含まれる前記所定の演算を、前記構造体配列に対する演算に変換させ、前記複数の配列各々の異なるデータに対して、前記構造体配列に対する演算を並列に実行する所定の命令を含む、第2コードを生成させることを特徴とするコード変換プログラム。
Independent claims10
204 paragraphs in 1 section, as filed
The present invention relates to a code conversion device, a code conversion method, and a code conversion program.
In conventional computers, SIMD (Single Instruction Multiple Data) instructions, which execute operations on a plurality of data in parallel by the same arithmetic unit, are often used in order to improve the arithmetic performance. In particular, SIMD instructions are provided in an arithmetic processing unit that operates in a supercomputer or a server that is expected to have high arithmetic performance. The arithmetic processing unit is sometimes called a processor.
A processor that supports SIMD instructions reads data from memory into a register when the SIMD instruction is executed, and uses that register to perform operations in parallel in units of multiple SIMD elements included in a given SIMD width. .. Then, the processor stores the calculation result in the memory in units of those SIMD elements. For example, when the same operation is performed on four elements at the same time, the number of SIMD elements (number of elements) is four.
Further, in order to speed up the program logic written in the software, particularly the iterative processing (loop processing), it is desired that the compiler performs the optimum instruction expansion. Various methods such as loop unrolling, software pipelines, and loop merging have been devised as technologies for speeding up loop processing.
In relation to SIMD instructions, there are known techniques for generating code containing specific instructions that instruct different data to perform the same type of operations in parallel so as to improve execution efficiency (eg, patents). See Ref. 1).
<p><patcit num="1"><text>Japanese Unexamined Patent Publication No. 2013-206291</text></patcit></p>
<p>Since the object expansion of the SIMD instruction in the loop included in the source code is often performed by the compiler in the horizontal direction of the vector register, the SIMD instruction is mainly applied in the horizontal direction. On the other hand, it is conceivable that the SIMD instruction is not applied to the vertical direction of the vector register, or the data arrangement is converted to the horizontal direction and then the SIMD instruction is applied to the horizontal direction.</p><p>In the following, the object expansion of the SIMD instruction may be referred to as SIMD expansion. In addition, the vector register used for SIMD operation by SIMD instruction may be referred to as SIMD register.</p><p>Data definitions in the Structure of Arrays (SOA) format are suitable for SIMD expansion. The SOA format is a data definition consisting of a plurality of consecutive elements, and the plurality of elements contained in the data in the SOA format can be easily accessed continuously.</p><p>However, in the SOA format data definition, not all the elements of each array fit in the cache memory, so that the cache efficiency for highly local access is reduced.</p><p>It should be noted that such a problem occurs not only when the SIMD instruction is applied to the data in SOA format but also when the operations are executed in parallel for different elements of the array based on other data definitions.</p><p>In one aspect, the present invention aims to improve the performance of operations performed in parallel on different elements of an array with high access locality.</p>
<p>In one proposal, the code converter includes a storage unit, a conversion unit, and a generation unit. The storage unit stores a first code including a data definition of a plurality of arrays, a predetermined operation on those arrays, and a data definition of an array representing the operation result of the predetermined operation.</p><p>The conversion unit converts the data definition of multiple arrays included in the first code and the data definition of the array representing the operation result into the data definition of the structure array (Array of Structures, AOS), and includes it in the first code. Converts a given operation to an operation on a structure array. The generator generates a second code containing a predetermined instruction for executing operations on the structure array in parallel for different data of each of the plurality of arrays.</p>
<p>According to one embodiment, it is possible to improve the performance of operations performed in parallel for different elements of an array with high access locality.</p>
<figref num="1">It is a figure which shows SIMD development for data of SOA format.</figref><figref num="2">It is a figure which shows SIMD operation for data of SOA format.</figref><figref num="3">It is a figure which shows the storage area of an array.</figref><figref num="4">It is a functional block diagram of a code conversion apparatus.</figref><figref num="5">It is a flowchart of a code conversion process.</figref><figref num="6">It is a functional block diagram which shows the specific example of a code conversion apparatus.</figref><figref num="7">It is a figure which shows the data definition and SIMD operation of AOS format.</figref><figref num="8">It is a figure which shows the data definition of a hybrid AOS format.</figref><figref num="9">It is a figure which shows the processing performance.</figref><figref num="10">It is a figure which shows the extraction method M1.</figref><figref num="11">It is a figure which shows the extraction method M2.</figref><figref num="12">It is a figure which shows the extraction method M3.</figref><figref num="13">It is a figure which shows the loop management table.</figref><figref num="14">It is a figure which shows the evaluation value table.</figref><figref num="15">It is a figure which shows the conversion process for a one-dimensional array.</figref><figref num="16">It is a figure which shows the conversion process for a two-dimensional array.</figref><figref num="17">It is a figure which shows SIMD expansion using an existing instruction.</figref><figref num="18">It is a figure which shows the SIMD expansion using the AOS exclusive instruction.</figref><figref num="19">It is a flowchart which shows the specific example of a code conversion process.</figref><figref num="20">It is a flowchart of a group number setting process.</figref><figref num="21">It is a flowchart of conversion candidate extraction processing.</figref><figref num="22">It is a flowchart of conversion target selection process.</figref><figref num="23">It is a flowchart of an intermediate code generation process.</figref><figref num="24">It is a flowchart of a machine language code generation process.</figref><figref num="25">It is a block diagram of an information processing apparatus.</figref>
Hereinafter, embodiments will be described in detail with reference to the drawings.
Figure 1 shows an example of SIMD expansion of operations on SOA-formatted data described in FORTRAN. FIG. 1 (a) shows an example of SOA-formatted data definitions for one-dimensional arrays A, B, and C. The elements of each array are double-precision real numbers, and the number of elements of each array is n (n is an integer greater than or equal to 2).
FIG. 1 (b) shows an example of the storage area of Array A, Array B, and Array C. Ai represents the i-th element A (i) of the array A (i = 1 to n), Bi represents the i-th element B (i) of the array B, and Ci represents the i-th element B (i) of the array C. Represents element C (i). The stream consisting of A1 to An is continuously stored in the area 101, the stream consisting of B1 to Bn is continuously stored in the area 102, and the stream consisting of C1 to Cn is continuously stored in the area 103. Is stored. In this case, it is possible to access three streams at the same time.
FIG. 1 (c) shows an example of source code containing a loop of operations on arrays A and B. In this example, n = 1024 and the do loop contains the operation C (i) = A (i) + B (i).
FIG. 1 (d) shows an example of SIMD expansion for the loop of FIG. 1 (c). In this example, the number of elements that can be processed simultaneously by the SIMD instruction is 4, and 3 streams are the targets of continuous area access. Therefore, using regions 101 to 103 in FIG. 1 (b), each stream is accessed for each of the four elements, and addition processing is performed in parallel for the four elements of array A and the four elements of array B. Will be done. Then, the four addition results are stored in the area 103 in parallel.
Thus, according to the SOA format data definition, a plurality of elements of each array are stored in a contiguous area in the memory. On the other hand, when reading data used for a SIMD operation from a memory to a SIMD register, it is common to continuously read a plurality of continuously stored elements into the SIMD register.
FIG. 2 shows an example of a SIMD operation that performs the processing of FIG. 1 (c) using the SIMD register. Memory 1 to memory 3 represent continuous areas in the memory. The elements of the array A are stored in the memory 1, the elements of the array B are stored in the memory 2, and the elements of the array C are stored in the memory 3.
The data size of the elements of each array is 8 bytes, and SIMD registers 1 to 3 can store eight 64-bit data. Therefore, the number of elements that can be processed simultaneously by the SIMD instruction is eight.
First, by the SIMD load instruction, eight consecutive elements A1 to A8 are read out in order from the start address of the memory 1 and are continuously written in the horizontal direction of the SIMD register 1. At the same time, eight consecutive elements B1 to B8 are read out in order from the start address of the memory 2 and are continuously written in the horizontal direction of the SIMD register 2.
Next, the addition process is executed in parallel for the eight data of the SIMD register 1 and the SIMD register 2, and the addition results C1 to C8 are written to the SIMD register 3. Then, C1 to C8 are continuously read from the SIMD register 3 and written in order from the start address of the memory 3. As a result, the SIMD calculation of one loop is completed, and in the SIMD calculation of the next loop, the same processing is repeated for the next eight elements.
In this way, since the calculation results of the SIMD operation are continuously stored in the SIMD register 3, the calculation results may be stored in the memory 3 as SOA format data, and the calculation results do not need to be rearranged. be.
However, the SOA format data definition has a problem that the locality of access is lowered when accessing the elements of a plurality of arrays included in the array structure. For example, in business application programs, the reuse rate of specific data is often high, and the locality of access to the data is high. In the case of SOA format data, not all elements of each array fit in the cache memory, which reduces the cache efficiency for highly local access.
In this case, handling discrete data defined in AOS format has higher cache efficiency and improved processing performance than data in SOA format. Therefore, in order to improve the processing performance, it is conceivable that the programmer changes the SOA format data definition included in the source code to the AOS format data definition.
FIG. 3 shows an example of the storage area of Array A, Array B, and Array C defined in AOS format. A1, B1, and C1 are contiguously stored in region 301, A2, B2, and C2 are contiguously stored in region 302, and A3, B3, and C3 are contiguously stored in region 303. Is stored. When a specific combination of Ai, Bi, and Ci is frequently reused in an application program, the cache efficiency is improved by keeping the data of the combination in the cache memory.
However, in the conventional SIMD expansion, since continuous elements are stored in the horizontal direction of the SIMD register, it is difficult to perform SIMD calculation using the SIMD register for AOS format data.
In addition, in the SOA format data definition, since the area handled by one process is long, TLB (Translation Lookaside Buffer) mistakes due to page size overrun due to continuous area access may occur frequently and the processing performance may deteriorate. .. Further, if the hardware prefetch or the software prefetch for the continuous stream is issued redundantly, the processing performance is further deteriorated.
In the examples of FIGS. 1 and 2, hardware resources are consumed by the hardware prefetch or software prefetch issued for each stream of the array A, the array B, and the array C. For this reason, various performance deteriorations occur, such as an increase in the number of instructions input to the pipeline due to redundant data writing to the cache memory, an obstruction in scheduling, and a decrease in transfer speed due to consumption of the bus width.
FIG. 4 shows an example of a functional configuration of the code conversion device of the embodiment. The code conversion device 401 of FIG. 4 includes a storage unit 411, a conversion unit 412, and a generation unit 413. The storage unit 411 stores the first code 421 including the data definition of a plurality of arrays, the predetermined operation on those arrays, and the data definition of the array representing the operation result of the predetermined operation.
FIG. 5 is a flowchart showing an example of the code conversion process performed by the code conversion device 401 of FIG. First, the conversion unit 412 converts the data definition of the plurality of arrays included in the first code 421 and the data definition of the array representing the operation result into the data definition of the structure array (step 501). Next, the conversion unit 412 converts the predetermined operation included in the first code 421 into an operation on the structure array (step 502). Then, the generation unit 413 generates a second code including a predetermined instruction for executing operations on the structure array in parallel for different data of each of the plurality of arrays (step 503).
According to the code conversion device 401 of FIG. 4, it is possible to improve the performance of operations executed in parallel for different elements of an array having high access locality.
FIG. 6 shows a specific example of the code conversion device 401 of FIG. The code conversion device 401 of FIG. 6 includes a storage unit 411, a conversion unit 412, a generation unit 413, and an analysis unit 611, and converts a source code 621 written in a high-level language into a machine language code 626. For example, the source code 621 may be code written in FORTRAN, C language, C ++, LISP, or the like. The code conversion device 401 is sometimes called a compiler device.
The storage unit 411 stores the source code 621 and the evaluation function 622. The source code 621 corresponds to the first code 421 in FIG. 4, and is sometimes called a source program. The evaluation function 622 is used to calculate the evaluation value of the array contained in the source code 621, and the calculated evaluation value indicates the degree to which the array is suitable for data definition in AOS format.
The analysis unit 611 analyzes the source code 621 according to the optimization instruction input from the user, generates the loop management table 623 based on the analysis result, and stores it in the storage unit 411. The loop management table 623 is a table that includes attributes such as the number of dimensions of each array included in the loop, the number of occurrences, and the subscripts of each dimension for each loop included in the source code 621.
The conversion unit 412 refers to the loop management table 623 and extracts an array of conversion candidates for converting the data definition. Then, the conversion unit 412 calculates the evaluation value for each array of conversion candidates using the evaluation function 622, generates an evaluation value table 624 including the calculated evaluation value, and stores it in the storage unit 411.
Next, the conversion unit 412 refers to the evaluation value table 624, selects an array to be converted from the array of conversion candidates, and converts the data definition of the selected array into the data definition of the AOS format. The array to be converted includes a plurality of arrays to which a predetermined operation is applied, and an array representing an operation result of a predetermined operation on those arrays. The data definition of the array to be converted may be in SOA format or may be a data definition other than SOA format.
Next, the conversion unit 412 converts the predetermined operation included in the source code 621 into an operation on the data in AOS format, generates an intermediate code 625 including the converted data definition and the operation, and stores it in the storage unit 411. Store.
The generation unit 413 optimizes the intermediate code 625 by performing SIMD expansion for a predetermined operation included in the intermediate code 625, and generates a machine language code 626 including a SIMD instruction for reading and writing AOS format data. Then, it is stored in the storage unit 411. The machine language code 626 corresponds to the second code and is sometimes called a machine language program.
According to the code conversion device 401 of FIG. 6, the cache efficiency of the processor that executes the machine language code 626 is improved by converting the data definition of the array into the AOS format by focusing on the data having high access locality. .. In the converted AOS format data definition, multiple elements of different arrays are locally arranged, so the data of those elements often stays together in the cache memory. Therefore, when the locality of access to the array is high, the cache miss rate is kept low and the cache efficiency is improved. This can improve the performance of SIMD computation for such arrays.
In addition, by converting the data definition in SOA format to AOS format, the area handled by one process is shortened, and TLB mistakes caused by page size over due to continuous area access are reduced. Further, since a plurality of streams are combined into one stream and the number of streams is reduced, it is possible to reduce the consumption of hardware resources due to hardware prefetching and the like. Therefore, the limited hardware resources can be efficiently utilized, the processing performance of the processor is improved, and the power consumption is also reduced.
As the SIMD instruction for reading and writing the AOS format data, the generation unit 413 may use an existing instruction for accessing the SIMD register, or may use a newly defined AOS-dedicated instruction. The AOS-dedicated instruction is defined as a dedicated load instruction that reads AOS format data from the memory and writes it to the SIMD register, and a dedicated store instruction that reads data from the SIMD register and writes it to the memory in AOS format.
The dedicated load instruction is an instruction to read the data of a plurality of structure arrays continuously stored in the memory and write the data of the plurality of arrays included in each structure array to the plurality of SIMD registers.
On the other hand, the dedicated store instruction is an instruction to read data of a plurality of arrays included in each structure array from a plurality of SIMD registers and write them to the position of each structure array stored in the memory. Therefore, by executing the dedicated store instruction, the data of the array representing the operation result is read from the predetermined SIMD register, and it is at the position of the array representing the operation result included in each structure array stored in the memory. Written.
The dedicated load instruction is used to directly expand the elements in memory with respect to the vertical direction of the SIMD register, and the dedicated store instruction extracts the vertically expanded elements of the SIMD register and puts them in memory. Used to store. By using these AOS-dedicated instructions, it is possible to efficiently perform vertical SIMD expansion instead of the conventional horizontal SIMD expansion. The processor supports dedicated load instructions and dedicated store instructions to further improve the processing performance for AOS format data.
FIG. 7 shows an example of AOS format data definition and SIMD operation. FIG. 7 (a) shows an example of AOS format data definitions for one-dimensional arrays A, B, and C. The structure struct consists of the elements of the array A, the array B, and the array C, the elements of each array are double-precision real numbers, and the number of elements of each array is 1024. The structure array St is an array of structure structs, and the number of elements of the structure array St is also 1024. In this case, the data of Ai, Bi, and Ci included in the i-th (i = 1 to 1024) element of the structure array St are continuously stored in the memory 701 and are targeted for continuous area access.
FIG. 7 (b) shows an example of the source code in which the operation loop for the array A and the array B is described by using the structure array St. In this example, the do loop contains the operation St (i)% C = St (i)% A + St (i)% B. St (i)% A represents the element of the array A contained in the i-th element of the structure array St, and St (i)% B is the element of the array B contained in the i-th element of the structure array St. Represents an element, and St (i)% C represents an element of the array C contained in the i-th element of the structure array St.
FIG. 7 (c) shows an example of SIMD expansion for the loop of FIG. 7 (b). In this example, the number of elements that can be processed simultaneously by the SIMD instruction is 4, and only one stream stored in the memory 701 is the target of continuous area access.
Therefore, 12 data of A1 to C4 corresponding to the 4 elements of the structure array St are read out in order from the start address of the memory 701 in FIG. 7 (a), and the vertical of SIMD register 1 to SIMD register 3 Written in order in the direction. Then, the four elements of the array A stored in the SIMD register 1 and the four elements of the array B stored in the SIMD register 2 are added in parallel, and the four addition results are obtained. Written to SIMD register 3 in parallel.
Since the data of Ai, Bi, and Ci that are accessed at the same time are stored in close proximity to each other in the memory 701, they are also arranged in close proximity to each other in the cache memory. Therefore, unlike the case of the SOA format, it is less likely that some data of Ai, Bi, and Ci will be lost from the cache memory.
By caching the data, the data can be kept in cache memory until it is used in the next processing step. This reduces the access cost at the next access. However, for larger datasets, all the data may not fit in the cache memory and may be rewritten before it is used next time. Therefore, it is effective to add only frequently used sequences at the same time to the members of the AOS format structure.
It is also possible to use a hybrid AOS format as a data definition, which supports the loading order of SOA format data while ensuring data adjacency, which is a characteristic of AOS format data.
Figure 8 shows an example of a hybrid AOS format data definition. The structure Hybrid_struct consists of 8 elements in array A, 8 elements in array B, and 8 elements in array C. The elements in each array are double-precision real numbers, and the number of elements in each array is There are 1024. The structure array St is an array of the structure Hybrid_struct, and the number of elements of the structure array St is 128.
In this case, the i-th (i = 1 ~ 128) element of the structure array St is A (8 * (i-1) +1) ~ A (8 * i), B (8 * (i-1)). It consists of +1) ~ B (8 * i) and C (8 * (i-1) +1) ~ C (8 * i). These 24 pieces of data are continuously stored in the memory 801 and are the targets of continuous area access. Therefore, 24 data can be specified as access targets by one subscript of the structure array St.
According to the data definition in hybrid AOS format in Figure 8, the processor can load eight data from any of Array A, Array B, and Array C at the same time, as in the case of the SIMD operation in Figure 2. can. In this case, even if the elements with the same subscripts in Array A, Array B, and Array C are not adjacent to each other, they are close enough that they are usually stored in the same memory page. it is conceivable that.
Therefore, since a plurality of elements of different arrays are locally arranged, there is a high possibility that the cache efficiency will be improved. In addition, since the area handled by one process is shortened, there is a high possibility that TLB mistakes due to page size overrun due to continuous area access will be reduced.
In this way, the code conversion device 401 can convert the data definition of the array into the AOS format or the hybrid AOS format according to the characteristics of the data handled by the program. By switching the data definition according to the data characteristics and the processing for the data, it is possible to optimize the entire program.
Figure 9 shows an example of processing performance according to the combination of program characteristics and data definitions. mark indicates that the processing speed can be increased, mark indicates that the processing speed can be partially increased, and × mark indicates that the processing speed cannot be increased. show.
If there is no locality of access to the data, the SOA format data definition has higher processing performance than the AOS format data definition. On the other hand, when there is locality of access to the data, the processing performance of the AOS format data definition is higher than that of the SOA format data definition.
Therefore, if there is locality of access to the data, the SOA format data definition included in the source code 621 is converted to the AOS format data definition, and the predetermined operation is converted to the operation for the AOS format data. A significant improvement in processing performance can be expected.
As the load of hardware resources, the load due to HPF (Hardware Prefetch) and the load due to TLB mistake are considered. In the SOA format data definition, the load due to HPF and the load due to TLB mistakes are both large, so the processing performance is low. On the other hand, in the AOS format data definition, the load due to HPF does not exist and the load due to TLB mistake is small, so the processing performance is high.
Therefore, by converting the SOA format data definition included in the source code 621 to the AOS format data definition and converting the predetermined operation to the operation for the AOS format data, the load on the hardware resources is reduced and the processing is performed. Performance can be further improved.
In the SIMD support status of the processor, if the horizontal SIMD instruction is supported, the processing performance of the SOA format data definition is higher than that of the AOS format data definition. In the AOS format data definition, after the data is stored in the SIMD register, the process of rearranging the data in the horizontal direction occurs, so the effect of the SIMD calculation is offset and the performance may deteriorate.
On the other hand, if the vertical SIMD instruction is supported, the AOS format data definition has higher processing performance than the SOA format data definition. In particular, if AOS-specific instructions are supported, the processing performance for AOS format data will be further improved.
The conversion unit 412 can extract a conversion candidate sequence from the sequences included in the source code 621 by using any of the following extraction methods.
M1: Extraction of conversion candidates based on static analysis of source code 621 M2: Extraction of conversion candidates based on the control statement described in source code 621 M3: Extraction of conversion candidates based on profile information
When the extraction method M1 is adopted, the user specifies a compiler option indicating conversion of the data definition, and the conversion unit 412 extracts an array of conversion candidates according to the specified compiler option. For example, the following are used as compiler options indicating the conversion of data definitions.
-KAos: Compiler option that automatically extracts conversion candidates from all arrays -KAos (A, B): Compiler option that extracts arrays with the array name explicitly specified by the user as conversion candidates.
-A and B of KAos (A, B) represent the array name specified by the user. In this case, among the arrays having the array name A and the array name B, the array having the same number of dimensions and the number of elements is extracted as a conversion candidate. You may use a name other than -KAos as the name of the compiler option.
-If KAos is specified, conversion candidates can be automatically extracted without the user explicitly specifying an array. On the other hand, when -KAos (A, B) is specified, the array explicitly specified by the user can be extracted as a conversion candidate.
FIG. 10 shows an example of the extraction method M1. -If KAos (A, B) is specified, one-dimensional array A and array B are extracted from the DO loop as conversion candidates. Then, when arrays A and B are selected as conversion targets, the data definitions of those arrays are converted into the data definitions of the structure array St, and A (i) and B (i) in the DO loop are St. It is converted to (i)% A and St (i)% B, respectively. The number of dimensions of the extracted array may be two or more.
When the extraction method M2 is adopted, the user describes a control statement that explicitly specifies an array of conversion candidates in the source code 621, and the conversion unit 412 extracts the array of conversion candidates according to the control statement. For example, an OCL (Object Constraint Language) statement in FORTRAN, #pragma in C language, or the like can be used as the control statement, and the array name, the number of dimensions, and the number of elements can be described in the control statement. By using the control statement, the array explicitly specified by the user can be extracted as a conversion candidate.
FIG. 11 shows an example of the extraction method M2. If array A, array B, and array C are specified as conversion candidates by the OCL statement "! Ocl AOS (A, B, C)", the two-dimensional array A, array B, and array C from the DO loop Be extracted. Then, when arrays A, B, and C are selected as conversion targets, the data definitions of those arrays are converted into the data definitions of the structure array St. Furthermore, A (i, j), B (i, j), and C (i, j) in the DO loop are St (i, j)% A, St (i, j)% B, and St ( i, j) Converted to% C respectively. The number of dimensions of the extracted array may be one-dimensional or three-dimensional or more.
When the extraction method M3 is adopted, the conversion unit 412 acquires profile information indicating the access frequency of each array in the loop processing included in the source code 621. Then, the conversion unit 412 uses the acquired profile information to extract a plurality of arrays that are frequently accessed at the same time as conversion candidates. If multiple arrays in the same loop are accessed both frequently, converting the data definitions in these arrays to AOS format can cause the data in those arrays to stay in cache memory for the same period of time. Will be higher.
FIG. 12 shows an example of the extraction method M3. Profile information 1201 indicates that in high-cost loop processing, arrays A and C are frequently accessed at the same time, and array B is not accessed at the same time as other sequences. In this case, the one-dimensional array A and the array C are extracted from the DO loop as conversion candidates. Then, when arrays A and C are selected as conversion targets, the data definitions of those arrays are converted into the data definitions of the structure array St, and A (i) and C (i) in the DO loop become St. It is converted to (i)% A and St (i)% C, respectively. The number of dimensions of the extracted array may be two or more.
FIG. 13 shows an example of the loop management table 623 of the loop included in the source code 621. FIG. 13 (a) shows an example of a DO loop, and FIG. 13 (b) shows an example of a loop management table 623 generated by the analysis unit 611 analyzing the DO loop of FIG. 13 (a). There is. The loop management table 623 of FIG. 13 (b) includes the following items.
Variable: Array description in loop (including subscript) Array name: Array name (not including subscript) Number of dimensions: Number of dimensions of array Number of occurrences: Number of occurrences of array in loop p dimension (p = 1) ~ P): p-th subscript (including constant) of the array Group number: Identification information indicating the group of the array with the same subscript
The conversion unit 412 refers to the loop management table 623, searches for a plurality of arrays having the same subscript, and assigns the same group number to those arrays. In the case of the loop management table 623 of FIG. 13 (b), the following groups are extracted as a group of arrays having the same subscript.
{A (i), B (i)} {AA (i, j), BB (i, j)} {CC (x, y), DD (x, y)} {α (W (i))) , β (W (i))}
Since the subscripts of sequence α and sequence β are W (i) indicating indirection and can be regarded as the same subscript, these sequences are classified into the same group. Even if the subscripts indicating indirect references are different among multiple arrays, if it can be determined from the profile information etc. that the subscripts are equal at the time of execution, those arrays are classified into the same group. Will be done.
In the DO loop of FIG. 13 (a), a static area is used as the data area of the array, but an array in which the data area is dynamically acquired can also be registered in the loop management table 623. ..
The conversion unit 412 extracts a conversion candidate sequence from the sequences included in the loop management table 623 by using any of the extraction method M1 to the extraction method M3. When the compiler option -KAos is specified in the extraction method M1, the conversion unit 412 extracts the array classified into one of the groups as a conversion candidate.
When a plurality of arrays are explicitly specified by a compiler option or a control statement in the extraction method M1 or the extraction method M2, the conversion unit 412 indicates that the specified plurality of arrays have the same group number in the loop management table 623. Check if you have it. Then, when the specified plurality of sequences have the same group number, the conversion unit 412 determines those sequences as conversion candidates. If the specified plurality of arrays do not have the same group number, the conversion unit 412 excludes those arrays from the conversion candidates.
When profile information is specified in the extraction method M3, the conversion unit 412 uses the specified profile information to extract a plurality of frequently accessed sequences at the same time as conversion candidates.
As the evaluation function 622 of the array having the array name Q, for example, the evaluation function E (Q) of the following equation can be used.
E (Q) = (C (Q) / S) * w1 + (M (Q) / G (Q)) * w2 (1)
S in Eq. (1) represents the total number of arrays contained in the loop, and C (Q) represents the number of occurrences of the array Q in the loop. Therefore, C (Q) / S represents the ratio (occurrence rate) of the array Q in the loop.
G (Q) represents the total number of sequences having the same group number as the sequence Q, and M (Q) represents the number of occurrences of the sequence Q in the group indicated by the group number. Therefore, M (Q) / G (Q) represents the ratio (match rate) of the sequence Q in the group.
It is effective to change the data definition to AOS format because the higher the occurrence rate of the array, the higher the frequency of access. Similarly, the higher the match rate, the higher the frequency of access, so it is effective to change the data definition to AOS format. w1 represents the weighting factor for the appearance rate, and w2 represents the weighting factor for the matching rate.
The conversion unit 412 calculates the value (evaluation value) of the evaluation function E (Q) using the number of occurrences of each array registered in the loop management table 623. For example, assuming that w1 = 1 and w2 = 2, the evaluation value of the array having the array name A is calculated from the loop management table 623 of FIG. 13 (b) as follows.
S = 14: The total number of arrays included in the loop is 14 below.
A (i), B (i), AA (i, j), BB (i, j), AA (i + 1, j), AA (x, z), BB (i + 2, j), BB (z, c), CC (x, y), A (i + 2), AA (i, j), DD (x, y), α (W (i)), β (W (i))
C (A) = 2: The number of occurrences of the array A is A (i) and A (i + 2) twice.
G (A) = 2: The total number of sequences having the same group number 1 as the sequence A is A (i) and B (i).
M (A) = 1: The number of occurrences of the array A in the group indicated by the group number 1 is once in A (i).
E (A) = (2/14) * 1 + (1/2) * 2 = 1.14 (2)
FIG. 14 shows an example of the evaluation value table 624 for the array of conversion candidates. In this example, all the arrays belonging to the four groups of group number "1" to group number "4" are extracted as conversion candidates. The evaluation value table 624 of FIG. 14 includes the group number, the sequence name Q, C (Q), w1, M (Q), G (Q), w2, the evaluation value, and the total evaluation value. The evaluation value represents the evaluation value of each array calculated by using the evaluation function E (Q) of the equation (1), and the total evaluation value represents the sum of the evaluation values of the sequences belonging to the same group.
The conversion unit 412 refers to the evaluation value table 624 and selects an array belonging to the group whose total evaluation value is larger than the threshold value as the conversion target. Further, the conversion unit 412 may select an array having an evaluation value larger than the threshold value as a conversion target from the arrays belonging to each group. These threshold values may be preset predetermined values or may be user-specified values.
For example, when the threshold value of the total evaluation value is 2.2, A (i) and B (i) belonging to the group of group number 1 in FIG. 14 and AA (i, j) belonging to the group of group number 2. ) And BB (i, j) are selected for conversion.
Instead of generating the evaluation value table 624 separately from the loop management table 623, the conversion unit 412 may add the item of the evaluation value table 624 to the loop management table 623 to integrate the two tables.
The evaluation function E (Q) may be a function containing only one of the appearance rate of the array Q and the match rate of the array Q. Further, the evaluation function E (Q) may include attributes other than the appearance rate and the match rate. For example, the run-time information of the program obtained from the profile information can be used as an attribute of the evaluation function E (Q). Examples of such information include the number of accesses to each array, processor event information such as cache miss, and actual measurement value (experience value) or logical value acquired by the processor.
The code converter 401 can also calculate the evaluation value by using the evaluation function E (Q) given from the outside as a parameter of the compiler instead of using the evaluation function E (Q) stored in advance. .. Further, the code conversion device 401 can also feed back the information acquired at the time of executing the program as learning data by machine learning of artificial intelligence, and automatically generate the evaluation function E (Q).
The conversion unit 412 adds the structure array of the array selected as the conversion target to the source code 621. For example, when the array A and the array B are selected as the conversion target, the conversion unit 412 defines the structure struct of the array A and the array B, and sets the structure array of any sequence name as the array of the structure. Define. Then, the conversion unit 412 adds those data definitions to the data description unit in the source code 621.
type struct attribute :: A attribute 2 :: Bend type struct type (struct) :: St (n) In this example, a structure array with the array name St is defined. The number of elements n of the structure array St is the same as the number of elements of the array A and the array B.
Next, the conversion unit 412 replaces the description of the array A and the array B included in the source code 621 with the description using the array name of the structure array St, and generates the intermediate code 625.
A () St ()% AB () St ()% B
FIG. 15 shows an example of data definition and operation conversion processing for one-dimensional arrays A, B, and C. If the source code 621 contains one-dimensional arrays A, B, and C, a structure struct consisting of the elements of those arrays is defined, and the structure array St is defined as the array of the structures. Will be done. The number of elements in the structure array St is 1024. Then, the operation C (i) = ... A (i) + B (i) ... in the DO loop is St (i)% C = ... St (i)% A + St (i). ) Is replaced by the operation% B ...
FIG. 16 shows an example of data definition and operation conversion processing for two-dimensional arrays A, B, and C. If the source code 621 contains two-dimensional arrays A, B, and C, a structure struct consisting of the elements of those arrays is defined, and the structure array St is defined as the array of the structures. Will be done. The subscripts i and j of the structure array St are integers in the range 1 to 1024. Then, the operation C (i, j) = A (i, j) + B (i, j) in the DO loop is St (i, j)% C = St (i, j)% A + St ( i, j) Replaced by the operation% B.
The conversion unit 412 may change the array names of the array A and the array B to the intermediate code 625 instead of the source code 621.
Next, the generation unit 413 generates the machine language code 626 by performing SIMD expansion for the intermediate code 625 using an existing instruction or an AOS-dedicated instruction.
FIG. 17 shows an example of SIMD deployment using existing instructions. The memory 1701 continuously stores AOS format data for arrays A, B, and C, and the data size of the elements of each array is 8 bytes. reg1, reg4, reg5, and reg6 are SIMD registers and can store a plurality of 64-bit data.
FIG. 17 (a) shows an example of a load instruction. By executing the load instruction ld3 reg1 and addr, the processor reads AOS format data A1 to C3 from the memory 1701 and continuously writes them in the horizontal direction of reg1.
FIG. 17 (b) shows an example of a select instruction for array A. First, the processor writes the element numbers 0, 3, and 6 indicating the positions of the elements A1 to A3 of the array A in the reg1 to the register regx by executing the instruction mov regx, (0x6 & 0x3 & 0x0).
Next, the processor executes the select instruction select reg4, reg1, regx, 3 to read the three elements indicated by the three element numbers in regx from reg1 and continue in the horizontal direction of reg4. And write. This select instruction is an instruction to specify the position of the data of the array A included in each structure array from reg1, read the data at the specified position, and continuously write to reg4.
FIG. 17 (c) shows an example of a select instruction for array B. First, the processor writes the element numbers 1, 4, and 7 indicating the positions of the elements B1 to B3 of the array B in the reg1 to the register regx by executing the instruction mov regx, (0x7 & 0x4 & 0x1).
Next, the processor executes the select instruction select reg5, reg1, regx, 3 to read the three elements indicated by the three element numbers in regx from reg1 and continue in the horizontal direction of reg5. And write. This select instruction is an instruction to specify the position of the data of the array B included in each structure array from reg1, read the data at the specified position, and continuously write to reg5.
The processor can write A1 to A8 to the register 4 by executing the same select instruction as in FIG. 17 (a) for the other elements of the array A. Further, the processor can write B1 to B8 to the register 5 by executing the same select instruction as in FIG. 17 (b) for the other elements of the array B.
FIG. 17 (d) shows an example of a SIMD instruction using reg4 to reg6. By executing the SIMD instructions ADD reg6, reg4, reg5, the processor adds Ai (i = 1 ~ 8) stored in reg4 and Bi stored in reg5 in parallel, and adds the addition result Ci. Write to reg6.
FIG. 17 (e) shows an example of the scatter instruction. First, the processor calculates the storage destination start address of the addition result Ci (i = 1 to 8) in the memory 1701 by executing the load instruction ldr x1 and & A1, and writes it to the register x1 (not shown). For example, the storage destination start addresses of C1, C2, and C3 are 16, 40, and 64, respectively.
Next, the processor executes the instruction mov regx, (64,40,16) to write the storage destination start addresses of C1 to C3 stored in the register x1 to the regx. The processor can write the storage destination start address of C1 to C8 to regx by executing the same instruction for other elements of array C.
Next, the processor reads the three elements C1 to C3 from reg6 by executing the scatter instruction scatter reg6, (x1, regx), 3, and the address of the memory 1701 indicated by the three elements in the regx. Write to. This scatter instruction is an instruction to read the data of the array C from reg6, specify the position of the data of the array C included in each structure array stored in the memory 1701, and write the read data to the specified position. ..
The processor can write C1 to C8 to memory 1701 by executing similar instructions for other elements of array C.
According to the SIMD expansion using the existing instructions in FIG. 17, it is possible to perform SIMD operations on AOS format data even when the AOS-dedicated instructions are not defined.
FIG. 18 shows an example of SIMD deployment using AOS dedicated instructions. reg1 to reg3 are SIMD registers and can store eight 64-bit data.
FIG. 18 (a) shows an example of a dedicated load instruction. The processor reads the AOS format data A1 to A8 from the memory 1701 and writes them in order in the vertical direction of reg1 to reg3 by executing the dedicated load instruction ld3 reg1, reg2, reg3, addr. In this way, by using the dedicated load instruction, AOS format data can be loaded from memory 1701 to reg1 to reg3 with one instruction.
FIG. 18 (b) shows an example of a SIMD instruction using reg1 to reg3. By executing the SIMD instructions ADD reg3, reg1, reg2, the processor adds Ai (i = 1 ~ 8) stored in reg1 and Bi stored in reg2 in parallel, and adds the addition result Ci. Write to reg3.
FIG. 18 (c) shows an example of a dedicated store instruction. First, the processor calculates the storage destination start addresses of Ai, Bi, and Ci (i = 1 to 8) in the memory 1701 by executing the instructions ldr x1 and & A1, and writes them to the register x1 (not shown). ..
Next, the processor executes the dedicated store instruction st3 reg1, reg2, reg3, (x1) to read Ai, Bi, and Ci vertically from reg1 to reg3 in order to the memory 1701 in AOS format. Write. Ai in reg1 and Bi in reg2 are already stored in memory 1701, but since the dedicated store instruction is an instruction to read reg1 to reg3, it is written to memory 1701 together with Ci in reg3. In this way, by using the dedicated store instruction, AOS format data can be stored in the memory 1701 from reg1 to reg3 with one instruction.
According to the SIMD expansion using the AOS-dedicated instructions in FIG. 18, the number of instructions for SIMD operation is smaller than that in the SIMD expansion using the existing instructions in FIG. 17, so that the SIMD operation can be executed efficiently. It will be possible.
Next, the procedure of the code conversion process performed by the code conversion device 401 of FIG. 6 will be described with reference to FIGS. 19 to 24.
FIG. 19 is a flowchart showing a specific example of the code conversion process. First, the user specifies one of the extraction method M1 to the extraction method M3 as the extraction method of the conversion candidate, and inputs the optimization instruction (step 1901).
If the user specifies the extraction method M1, the code converter 401 extracts conversion candidates according to the specified compiler options. When the user specifies the extraction method M2, the code conversion device 401 extracts conversion candidates according to the control statement described in the source code 621. When the user specifies the extraction method M3, the code conversion device 401 extracts conversion candidates using the specified profile information.
Next, the analysis unit 611 analyzes the source code 621 and generates the loop management table 623 based on the analysis result (step 1902).
Next, the conversion unit 412 sets a group number in the loop management table 623 (step 1903), refers to the loop management table 623, and extracts an array of conversion candidates (step 1904). Then, the conversion unit 412 selects an array to be converted from the array of conversion candidates (step 1905), performs conversion processing on the array to be converted, and generates an intermediate code 625 (step 1906).
Next, the generation unit 413 performs SIMD expansion for the intermediate code 625 to generate the machine language code 626 (step 1907).
FIG. 20 is a flowchart showing an example of the group number setting process in step 1903 of FIG. First, the conversion unit 412 extracts variables having the same number of dimensions from the loop management table 623 (step 2001). For example, in the case of the loop management table 623 of FIG. 13 (b), the following variables are extracted as variables having the same number of dimensions.
One-dimensional variables: A (i), A (i + 2), B (i), α (W (i)), β (W (i)) Two-dimensional variables: AA (i, j), AA (i + 1, j), AA (x, z), BB (i, j), BB (i + 2, j), BB (z, c), CC (x, y), DD (x, y )
Next, the conversion unit 412 extracts variables having the same subscript from variables having the same number of dimensions, and generates a group of the extracted variables (step 2002). As a result, the following four groups are generated.
{A (i), B (i)} {AA (i, j), BB (i, j)} {CC (x, y), DD (x, y)} {α (W (i))) , β (W (i))}
Next, the conversion unit 412 sets a group number for each group (step 2003). As a result, the following group numbers are set.
Group number 1: {A (i), B (i)} Group number 2: {AA (i, j), BB (i, j)} Group number 3: {CC (x, y) ), DD (x, y)} Group number 4: {α (W (i))), β (W (i))}
FIG. 21 is a flowchart showing an example of the conversion candidate extraction process in step 1904 of FIG. First, the conversion unit 412 checks whether or not a plurality of arrays are explicitly specified by the compiler option or the control statement (step 2101).
If multiple arrays are explicitly specified (step 2101, YES), the transformator 412 checks if the specified arrays have the same group number in the loop management table 623 (steps 2101, YES). Step 2102). If the specified plurality of sequences have the same group number (step 2102, YES), the conversion unit 412 determines those sequences as conversion candidates (step 2103). On the other hand, if the specified plurality of arrays do not have the same group number, the conversion unit 412 excludes those arrays from the conversion candidates (step 2104).
If a plurality of arrays are not explicitly specified (steps 2101 and NO), the conversion unit 412 extracts conversion candidates from the generated groups. For example, if the compiler option -KAos is specified, all arrays in any group will be extracted as conversion candidates. In addition, when profile information is specified, a plurality of arrays that are frequently accessed at the same time are extracted as conversion candidates.
FIG. 22 is a flowchart showing an example of the conversion target selection process in step 1905 of FIG. First, the conversion unit 412 calculates the evaluation value for each array of conversion candidates using the evaluation function 622, and generates an evaluation value table 624 including the calculated evaluation value (step 2201). Then, the conversion unit 412 refers to the evaluation value table 624 and selects an array belonging to the group whose total evaluation value is larger than the threshold value as the conversion target (step 2202).
FIG. 23 is a flowchart showing an example of the intermediate code generation process in step 1906 of FIG. First, the conversion unit 412 changes the data definition of the array to be converted included in the source code 621 to the data definition in AOS format for each group, and defines the structure array (step 2301). As the subscript and the number of elements of the structure array, the subscript and the number of elements of each array before the change are used.
Next, the conversion unit 412 changes the description of the array to be converted included in the source code 621 to the description using the structure array (step 2302). Then, the conversion unit 412 generates the intermediate code 625 by compiling the code including the data definition in AOS format and the description of the structure array (step 2303).
FIG. 24 is a flowchart showing an example of the machine language code generation process in step 1907 of FIG. First, the generation unit 413 checks whether or not an AOS-dedicated instruction including a dedicated load instruction and a dedicated store instruction is defined (step 2401).
When the AOS dedicated instruction is defined (step 2401, YES), the generator 413 describes the dedicated load instruction in the machine language code 626 (step 2402). On the other hand, when the AOS-dedicated instruction is not defined (step 2401, NO), the generation unit 413 combines the existing instructions to read the AOS format data from the memory and write it to the SIMD register in the machine language code 626. (Step 2403).
Next, the generation unit 413 describes the SIMD instruction using the SIMD register in the machine language code 626 (step 2404), and checks whether or not the AOS-dedicated instruction is defined (step 2405).
When the AOS dedicated instruction is defined (step 2405, YES), the generator 413 describes the dedicated store instruction in the machine language code 626 (step 2406). On the other hand, when the AOS-dedicated instruction is not defined (step 2405, NO), the generation unit 413 combines the existing instructions to read the AOS format data from the SIMD register and write it to the memory with the machine language code 626. (Step 2407).
Then, the generation unit 413 generates the machine language code 626 including the dedicated load instruction or the existing instruction, the SIMD instruction, and the dedicated store instruction or the existing instruction (step 2408).
The configuration of the code conversion device 401 of FIGS. 4 and 6 is only an example, and some components may be omitted or changed depending on the use or conditions of the code conversion device 401. For example, in the code conversion device 401 of FIG. 6, when the loop management table 623 is generated by an external device, the analysis unit 611 can be omitted.
The flowcharts of FIGS. 5 and 19 to 24 are merely examples, and some processes may be omitted or changed depending on the configuration or conditions of the code conversion device 401. For example, if the loop management table 623 is generated by an external device, the process of step 1902 in FIG. 19 can be omitted. If a plurality of arrays are not explicitly specified by the compiler option or control statement, the process of step 1904 in FIG. 19 can be omitted.
The SOA format data definition and SIMD expansion shown in FIGS. 1 to 3 are only examples. The SOA format data definition and SIMD expansion are the language of source code 621 and the types of arrays and operations included in source code 621. It changes according to.
The AOS format data definition and SIMD expansion shown in FIGS. 7, 10-12, and 15-18 are only examples, and the AOS format data and SIMD expansion are the language and source code of source code 621. It varies depending on the type of array and operation included in 621. The operation included in the source code 621 may be a combination of a plurality of operations such as addition, subtraction, multiplication, and division.
The data definition in the hybrid AOS format in FIG. 8 is only an example, and the data definition in the hybrid AOS format changes depending on the language of the source code 621 and the types of sequences and operations included in the source code 621. The processing performance in FIG. 9 is only an example, and the processing performance changes according to the source code 621.
The loop management table 623 of FIG. 13 and the evaluation value table 624 of FIG. 14 are merely examples, and the loop management table 623 and the evaluation value table 624 change according to the type and number of sequences included in the source code 621. Some items in the loop management table 623 and the evaluation value table 624 may be omitted or changed depending on the configuration or conditions of the code conversion device 401.
The evaluation function E (Q) in Eq. (1) is only an example, and the evaluation value of the array may be calculated using another evaluation function E (Q).
FIG. 25 shows a hardware configuration example of an information processing device (computer) used as the code conversion device 401 of FIGS. 4 and 6. The information processing device of FIG. 25 includes a CPU (Central Processing Unit) 2501, a memory 2502, an input device 2503, an output device 2504, an auxiliary storage device 2505, a medium drive device 2506, and a network connection device 2507. These components are connected to each other by bus 2508.
The memory 2502 is, for example, a semiconductor memory such as a ROM (Read Only Memory), a RAM (Random Access Memory), or a flash memory, and stores a program and data used for processing. The memory 2502 can be used as the storage unit 411 of FIGS. 4 and 6.
The CPU 2501 (processor) operates as the conversion unit 412 and the generation unit 413 of FIGS. 4 and 6 by executing a program using, for example, the memory 2502. The CPU 2501 also operates as the analysis unit 611 in FIG. 6 by executing a program using the memory 2502.
The input device 2503 is, for example, a keyboard, a pointing device, or the like, and is used for inputting an instruction or information from an operator or a user. The output device 2504 is, for example, a display device, a printer, a speaker, or the like, and is used for inquiring or instructing an operator or a user and outputting a processing result.
The auxiliary storage device 2505 is, for example, a magnetic disk device, an optical disk device, a magneto-optical disk device, a tape device, or the like. The auxiliary storage device 2505 may be a hard disk drive. The information processing device can store programs and data in the auxiliary storage device 2505 and load them into the memory 2502 for use.
The medium drive device 2506 drives the portable recording medium 2509 to access the recorded contents. The portable recording medium 2509 is a memory device, a flexible disk, an optical disk, a magneto-optical disk, or the like. The portable recording medium 2509 may be a CD-ROM (Compact Disk Read Only Memory), a DVD (Digital Versatile Disk), a USB (Universal Serial Bus) memory, or the like. The operator or the user can store the programs and data in the portable recording medium 2509 and load them into the memory 2502 for use.
In this way, the computer-readable recording medium that stores the programs and data used for processing is physical (non-temporary) recording, such as memory 2502, auxiliary storage device 2505, or portable recording medium 2509. It is a medium.
The network connection device 2507 is a communication interface circuit that is connected to a communication network such as LAN (Local Area Network) and WAN (Wide Area Network) and performs data conversion associated with communication. The information processing device can receive programs and data from an external device via the network connection device 2507 and load them into the memory 2502 for use.
It should be noted that the information processing apparatus does not have to include all the components shown in FIG. 25, and some components may be omitted depending on the intended use or conditions. For example, if an interface with the user or operator is not required, the input device 2503 and the output device 2504 may be omitted. If the portable recording medium 2509 or the communication network is not used, the medium driving device 2506 or the network connection device 2507 may be omitted.
Although the embodiments of the disclosure and their advantages have been described in detail, those skilled in the art will be able to make various changes, additions and omissions without departing from the scope of the invention expressly described in the claims. Let's do it.
The following additional notes are further disclosed with respect to the embodiments described with reference to FIGS. 1 to 25.
(Appendix 1) A storage unit for storing a first code, including a data definition of a plurality of arrays, a predetermined operation on the plurality of arrays, and a data definition of an array representing the operation result of the predetermined operation, and the above. The data definition of the plurality of arrays included in the first code and the data definition of the array representing the operation result are converted into the data definition of the structure array, and the predetermined operation included in the first code is performed. A conversion unit that converts to an operation on a structure array, and a generation unit that generates a second code including a predetermined instruction that executes an operation on the structure array in parallel for different data of each of the plurality of arrays. A code conversion device characterized by comprising.
(Appendix 2) The predetermined instruction is an instruction to execute an operation on the structure array for the array data stored in each of a plurality of registers and write the array data representing the operation result to the predetermined register. The second code reads the data of a plurality of structure arrays continuously stored in the memory, and the data of the plurality of arrays included in the data of each structure array is stored in the plurality of registers. An instruction to write and an instruction to read the data of the array representing the operation result from the predetermined register and write it to the position of the data of the array representing the operation result included in the data of each structure array stored in the memory. The code conversion device according to Appendix 1, further comprising:
(Appendix 3) The predetermined instruction is an instruction to execute an operation on the structure array for the data of the array stored in each of a plurality of registers and write the data of the array representing the operation result to the predetermined register. The second code includes an instruction to read data of a plurality of structure arrays continuously stored in a memory and continuously write the data to the first register, and data of each structure array from the first register. An instruction to read the data at the specified position by designating the position of the data in the same array included in, and continuously write to the same register among the plurality of registers, and an array representing the operation result from the predetermined register. The data is read, the position of the data of the array representing the operation result included in the data of each structure array stored in the memory is specified, and the data read from the predetermined register is the designated position of the memory. The code conversion device according to Appendix 1, further comprising an instruction to be written in.
(Appendix 4) The conversion unit is characterized in that the plurality of arrays and the array representing the operation result are selected from the sequences included in the first code according to the compiler option indicating the conversion of the data definition. The code conversion device according to any one of Supplementary note 1 to 3.
(Appendix 5) The first code includes a control statement for designating the plurality of arrays and an array representing the operation result, and the conversion unit is included in the array included in the first code according to the control statement. The code conversion apparatus according to any one of Supplementary note 1 to 3, wherein the plurality of arrays and the array representing the operation result are selected from the above.
(Appendix 6) The conversion unit represents the plurality of sequences and the calculation result from the sequences included in the first code by using the profile information indicating the access frequency of the sequences included in the first code. The code conversion device according to any one of Supplementary note 1 to 3, wherein the sequence is selected.
(Appendix 7) The conversion unit shall be used for at least one of the number of occurrences of each sequence in the loop included in the first code or the number of occurrences of each sequence in a group of sequences having the same subscript in the loop. The code conversion apparatus according to any one of Supplementary note 1 to 6, wherein the plurality of sequences are selected from the sequences included in the loop based on the above.
(Supplementary Note 8) The code conversion device according to any one of Supplementary note 1 to 7, wherein the data definition of a plurality of arrays included in the first code is a data definition of an array structure.
(Appendix 9) A computer having a storage unit for storing a first code, including a data definition of a plurality of arrays, a predetermined operation on the plurality of arrays, and a data definition of an array representing the operation result of the predetermined operation. Converts the data definition of the plurality of arrays included in the first code and the data definition of the array representing the operation result into the data definition of the structure array, and the predetermined operation included in the first code. Is converted into an operation on the structure array, and a second code including a predetermined instruction for executing an operation on the structure array in parallel for different data of each of the plurality of arrays is generated. Code conversion method.
(Appendix 10) The predetermined instruction is an instruction to execute an operation on the structure array for the data of the array stored in each of a plurality of registers and write the data of the array representing the operation result to the predetermined register. The second code reads the data of a plurality of structure arrays continuously stored in the memory, and the data of the plurality of arrays included in the data of each structure array is stored in the plurality of registers. An instruction to write and an instruction to read the data of the array representing the operation result from the predetermined register and write it to the position of the data of the array representing the operation result included in the data of each structure array stored in the memory. And, the code conversion method described in Appendix 9, which further comprises.
(Appendix 11) The predetermined instruction is an instruction to execute an operation on the structure array for the data of the array stored in each of a plurality of registers and write the data of the array representing the operation result to the predetermined register. The second code includes an instruction to read data of a plurality of structure arrays continuously stored in a memory and continuously write the data to the first register, and data of each structure array from the first register. An instruction to read the data at the specified position by designating the position of the data in the same array included in, and continuously write to the same register among the plurality of registers, and an array representing the operation result from the predetermined register. The data is read, the position of the data of the array representing the operation result included in the data of each structure array stored in the memory is specified, and the data read from the predetermined register is the designated position of the memory. The code conversion method described in Appendix 9, which further includes an instruction to be written in.
(Appendix 12) A computer having a storage unit for storing a first code, including a data definition of a plurality of arrays, a predetermined operation on the plurality of arrays, and a data definition of an array representing the operation result of the predetermined operation. The data definition of the plurality of arrays included in the first code and the data definition of the array representing the operation result are converted into the data definition of the structure array, and the predetermined operation included in the first code. Is converted into an operation on the structure array, and a second code including a predetermined instruction for executing the operation on the structure array in parallel is generated for different data of each of the plurality of arrays. Code conversion program.
(Appendix 13) The predetermined instruction is an instruction to execute an operation on the structure array for the data of the array stored in each of a plurality of registers and write the data of the array representing the operation result to the predetermined register. The second code reads the data of a plurality of structure arrays continuously stored in the memory, and the data of the plurality of arrays included in the data of each structure array is stored in the plurality of registers. An instruction to write and an instruction to read the data of the array representing the operation result from the predetermined register and write it to the position of the data of the array representing the operation result included in the data of each structure array stored in the memory. And, the code conversion program described in Appendix 12, which further comprises.
(Appendix 14) The predetermined instruction is an instruction to execute an operation on the structure array for the data of the array stored in each of a plurality of registers and write the data of the array representing the operation result to the predetermined register. The second code includes an instruction to read data of a plurality of structure arrays continuously stored in a memory and continuously write the data to the first register, and data of each structure array from the first register. An instruction to read the data at the specified position by designating the position of the data in the same array included in, and continuously write to the same register among the plurality of registers, and an array representing the operation result from the predetermined register. The data is read, the position of the data of the array representing the operation result included in the data of each structure array stored in the memory is specified, and the data read from the predetermined register is the designated position of the memory. The code conversion program described in Appendix 12, which further comprises an instruction to be written in.
101 ~ 103, 301 ~ 303 areas
401 Code converter
411 Memory
412 Conversion unit
413 Generator
611 Analysis department
621 Source code
622 Evaluation function
623 Loop management table
624 Evaluation value table
625 Intermediate code
626 Machine language code
701, 801, 1701 memory
1201 Profile information
2501 CPU
2502 memory
2503 Input device
2504 Output device
2505 Auxiliary storage
2506 Medium drive
2507 Network connection device
2508 bus
2509 Portable recording medium
25 sheets
Sheet 1 Sheet 2 Sheet 3 Sheet 4 Sheet 5 Sheet 6 Sheet 7 Sheet 8 Sheet 9 Sheet 10 Sheet 11 Sheet 12 Sheet 13 Sheet 14 Sheet 15 Sheet 16 Sheet 17 Sheet 18 Sheet 19 Sheet 20 Sheet 21 Sheet 22 Sheet 23 Sheet 24 Sheet 25
Every citation, both ways
| Document | Relation | Office |
|---|---|---|
| JP675987A | Cites | Japan |
| JP728702A | Cites | Japan |
| JP2005174292A | Cites | Japan |
| JP2014038624A | Cites | Japan |
| JP2015225427A | Cites | Japan |
| JP2016081135A | Cites | Japan |
| US20120089792A1 | Cites | United States of America |
| US20150294435A1 | Cites | United States of America |
| US20170177356A1 | Cites | United States of America |
4 members in 2 offices
Priority claims2
| Document | Office | Kind | Date |
|---|---|---|---|
| 2018077108 | Japan | A | |
| JP20180077108 | – | – | – |
Members4
| Document | Office | Kind | |
|---|---|---|---|
| US2019317767A1 | United States of America | A1 | |
| JP2019185486A | Japan | A | |
| US10908899B2 | United States of America | B2 | |
| JP7035751B2This record | Japan | B2 |
6 legal events, as the office reported them to INPADOC
Over the term
Point at a mark for the eventEvents
| Event | Code | |
|---|---|---|
| First payment of annual fees (during grant procedure)JAPANESE INTERMEDIATE CODE: A61A61 | A61 | |
| Certificate of patent or registration of utility modelJAPANESE INTERMEDIATE CODE: R150R150 | R150 | |
| Written decision to grant a patent or to grant a registration (utility model)JAPANESE INTERMEDIATE CODE: A01A01 | A01 | |
| Decision of grant or rejection writtenTRDD | TRDD | |
| Report on retrievalJAPANESE INTERMEDIATE CODE: A971007A977 | A977 | |
| Written request for application examinationJAPANESE INTERMEDIATE CODE: A621A621 | A621 |
Numbers
- Publication
- 7035751
- Publication, DOCDB
- 7035751
- Publication, EPODOC
- JP7035751B
- Application
- 77108
- Application, DOCDB
- 2018077108
- Application, EPODOC
- JP20180077108
Titles2
- Japanese
- コード変換装置、コード変換方法、及びコード変換プログラム
- English
- Code conversion device, code conversion method, and code conversion program
Classification
- CPC, 10
- G06F9/30036
- G06F9/30025
- G06F9/30043
- G06F8/453
- G06F9/3887
- G06F9/30101
- G06F9/4881
- G06F9/30076
- G06F9/30109
- G06F9/45504
- IPC, 4
- G06F8 41
- G06F9 38
- G06F9 312
- G06F17 16
