Constraint solving method based on parallel multi-core, electronic device and medium
By using a parallel multi-core method to execute candidate solver cores in parallel and selecting the core that obtains the earliest result as the optimal core, the problem of inappropriate solver core selection in existing technologies is solved, achieving more efficient constraint problem solving and stronger robustness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2026-03-31
AI Technical Summary
In existing technologies, the selection of the solver core for constraint problems is usually random or coarse, resulting in poor overall solution performance and failing to guarantee the selection of the optimal solver core.
A parallel multi-core approach is adopted, which obtains a set of candidate solver cores through the main thread, executes the target constraint problem in parallel, selects the core that obtains the solution result earliest as the current optimal core, and performs collaborative solving in conjunction with a shared inference constraint library.
It improves the overall solution performance of constrained problems, enhances the robustness and generalization ability of the solver, simplifies the selection process of the optimal core, and improves the solution efficiency.
Smart Images

Figure CN120066728B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a constraint solving method, electronic device, and medium based on parallel multi-core processing. Background Technology
[0002] Constraint problem solving techniques have wide applications in hardware verification, software automated testing, and a range of common programming problems. Many problems can be transformed into constraint problems and solved using constraint solvers. There are various types of solver cores used for constraint problem solving, and a single constraint solver can contain different types of solver cores. Different types of constraint solver cores typically excel at solving very different types of problems, and the same type of solver core may exhibit different performance on different constraint problems. Therefore, for the same constraint problem, the solution speed will vary significantly depending on the solver core used.
[0003] Selecting an optimal solver core before attempting to solve a constraint problem is an extremely complex issue. Current technologies typically involve randomly or coarsely selecting a solver core, which cannot guarantee the selection of the optimal core and results in poor overall performance in solving constraint problems. Therefore, determining how to select the optimal solver core for constraint problems and improve their overall performance is a pressing technical problem that needs to be solved. Summary of the Invention
[0004] The purpose of this invention is to provide a constraint solving method, electronic device, and medium based on parallel multi-core, which improves the overall solution performance of constraint problems and enhances the robustness and generalization ability of the constraint solver.
[0005] According to a first aspect of the present invention, a constraint solving method based on parallel multi-core is provided, comprising:
[0006] Step S1: The main thread obtains the core set of candidate solvers for the objective constraint problem {C1, C2, ..., C...}. m ,...,C M}, C m The m-th candidate solver core is the constraint problem to be solved, where m ranges from 1 to M, and M is the total number of candidate solver cores for the target constraint problem.
[0007] Step S2: If M equals 1, then C1 is determined as the current optimal C. m The main thread calls the optimal C m To solve the objective constraint problem, proceed to step S6. If M > 1, then proceed to step S3.
[0008] Step S3: The main thread obtains M child threads {W1, W2, ..., W...} from the thread pool. m,...,W M}, and establish a one-to-one correspondence between each sub-thread and the candidate solver core, W m For the m-th child thread, W m With C m Correspondingly;
[0009] Step S4: The main thread copies the target constraint problem M times and sends them to each W. m ;
[0010] Step S5, each W m Parallel execution of the objective constraint problem will result in the earliest C being able to obtain the solution. m Determined as the current optimal C m ;
[0011] Step S6: The main thread returns the current optimal C. m The solution results are as follows.
[0012] According to a second aspect of the present invention, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the method described in the first aspect of the present invention.
[0013] According to a third aspect of the present invention, a computer-readable storage medium is provided, storing computer-executable instructions for performing the method described in the first aspect of the present invention.
[0014] Compared with existing technologies, this invention has significant advantages and beneficial effects. Through the above technical solution, the constraint solving method, electronic device, and medium based on parallel multi-core provided by this invention achieve considerable technological advancement and practicality, and have broad industrial application value. It has at least the following beneficial effects:
[0015] In the presence of multiple candidate solver cores, this invention solves the same objective constraint problem in parallel based on multiple candidate solver cores, obtains the current optimal candidate solver core to execute the objective constraint problem, improves the overall solution performance of the constraint problem, and enhances the robustness and generalization ability of the constraint solver. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 The flowchart illustrates the constraint solving method based on parallel multi-core provided in this embodiment of the invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] This invention provides a constraint solving method based on parallel multi-core architecture, such as... Figure 1 As shown, it includes:
[0020] Step S1: The main thread obtains the core set of candidate solvers for the objective constraint problem {C1, C2, ..., C...}. m ,...,C M}, C m is the m-th candidate solver core of the constraint problem to be solved, where m ranges from 1 to M, and M is the total number of candidate solver cores of the target constraint problem.
[0021] Among them, different C m The solver core types may be the same or different. The solver core types include SAT (Booleansatisfiability problem) solver, SMT (Satisfiability modulo theories) solver, CSP (Constraint satisfaction problem) solver, and BDD (Binary decision diagram) solver.
[0022] Step S2: If M equals 1, then C1 is determined as the current optimal C. m The main thread calls the optimal C m To solve the objective constraint problem, proceed to step S6. If M > 1, then proceed to step S3.
[0023] It should be noted that if M equals 1, the optimal solver core is directly determined, and the main thread directly calls the optimal C. m Solve the objective constraint problem.
[0024] Step S3: The main thread obtains M child threads {W1, W2, ..., W...} from the thread pool. m ,...,W M}, and establish a one-to-one correspondence between each sub-thread and the candidate solver core, W mFor the m-th child thread, W m With C m Correspondingly.
[0025] Step S4: The main thread copies the target constraint problem M times and sends them to each W. m .
[0026] Step S5, each W m Parallel execution of the objective constraint problem will result in the earliest C being able to obtain the solution. m Determined as the current optimal C m .
[0027] Step S6: The main thread returns the current optimal C. m The solution results are as follows.
[0028] Specifically, the main thread will use the current optimal C m The solution results are returned to the simulator, which can be a simulator that performs chip verification.
[0029] This invention combines different types of solver cores, enabling them to solve the same objective constraint problem in parallel. This simplifies the selection of which solver core to use, ensuring that the most suitable core is always chosen. It reduces the performance loss caused by incorrect solver core selection. Furthermore, the method described in this invention has strong generalization ability; it can easily and quickly find a suitable solver core for any type of constraint problem, thus improving overall solution efficiency.
[0030] As one embodiment, step S1 includes:
[0031] Step S11: The main thread extracts feature information from the target constraint problem. The feature information includes the number of variables, the number of variable bits, the number of expressions, and the expression type.
[0032] The objective constraint problem consists of variables, constants, and expressions. Variables are signed or unsigned bit vectors with a fixed bit width. Expressions consist of operands and operators. Operands can be constants or variables, and operators can be categorized into six types: logical operators, bitwise operators, arithmetic operators, relational operators, if-then-else operators, and set relational operators. Logical operators include &&, ||, and !. Bitwise operators include &, |, ^, ~, etc. Arithmetic operators include +, -, *, / , and %. Relational operators include >, <, >=, <=, ==, !, and =. Set relational operators include inside and dist.
[0033] Step S12: Determine the solver cores that can match the feature information corresponding to the target constraint problem and are not marked with the target constraint problem disable flag as candidate solver cores, and generate a set of candidate solver cores.
[0034] It should be noted that solver cores marked with the "disabled for target constraint problems" label refer to solver cores that are not applicable to target constraint problems. Specifically, they can be solver cores whose target constraint problem solution time exceeds a preset waiting time threshold.
[0035] As one embodiment, step S5 includes:
[0036] Step S51, each W m For the objective-constrained problem, a targeted approach is taken for C. m Preprocessing modeling adaptation to generate C m The corresponding intermediate state constraint problem P m .
[0037] Preprocessing modeling adaptation is a process of adjusting and optimizing the original constraint model based on the characteristics of the specific problem, its environment, and specific requirements before formally applying the solution algorithm to find solutions that satisfy the constraints. Intermediate constraint problems are transitional problem forms after preprocessing modeling adaptation during the process of solving the original constraint problem. Step S51 can be directly implemented based on the existing preprocessing modeling adaptation process and will not be elaborated further here.
[0038] Step S52, Start each C m Combined with the shared inference constraint library, for the corresponding P m The solution is performed, and the shared inference constraint library is initially empty.
[0039] Step S53, if C m Generate inference constraints, then C m The corresponding inference constraints are returned to the main thread, and the main thread will then return C. m The corresponding inference constraints are stored in the shared inference constraint library.
[0040] Among them, inference constraints refer to additional constraint information derived through inference mechanisms based on existing constraints of the target problem, relevant knowledge of the problem domain, and logical rules. This information helps to further limit the solution space of the problem and helps to find feasible solutions that satisfy all constraints more efficiently and accurately. By setting up a shared inference constraint library, each C... m Interact with the shared inference constraint library to collaboratively solve the corresponding P m This can accelerate the solution process.
[0041] Step S54: The earliest C to obtain the solution result m Determined as the current optimal C m .
[0042] During chip verification, the same constraint problem may be solved multiple times. To further improve the efficiency of solving the same target constraint problem subsequently, this invention provides the following three embodiments for subsequent processing:
[0043] Example 1
[0044] Step S6 is followed by:
[0045] Step S7: The main thread will select the current optimal C m This is labeled as the core of the optimal solver for the objective-constrained problem, and distributed to all W... m End of broadcast signal.
[0046] Step S8, all W m End the problem-solving process for the objective constraint and release the memory resources it occupies.
[0047] It should be noted that steps S7-S8 are used so that the optimal solver core can be directly called in the main thread to solve the target constraint problem in the subsequent process, thereby improving the solution speed.
[0048] Following step S8, the following is also included:
[0049] Step S9: Obtain the target constraint problem again, and directly call the solver core of the optimal solver core marked with the target constraint problem to solve the target constraint problem.
[0050] It should be noted that by directly calling the solver core of the optimal solver core marked with the objective constraint problem in step S9, the solution speed of the objective constraint problem is improved.
[0051] Example 2
[0052] Step S6 is followed by:
[0053] Step C7: Divide the current optimal C m C other than m The corresponding W m Continue running in the background.
[0054] Step C8: The solution results returned within the preset waiting time threshold will be cached sequentially in the solution result cache queue corresponding to the target constraint problem. The initial state of the solution result cache queue corresponding to the target constraint problem is empty.
[0055] Step C9: If no solution result is returned after the preset waiting time threshold has been exceeded... mThe target constraint issue is marked as disabled.
[0056] It should be noted that by marking the target constraint problem with a disabled flag in step C9, the speed and accuracy of obtaining the candidate solver core set when step S1 is executed again can be improved.
[0057] Following step C9, the following also includes:
[0058] Step C10: Obtain the target constraint problem again. If the solution result cache queue corresponding to the target constraint problem is not empty, then execute step C20. If it is empty, then return to execute step S1.
[0059] Step C20: The main thread takes the earliest solution result stored in the solution result cache queue corresponding to the current target constraint problem as the target constraint problem, obtains the solution result, and returns it, and deletes the earliest solution result stored in the solution result cache queue corresponding to the current target constraint problem.
[0060] It should be noted that by using steps C10-C20, the solution results in the solution result cache queue can be directly used, skipping the solution process of the solver core, thus improving the overall solution efficiency.
[0061] Example 3
[0062] Step S6 is followed by:
[0063] Step E7: If the current memory capacity is less than the preset memory threshold, proceed to step E8; otherwise, proceed to step E9.
[0064] Step E8: The main thread will select the current optimal C m This is labeled as the core of the optimal solver for the objective-constrained problem, and distributed to all W... m The broadcast ends with a signal from all Ws. m The process of solving the objective constraint problem ends, and the occupied memory resources are released, thus terminating the process.
[0065] Step E9: Divide the current optimal C m C other than m The corresponding W m Continuing to run in the background, the solution results returned within the preset waiting time threshold will be cached sequentially in the solution result cache queue corresponding to the target constraint problem. If no solution result is returned after the preset waiting time threshold has elapsed, the solution will be cached in the background. m The target constraint problem is marked with a disabled flag, and the cache queue of the solution result corresponding to the target constraint problem is initially empty.
[0066] Steps E7-E9 determine the optimal C based on the current memory capacity. m C other thanm The corresponding W m Regarding subsequent execution, if there is sufficient memory, the solution result cache queue will be retrieved first; if there is insufficient memory, the current optimal C value will be retrieved first. m This is labeled as the core of the optimal solver for the objective-constrained problem.
[0067] The process following step E8 or step E9 also includes:
[0068] Step E10: Obtain the target constraint problem again. If the solution result cache queue corresponding to the target constraint problem is not empty, proceed to step E20. If it is empty, proceed to step E30.
[0069] Step E20: The main thread takes the earliest solution result stored in the solution result cache queue corresponding to the current target constraint problem as the target constraint problem, obtains the solution result, and returns it, and deletes the earliest solution result stored in the solution result cache queue corresponding to the current target constraint problem.
[0070] Step E30: Determine whether there is a solver core labeled with the optimal solver core of the objective constraint problem. If there is, proceed to step E40; otherwise, return to step S1.
[0071] Step E40: The main thread determines the solver core labeled with the optimal solver core of the objective constraint problem as the current optimal C. m Call the optimal C m Solve the objective-constrained problem and return the current optimal value C. m The solution results are as follows.
[0072] It should be noted that, through steps E10-E40, when a solution result cache queue exists, a solution for the target constraint problem can be selected first from the solution result cache queue, skipping the solution step. When the solution result cache queue is empty, the solver core of the optimal solver core is selected for solution. When the solution result cache queue is empty and there is no optimal solver core, the solution process is executed through steps S1-S6.
[0073] It should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of these steps can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the steps can be rearranged. A process can be terminated when its operation is complete, but it may also have additional steps not included in the figures. A process can correspond to a method, function, procedure, subroutine, subroutine, etc.
[0074] This invention also provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the method described in this invention.
[0075] This invention also provides a computer-readable storage medium storing computer-executable instructions for performing the methods described in this invention.
[0076] In the case of multiple candidate solver cores, the present invention solves the same objective constraint problem in parallel based on multiple candidate solver cores, obtains the current optimal candidate solver core to execute the objective constraint problem, improves the overall solution performance of the constraint problem, and enhances the robustness and generalization ability of the constraint solver.
[0077] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A constraint solving method based on parallel multi-core, characterized in that, Comprising: Step S1, the main thread acquires a candidate solver core set {C1, C2,..., C m ,...,C M} of the target constraint problem, C m is the mth candidate solver core of the constraint problem to be solved, m ranges from 1 to M, and M is the total number of candidate solver cores of the target constraint problem; Step S2, if M is equal to 1, then C1 is determined as the current optimal C m , the main thread calls the optimal C m solving the objective constraint problem, performing step S6, if M>1, then performing step S3; Step S3: The main thread obtains M child threads {W1, W2, ..., W...} from the thread pool. m ,...,W M }, and establish a one-to-one correspondence between each sub-thread and the candidate solver core, W m For the m-th child thread, W m With C m Correspondingly; Step S4, the main thread copies M copies of the target constraint problem and sends each copy to each W m ; Step S5, each W m The target constraint problem is executed in parallel, and the C m determined as the current optimal C m ; Step S6, the main thread returns the current optimal C m solution result; The step S6 further comprises: Step E7, if the current memory capacity is less than the preset memory threshold, then execute step E8, otherwise, execute step E9; Step E8, the main thread will the current optimal C m annotates the optimal solver core of the target constraint problem, and sends it to all W m broadcasts the end signal, and all W m ends the target constraint problem solving process, and releases the occupied memory resources, and ends the process; Step E9, except for the current optimal C m C m Corresponding W m Continuing to run in the background, the solution results returned within the preset waiting time threshold are cached in the solution result cache queue corresponding to the target constraint problem in order, and the C m The superscript indicates the target constraint problem disable identifier, and the initial state of the solution result cache queue corresponding to the target constraint problem is empty.
2. The method of claim 1, wherein, The step S6 further comprises: Step S7, the main thread will the current optimal C m annotated as optimal solver core of the goal constraint problem, and to all W m broadcast end signal; Step S8, all W m End the solution process of the goal constraint problem and release the occupied memory resources.
3. The method of claim 2, wherein, The step S8 further comprises: Step S9, again obtain the target constraint problem, directly call the solver core of the optimal solver core marked with the target constraint problem to solve the target constraint problem.
4. The method of claim 1, wherein, The step S6 further comprises: Step C7, remove all C m except the current best C m corresponding W m Continue running in the background; Step C8, cache the solving results returned within the preset waiting time threshold in the solving result cache queue corresponding to the target constraint problem in order, and the initial state of the solving result cache queue corresponding to the target constraint problem is empty; Step C9, C not returned a solution result in more than a preset waiting time threshold m The superscript target constraint problem disables the identification.
5. The method of claim 4, wherein, The step C9 further comprises: Step C10, again obtain the target constraint problem, if the solving result cache queue corresponding to the target constraint problem is not empty, then execute step C20, if it is empty, then return to execute step S1; Step C20, the main thread takes the earliest stored solving result in the solving result cache queue corresponding to the current target constraint problem as the solving result of the target constraint problem and returns, and deletes the earliest stored solving result in the solving result cache queue corresponding to the current target constraint problem.
6. The method of claim 1, wherein, The step E8 or step E9 further comprises: Step E10, again obtain the target constraint problem, if the solving result cache queue corresponding to the target constraint problem is not empty, then execute step E20, if it is empty, then execute step E30; Step E20, the main thread takes the earliest stored solving result in the solving result cache queue corresponding to the current target constraint problem as the solving result of the target constraint problem and returns, and deletes the earliest stored solving result in the solving result cache queue corresponding to the current target constraint problem; Step E30, judge whether there is a solver core of the optimal solver core marked with the target constraint problem currently, if there is, then execute step E40, otherwise, return to execute step S1; Step E40, the main thread determines the solver core marked as the optimal solver core for the target constraint problem as the current optimal C m , invokes the optimal C m to solve the target constraint problem, and returns the solution result of the current optimal C m .
7. The method of claim 1, wherein, The step S5 comprises: Step S51, each W m The target constraint problem is pre-processed and modeled to adapt to C m , and a corresponding intermediate state constraint problem P m is generated. m ; Step S52, start each C m corresponding P m solving, the shared inference constraint library initial state is empty; Step S53, if C m The inference constraint is generated, and C m The corresponding inference constraint is returned to the main thread, and the main thread stores C m The corresponding inference constraint is stored in the shared inference constraint library. Step S54, C m determined as the current optimal C m .
8. An electronic device, comprising: Comprising: At least one processor; And a memory connected in communication with the at least one processor; Wherein the memory stores instructions executed by the at least one processor, the instructions are set to execute the method of any one of the preceding claims 1-7.
9. A computer-readable storage medium, characterized in that, Computer executable instructions are stored, the computer executable instructions are used to execute the method of any one of the preceding claims 1-7.
Citation Information
Patent Citations
Constraint classification method for generating random excitation, electronic equipment and storage medium
CN116933142A