CN108932137B - Assembly-level inter-process pointer analysis method based on speculative multithreading - Google Patents

Assembly-level inter-process pointer analysis method based on speculative multithreading Download PDF

Info

Publication number
CN108932137B
CN108932137B CN201810785251.3A CN201810785251A CN108932137B CN 108932137 B CN108932137 B CN 108932137B CN 201810785251 A CN201810785251 A CN 201810785251A CN 108932137 B CN108932137 B CN 108932137B
Authority
CN
China
Prior art keywords
pointing
analysis
loop
relation
processes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810785251.3A
Other languages
Chinese (zh)
Other versions
CN108932137A (en
Inventor
李美蓉
赵银亮
程传旭
张少应
陈庆荣
许雯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xian Aeronautical University
Original Assignee
Xian Aeronautical University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xian Aeronautical University filed Critical Xian Aeronautical University
Priority to CN201810785251.3A priority Critical patent/CN108932137B/en
Publication of CN108932137A publication Critical patent/CN108932137A/en
Application granted granted Critical
Publication of CN108932137B publication Critical patent/CN108932137B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline, look ahead
    • G06F9/3836Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution
    • G06F9/3842Speculative instruction execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30145Instruction analysis, e.g. decoding, instruction word fields

Landscapes

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

Abstract

The invention discloses an assembly-level inter-process pointer analysis method based on speculative multithreading, which comprises the steps of constructing process call graphs of all processes in a source program through assembly-level inter-process pointing analysis before the inter-process pointing analysis is carried out, and carrying out the pointing analysis in two stages after construction. Firstly, constructing a probability-based path analysis cost model, extracting a presumed path selected by all process nodes in a process call graph, and then carrying out orientation analysis in the process; and in the second stage, the pointing analysis between the processes and the side effect calculation between the processes are carried out, and the mapping and reflection of the pointing relationship are carried out at each process calling point by utilizing the pointing analysis result in the process to obtain the side effect calculation result between the processes, so that the updating of the pointing relationship of the calling process context is realized. On the basis, the whole program is guided to perform data flow analysis among processes, the data dependence degree among pointer variable memory pointing relations is evaluated, and a more accurate thread division result is obtained.

Description

Assembly-level inter-process pointer analysis method based on speculative multithreading
Technical Field
The invention belongs to the field of computers, relates to a thread-level parallelism and thread-level speculation technology, and particularly relates to an assembly-level inter-process pointer analysis method based on speculative multithreading.
Background
Speculative Multithreading (SpMT), also known as Thread-Level Speculation (TLS), is a mainstream Thread-Level parallelism technique that can identify and extract multiple threads with potential control and data dependencies from an irregular serial C program. The threads are excited, executed, verified and submitted according to correct serial semantics under the action of an execution model, and the threads are used for realizing the automatic speculative parallelism of the whole program. In the process of speculation, once a data dependence violation occurs, the current violation thread and all subsequent threads triggered by the violation thread need to be cancelled in time, and speculation is performed again, so that a large amount of speculation parallel overhead is generated due to frequent data dependence violation, and the improvement of the program parallel performance is influenced.
The existing speculation multithreading framework mostly adopts software and hardware cooperation technology to realize the automatic speculation parallelism of programs. Such a speculation framework typically utilizes compile-time data dependency profiling to perform data dependency analysis and evaluation on multiple candidate parallel domains to determine the specific locations of thread partitioning and generation. However, because a great number of complicated pointer references and side effect influence of inter-process calls often exist in the C program, it is difficult for the conventional inter-process analysis technology to accurately analyze the dependency relationship between parallel domains, so that a great number of speculative thread sets with fuzzy data dependency relationship are obtained. The main reasons are three aspects, first, the conventional inter-process analysis techniques mostly perform pointer pointing analysis on source program code or a high-level intermediate representation at compile time, and calculate and collect all possible reference relationships between variables. And the assembly-level inter-process pointer analysis can easily obtain the storage space organization structure when the program runs, so that the method is favorable for accurately analyzing the identification register and the memory access instruction, is favorable for developing the instruction-level scheduling speculation optimization, and improves the speculation execution efficiency. Secondly, the traditional interprocess analysis technology mostly adopts conservative directional analysis, and directional relations on all possible paths are always analyzed without combining the characteristics of a speculation frame to obtain a large number of directional relation sets, so that the parallel of radical speculation of threads is limited. Thirdly, the data flow analysis library function in the currently adopted compiling framework can only carry out data dependence analysis and extraction on scalar variables in the process, and the data dependence influence between the pointer variables and the process is ignored. Therefore, to obtain a reasonable thread partition result, it is necessary to accurately analyze the data dependency relationship between threads, thereby improving the performance and efficiency of the program automated speculative parallelism.
Disclosure of Invention
The invention aims to provide an assembly-level inter-process pointer analysis method based on speculative multithreading, which can perform pointing analysis on in-process memory read-write instructions and collect and calculate inter-process side effects on assembly codes so as to realize the radical speculation parallelism of speculative multithreading.
In order to achieve the purpose, the invention adopts the following technical scheme to realize the purpose:
an assembly-level inter-process pointer analysis method based on speculative multithreading comprises the following steps:
step 1, extracting a process call instruction through traversal of an MIPS assembly instruction generated at a compiling rear end, and constructing a process call graph according to a relation between a call process and a called process, wherein nodes in the process call graph represent processes, the processes comprise the call process and the called process, and the call and called relation between the processes is represented at the same time;
step 2, analyzing the path of each node in the process call graph, and collecting all execution paths; constructing a probability-based path analysis cost model, carrying out cost evaluation on all execution paths, and selecting a path with the maximum cost as a candidate conjecture path to be added into a working set until the candidate conjecture paths of all nodes in the process call graph are added into the working set;
step 3, traversing each node in the process call graph from bottom to top, selecting a speculative path corresponding to the node from the working set, expressing the abstract position and the instruction type of a memory pointing variable on the speculative path by adopting the abstract position set and the predicate, constructing a pointing relation tree to guide the pointing analysis in the process, constructing a rule transformation library based on the process by using the pointing analysis result in the process, and storing the rule transformation library in the relevant nodes of the process call graph after formalization;
step 4, carrying out orientation analysis among the processes on each node in the process call graph from top to bottom, and when the orientation analysis reaches a process call instruction, mapping and reflection of the orientation relation of the process to be called by combining the context orientation relation of the current calling process and utilizing the formalized orientation analysis result in the rule conversion library, and calculating and collecting side effects among the processes;
step 5, according to the inter-process pointing analysis and the collected inter-process side effect calculation results, performing inter-process data flow analysis, determining a data dependence position of a memory pointing variable in the inter-process context pointing relationship, taking the obtained data dependence position as the input of a speculative multithreading data dependence model, and calculating the data dependence number and data dependence distance required by speculative multithreading;
and 6, according to the data dependence number and the data dependence distance result calculated by the speculative multithreading data dependence model, the division positions of the threads are refined, and a plurality of speculative threads are generated.
Further, the path parsing cost model based on the probability in step 2 is obtained through the following steps:
step 2.1, constructing a control flow diagram of each process, wherein each branch node in the control flow diagram only comprises two successor nodes: taken and Fall branches; each loop node then also includes two successor nodes: enter loop branch and exit loop branch;
step 2.2, when the path is analyzed to a branch node or a loop node, firstly, calculating a nearest public backward domination node corresponding to a successor node to determine a branch range, then, obtaining the execution times of a Taken branch and a Fall branch in each branch node, the number of loop nodes and the number of loop iteration times, the number of basic blocks in the branch and the distribution condition of corresponding memory read-write instructions by utilizing a program analyzing technology, and constructing a path analyzing cost model based on probability, wherein the path analyzing cost model is specifically as follows:
A) if the node executed currently belongs to the branch node, the formula Path is adopted non_loop =C taken -(1+ζ)×C fall Determining the speculative Path to be further analyzed if Path non_loop More than or equal to 0, analyzing all loop and non-loop instructions on the Taken branch; if Path non_loop If less than 0, all loop and non-loop instructions on the Fall branch are analyzed;
B) if the currently executed node belongs to the cyclic node, the method adopts
Figure BDA0001733578270000031
To determine the speculative Path to be further analyzed if Path loop Analyzing all nested loop instructions and non-nested loop instructions in the loop body, wherein the number of the nested loop instructions is more than or equal to 0; if Path loop If < 0, analyzing all nested loop instructions and non-nested loop instructions which jump out of the loop body to the loop back-dominance node,
wherein, Path non_loop Represents the calculation result, Path, of the branch node when selecting the candidate speculative Path with higher cost loop Representing the calculation result when the loop node selects the candidate speculative path with higher cost; zeta is the coefficient of regulation, N iter_taken And N iter_fall Respectively representing the number of iterations into and out of the loop body, lambda i And λ j Respectively representing dynamic matrixes for simulating and controlling the convergence process of the loop iteration execution, wherein the number of elements in the dynamic matrixes and the value of each element are respectively obtained by the total number of loop iteration times and the ratio of each loop iteration; c taken And C fall Respectively representing the cost calculation results of a single Taken branch and a Fall branch, wherein the cost calculation results are calculated by the following formulas:
Figure BDA0001733578270000041
Figure BDA0001733578270000042
wherein prob represents the probability of selecting Taken branch execution, N total_loop And N total_non_loop Respectively representing the number of loops on the selected branch path and the number of basic blocks in the non-loop, and R set And W set Representing sets of memory read and write instructions in cycles and non-cycles, respectively.
Further, in step 2, the value range of the adjustment coefficient ζ is as follows: [ -1,1].
Further, in the step 2,
Figure BDA0001733578270000043
wherein, F taken And F fall Representing the number of executions of the Taken branch and Fall branch, respectively.
Further, the specific steps of step 3 are:
step 3.1, searching a speculative path selected by a node in a process call graph from a working set according to a bottom-to-top sequence according to an evaluation result of a probability-based path analysis cost model to obtain all instruction sets on the speculative path;
step 3.2, a value set analysis method is adopted to divide the whole memory domain into a group of abstract position sets, and abstract position sets of pointer variable memory pointing analysis related global variables, local variables on a stack and dynamically allocated heap variables among processes are extracted from all instruction sets on a speculative path, namely the abstract position sets of the memory pointing variables;
3.3, expressing the instruction types of all instructions on the speculative path by adopting a group of predicates, and collecting the pointing relations of the instructions related to the memory operation in the process call, namely the pointing relations of a global variable in the instructions, a local variable on a stack as a parameter and a dynamically distributed heap variable;
step 3.4, constructing a pointing relation tree to represent all possible pointing relations among the relevant instructions of the memory operation in the process call for guiding the pointing analysis in the process; the directional relation tree is a directional tree, and each node in the directional relation tree represents the memory operation instruction collected by the analysis in the process; the edges represent the pointing and pointed relations among related instructions and are used for measuring the indirect reference relation among different variables;
step 3.5, constructing a rule conversion library based on the process by using the analysis result of the step 3.4, wherein the rule conversion library comprises nodes related to the orientation relation between the processes in the orientation relation tree, namely the orientation relation between all global variables, stack local variables serving as parameters and dynamically distributed heap variables, between the calling process and the called process; traversing the directional relation tree according to the depth-first order, and formalizing the directional relation to be converted by adopting a directional relation hexahedron; after traversing one by one, obtaining a six-tuple of the directional relation required by the rule conversion library;
and 3.6, storing the directional relation six-tuple which is formalized in the rule conversion library into the corresponding node of the process call graph.
Further, in step 3.2, the abstract position of the global variable is obtained from the memory offset position stored in the global variable; the abstract position of the local variable on the stack is obtained from the corresponding offset position in the activity record stack of the current process; the abstract position of the dynamically allocated heap variable needs to be obtained by adopting a single named object mechanism in combination with the call point of the current dynamically allocated instruction.
Further, the specific process of step 4 is as follows:
step 4.1, when the node in the process call graph belongs to a call process, analyzing the pointing relation of the memory operation and the process call related instruction on the selected speculative path in the call process, performing pointing analysis on a constant operation instruction, a data transmission instruction, an offset position and memory address calculation instruction, a memory read instruction, a memory write instruction, a process call instruction and a branch jump instruction, and guiding the pointing analysis among the processes;
and 4.2, when the direction is analyzed to a process call instruction, extracting the direction relation of the global variable related to the process call, the local variable on the stack as the parameter and the dynamically distributed stack variable in the calling process by combining the context direction relation among the processes obtained by analyzing in the step 4.1, calculating and collecting the side effect of the call among the processes by using the rule conversion library obtained in the step 3, wherein the calculation result of the side effect among the processes adopts six-tuple of the direction relation to represent the modification and update results of the direction relation of the global variable in the calling process, the local variable on the stack as the parameter and the dynamically distributed stack variable in the called process in the execution process.
Further, in step 4.2, the inter-process side effects are calculated in two cases, namely, a recursive function and a non-recursive function:
A) the calculation of side effects between non-recursive functional processes includes three stages:
the first stage, mapping the context direction relation of the current process call instruction to the process to be called, mapping the direction relation of the global variable, the local variable on the stack as the parameter and the dynamically distributed stack variable;
in the second stage, traversing the process call graph according to the called process name, extracting the directional relation six-tuple stored in the rule conversion library from the called process node, and replacing a formal directional object in the formal directional relation six-tuple in the rule conversion library by an actual directional object in the directional relation mapped by the context to obtain a side effect calculation result among the processes;
reflecting the pointing result in the six-tuple of the pointing relationship obtained after the context mapping of the second stage to the current calling process, modifying and updating the context pointing relationship among the global variable, the local variable on the stack as the parameter and the dynamically allocated heap variable in the current calling process, and obtaining the context pointing relationship after the process calling;
B) the calculation process of the side effect between the recursive function processes is as follows: firstly, obtaining the recursion depth of the current recursion function by using a program parsing technology, and then mapping and reflecting the orientation relation between processes by taking the recursion depth as a boundary until the obtained orientation relation between the processes is converged; and if the convergence does not occur after the recursion is carried out for multiple times, the pointing relation obtained by the last inverse mapping is used as the final context pointing result of the current recursion function.
Further, in step 4, when calculating the side effects among the processes, firstly, whether the related rule transformation library exists in the current called process node in the process call graph is inquired,
if the instruction exists, replacing the pointing relationship in the six-tuple of the pointing relationship stored in the called process in the rule conversion library by the context pointing relationship of the current calling process, collecting the generated inter-process pointing information to obtain the inter-process side effect, further updating the context pointing relationship of the current calling process, and guiding the pointing analysis of other memory operation related instructions after the called instruction;
if the context orientation relation does not exist, the context-related global variables of the current calling process, the on-stack local variables as the parameters and the dynamically-distributed stack variables are transmitted to the called process to be analyzed in the called process, an orientation relation tree is constructed after the orientation analysis of relevant instructions of the memory operation, the orientation relations of all the variables in the process are obtained, finally the orientation relations are formalized and updated into a rule conversion library, the orientation relations of the process-calling-related global variables, the on-stack local variables as the parameters and the dynamically-distributed stack variables are reflected into the current calling process, and the context orientation relations of the current calling process are further updated.
Further, step 5 comprises the following steps:
step 5.1, expanding the directional analysis result and the side effect calculation result between processes to the existing data flow analysis library function of a compiler for guiding the data flow analysis between processes of the memory directional variable;
step 5.2, extracting the fixed value positions and the reference positions of all the memory pointing variables by adopting active variable analysis and arrival fixed value analysis, and constructing a reference fixed value linked list of the memory pointing variables;
step 5.3, searching a fixed value position which is closest to the current reference position in the reference fixed value chain table for the reference position of each memory pointing variable, and calculating the closest fixed value position reached by the memory pointing variable to obtain the real data dependent position of the memory pointing variable; and calculating the data dependence number and the data dependence distance required by the speculative multithreading according to the number of the data dependence positions and the number of the instructions between the fixed value position and the reference position in each data dependence position.
Compared with the prior art, the invention has at least the following beneficial technical effects: the invention constructs a speculative path by using a program parsing technology, collects and calculates the direction relation of the memory operation related instructions in the process and the side effect among the processes, and refines the data dependency relation among the instructions. The concrete aspects are as follows:
firstly, the invention can easily use the storage space organization structure when the program runs, and in step 3.2, different variable types are distinguished by means of the abstract position set, thereby being beneficial to calculating different offsets and step lengths in an array and a structure body, accurately analyzing the pointing relation of a register and a memory access instruction, and obtaining context sensitive, stream sensitive and domain sensitive pointer analysis;
secondly, the data dependence degree between pointer variables in the program can be well quantized by the orientation analysis result in the process in the step 4, so that the correct parallel performance evaluation can be favorably carried out in the thread dividing process, the starting and ending boundaries of each thread can be accurately judged, and the reasonable excitation point position can be determined;
thirdly, the results of the pointing analysis and the calculation of the side effects of the processes in the step 4 can accurately reveal the incidence relation among different instructions, thereby being beneficial to the development of other speculation optimization technologies such as instruction-level scheduling in speculation multithreading and providing possibility for potential instruction-level parallelism and thread-level parallelism in the discovery program; fourthly, after the data flow analysis result in the process of the step 5 is applied to guide the speculation multithreading technology, the more accurate data dependence number and data dependence distance can be obtained, the frequency of violation occurrence of data dependence during running is effectively reduced, and the overall parallel performance of the program is improved.
Drawings
FIG. 1 is an overall phase diagram of assembly-level inter-process pointer analysis based on speculative multithreading;
FIG. 2 is a diagram of mapping and mirrored flow of speculative multithreading based assembly-level inter-process pointer analysis;
FIG. 3 is a schematic diagram of an application framework for assembly-level inter-process pointer analysis based on speculative multithreading;
FIG. 4 is a schematic of the acceleration ratio over the 4 core;
FIG. 5 is a schematic of the acceleration ratio over an 8-core.
Detailed Description
The present invention will now be described in further detail, with the understanding that the present invention is to be considered as illustrative and not restrictive.
The invention provides an assembly-level inter-process pointer analysis method based on speculative multithreading, which comprises the steps of firstly carrying out probability-based path analysis cost evaluation on all execution paths at an assembly level, constructing a candidate speculative path to be analyzed, and then carrying out radical directional analysis on all memory operation instructions on the path with the maximum cost (embodied in the steps 2 and 3 of the claims, compared with the traditional process, only considering the directional relation on the path with the maximum cost at the moment, so that the difference is explained by radical directional analysis), on one hand, carrying out the in-process directional analysis by using an abstract position set and a predicate expression to obtain the accurate directional relation of a context before process calling, on the other hand, carrying out the in-process directional analysis on calling instructions, calculating and collecting the side effect calculation result among processes, and refining the result of the in-process directional analysis, and obtaining the accurate pointing relation of the context after the process is called. Under the action of orientation analysis among processes, the data dependence degree of all nodes in the process call graph is effectively quantized, the data dependence position among instructions is accurately determined, and a foundation is laid for further thread division.
The method comprises the following specific steps:
step one, extracting a process call instruction through traversing an MIPS assembly instruction generated at a compiling rear end, and constructing a process call graph according to the relation between a call process and a called process, wherein nodes in the process call graph represent processes, including the call process and the called process, and the sides represent the call and called relation between the processes.
Step two, analyzing the path of each node in the process call graph, and collecting all execution paths; and constructing a probability-based path analysis cost model to evaluate the cost of all execution paths, and selecting a path with the maximum cost as a candidate speculative path to be added into the working set until the candidate speculative paths of all nodes in the process call graph are added into the working set.
And step three, traversing each node in the process call graph from bottom to top, selecting a speculative path corresponding to the node from the working set, expressing the abstract position and the instruction type of a memory pointing variable on the speculative path by adopting the abstract position set and the predicate, constructing a pointing relation tree to guide the pointing analysis in the process, constructing a process-based rule transformation library by using the pointing analysis result in the process, and storing the rule transformation library in the relevant nodes of the process call graph after formalization.
And fourthly, performing orientation analysis among the processes on each node in the process call graph from top to bottom, and when the orientation analysis reaches a process call instruction, mapping and reflection of the orientation relation of the process to be called by combining the context orientation relation of the current call process and utilizing the formalized orientation analysis result in the rule conversion library, and calculating and collecting side effects among the processes.
And step five, performing data flow analysis among the processes according to the orientation analysis among the processes and the collected calculation results of the side effects among the processes, determining the data dependence position of the memory orientation variable in the context orientation relation among the processes, taking the obtained data dependence position as the input of a speculative multithreading data dependence model, and calculating the data dependence number and data dependence distance required by speculative multithreading.
And sixthly, according to the data dependence number and the data dependence distance result calculated by the speculative multithreading data dependence model, the thread dividing positions are refined, and a plurality of speculative threads are generated.
In the path analysis, the analysis information of the branch and the cycle node in each process is obtained by using a program analysis technology, and the analysis information is used for respectively constructing corresponding path analysis cost models based on probability for the branch node and the cycle node, evaluating the most probable speculative path and storing the most probable speculative path in a working set of candidate speculative paths. The method comprises the following specific steps:
2-1) constructing a control flow diagram of each process by using a compiling end control flow library function, wherein each branch node in the control flow diagram only comprises two successor nodes: taken and Fall branches; each loop node then also includes two successor nodes: an enter loop branch and an exit loop branch.
2-2) when the path is analyzed to branch nodes or loop nodes, firstly calculating the nearest public backward domination node corresponding to the successor node to determine the branch range, then obtaining the execution times of the take branch and the Fall branch in each branch node, the number and loop iteration times of the loop nodes, the number of basic blocks in the branches and the distribution condition of corresponding memory read-write instructions by using a program analyzing technology, and constructing a path analyzing cost model based on probability, wherein the specific steps are as follows:
A) if the current executed node belongs to the branch node, the formula (1) is adopted to determine the speculative Path to be further analyzed, if Path non_loop When the number of the loop instructions is more than or equal to 0, analyzing all loop and non-loop instructions on the Taken branch; otherwise, if Path non_loop If < 0, then all loop and non-loop instructions on the Fall branch are analyzed.
Path non_loop =C taken -(1+ζ)×C fall (1)
B) If the current executed node belongs to the loop node, the formula (2) is adopted to determine the speculative Path to be further analyzed, if Path loop When the number of the loop instructions is more than or equal to 0, analyzing all nested loop instructions and non-nested loop instructions in the loop body; otherwise, if Path loop If the number is less than 0, analyzing all nested loop instructions and non-nested loop instructions which jump out of the loop body to the loop backward domination node.
Figure BDA0001733578270000101
Wherein, Path in the formulas (1) and (2) non_loop Represents the calculation result, Path, of the branch node when selecting the candidate speculative Path with higher cost loop Representing the calculation result when the loop node selects the candidate speculative path with higher cost; zeta is taken as an adjusting coefficient, and the value range of zeta is as follows: [ -1,1]For adjusting the condition of memory read/write instruction access conflict among multiple candidate speculative paths, N in equation (2) iter_taken And N iter_fall Respectively representing the number of iterations of entering the loop body and the number of iterations of jumping out of the loop body, lambda in formula (2) i And λ j And respectively representing dynamic matrixes for simulating and controlling the convergence process of the loop iteration execution, wherein the number of elements in the dynamic matrixes and the value of each element are respectively obtained by the total number of loop iteration times and the ratio of each loop iteration. C in formulas (1) and (2) taken And C fall Obtained by the following formula:
Figure BDA0001733578270000111
Figure BDA0001733578270000112
where prob represents the probability of selecting a Taken branch for execution, N total_loop And N total_non_loop Respectively representing the number of loops on the selected branch path and the number of basic blocks in the non-loop, and R set And W set Representing sets of memory read and write instructions in cycles and non-cycles, respectively.
Figure BDA0001733578270000113
Wherein, F taken And F fall Representing the number of executions of the Taken branch and Fall branch, respectively.
2-3) adding the selected speculative path of each node in the process call graph into a working set according to the evaluation result of the probability-based path analysis cost model for guiding intra-process and inter-process orientation analysis.
In the pointing analysis in the process, firstly, an abstract position set of memory pointing related variables in inter-process pointer analysis is obtained by adopting value set analysis, then, predicates are used for representing instruction types of all instructions on a speculative path, pointing analysis is carried out on memory operation related instructions in process calling, then, a rule transformation library based on the process is constructed by combining pointing analysis results, and the rule transformation library is formalized and stored in corresponding nodes of a process calling graph and used for calculating the side effects among the processes, and the specific steps are as follows:
3-1) searching the speculative path selected by the nodes in the process call graph from the working set according to the evaluation result of the probability-based path parsing cost model from bottom to top to obtain all instruction sets on the speculative path.
And 3-2) adopting a value set analysis method to divide the whole memory domain into a group of abstract position sets, and analyzing the pointing relation between the instructions by using the abstract positions. The types of abstract locations involved in inter-procedural pointer analysis include three types: global variables, local variables on the stack, and dynamically allocated heap variables. The method comprises the following steps:
A) global variables: obtaining the memory offset position stored by the global variable;
B) local variables on the stack: obtaining the corresponding offset position in the active record stack of the current process;
C) dynamically allocated heap variables: and combining the call points of the current dynamic allocation instruction, and obtaining the instruction by adopting a single named object mechanism.
After the abstract position set is adopted, each element in the array and the structure body is easily distinguished through different deviation values in the abstract domain, so that the memory pointing analysis has domain sensitivity accuracy, and the analyzed pointing relationship can be changed according to different calling processes and guessing paths, thereby realizing the context sensitivity and the flow sensitivity accuracy of the memory pointing analysis.
3-3) expressing the instruction types of all instructions on the speculative path by adopting a group of predicates, collecting the pointing relation of the memory operation related instructions in the process call, and mainly comprising the following steps: and the direction relation among the global variable, the local variable on the stack as a parameter and the dynamically allocated heap variable.
Specifically, after the instruction types are represented by the predicates, all the instruction types on the speculative path need to be represented by ten types:
type of instruction Predicate representation
(1)Reg dst =Constant Inst(num,CONST,Reg dst ,const,Constant,none)
(2)Reg dst =Reg src1 bop Reg src2 Inst(num,BINOP,Reg dst ,bop,Reg src1 ,Reg src2 )
(3)Reg dst =uop Reg src Inst(num,UNOP,Reg dst ,uop,Reg src ,none)
(4)Reg dst =Reg src Inst(num,MOVE,Reg dst ,mv,Reg src ,none)
(5)Reg dst =mem[Reg src ] Inst(num,LOAD,Reg dst ,ld,Reg src ,none)
(6)mem[Reg dst ]=Reg src Inst(num,STORE,Reg dst ,st,Reg src ,none)
(7)jmp Label target Inst(num,JMP,Label target ,none,none,none)
(8)ijmp Reg target Inst(num,IJMP,Reg target ,none,none,none)
(9)if Reg src then jmp Reg target1 else Reg target2 Inst(num,CJMP,Reg src ,none,Reg target1 ,Reg target2 )
(10)nop Inst(num,NOP,none,none,none)
The predicate is expressed by an Inst six-tuple, different from a pointing relation six-tuple, the instruction type (1) represents a constant operation instruction, num represents an instruction number in the predicate expression of the instruction type (1) and serves as an unique identifier of the instruction, CONST represents a constant operation type, Reg dst The instruction indicates a target register, const indicates a Constant operation code, Constant indicates a Constant, none indicates an operation item in which the current instruction is missing or does not exist, and a specific operation description is not required. The instruction type (2) represents a binocular arithmetic operation instruction, BINOP represents a binocular arithmetic operation type, bop represents an arithmetic operation opcode, Reg, in predicate representation of the instruction type (2) src1 And Reg src2 Representing a first source operand and a second source operand, respectively. The instruction type (3) represents a monocular operation instruction, in the predicate representation of the instruction type (3), UNOP represents a monocular operation type, uop represents a monocular operation opcode, Reg src Representing the source operand. Instruction type (4) represents a data transfer instruction, and in the predicate representation of instruction type (4), MOVE represents a data transfer operation type and mv represents a data transfer opcode. The instruction type (5) represents a memory read instruction, in the predicate representation of the instruction type (5), the LOAD represents a memory read operation type, and the ld represents a memory read opcode. The instruction type (6) represents a memory write instruction, in the predicate representation of the instruction type (6), STORE represents a memory write operation type, and st represents a memory write operation code. The instruction type (7) represents an unconditional jump instruction, and in the predicate representation of the instruction type (7), JMP represents an unconditional jump operation type, Label target Indicating the destination address of the jump. An instruction type (8) indirect jump instruction, wherein in predicate representation of the instruction type (8), IJMP represents an indirect jump operation type, Reg target And a target register for indicating the indirect jump, wherein the target register stores the address of the indirect jump. The instruction type (9) represents a conditional jump instruction, in the instruction classIn predicate representation of type (9), CJMP represents the conditional jump operation type, Reg target1 And Reg target2 Respectively indicate a target address register when a jump condition is satisfied and a target address register when the jump condition is not satisfied. The instruction type (10) represents a null instruction, in the predicate representation of the instruction type (10), NOP represents a null operation type, and the representation of the rest part in the Inst six-tuple refers to the relevant introduction in other instruction types.
Of the above ten instruction types, the instructions directly related to the memory operation mainly have instruction types (2), (4), (5) and (6), and the in-process direction analysis will focus on the direction relationship analysis of these four instruction types.
3-4) constructing a pointing relation tree to express all possible pointing relations among related instructions of the memory operation in the process call for guiding the pointing analysis in the process; the directional relation tree is a directed tree, each node in the directional relation tree represents memory operation instructions collected in the analysis in the process, and the edges represent the directional and pointed relations among the related instructions and are used for measuring indirect reference relations among different variables.
3-5) constructing a rule conversion library based on the process by utilizing the analysis result of the step 3-4), wherein the rule conversion library comprises nodes related to the orientation relation among the processes in the orientation relation tree, namely: all global variables between the calling process and the called process, local variables on a stack as parameters and the pointing relation of dynamically allocated heap variables; traversing the directional relation tree according to the depth-first order, formalizing the directional relation to be converted by adopting a directional relation hexahedron, wherein the directional relation hexahydric group specifically comprises: the register of the target operand, the indirect pointing degree of the target operand, the offset distance of the target operand, the register of the source operand, the indirect pointing degree of the source operand and the offset distance of the source operand. For the nodes with multiple indirect pointing, only the pointing relation between the root node and the leaf nodes is maintained, and the inter-process pointing information can be conveniently dereferenced. And finally obtaining the six-tuple of the directional relation required by the rule conversion library after traversing one by one.
3-6) storing the directional relation six-tuple after formalization in the rule conversion library into the corresponding node of the process call graph for calculating the side effect among the processes.
After the pointing analysis in the bottom-up process, the pointing relationship six-tuple stored in the called process rule conversion library is easily searched and obtained in the process call graph. In the process of pointing analysis between top-down processes, the pointing relationship in the pointing relationship six-tuple stored in the rule transformation library can be mapped and demapped by combining the context pointing relationship of the calling process, so that the calculation and collection of inter-process side effects are realized, the memory pointing information after the calling instruction is accurate, and the method specifically comprises the following steps:
4-1) when the node in the process call graph belongs to the call process, analyzing the pointing relation of the memory operation and the process call related instruction on the selected speculative path in the call process, performing pointing analysis on a constant operation instruction, a data transmission instruction, an offset position and memory address calculation instruction, a memory read instruction, a memory write instruction, a process call instruction and a branch jump instruction, and guiding the pointing analysis among the processes.
4-2) when the direction is analyzed to a process call instruction, combining the context direction relation between the processes obtained by the analysis of the step 4-1), extracting the direction relation between the global variable related to the process call, the local variable on the stack as the parameter and the dynamically distributed stack variable in the calling process, calculating and collecting the side effect of the call between the processes by using the rule conversion library obtained in the step 3-5), wherein the calculation result of the side effect between the processes adopts six-tuple of direction relation to represent the modification and update results of the direction relation of the global variable in the calling process, the local variable on the stack as the parameter and the dynamically distributed stack variable in the called process in the execution of the called process, namely the influence of the called process on the memory direction relation of the calling process is quantified. The calculation of side effects between processes needs to be divided into two cases, recursive and non-recursive.
A) Non-recursive functions mainly refer to both procedure calls with function names and function pointers. The function pointer can obtain the specific process name pointed by the function pointer when the process call graph is built. For non-recursive functions, the inter-procedural side effects are computed in three stages:
the first stage, the context orientation relation of the current procedure call instruction is mapped to the called procedure, and the orientation relation of the global variable, the local variable on the stack as the parameter and the dynamically distributed heap variable is mainly mapped;
in the second stage, traversing the process call graph according to the called process name, extracting the directional relation six-tuple stored in the rule conversion library from the called process node, and replacing the formal directional object in the formal directional relation six-tuple in the rule conversion library by using the actual directional object in the directional relation mapped by the context to obtain the side effect calculation result between the processes;
and in the third stage, reflecting the pointing result in the six-tuple of the pointing relationship obtained after the context mapping in the second stage to the current calling process, modifying and updating the context pointing relationship among the global variable, the local variable on the stack as the parameter and the dynamically allocated heap variable in the current calling process, and obtaining the context pointing relationship after the process calling. B) The recursive function, like the non-recursive function, also needs to go through two stages, mapping and demapping. The method is characterized in that a recursive function needs to be recurred for multiple times and needs to be executed repeatedly, in order to collect and calculate side effects among processes, a program parsing technology is firstly adopted to analyze the recursion depth of the current recursive function, and then the mapping and reflection of the orientation relation among the processes are carried out by taking the recursion depth as a boundary until the obtained orientation relation among the processes is converged. And if the convergence does not occur after the recursion is carried out for multiple times, the pointing relation obtained by the last inverse mapping is used as the final context pointing result of the current recursion function.
After collecting the side effect calculation results among all the processes for each node in the process call graph, the specific orientation relations among all the instructions can be obtained, the orientation relations indicate the fixed values and the reference relations of all the memory orientation variables among the processes, and a foundation is laid for further data dependence evaluation in subsequent thread division, and the specific steps are as follows:
5-1) expanding the directional analysis result and the side effect calculation result between processes into the existing data flow analysis library function of the compiler for guiding the data flow analysis between processes of the memory directional variable.
And 5-2) extracting the fixed value positions and the reference positions of all the memory pointing variables by adopting active variable analysis and arrival fixed value analysis, and constructing a reference fixed value linked list of the memory pointing variables.
5-3) searching a constant value position which is closest to the current reference position in the reference constant value linked list for the reference position of each memory pointing variable, and calculating the position where the memory pointing variable reaches the constant value most recently to obtain the real data dependent position of the memory pointing variable; and calculating the data dependence number and the data dependence distance required by the speculative multithreading according to the number of the data dependence positions and the number of the instructions between the fixed value position and the reference position in each data dependence position.
The present invention will be described in further detail with reference to the accompanying drawings.
Referring to the overall stage diagram of the assembly-level inter-process pointer analysis based on speculative multithreading shown in fig. 1, the specific implementation steps are as follows:
step one, analyzing and extracting all process call instructions from MIPS instructions generated at a compiling rear end, constructing a process call graph, and generating corresponding nodes and directed edges in the process call graph to represent a call relation between a call process and a called process. For the process call adopting the function pointer, the subsequent pointer is used for pointing to the analysis result, and then the process call graph is updated and perfected.
And step two, constructing a speculative path required by each node in the process call graph, firstly analyzing each process node by using a program analyzing technology to obtain the execution times, the number of loop nodes and the loop iteration times of each branch node, the number of basic blocks in the branch and the distribution condition of corresponding memory read-write instructions, and constructing a path analyzing cost model based on probability according to the analyzing information. And then, performing cost evaluation on all paths by adopting a probability-based path analysis cost model, and selecting one path with the largest cost as a candidate speculative path to be added into the working set until the candidate speculative paths of all processes are added into the working set. Because each process only selects one path with the largest cost as a candidate speculative path, the analysis efficiency is improved.
And step three, traversing each node in the process call graph from bottom to top, and selecting the speculative path of the current process node from the working set to perform direction analysis in the process. In the pointing analysis, an abstract value set is adopted to represent all variables related to memory pointing in inter-process pointer analysis, a group of predicates is utilized to represent all instruction types, in all instruction types, only memory operation instructions are related to pointer pointing, a pointing relation tree is adopted to represent indirect reference relations between variables related to memory pointing, and a rule transformation library required by inter-process pointer analysis is obtained after the pointing relations in the pointing tree are formalized.
Step four, according to a rule conversion library obtained by orientation analysis in the process, performing memory orientation analysis on each node in the process call graph from top to bottom: when a process calling instruction is analyzed, firstly inquiring a rule conversion library, if the rule conversion library of the process to be called exists, mapping and demapping the context pointing relationship in the current calling process by adopting the formalized pointing relationship stored in the rule conversion library to obtain a side effect calculation result among the processes; and if the rule conversion library of the required regulated process does not exist, mapping the context pointing relationship of the current calling process to the regulated process, reconstructing the rule conversion library of the current regulated process, and dynamically updating the rule conversion library. When the adjusted process belongs to the recursion function, the adjusted process needs to be subjected to multiple times of convergence calculation according to the recursion depth so as to obtain a more accurate pointing relationship.
And fifthly, calculating to obtain a directional relation according to directional analysis among processes and side effects among the processes, performing data flow analysis among the processes, determining a fixed value position and a reference position of a memory directional variable corresponding to each pointer variable, namely a data dependence position, by using a related data flow analysis function, and then taking the data dependence position as an input of a speculative multithreading data dependence model for data dependence evaluation to calculate the data dependence number and the data dependence distance required by speculative multithreading.
And sixthly, according to the data dependence number and the data dependence distance result calculated in the speculative multithreading data dependence model, the division positions of the threads are refined, and a plurality of speculative threads are generated.
See fig. 2 for a mapping and reflective-fluid flow diagram of speculative multithreading based assembly-level inter-procedural pointer analysis. In this framework, the entire flow in the inter-process side-effect calculation process is given. Firstly, the direction analysis is carried out on all instructions related to memory operation and process calling in the calling process from top to bottom, and the direction analysis is mainly carried out on the following types of instructions: constant operation instructions, data transfer instructions, offset location and memory address calculation instructions, memory read instructions, memory write instructions, procedure call instructions, and branch jump instructions. And when the direction analysis reaches the procedure call instruction, taking the direction relation obtained by the current direction analysis as the context direction relation at the procedure call point to calculate the side effect among the procedures.
When calculating the side effects among the processes, on one hand, firstly, whether a rule conversion library exists in a current regulated process node is inquired in a process call graph, if so, the context direction relationship at the current process calling point is directly used for mapping and replacing the direction relationship formalized in the rule conversion library, then the replaced direction relationship is reflected to the process calling point, the generated direction relationship among the processes is collected, and the side effects among the processes (the modification and update results of the regulated process on the global variable in the calling process, the local variable on the stack as the parameter and the dynamically distributed stack variable direction relationship in the execution, namely the influence of the regulated process on the direction relationship of the calling process is quantized) are obtained, so that the context information of the current regulated process is updated, and the direction analysis of the subsequent memory instruction is continuously carried out.
On the other hand, if the rule conversion library of the required called process does not exist in the process call graph, the orientation relation of the context-related global variable of the current calling process, the local variable on the stack as the parameter and the dynamically allocated heap variable is directly transmitted to the called process, and the orientation analysis in the process is carried out on the called process; in the analysis process, after the pointing analysis of the relevant instructions of the memory operation, a pointing relation tree is constructed to obtain the pointing relation of the pointing variables of the relevant memory of the process call, finally the pointing relation is formalized and updated into a rule conversion library, the pointing relation of the global variables relevant to the process call, the local variables on the stack as parameters and the dynamically distributed heap variables is reflected to the process call point, the collection and calculation of the side effects among the processes are carried out, and the context pointing relation of the current call process is further updated.
According to the calculation result of the side effect among the processes, referring to an application framework schematic diagram of assembly-level inter-process pointer analysis based on speculation multithreading shown in fig. 3, a specific implementation flow of the inter-process pointer analysis applied to the speculation multithreading framework is given. The specific execution flow is as follows:
firstly, performing relevant compiling analysis and compiling optimization on an input C source program at a compiling front end by adopting an SUIF compiler to obtain an intermediate representation during compiling, performing program parsing on the intermediate representation by using a program parsing tool, and extracting relevant information required by orientation analysis in and among subsequent processes, such as the number of branch nodes, the number of loop nodes and loop iteration times in the program running process, the number of basic blocks in branches and the distribution condition of corresponding memory read-write instructions. And then under the action of a compiling back-end code generator, converting the intermediate representation generated by the compiling end into an MIPS instruction.
Step two, constructing a process call graph of the whole program by using the MIPS instruction generated by the compiling rear end, constructing a probability-based cost analysis model according to the step one, and acquiring a speculative path selected by each node in the process call graph; starting from leaf nodes, conducting in-process pointing analysis on each process in a bottom-up process call graph, obtaining related abstract positions of memory pointing variables in inter-process pointer analysis by adopting an abstract value set according to a storage space organization structure of a runtime obtained at a compiling rear end, then representing all instruction types by using predicates, mainly conducting pointing relation analysis on related instructions of memory after the pointing relation among pointer variables in assembly codes is converted, constructing a corresponding pointing relation tree for storing the pointing relation among the memory pointing variables in the memory operation instructions after the pointing relation is finished, finally formalizing the pointing relation by adopting a pointing relation six-element group to obtain a process-based rule conversion library, conducting in-process pointing analysis on each node in the process call graph according to the method, a rule transformation library for all processes in the input program will be obtained.
Thirdly, on the basis of orientation analysis in the process, utilizing the obtained orientation relation in the rule conversion library to carry out orientation analysis between the processes on the calling process nodes in the process call graph from top to bottom; when the direction is analyzed to a process calling instruction, mapping is needed according to the direction relation of the context where the current process calling instruction is located, in the mapping process, a rule conversion library of the called process needs to be searched and updated continuously, the direction relation formalized in the rule conversion library is replaced by the actual direction relation of the context where the process calling instruction is located, and finally the actual direction relation is reflected to the calling process to obtain the side effect calculation result between the processes, so that the updating of the direction relation of the context of the calling process is realized.
Step four, after side effect calculation results among the processes of each calling process node in the process calling graph are collected, more accurate pointing relationships among memory pointing variables, namely memory pointing relationships among pointer variables, can be obtained; on the basis, inter-process data flow analysis is carried out, constant value positions and reference positions of all memory pointing to related variables are collected by utilizing active variable analysis and arrival constant value analysis, a reference constant value linked list is constructed and used as the input of a speculative multithreading data dependence model to guide further data dependence analysis and evaluation.
And step five, evaluating the data dependence degree between the candidate threads by adopting a data dependence model, wherein the data dependence degree mainly comprises two aspects of data dependence number and data dependence distance, the data dependence number mainly calculates the fixed values of all variables between the candidate threads and the number of the reference relation point pairs, the data dependence distance calculates the mutual distance between the variables with the reference relation, and the data dependence number and the data dependence distance can be obtained by calculating the nearest arrival fixed value point by using a reference fixed value linked list constructed by data flow analysis in the four processes.
And step six, analyzing the data dependence degree of the candidate parallel domain by using the data dependence number and the data dependence distance obtained by the data dependence model, feeding back the analysis result to a thread division algorithm, finding proper thread starting and ending positions after multiple division analysis, determining corresponding excitation positions, generating the required candidate threads, and according to the method, until the whole program is divided and ended.
An assembly-level inter-process pointer analysis method based on speculative multithreading mainly collects accurate reference relations among variables through assembly-level inter-process pointer analysis, and achieves the purpose of improving data stream analysis accuracy in thread division. Before inter-process analysis, process call graphs of all processes in a source program need to be constructed, and pointer pointing analysis is carried out in two stages after construction. In the first stage, a probability-based path analysis cost model is firstly constructed, the guess paths selected by all process nodes in the process call graph are extracted, and the path working set to be analyzed is refined. And traversing each node in the process call graph in a bottom-up order, searching the selected path from the working set, extracting the directional relation between the related instructions of the memory by means of abstract value set and predicate expression, constructing a process-based rule transformation library by using the obtained directional relation, and storing the process-based rule transformation library in the related nodes of the process call graph after formalization. And in the second stage, the pointing analysis among the processes and the calculation of the side effect among the processes are carried out by adopting a top-down sequence, at each process calling point, the context pointing relationship of the current calling process is firstly established, then the pointing relationship related to the process calling is mapped into a rule conversion library of the called process, in the mapping process, the rule conversion library of the called process needs to be continuously searched and updated, the formalized pointing relationship in the rule conversion library is replaced by the actual pointing relationship of the context of the process calling instruction, and finally the actual pointing relationship is reflected into the calling process to obtain the calculation result of the side effect among the processes, so that the updating of the context pointing relationship of the calling process is realized. On the basis, inter-process data flow analysis is carried out, the data dependence degree of memory pointing variables in pointer analysis is evaluated, and more accurate thread division results are obtained.
The invention adopts the pointing analysis among the processes to collect the pointing relation of the pointer variable in the memory and the side effect calculation result, thereby the data dependency relation among the threads is accurate and the accuracy of the thread division result is improved. The method mainly relies on a probability-based path analysis cost model, identifies and calculates a speculative path selected by each process, adopts abstract value sets and predicate expressions on the speculative paths to perform in-process pointing analysis on memory operation related instructions to obtain a process-based rule conversion library, stores the rule conversion library in corresponding nodes of a process call graph after formalization, is used for calculating and collecting side effects among the processes, performs data flow analysis among the processes by using a pointing relation obtained by the in-process pointing analysis to obtain a specific fixed value position and a reference position of each pointer variable in the memory pointing relation, and finally guides subsequent thread division work by combining an evaluation result of a data dependence model.
The method fully considers the characteristics of the speculation frame, adopts the path analysis cost model based on the probability to always select the path with the maximum cost for direction analysis, can effectively reduce unnecessary direction relations, and realizes the radical speculation parallelism of threads.
The specific contents described above with reference to the drawings are only illustrative and not intended to limit the scope of the present invention, and various modifications or variations made by those skilled in the art without inventive efforts based on the assembly-level inter-process pointer analysis method based on speculative multithreading provided by the present invention are still within the scope of the present invention.

Claims (10)

1. An assembly-level inter-process pointer analysis method based on speculative multithreading is characterized by comprising the following steps of:
step 1, extracting a process call instruction through traversal of an MIPS assembly instruction generated at a compiling rear end, and constructing a process call graph according to a relation between a call process and a called process, wherein nodes in the process call graph represent processes, the processes comprise the call process and the called process, and the call and called relation between the processes is represented at the same time;
step 2, analyzing the path of each node in the process call graph, and collecting all execution paths; constructing a probability-based path analysis cost model, carrying out cost evaluation on all execution paths, and selecting a path with the maximum cost as a candidate speculative path to be added into a working set until the candidate speculative paths of all nodes in the process call graph are added into the working set;
step 3, traversing each node in the process call graph from bottom to top, selecting a speculative path corresponding to the node from the working set, expressing the abstract position and the instruction type of a memory pointing variable on the speculative path by adopting the abstract position set and the predicate, constructing a pointing relation tree to guide the pointing analysis in the process, constructing a rule transformation library based on the process by using the pointing analysis result in the process, and storing the rule transformation library in the relevant nodes of the process call graph after formalization;
step 4, carrying out orientation analysis among the processes on each node in the process call graph from top to bottom, and when the orientation analysis reaches a process call instruction, mapping and reflection of the orientation relation of the process to be called by combining the context orientation relation of the current calling process and utilizing the formalized orientation analysis result in the rule conversion library, and calculating and collecting side effects among the processes;
step 5, performing data flow analysis among the processes according to the orientation analysis among the processes and the collected calculation results of the side effects among the processes, determining the data dependence position of the memory orientation variable in the context orientation relation among the processes, taking the obtained data dependence position as the input of a speculative multithreading data dependence model, and calculating the data dependence number and data dependence distance required by speculative multithreading;
and 6, according to the data dependence number and the data dependence distance result calculated by the speculative multithreading data dependence model, the division positions of the threads are refined, and a plurality of speculative threads are generated.
2. The method of claim 1, wherein the probability-based path parsing cost model in step 2 is obtained by:
step 2.1, constructing a control flow diagram of each process, wherein each branch node in the control flow diagram only comprises two successor nodes: taken and Fall branches; each loop node then also includes two successor nodes: enter loop branch and exit loop branch;
step 2.2, when the path is analyzed to a branch node or a loop node, firstly calculating a nearest public backward domination node corresponding to a successor node to determine a branch range, then obtaining the execution times of a take branch and a Fall branch in each branch node, the number and loop iteration times of the loop node, the number of basic blocks in the branch and the distribution condition of corresponding memory read-write instructions by using a program analysis technology, and constructing a path analysis cost model based on probability, wherein the specific steps are as follows:
A) if the node executed currently belongs to the branch node, the formula Path is adopted non_loop =C taken -(1+ζ)×C fall Determining the speculative Path to be further analyzed if Path non_loop More than or equal to 0, analyzing all loop and non-loop instructions on the Taken branch; if Path non_loop If less than 0, all loop and non-loop instructions on the Fall branch are analyzed;
B) if the currently executed node belongs to the cyclic node, the method adopts
Figure FDA0001733578260000021
To determine the speculative Path to be further analyzed if Path loop More than or equal to 0, analyzing all nested loop instructions and non-nested loop instructions in the loop body; if Path loop If < 0, analyzing all nested loop instructions and non-nested loop instructions which jump out of the loop body to the loop back-dominance node,
wherein, Path non_loop Representing the calculation result when the branch node selects the candidate speculative path with larger cost,Path loop representing the calculation result when the loop node selects the candidate speculative path with higher cost; zeta is the coefficient of regulation, N iter_taken And N iter_fall Respectively representing the number of iterations into and out of the loop body, lambda i And λ j Respectively representing dynamic matrixes for simulating and controlling the convergence process of the loop iteration execution, wherein the number of elements in the dynamic matrixes and the value of each element are respectively obtained by the total number of loop iteration times and the ratio of each loop iteration; c taken And C fall Respectively representing the cost calculation results of a single Taken branch and a Fall branch, wherein the cost calculation results are calculated by the following formulas:
Figure FDA0001733578260000022
Figure FDA0001733578260000031
where prob represents the probability of selecting a Taken branch for execution, N total_loop And N total_non_loop Respectively representing the number of loops on the selected branch path and the number of basic blocks in the non-loop, and R set And W set Representing sets of memory read and write instructions in cycles and non-cycles, respectively.
3. The assembly-level inter-process pointer analysis method based on speculative multithreading as claimed in claim 2, wherein in step 2, the value range of the adjustment coefficient ζ is: [ -1,1].
4. The method of claim 2, wherein, in step 2,
Figure FDA0001733578260000032
wherein, F taken And F fall Each represents TaThe number of executions of the ken branch and the Fall branch.
5. The method for analyzing the inter-procedural pointer at the assembly level based on speculative multithreading as recited in claim 1, wherein the specific steps of step 3 are as follows:
step 3.1, searching a speculative path selected by a node in a calling graph in the process from the bottom to the top in the working set according to an evaluation result of a probability-based path parsing cost model to obtain all instruction sets on the speculative path;
step 3.2, a value set analysis method is adopted to divide the whole memory domain into a group of abstract position sets, and abstract position sets of inter-process pointer variable memory pointing analysis related global variables, stack local variables and dynamically distributed heap variables, namely abstract position sets of memory pointing variables, are extracted from all instruction sets on a speculative path;
3.3, expressing the instruction types of all instructions on the speculative path by adopting a group of predicates, and collecting the pointing relations of the instructions related to the memory operation in the process call, namely the pointing relations of a global variable in the instructions, a local variable on a stack as a parameter and a dynamically distributed heap variable;
step 3.4, constructing a pointing relation tree to represent all possible pointing relations among the relevant instructions of the memory operation in the process call for guiding the pointing analysis in the process; the directional relation tree is a directional tree, and each node in the directional relation tree represents the memory operation instruction collected by the analysis in the process; the edges represent the pointing and pointed relations among the related instructions and are used for measuring indirect reference relations among different variables;
3.5, constructing a process-based rule conversion library by using the analysis result of the step 3.4, wherein the rule conversion library comprises nodes related to the orientation relation between the processes in the orientation relation tree, namely the orientation relation between all global variables between the calling process and the called process, local variables on the stack as parameters and dynamically distributed heap variables; traversing the directional relation tree according to the depth-first order, and formalizing the directional relation to be converted by adopting a directional relation hexahedron; after traversing one by one, obtaining a six-tuple of the directional relation required by the rule conversion library;
and 3.6, storing the formal pointing relationship six-tuple in the rule conversion library into a corresponding node of the process call graph.
6. The assembly-level inter-process pointer analysis method based on speculative multithreading as recited in claim 5, wherein in step 3.2, the abstract position of the global variable is obtained from a memory offset position stored in the global variable; the abstract position of the local variable on the stack is obtained from the corresponding offset position in the activity record stack of the current process; the abstract position of the dynamically allocated heap variable needs to be obtained by adopting a single named object mechanism by combining with the call point of the current dynamically allocated instruction.
7. The method for analyzing the assembly-level inter-process pointer based on the speculative multithreading as claimed in claim 1, wherein the specific process of step 4 is:
step 4.1, when the node in the process call graph belongs to a call process, analyzing the pointing relation of the memory operation and the process call related instruction on the selected speculative path in the call process, performing pointing analysis on a constant operation instruction, a data transmission instruction, an offset position and memory address calculation instruction, a memory read instruction, a memory write instruction, a process call instruction and a branch jump instruction, and guiding the pointing analysis among the processes;
and 4.2, when the direction is analyzed to a process call instruction, extracting the direction relation of the global variable related to the process call, the local variable on the stack serving as the parameter and the dynamically distributed stack variable in the call process by combining the context direction relation among the processes obtained by the analysis in the step 4.1, calculating and collecting the side effect of the call among the processes by using the rule conversion library obtained in the step 3, wherein the calculation result of the side effect among the processes adopts six-tuple of direction relation to represent the modification and update results of the direction relation among the global variable, the local variable on the stack serving as the parameter and the dynamically distributed stack variable in the call process in the execution of the called process.
8. The method of claim 7, wherein in step 4.2, the computation of inter-procedural side effects is divided into two cases, recursive and non-recursive:
A) the calculation of side effects between non-recursive functional processes includes three stages:
the first stage, the context orientation relation of the current procedure call instruction is mapped to the called procedure, and the orientation relation of the global variable, the local variable on the stack as the parameter and the dynamically distributed heap variable is mapped;
in the second stage, traversing the process call graph according to the called process name, extracting the directional relation six-tuple stored in the rule conversion library from the called process node, and replacing the formal directional object in the formal directional relation six-tuple in the rule conversion library by using the actual directional object in the directional relation mapped by the context to obtain the side effect calculation result between the processes;
reflecting the pointing result in the six-tuple of the pointing relationship obtained after the context mapping of the second stage to the current calling process, modifying and updating the context pointing relationship among the global variable, the local variable on the stack as the parameter and the dynamically allocated heap variable in the current calling process, and obtaining the context pointing relationship after the process calling;
B) the calculation process of the side effect between the recursive function processes is as follows: firstly, obtaining the recursion depth of the current recursion function by using a program parsing technology, and then mapping and reflecting the orientation relation between processes by taking the recursion depth as a boundary until the obtained orientation relation between the processes is converged; and if the convergence does not occur after the recursion is carried out for multiple times, the pointing relation obtained by the last inverse mapping is used as the final context pointing result of the current recursion function.
9. The assembly-level interprocess pointer analysis method based on speculative multithreading as claimed in claim 1, wherein in step 4, when calculating interprocess side effects, it is first queried whether there is a related rule transformation library in the currently called process node in the process call graph,
if the instruction exists, replacing the pointing relationship in the six-tuple of the pointing relationship stored in the called process in the rule conversion library by the context pointing relationship of the current calling process, collecting the generated inter-process pointing information to obtain the inter-process side effect, further updating the context pointing relationship of the current calling process, and guiding the pointing analysis of other memory operation related instructions after the called instruction;
if the context orientation relation does not exist, the context-related global variables of the current calling process, the on-stack local variables as the parameters and the dynamically-distributed stack variables are transmitted to the called process to be analyzed in the called process, an orientation relation tree is constructed after the orientation analysis of relevant instructions of the memory operation, the orientation relations of all the variables in the process are obtained, finally the orientation relations are formalized and updated into a rule conversion library, the orientation relations of the process-calling-related global variables, the on-stack local variables as the parameters and the dynamically-distributed stack variables are reflected into the current calling process, and the context orientation relations of the current calling process are further updated.
10. The method of claim 1, wherein step 5 comprises the steps of:
step 5.1, expanding the directional analysis result and the side effect calculation result between processes to the existing data flow analysis library function of a compiler for guiding the data flow analysis between processes of the memory directional variable;
step 5.2, extracting the fixed value positions and the reference positions of all the memory pointing variables by adopting active variable analysis and arrival fixed value analysis, and constructing a reference fixed value linked list of the memory pointing variables;
step 5.3, searching a fixed value position which is closest to the current reference position in the reference fixed value chain table for the reference position of each memory pointing variable, and calculating the closest fixed value position reached by the memory pointing variable to obtain the real data dependent position of the memory pointing variable; and calculating the data dependence number and the data dependence distance required by the speculative multithreading according to the number of the data dependence positions and the number of the instructions between the fixed value position and the reference position in each data dependence position.
CN201810785251.3A 2018-07-17 2018-07-17 Assembly-level inter-process pointer analysis method based on speculative multithreading Active CN108932137B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810785251.3A CN108932137B (en) 2018-07-17 2018-07-17 Assembly-level inter-process pointer analysis method based on speculative multithreading

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810785251.3A CN108932137B (en) 2018-07-17 2018-07-17 Assembly-level inter-process pointer analysis method based on speculative multithreading

Publications (2)

Publication Number Publication Date
CN108932137A CN108932137A (en) 2018-12-04
CN108932137B true CN108932137B (en) 2022-09-27

Family

ID=64447847

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810785251.3A Active CN108932137B (en) 2018-07-17 2018-07-17 Assembly-level inter-process pointer analysis method based on speculative multithreading

Country Status (1)

Country Link
CN (1) CN108932137B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109828788A (en) * 2018-12-21 2019-05-31 天翼电子商务有限公司 The regulation engine accelerated method executed and system are speculated based on thread-level
CN110442076A (en) * 2019-07-03 2019-11-12 苏州保控电子科技有限公司 The method of PLC technology based on ST language pointer variable
CN110633212B (en) * 2019-09-04 2022-07-26 中国石油大学(华东) Data flow analysis method based on abstract memory model
CN114254068B (en) * 2022-02-28 2022-08-09 杭州未名信科科技有限公司 Data transfer method and system

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050144602A1 (en) * 2003-12-12 2005-06-30 Tin-Fook Ngai Methods and apparatus to compile programs to use speculative parallel threads
CN101833476B (en) * 2010-05-28 2013-08-14 西安交通大学 Independent stack function calling method based on CMP speculation multi-thread mechanism
US8892946B2 (en) * 2011-12-15 2014-11-18 International Business Machines Corporation Verifying speculative multithreading in an application
CN105260165B (en) * 2015-10-10 2018-01-05 西安交通大学 The dynamic control method of speculative threads number in thread-level hypothetical system based on SMT

Also Published As

Publication number Publication date
CN108932137A (en) 2018-12-04

Similar Documents

Publication Publication Date Title
CN108932137B (en) Assembly-level inter-process pointer analysis method based on speculative multithreading
Du et al. A cost-driven compilation framework for speculative parallelization of sequential programs
US6381739B1 (en) Method and apparatus for hierarchical restructuring of computer code
US6064819A (en) Control flow and memory management optimization
US5889999A (en) Method and apparatus for sequencing computer instruction execution in a data processing system
US9798528B2 (en) Software solution for cooperative memory-side and processor-side data prefetching
EP3465428B1 (en) Sample driven profile guided optimization with precise correlation
Cascaval et al. Compile-time based performance prediction
US6412105B1 (en) Computer method and apparatus for compilation of multi-way decisions
Hall et al. Interprocedural transformations for parallel code generation
Steiner et al. Value learning for throughput optimization of deep learning workloads
Ghiya et al. Detecting parallelism in C programs with recursive data structures
Ball et al. Using paths to measure, explain, and enhance program behavior
US6415433B1 (en) Method and system for identifying locations to move portions of the computer program
Meng et al. Mira: A framework for static performance analysis
Sharygin et al. Runtime specialization of PostgreSQL query executor
Novillo Samplepgo-the power of profile guided optimizations without the usability burden
Prokesch et al. A generator for time-predictable code
CN105260222B (en) Start spacing optimization method between cycle flowing water iteration in a kind of reconfigurable compiling device
Sukumaran-Rajam et al. Speculative program parallelization with scalable and decentralized runtime verification
KR101503620B1 (en) Intelligent architecture creator
CN112130848B (en) Band-width sensing circulation block optimization method, compiling system, equipment and storage medium for scratch-pad memory
Shobaki et al. Optimal superblock scheduling using enumeration
Rodrigues et al. Real-world loops are easy to predict: a case study
Fauster et al. Intelligent editor for writing worst-case-execution-time-oriented programs

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant