Vectorization device, vectorization method and program

By dividing list arrays into groups with unique values and modifying loop calculations, the method facilitates vectorization of loop operations with overlapping dependencies, improving parallel processing efficiency.

JP2025139469APending Publication Date: 2025-09-26NEC CORP
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
JP2024038424
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2024-03-12
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

Existing technologies struggle to vectorize loop calculations when accessing both updated and referenced terms via a list array with overlapping values, as dependencies inhibit parallel processing.

Method used

The method involves dividing the list array into groups where elements within each group have unique values and modifying the loop calculation process to perform operations for each group, allowing parallel processing.

Benefits of technology

This approach enables vectorization of loop calculations where both updated and referenced terms are accessed via a list array, enhancing performance by enabling parallel processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2025139469000001_ABST
    Figure 2025139469000001_ABST
Patent Text Reader

Abstract

To provide a technique that can perform vectorization in relation to summation processing via list arrays having a dependence relation that inhibits the vectorization.SOLUTION: A vectorization device includes: means for dividing a list array into groups in which values of elements of the list array within a group are all different, for loop calculation processing that includes access to values via the list array having a dependence relation that inhibits vectorization; and means for modifying the loop calculation processing so that the loop calculation processing is performed for each group.SELECTED DRAWING: Figure 5
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present disclosure relates to a vectorization device, a vectorization method, and a program. [Background technology]

[0002] Vectorization is a technique for speeding up loop calculations on arrays. Vectorization allows loops to be processed in parallel rather than sequentially. For example, compilers are available that read the source code to be processed, determine whether vectorization is possible, and, if so, vectorize and execute it. In the field of scientific computing, vectorization is generally recognized as essential for extracting the full performance of computers. However, as shown in Figure 1, when a calculation is performed by accessing the element values ​​of array a via list array x[i], it is known that if the element values ​​of list array x[i] overlap (the same value appears multiple times), a dependency that inhibits vectorization occurs and vectorization is impossible. In the summation calculation shown in Figure 1, vectorization is possible if the element values ​​of list array x[i] do not overlap. However, if the values ​​of x[0] and x[1] are the same, for example, vectorization is inhibited. Because it is impossible to determine whether there are overlaps in the values ​​from the source code in Figure 1, vectorization is difficult. Patent Document 1 discloses a technique for vectorizing loop processing in which a list array x[i] is applied to the subscript of a referenced term B in a loop, such as A(i) = A(i) + B(x[i]). However, Patent Document 1 does not disclose a technique for vectorizing processing in which a list array x[i] is applied to the subscript of a term (array a) that is updated and referenced, such as a(x[i]) = a(x[i]) + b(i), as shown in the example of Figure 1. [Prior art documents] [Patent documents]

[0003] [Patent Document 1] Japanese Patent Application Publication No. 11-203256 Summary of the Invention [Problem to be solved by the invention]

[0004] One of the objects is to provide a technology that enables vectorization of calculation processing by a loop in which access occurs via a list array to both the item to be updated and the item to be referenced. [Means for solving the problem]

[0005] According to one aspect of the present disclosure, a vectorization device includes means for dividing a list array into groups in which the values ​​of elements of the list array within a group are all different, for a loop calculation process that includes access to a value via a list array and has a dependency that inhibits vectorization, and means for modifying the loop calculation process to a process in which the loop calculation process is performed for each group.

[0006] According to one aspect of the present disclosure, there is provided a vectorization method for a loop calculation process that includes access to a value via a list array, which has a dependency that inhibits vectorization, by dividing the list array into groups in which the values ​​of the elements of the list array within each group are all different, and modifying the loop calculation process to perform the loop calculation process for each group.

[0007] According to one aspect of the present disclosure, a program causes a computer to execute a process for a loop calculation process that includes access to a value via a list array, which has a dependency that inhibits vectorization, by dividing the list array into groups in which the values ​​of the elements of the list array within each group are all different, and modifying the loop calculation process to perform the loop calculation process for each group. [Effects of the Invention]

[0008] According to the present disclosure, it is possible to vectorize a loop calculation process in which accesses to both the updated term and the referenced term occur via list arrays. [Brief explanation of the drawings]

[0009] [Figure 1] FIG. 10 is a diagram illustrating an example of a summation process via a list array having a dependency relationship that inhibits vectorization. [Figure 2] FIG. 1 illustrates an example of a vectorization device according to an embodiment. [Figure 3] 10 is a flowchart illustrating an example of vectorization processing according to the embodiment. [Figure 4A] FIG. 1 is a first diagram showing an example of a vectorization processing result according to the embodiment. [Figure 4B] FIG. 2 is a second diagram showing an example of a vectorization processing result according to the embodiment. [Figure 5] FIG. 2 is a second diagram illustrating an example of a vectorization device according to an embodiment. [Figure 6] 10 is a flowchart illustrating an example of an operation of the vectorization device according to the embodiment. [Figure 7] FIG. 2 is a diagram illustrating an example of a hardware configuration of a vectorization device according to an embodiment. DETAILED DESCRIPTION OF THE INVENTION

[0010] Vectorization processing according to each embodiment of the present disclosure will be described below with reference to the drawings. In the drawings used in the following description, the description of parts not related to the present disclosure may be omitted or not shown. The same or equivalent parts in all drawings will be denoted by the same reference numerals, and common descriptions may be omitted.

[0011] First Embodiment (System Configuration) 2 shows a vectorization device 100 according to an embodiment. The vectorization device 100 includes a detection device 101, an access range detection processing addition device 102, an access count processing addition device 103, a maximum access count processing addition device 104, a work array creation processing addition device 105, a grouping list creation processing addition device 106, and a structure transformation device 107.

[0012] The detection device 101 acquires source code to be vectorized and detects a loop structure to which this embodiment is applied from a series of processes described in the source code. The detection device 101 detects a portion of the source code input by a user to the vectorization device 100 that describes a summation process via a list array having a dependency that inhibits vectorization, as shown in the example of FIG.

[0013] The access range detection process adding device 102 adds to the vectorization process a process for detecting the range of values ​​that appear in the list array in the loop structure detected by the detection device 101. The range of values ​​is the range of values ​​that x[i] takes in Figure 1. For example, if x[0] = 1, x[1] = 2, x[2] = 2, x[3] = 4, x[4] = 1, and x[5] = 2, the range of values ​​is 1 to 4.

[0014] The access count processing adding device 103 adds to the vectorization processing a process that counts how many times each value appears in the list array within the range detected by the access range detection processing adding device 102. In the above example, 1 appears twice, 2 appears three times, and 4 appears once.

[0015] The maximum access count processing addition device 104 adds to the vectorization processing a process that counts the number of times the most frequently occurring value appears based on the processing result of the access count processing addition device 103. In the above example, the most frequently occurring value is 2, and it appears three times. This "3" is the number of groups. A group is a list array whose elements are a set of values ​​such that no two list array elements have the same value within that group. In this embodiment, by dividing the original list array, which may contain the same value, into such groups, it is guaranteed that the values ​​of the list array elements within a group do not overlap, making vectorization within the group possible.

[0016] The work array creation processing addition device 105 adds to the vectorization processing a process for creating and initializing a work array required for grouping based on the processing result of the maximum access count processing addition device 104.

[0017] The grouping list creation process adding device 106 adds to the vectorization process a process for creating a grouping list using the work arrangement created by the work arrangement creation process adding device 105 .

[0018] The structure transformation unit 107 uses the grouping list created by the grouping list creation processing addition unit 106 to transform the target loop structure into a vectorizable structure.

[0019] Vectorization device 100 converts input source code into vectorizable source code using devices 101 to 107. Next, the flow of vectorization processing will be described with reference to Fig. 3 and Fig. 4A to Fig. 4B.

[0020] (operation) FIG. 3 is a flowchart illustrating an example of vectorization processing according to the embodiment. FIG. 4A is a first diagram showing an example of a result of the vectorization process according to the embodiment. FIG. 4B is a second diagram showing an example of a result of the vectorization process according to the embodiment. By the process of Figure 3, the loop structure of Figure 1 is modified as shown in 408 of Figure 4B, making it possible to vectorize it. The source code of Figures 4A and 4B is one source code divided into two parts, with the first half shown in Figure 4A and the second half shown in Figure 4B. First, a user inputs source code into the vectorization device 100. The vectorization device 100 acquires the input source code and outputs it to the detection device 101 (step S101). Next, the detection device 101 detects a target loop structure from the input source code (step S102). The target loop structure is code for a loop calculation process that includes access via a list array and has a dependency relationship that inhibits vectorization. For example, the detection device 101 detects a loop process from the input source code, and checks whether a variable indicating the number of loops is used as a value to identify an element of a list array in the detected loop process. If a variable indicating the number of loops is used, the detection device 101 checks whether the list array is used as a value to identify an element of the array of the reference side and / or update side term (a or b in FIG. 1). If a variable indicating the number of loops is used, the detection device 101 detects the corresponding part of the code as the target loop structure. If the detection of the loop structure fails (step S102; No), the process ends. If the target loop structure does not exist in the input source code, the process of FIG. 3 ends.

[0021] If a loop structure is detected (step S102; Yes), the access range detection process adding device 102 adds a process for detecting the range of values ​​appearing in the list array in the detected loop structure (step S103). An example of the process to be added is shown in 401 of the source code in FIG. 4A.

[0022] Next, the access count process adding device 103 adds a process for counting how many times each value appears in the list array within the detected range (step S104). An example of the process to be added is shown in 402 of the source code in FIG. 4A.

[0023] Next, the maximum access count process adding device 104 adds a process for counting how many times the most frequently appearing value appears among the values ​​appearing in the list array (step S105). An example of the process to be added is shown in 403 of the source code in FIG. 4A.

[0024] Next, the work array creation process adding device 105 adds a process for creating and initializing a work array required for creating a grouping list (step S106). An example of the process to be added is shown in 404 and 405 of the source code in FIG.

[0025] Next, the grouping list creation process adding device 106 adds a process for creating a grouping list using the work array created in step S106 (step S107). An example of the process to be added is shown in 406 and 407 of the source code in FIG.

[0026] Next, the structure transformation unit 107 transforms the target structure using the grouping list created in step S107 (step S108). An example of the transformed structure is shown in 408 of the source code in Figure 4B. 408 is the loop structure detected in step S102, modified based on the processing results up to this point.

[0027] Next, the vectorization device 100 outputs the source code created (modified) by the processes of steps S103 to S108, and ends the process (step S109).

[0028] Here, we will explain the processing described in the source code of Figures 4A and 4B using the example where i = 0 to 5 and x[0] = 1, x[1] = 2, x[2] = 2, x[3] = 4, x[4] = 1, x[5] = 2. In 401 of FIG. 4A, max_x=4. In 402 of FIG. 4A, we obtain num_each_col[1]=2, num_each_col[2]=3, and num_each_col[4]=1. In 403 of FIG. 4A, ncol=3. 3 is the number of occurrences of the most frequently occurring value 2, and is the number of groups. In 404 of FIG. 4A, each element of list[2][3][4] is initialized to -1. In 405 of FIG. 4A, num_each_col[0] to num_each_col[3] are initialized to 0. In addition, len[0] to len[2] are initialized to 0.

[0029] In 406 of FIG. 4B, the following is obtained: list[0][0][1]=1 (calculation result for i=0) list[1][0][1]=0 (calculation result for i=0) list[0][0][2]=2(calculation result for i=1) list[1][0][2]=1(calculation result for i=1) list[0][1][2]=2(calculation result for i=2) list[1][1][2]=2(calculation result for i=2) list[0][0][4]=4 (calculation result for i=3) list[1][0][4]=3 (calculation result for i=3) list[0][1][1]=1 (calculation result for i=4) list[1][1][1]=4 (calculation result for i=4) list[0][2][2]=2(calculation result for i=5) list[1][2][2]=5(calculation result for i=5)

[0030] In 407 of FIG. 4B, we obtain: list[0][0][0]=1 (calculation result for ic=0, i=0) list[1][0][0]=0 (calculation result for ic=0, i=0) list[0][0][1]=2(calculation result for ic=0, i=1) list[1][0][1]=1 (calculation result for ic=0, i=1) list[0][0][2]=4 (calculation result for ic=0, i=2) list[1][0][2]=3 (calculation result for ic=0, i=2) list[0][1][0]=2 (calculation result for ic=1, i=0) list[1][1][0]=2 (calculation result for ic=1, i=0) list[0][1][1]=1(calculation result for ic=1, i=1) list[1][1][1]=4 (calculation result for ic=1, i=1) list[0][2][2]=2 (calculation result for ic=2, i=0) list[1][2][2]=5 (calculation result for ic=2, i=0)

[0031] In 408 of FIG. 4B, the inner loop for ic=0 is list[0][0][0]=1 list[0][0][1]=2 list[0][0][2]=4 As shown above, the values ​​of a list array are guaranteed not to contain the same value, such as 1, 2, and 4, so they can be vectorized. Similarly, the inner loop for ic=1 is list[0][1][0]=2 list[0][1][1]=1 As shown above, the values ​​of a list array are guaranteed not to contain the same value, such as 2,1, so they can be vectorized.

[0032] (effect) As described above, according to this embodiment, vectorization is possible for loop calculations involving access via a list array by dividing values ​​appearing in the list array into multiple groups that do not contain identical values ​​and modifying the processing so that each group is processed in a different loop. This makes it possible to vectorize loop calculations for arrays in which access via list arrays occurs for both the updated and referenced terms, as shown in FIG. 1 . Furthermore, the vectorization processing of this embodiment can also be applied to summation processing, as described in Patent Document 1, in which access via list arrays occurs only for the referencing array, such as A(i) = A(i) + B(x[i]). The vectorization processing of this embodiment can be applied to scientific computing fields, devices using vectorization functions, and SIMD (Single Instruction / Multiple Data) functions.

[0033] Whether or not performance improvement results from applying vectorization according to this embodiment depends on the contents of the list array. As an extreme example, if all values ​​in the list array are the same, performance will not improve. Therefore, vectorization may be applied not when a target structure is detected in step S102, but when a compiler directive instructing the application of vectorization according to this embodiment is inserted. For example, if it is known that most of the values ​​in the list array are the same, compilation may be performed without issuing a compiler directive instructing the application of vectorization. Otherwise, compilation may be performed with a compiler directive instructing the application of vectorization. Furthermore, in the maximum access count process 403 of FIG. 4A, if ncol accounts for a large portion of the total number of elements (ncol > a predetermined threshold), it may be determined that vectorization will not improve performance, and the process of FIG. 3 may be configured to not execute subsequent processes.

[0034] The vectorization device 100 according to this embodiment is a device that converts source code, and outputs "modified source code (FIGS. 4A and 4B)." Outputting modified source code has the advantages of "not turning the source code into a black box" and "allowing the modified source code to be further manually modified and reused as needed," but this is not necessarily required. The modified source code may be implemented as a function of the compiler, with the output being a "vectorized object file" that is used as input to the compiler.

[0035] The series of grouping processes added as a result of applying this embodiment requires a certain amount of execution time. Therefore, it is effective in situations where list summation is performed multiple times for each grouping process. In actual applications, list arrays are often not changed after they are determined immediately after the start of calculation. Therefore, it is effective to implement the position where the "series of grouping processes" is added by "specifying it in a compiler directive line, etc."

[0036] Second Embodiment FIG. 5 shows another example of a vectorization device according to an embodiment. The vectorization device 800 includes a grouping means 801 for dividing a list array into groups in which the values ​​of the elements of the list array within a group are all different, for a loop calculation process that includes access to a value via a list array and has a dependency that inhibits vectorization, and a modification means 802 for modifying the loop calculation process into a process in which the loop calculation process is performed for each group.

[0037] FIG. 6 shows an example of the operation of the vectorization device according to the embodiment. The vectorization device 800 For loop calculation processing that includes access to values ​​via a list array and has dependencies that inhibit vectorization, the list array is divided into groups in which the values ​​of the elements of the list array within a group are all different (step S801), and the loop calculation processing is modified to a processing in which the loop calculation processing is performed for each group (step S802).

[0038] FIG. 7 is a diagram illustrating an example of a hardware configuration of a vectorization device according to an embodiment. The computer 900 includes a CPU 901, a main memory device 902, an auxiliary memory device 903, an input / output interface 904, and a communication interface 905. The above-described vectorization devices 100 and 800 are implemented in the computer 900. The above-described functions are stored in the auxiliary memory device 903 in the form of a program. The CPU 901 reads the program from the auxiliary memory device 903, loads it in the main memory device 902, and executes the above-described processing in accordance with the program. The CPU 901 also allocates a storage area in the main memory device 902 in accordance with the program. The CPU 901 also allocates a storage area in the auxiliary memory device 903 for storing data being processed in accordance with the program.

[0039] Alternatively, a program for implementing all or part of the functions of the vectorization devices 100 and 800 may be recorded on a computer-readable recording medium, and the program may be loaded into a computer system and executed to perform processing by each functional unit. The term "computer system" as used herein includes hardware such as an OS and peripheral devices. Furthermore, if a WWW system is used, the term "computer system" also includes the homepage provision environment (or display environment). Furthermore, the term "computer-readable recording medium" refers to portable media such as CDs, DVDs, and USBs, as well as storage devices such as hard disks built into the computer system. Furthermore, if the program is distributed to the computer 900 via a communication line, the computer 900 may load the program into the main storage device 902 and execute the above-described processing. Furthermore, the program may be for implementing part of the above-described functions, or may be capable of implementing the above-described functions in combination with a program already stored in the computer system.

[0040] Although one embodiment of the present disclosure has been described in detail above with reference to the drawings, the specific configuration is not limited to the above, and various design modifications are possible within the scope of the gist of the present invention. Furthermore, one aspect of the present disclosure may be modified in various ways within the scope of the claims, and embodiments obtained by appropriately combining the technical means disclosed in different embodiments are also included in the technical scope of the present disclosure. Furthermore, configurations in which elements described in the above embodiments and variations are substituted with elements that achieve the same effect are also included. Furthermore, each embodiment may be combined with other embodiments as appropriate.

[0041] Some or all of the above embodiments can be described as, but are not limited to, the following supplementary notes.

[0042] (Appendix 1) A vectorization device having a means for dividing a list array into groups in which the values ​​of elements of the list array within a group are all different, for a loop calculation process including access to values ​​via a list array having a dependency that inhibits vectorization, and a means for modifying the loop calculation process so that the loop calculation process is performed for each group.

[0043] (Appendix 2) In the vectorization device according to appendix (1), in the loop calculation process, access to values ​​occurs via the list array for both the term to be updated and the term to be referenced.

[0044] (Appendix 3) The dividing means divides the values ​​into groups by selecting one value from among the values ​​that appear one or more times in the list array and placing it in a first group, and then, where n is a natural number, selecting one value from the remaining values ​​that appear n or more times in the list array and placing it in the nth group, starting from n=2 and incrementing n by 1, until the values ​​appearing in the list array are classified into one of the groups, in the vectorization device described in appendix (1) or (2).

[0045] (Appendix 4) The vectorization device according to any one of claims (1) to (3) further comprises a means for acquiring source code and a means for detecting a loop calculation processing structure that includes access to a value via the list array contained in the source code.

[0046] (Appendix 5) This is a vectorization method for a loop calculation process that includes access to values ​​via a list array and has dependencies that hinder vectorization, by dividing the list array into groups in which the values ​​of the elements of the list array within each group are all different, and modifying the loop calculation process so that the loop calculation process is performed for each group.

[0047] (Appendix 6) This is a program that causes a computer to execute a process for a loop calculation process that includes access to values ​​via a list array, which has a dependency that inhibits vectorization, by dividing the list array into groups in which the values ​​of the elements of the list array within each group are all different, and modifying the loop calculation process so that the loop calculation process is performed for each group. [Explanation of symbols]

[0048] 100···Vectorizer 101 Detection device 102 Access range detection processing additional device 103 Access count processing additional device 104: Maximum access count processing additional device 105 Work arrangement creation processing additional device 106 Grouping list creation processing additional device 107 Structural transformation device 800···Vectorizer 801...Grouping Method 802...Correction method 900···Computer 901 CPU 902...Main memory 903...Auxiliary storage device 904 Input / Output Interface 905···Communication Interface

Claims

1. a means for dividing a list array into groups in which the values ​​of elements of the list array within a group are all different, for a loop calculation process including access to a value via a list array having a dependency that inhibits vectorization; a means for modifying the loop calculation process to a process in which the loop calculation process is performed for each of the groups; A vectorization device having:

2. In the loop calculation process, access to values ​​occurs via the list array for both the updated term and the referenced term. The vectorization device according to claim 1 .

3. the dividing means performs a process of selecting one value for each of the values ​​that appear one or more times in the list array, and setting the selected value as a first group; For the remaining values, one of the remaining values ​​that appears n times (n is a natural number) or more in the list array is selected for each value and made into the nth group. This process is carried out starting from n=2 and incrementing n by 1 until the values ​​of the elements of the list array are classified into one of the groups, thereby dividing the values ​​into groups.

3. The vectorization device according to claim 1.

4. A means of obtaining the source code; means for detecting a loop calculation process that includes access to a value via the list array, the loop calculation process being included in the source code; The vectorization device according to claim 1 or 2, further comprising:

5. For a loop calculation process including access to a value via a list array having a dependency that inhibits vectorization, the list array is divided into groups in which the values ​​of elements of the list array within each group are all different; modifying the loop calculation process to a process in which the loop calculation process is performed for each of the groups; Vectorization methods.

6. On the computer, For a loop calculation process including access to a value via a list array having a dependency that inhibits vectorization, the list array is divided into groups in which the values ​​of elements of the list array within each group are all different; a process of modifying the loop calculation process to a process of performing the loop calculation process for each of the groups; A program that executes the following.

Citation Information

Patent Citations

  • Method and device for parallelized complication

    JP1999203256A