Conditional statements are executed by arithmetic and / or bitwise units
By using arithmetic and/or bit units to execute conditional statements in the processor, and by transforming Boolean conditions into arithmetic and/or bitwise expressions, the processor bottleneck caused by digital comparators is solved, achieving faster execution speed and parallel execution of multi-level tasks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHARIOT TECHNOLOGIES LAB INC
- Filing Date
- 2021-05-12
- Publication Date
- 2026-07-10
AI Technical Summary
In the prior art, the digital comparator becomes a bottleneck for integrated circuit processors when executing conditional statements, which limits the processor's execution speed and makes it impossible to execute multi-level conditional tasks in parallel.
Conditional statements are executed by using the processor's arithmetic and/or bit units. Boolean conditions are transformed into arithmetic and/or bitwise expressions, and calculations are performed using arithmetic and/or bitwise operation units, avoiding the use of a numeric comparator.
It improves processor execution speed, removes the bottleneck of digital comparators, increases chip power utilization, and allows parallel execution of multi-level conditional tasks.
Smart Images

Figure CN114902176B_ABST
Abstract
Description
Technical Field
[0001] This description generally relates to computing systems, and more specifically to the execution of conditional statements and expressions by computing circuits. Background Technology
[0002] In computer science, conditional statements are a feature of programming languages that perform different computations or actions based on whether a specified Boolean condition evaluates to True or False.
[0003] The execution of conditional statements requires the evaluation of Boolean conditions, thus necessitating the comparison of numbers. This comparison determines whether one number is greater than, equal to, or less than another number. Boolean conditions are typically evaluated by a number comparator. A number comparator is a hardware electronic device that takes two numbers as input in binary form and determines whether one number is greater than, less than, or equal to the other.
[0004] Conditional statements use the output of a digital comparator to switch to executing one piece of computer code or another. Each complete "if-then do" operation of a digital comparator takes at least two clock cycles of the processor. Furthermore, digital comparators often cannot execute multi-level conditional tasks in parallel. Therefore, digital comparators (or blocks of logic in the ALU) often constitute a bottleneck for integrated circuit processors. Summary of the Invention
[0005] This specification describes how a system can execute a computer program, including conditional statements, using only the processor's arithmetic blocks and / or bit units.
[0006] Specific embodiments of the subject matter described in this specification may be implemented to achieve one or more of the following advantages.
[0007] Conditional statements are transformed into a set of arithmetic and / or bitwise operations. Accordingly, a computer program can be executed solely by the processor's arithmetic and / or bitwise units. Specifically, a computer program can be executed without using a digital comparator. As explained above, each overall operation of a digital comparator takes at least two clock cycles of the processor. On the other hand, the processor's arithmetic unit is capable of performing the vast majority of arithmetic calculations within one clock cycle. Accordingly, the techniques described in this specification improve the processor's execution speed of computer programs. The digital comparator can be removed, freeing up more space for arithmetic and / or bitwise operation units. For a constant chip size, this allows for increased chip power, thereby improving execution speed.
[0008] In addition, digital comparators often cannot perform parallel execution of multi-level conditional tasks. Therefore, digital comparators often become bottlenecks in integrated circuit processors. On the other hand, arithmetic and / or bitwise expressions can be divided into multiple segments, which can then be executed in parallel by multiple arithmetic and / or bitwise blocks. Accordingly, the techniques described in this specification can further improve the execution speed of a processor by executing a computer program through multiple arithmetic blocks working in parallel.
[0009] The method can be used at various levels of any suitable programming language. In particular, the method can be used in any suitable low-level language (e.g., assembly language, or at the instruction set architecture (ISA) level), as well as in specific software programs in any suitable high-level programming language (e.g., C++ code or Java, etc.).
[0010] Details of one or more embodiments of the subject matter of this specification are set forth in the accompanying drawings and the following description. Other features, aspects, and advantages of the subject matter will become apparent from the specification, the drawings, and the claims. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 is a diagram of an illustrated example system.
[0012] Figure 2 is a flowchart of an example process for executing a computer program using only the (one or more) arithmetic and / or bitwise units of a processor.
[0013] Figure 3 is pseudocode illustrating the basic structure of an if-then (-else) conditional statement.
[0014] Figure 4 is a flowchart of an example process for transforming a boolean condition into an arithmetic and / or bitwise expression.
[0015] Figure 5 is a flowchart of an example process for transforming A = B into an arithmetic and / or bitwise expression of A = B.
[0016] Figure 6 is a flowchart of an example process for transforming A ≥ B into an arithmetic and / or bitwise expression of A ≥ B.
[0017] Figure 7A and 7B is a flowchart of an example process for transforming A < B into an arithmetic and / or bitwise expression of A < B.
[0018] Figure 8 is a flowchart of an example process for generating an arithmetic and / or bitwise expression of a computer program when a conditional statement has an arithmetic body.
[0019] Figure 9 This is a flowchart of an example process for generating arithmetic and / or bitwise expressions for a computer program when a conditional statement has a non-arithmic body.
[0020] Figure 10 It is a flowchart for providing example procedures for arithmetic and / or bitwise expressions in a computer program.
[0021] Figure 11A This is an example of a C++ computer program that includes conditional statements with arithmetic bodies. Figure 11B It is by Figure 11A Examples of C++ computer programs generated by the transformation of computer programs. Figure 11C This is an example of an assembly language computer program that includes conditional statements with arithmetic bodies. Figure 11D It is by Figure 11C Examples of assembly language computer programs generated by transforming computer programs.
[0022] Figure 12A This is an example of a C++ computer program that includes conditional statements with non-arithmic bodies. Figure 12B It is by Figure 12A Examples of C++ computer programs generated by the transformation of computer programs. Figure 12C This is an example of an assembly language computer program that includes conditional statements with non-arithmic bodies. Figure 12D It is by Figure 12C Examples of assembly language computer programs generated by transforming computer programs.
[0023] Figure 13A and Figure 13B An example of a combinational logic circuit of an integrated circuit with arithmetic and / or bitwise operation units is illustrated.
[0024] Figure 14 This is a flowchart of an example process for reducing the size of matrix-type data.
[0025] Figure 15 This is a flowchart of an example process for parallel sorting of matrix-type data. Detailed Implementation
[0026] Figure 1 This is a diagram illustrating example system 100. System 100 is an example of a system that can implement the techniques described in this specification.
[0027] System 100 includes a processor 110, such as a central processing unit (CPU), graphics processing unit (GPU), neural processing unit (NPU), tensor processor unit (TPU), or any other type of processing unit capable of performing conditional tasks. The processor performs basic arithmetic, logic, control, and input / output (I / O) operations specified by instructions in computer program 182. Processor 110 may be a microprocessor, wherein the CPU is contained on a single metal-oxide-semiconductor (MOS) integrated circuit (IC) chip 160. The IC containing the CPU may also include memory units 150, such as dynamic random access memory (DRAM), and more than one level of cache memory, as well as peripheral interfaces connected to one or more input devices 180 or one or more output devices 190.
[0028] The processor 110 includes multiple functional components, including one or more arithmetic and / or bitwise operation units (ABUs) 130 that perform arithmetic and bitwise logic operations, one or more registers 140 that supply operands to the ABUs 130 and store the results of the ABU operations, and one or more control units (CUs) 120 that orchestrate the execution of instructions by directing the coordinated operation of the ABUs 130, registers 140 and other components.
[0029] ABU 130 is a digital circuit that performs arithmetic and / or bitwise logic operations. ABU 130 may include one or more arithmetic blocks 131, one or more bitwise shift blocks 132, and one or more bitwise logic blocks 133. Arithmetic blocks 131 perform arithmetic operations such as addition, carry-addition, subtraction, and borrow-subtraction. Bitwise shift blocks 132 perform shift operations such as arithmetic shift, logical shift, looping, and looping with carry. Bitwise logic blocks 133 perform bitwise logic operations such as AND, OR, and XOR. In some embodiments, ABU 130 does not include any digital comparators. In some embodiments, processor 110 does not include any digital comparators.
[0030] In operation, processor 110 accesses and executes computer program 182, which includes a sequence of instructions. Computer program 182 can be accessed from memory unit 150 or from input device 180. The processor can follow an instruction cycle that includes fetch, decode, and execute steps. Multiple instructions can be fetched, decoded, and executed simultaneously. Execution steps can consist of a single action or a series of actions. During each action, different parts of the processor are electrically connected, so they can perform all or part of the desired operation and then complete the action. The result can be written to one of registers 140 or to memory unit 150.
[0031] CU 120 directs the operation of processor 110. CU 120 controls memory 150 and ABU 130 in response to computer program 182 that has been accessed by the processor. In particular, CU 120 can direct the operation of other units by providing timing and control signals.
[0032] In some embodiments, CU 120 includes a transformation unit 121 that transforms computer program 182 into an arithmetic and / or bitwise expression 122 of the computer program. Transformation unit 121 identifies conditional statements found in computer program 182 and transforms them into arithmetic and / or bitwise expressions of the conditional statements. Transformation unit 121 generates the arithmetic and / or bitwise expression 122 of computer program 182 based on arithmetic and / or bitwise operations and operands. CU 120 then provides the arithmetic and / or bitwise expression 122 of computer program 182 to ABU 130. In other embodiments, the system includes a separate data processing device that identifies conditional statements found in computer program 182 and transforms them into arithmetic and / or bitwise expressions of the conditional statements.
[0033] In some embodiments, the arithmetic and / or bitwise expressions of conditional statements consist only of arithmetic and / or bitwise operations. In some embodiments, substantially all conditional statements (e.g., more than 50%, more than 60%, more than 70%, more than 80%, more than 90%, or more than 95%) are transformed, but some conditional statements do not need to be transformed if the processor still includes a digital compressor that can be used to evaluate a predetermined appropriate subset of conditional statements.
[0034] ABU 130 accesses arithmetic and / or bitwise expressions 122 of computer program 182 from CU 120. ABU 130 can access operands from register 140 or memory location 150. Operands can also be constants generated by ABU 130 itself. ABU 130 can also access status information, which conveys information about previous or current operations. ABU 130 outputs the result of the performed operation. The result can consist of a data word and / or status information. The result can be stored in register 140 or memory location 150.
[0035] Figure 2 This is a flowchart of an example process for executing a computer program. This process can be implemented by one or more computer programs installed on one or more computers at one or more locations and programmed according to this specification. For example, the process can be implemented by... Figure 1The system 100 shown in [description] performs. For convenience, the process will be described as being performed by a system of one or more computers. Some embodiments involve preprocessing a computer program, e.g., on a completely different computer system, to perform the transformation before the transformed computer program is executed on system 100. For example, a source compiler can perform the transformation when generating target code and / or machine-level code for a target computer.
[0036] The system accesses (210) a computer program (e.g., Figure 1 computer program 182). The system determines (205) whether the computer program includes at least one conditional statement that includes a Boolean condition. If the computer program includes at least one conditional statement, then the system transforms (220) the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition. If the computer program does not include any conditional statements, then the system provides (240) the arithmetic and / or bitwise expression of the computer program to the ABU 130 for execution.
[0037] When executed, a conditional statement causes the processor to perform an associated task depending on whether the specified Boolean condition evaluates to True or False. The task can include one or more computations and / or one or more actions. The specified Boolean condition requires at least one variable to be compared with a value or another variable. For example, the comparison can determine whether the value of a variable (e.g., A) is greater than (e.g., A > B), equal to (e.g., A = B), or less than (e.g., A < B) the value of another variable (e.g., B). The result of the comparison determines whether the associated task will be performed by the processor.
[0038] Figure 3 is pseudocode illustrating the basic structure of an if-then(-else) conditional statement 310. When the interpreter finds If, it expects a Boolean condition 301 and evaluates the Boolean condition 301 to a value of True or False. If the condition is True, then the processor performs the subsequent task 302. Otherwise, execution continues in the next branch. If there is an alternative task 303 (e.g., in an Else block), then the processor performs the alternative task 303. If there is no Else branch, then the processor performs the statement after End If. After performing any branch, control returns to the point after End If.
[0039] Referring again to Figure 2The system (e.g., transformation unit 121) transforms the Boolean condition (220) into an arithmetic and / or bitwise expression of the Boolean condition. The arithmetic and / or bitwise expression of the Boolean condition uses the variable of the conditional statement as the variable. In some implementations, the arithmetic and / or bitwise expression of the Boolean condition causes its output to validate the following two properties: If the value of the variable validates the Boolean condition, then the arithmetic and / or bitwise expression of the Boolean condition equals 1. If the value of the variable does not validate the Boolean condition, then the arithmetic and / or bitwise expression of the Boolean condition equals 0. Accordingly, the Boolean value TRUE is converted to 1, and the Boolean value FALSE is converted to 0. During execution, the arithmetic and / or bitwise expression of the Boolean condition maintains the portion of the executable code to be executed, while setting the portion not to be executed to zero. The transformation from the Boolean conditional statement to the arithmetic and / or bitwise expression... Figure 4 A more detailed description is available in the text.
[0040] The transformation can be performed at various levels of any suitable programming language. In particular, this method can be used for specific software programs in any suitable low-level language (e.g., assembly language, or at the instruction set architecture (ISA) level) and any suitable high-level programming language (e.g., C++ code, or Java, etc.). This process can be performed as a preprocessing step when compiling the source code into executable code for the target machine, or as just-in-time processing when implemented in an interpreter rather than a compiler.
[0041] Below are examples of specific and general transformation formulas that can be used to transform Boolean conditions into arithmetic and / or bitwise expressions.
[0042] Examples of specific transformation formulas (at the ASM and / or ISA levels)
[0043] Due to the specific transformation formulas for integer, character, or Boolean types
[0044] answer=z |k| %z (for the condition x = y and x >= y)
[0045] answer=1-z |k| %z (for all other conditions)
[0046] Specific transformation formulas for float or double types (floating-point data)
[0047] answer=z ceil|(k) |%z(for the condition x = y and x >= y)
[0048] answer=1-z ceil|(k) |%z (for all other conditions)
[0049] Examples of general transformation formulas for all data types (including arrays and strings)
[0050] General transformation of the Boolean condition "if(=)"
[0051]
[0052] General transformation of the Boolean condition "if(>=)"
[0053]
[0054] Boolean condition "if( < General transformation of ")"
[0055]
[0056] General transformation of the Boolean condition "if(>)"
[0057]
[0058] symbol:
[0059] -z is the base.
[0060] -A, B are arrays containing N elements.
[0061] -A[i], B[i] are the elements of the array. A single element such as an integer or a floating point number is a one-dimensional array (row vector matrix) with only one element.
[0062] -answer is an arithmetic and / or bitwise expression of a boolean condition.
[0063] -% is the remainder of the division.
[0064] -ceil(x) is the ceiling function that maps x to the smallest integer greater than or equal to x. <L
[0065] -If the boolean condition is x = y, then k = x - y
[0066] -If the boolean condition is x ≥ y, then k = (x - y) – (|x - y|)
[0067] -For x ≥ y, x < y is the "else" result
[0068] The base z can be the base of the number system. Most arithmetic operations based on the number system (e.g., power function and the remainder of division) can be calculated immediately by shift operations. In particular, if the processor uses the binary system, then z can be equal to 2.
[0069] In the case of arrays and strings, the elements of the array can be normalized. Any known normalization method can be used. This improves the execution speed of conditional statements.
[0070] Return to Figure 2 The system (e.g., transformation unit 121) generates (230) an arithmetic and / or bitwise expression for the computer program. The system replaces Boolean conditions in the computer program with arithmetic and / or bitwise expressions of Boolean conditions. During execution, the arithmetic and / or bitwise expressions of the Boolean conditions maintain the parts of the executable code to be executed, while zeroing out the parts not to be executed. The generation of the arithmetic and / or bitwise expressions of the computer program will be combined with... Figure 8 and 9 To describe in more detail.
[0071] The system (e.g., CU 120) provides (240) the arithmetic and / or bitwise expressions of a computer program to the arithmetic and / or bitwise unit (e.g., ABU 130) for execution. The arithmetic and / or bitwise expressions of the computer program can be specific software programs in any suitable programming language, particularly any suitable low-level language (e.g., assembly language, or at the instruction set architecture (ISA) level), and any suitable high-level programming language (e.g., C++ code or Java, etc.). Execution of the arithmetic and / or bitwise expressions of the computer program does not require any direct comparison of numbers. The system can therefore provide the arithmetic and / or bitwise expressions of the computer program to the arithmetic and / or bitwise unit, particularly the arithmetic and / or bitwise unit that does not include any numeric comparators.
[0072] The system (e.g., ABU 130) executes (250) arithmetic and / or bitwise expressions of a computer program. Execution of the arithmetic and / or bitwise expressions of a conditional statement provides the same result as execution of the conditional statement itself, without requiring any numeric comparisons. Thus, a processor without any numeric comparators can execute a computer program. Combined Figure 11A and 11B The execution of conditional statements with arithmetic bodies is described in more detail. Regarding... Figure 12A and 12B The execution of conditional statements with non-arithmic bodies is described in more detail. For example, regarding... Figure 10 In more detail, arithmetic and / or bitwise expressions in a computer program can be segmented and these segments can be executed in parallel (e.g., simultaneously or concurrently), especially in the case of multilevel conditional statements.
[0073] Figure 4 It is used to transform Boolean conditions (e.g., Figure 2 The flowchart for example procedures of (220) in arithmetic and / or bitwise expressions is shown. The Boolean condition takes A as the first variable and B as the second variable.
[0074] The system (e.g., transformation unit 121) subtracts (410)B from A.
[0075] The system (e.g., transformation unit 121) calculates the absolute value of the result of the subtraction (420).
[0076] The system (e.g., transformation unit 121) calculates the (430) exponent based on the absolute value of the result of the subtraction.
[0077] The system (e.g., transformation unit 121) calculates the (440) exponent by raising the calculated exponent to the power of the base. The base can be any number. In particular, the base can be the base of the number system used by the processor. Specifically, if the processor uses a binary system, then the base can be equal to 2. Most arithmetic operations with a base of a number system (e.g., power functions and remainders of division) can be calculated immediately by shift operations. In particular, the power operation of the calculated exponent to the base can be performed by left-shifting the bits equal to 1 by the number of bits of the calculated exponent. This improves execution speed.
[0078] The system (e.g., transformation unit 121) calculates (450) the remainder of the exponent divided by the base for the arithmetic and / or bitwise expression of the Boolean condition.
[0079] If the Boolean condition is validated, then the exponent is calculated to make the exponent equal to 0. Any number raised to the power of 0 produces 1. Thus, if the Boolean condition is validated, then the exponent equals 0, and the arithmetic sum and / or bitwise expression of the Boolean condition will equal 1.
[0080] In some embodiments, the base is 2. If the processor uses a binary system, the remainder when the exponent is divided by the base can be extracted by taking the last bit of the exponent. This reduces the computational complexity.
[0081] Figure 5 This is a flowchart of an example procedure for transforming the Boolean condition A = B into an arithmetic and / or bitwise expression of A = B.
[0082] The system (e.g., transformation unit 121) subtracts (510)B from A.
[0083] The system (e.g., transformation unit 121) calculates the (520) exponent as the absolute value of the result of 510.
[0084] The system (e.g., transformation unit 121) calculates the (530) exponent by raising the exponent calculated at 520 to the power of the base.
[0085] The system (e.g., transformation unit 121) calculates (540) the arithmetic and / or bitwise expression of the boolean condition as the remainder of the exponent calculated at 530 divided by the base.
[0086] Calculate the arithmetic and / or bitwise expression of A = B such that the following is verified. If A = B, then the exponent is equal to 0, and the arithmetic and / or bitwise expression of A = B is equal to 1. If A ≠ B, then the exponent is not equal to 0, and the arithmetic and / or bitwise expression of A = B is equal to 0.
[0087] Figure 6 Is a flowchart of an example process for transforming the boolean condition A ≥ B into its arithmetic and / or bitwise expression.
[0088] The system (e.g., transformation unit 121) subtracts (610) B from A.
[0089] The system (e.g., transformation unit 121) calculates (620) the absolute value of the result 610.
[0090] The system (e.g., transformation unit 121) subtracts (630) the result of 610 from the result of 620.
[0091] The system (e.g., transformation unit 121) calculates (640) the exponent as the absolute value of the result of 630.
[0092] The system (e.g., transformation unit 121) calculates (650) the exponent by taking the base to the power of the exponent calculated at 640.
[0093] The system (e.g., transformation unit 121) calculates (660) the arithmetic and / or bitwise expression of the boolean condition as the remainder of the exponent calculated at 650 divided by the base.
[0094] Calculate the arithmetic and / or bitwise expression of A ≥ B such that the following is verified. If A ≥ B, then the exponent is equal to 0, and the arithmetic and / or bitwise expression of A ≥ B is equal to 1. If A < B, then the exponent is not equal to 0, and the arithmetic and / or bitwise expression of A ≥ B is equal to 0.
[0095] Figure 7A Is a flowchart of an example process for transforming the boolean condition A < B into its arithmetic and / or bitwise expression.
[0096] The system (e.g., transformation unit 121) subtracts (710) B from A.
[0097] The system (e.g., transformation unit 121) calculates (720) the absolute value of the result 710.
[0098] The system (e.g., transformation unit 121) subtracts (730) the result of 710 from the result of 720.
[0099] The system (e.g., transformation unit 121) calculates (740) the exponent as the absolute value of the result of 730.
[0100] The system (e.g., transformation unit 121) calculates (750) the exponent by raising the base to the power of the exponent calculated at 740.
[0101] The system (e.g., transformation unit 121) calculates (760) the arithmetic and / or bitwise expression of the boolean condition as the remainder of the exponent calculated at 750 divided by the base.
[0102] Calculate the arithmetic and / or bitwise expression of A < B such that the following is verified. If A < B, then the exponent is equal to 0, and the arithmetic and / or bitwise expression of the boolean condition is equal to 1. If A ≥ B, then the exponent is not equal to 0, and the arithmetic and / or bitwise expression of the boolean condition will be equal to 0.
[0103] Figure 7B Is a flowchart of another example process for transforming the boolean condition A < B into an arithmetic and / or bitwise expression of A < B.
[0104] The system (e.g., transformation unit 121) subtracts (710B) B from A.
[0105] The system (e.g., transformation unit 121) calculates (720B) the arithmetic and / or bitwise expression of the boolean condition as the borrow value of the result of subtracting B from A.
[0106] Calculate the arithmetic and / or bitwise expression of A < B such that the following is verified. If A < B, then the borrow value of the result of subtracting B from A is equal to 1, and the arithmetic and / or bitwise expression of the boolean condition is equal to 1. If A ≥ B, then the borrow value of the result of subtracting B from A is equal to 0, and the arithmetic and / or bitwise expression of the boolean condition is equal to 0.
[0107] Figure 8 Is an example process for generating (e.g., Figure 2 of 230) the arithmetic and / or bitwise expression of a computer program when the conditional statement has an arithmetic body. Regarding Figure 11A and 11B Describe the example in more detail.
[0108] The system (e.g., transformation unit 121) performs subsequent (consequent) tasks (e.g., Figure 3The statement 302) is multiplied by the arithmetic and / or bitwise expression of the Boolean condition (810). Accordingly, when the computer program is executed, the following occurs: If the Boolean condition is validated, the arithmetic and / or bitwise expression of the Boolean condition equals 1, subsequent tasks are maintained by multiplying it by the arithmetic and / or bitwise expression of the Boolean condition, and subsequent tasks are executed. If the Boolean condition is not validated, the arithmetic and / or bitwise expression of the Boolean condition equals 0, subsequent tasks are invalidated by multiplying them by the arithmetic and / or bitwise expression of the Boolean condition, and subsequent tasks are not executed.
[0109] If the conditional statement includes an alternative task that is formulated as an arithmetic statement (e.g., Figure 3 If the Boolean condition is validated (e.g., transformation unit 121), then the system (e.g., transformation unit 121) multiplies the arithmetic follow-up task by (820) 1 minus the arithmetic and / or bitwise expression of the Boolean condition. Accordingly, when the computer program is executed, the following occurs: If the Boolean condition is validated, then the arithmetic and / or bitwise expression of the Boolean condition equals 1. The follow-up task is maintained by multiplying it by the arithmetic and / or bitwise expression of the Boolean condition, while the substitute task is invalidated by multiplying it by 1 minus the arithmetic and / or bitwise expression of the Boolean condition. Therefore, the follow-up task is executed, while the substitute task is not executed. If the Boolean condition is not validated, then the arithmetic and / or bitwise expression of the Boolean condition equals 0, the follow-up task is invalidated by multiplying it by the arithmetic and / or bitwise expression of the Boolean condition, while the substitute task is maintained by multiplying it by 1 minus the arithmetic and / or bitwise expression of the Boolean condition. Therefore, the substitute task is executed, while the follow-up task is not executed.
[0110] Figure 9 It is used to generate when the conditional statement has a non-arithmic body (e.g., Figure 2 (230) A flowchart of an example procedure for arithmetic and / or bitwise expressions in a computer program. About Figure 12A and 12B Provide a more detailed description of the example.
[0111] The system (e.g., transformation unit 121) includes an unconditional jump to a label associated with an arithmetic and / or bitwise expression of a Boolean condition in the arithmetic and / or bitwise expression of the computer program. The label is initiated with the arithmetic and / or bitwise expression of the Boolean condition such that when the arithmetic and / or bitwise expression of the conditional statement equals 1, the label is equal to the start statement of the subsequent task (e.g., ...). Figure 3 (302). Accordingly, when a computer program is executed, the following occurs: If the Boolean condition is validated, then the arithmetic sum and / or bitwise expression of the Boolean condition equals 1. The label equals the start statement of the subsequent task. An unconditional jump statement points to the subsequent task. During execution, when the processor finds an unconditional jump statement, the processor executes the subsequent task.
[0112] If there is an alternative task (e.g., Figure 3 If the condition (303) is not validated, then a label is further initiated such that when the arithmetic and / or bitwise expression of the conditional statement equals 0, it is equal to the start statement of the substitute task. Accordingly, when the computer program is executed, the following occurs: If the Boolean condition is validated, then the arithmetic and / or bitwise expression of the Boolean condition equals 1, the label equals the start statement of the subsequent task, an unconditional jump statement points to the subsequent task, and the subsequent task is executed. If the conditional statement is not validated, then the arithmetic and / or bitwise expression of the Boolean condition equals 0, the label equals the start statement of the substitute task, a jump statement points to the substitute task, and the substitute task is executed.
[0113] Figure 10 It is used to provide (e.g., Figure 2 (240) Computer programs performing arithmetic and / or bitwise expressions and optionally performing (e.g., Figure 2 (250) Arithmetic and / or bitwise expressions in a computer program. Arithmetic and / or bitwise expressions are segmented. Multiple segments can then be executed in parallel by multiple arithmetic and / or bitwise blocks. In this way, the processor's execution speed can be improved by executing the computer program by multiple arithmetic blocks working in parallel. In addition, multi-level conditional statements can be executed in parallel.
[0114] The system (e.g., transformation unit 121) segments (1010) the arithmetic and / or bitwise expressions of a computer program into multiple segments.
[0115] The system (e.g., ABU 130) executes (1020) segments in parallel. Specifically, the ABU 130 can execute multithreaded code. The ABU 130 executes at least two segments in parallel. In particular, reverse Polish notation can be used to execute the segments.
[0116] Figure 11A This is an example of a C++ computer program that includes a conditional statement 1110A with an arithmetic body.
[0117] The Boolean condition 1110A of conditional statement 1101A is whether x equals y. The subsequent task 1102 is that z equals 1. The alternative task 1103 is that z equals 0. Conditional statement 1110A can be represented as follows:
[0118] If x equals y, then z equals 1.
[0119] If x is not equal to y, then z is equal to 0.
[0120] Therefore, the execution of conditional statement 1110A requires comparison of variables x and y.
[0121] Figure 11B It is by Figure 11AExample of a C++ computer program generated by transformation of a computer program.
[0122] The conditional statement 1110A has been transformed into an arithmetic and / or bitwise expression 1110B that includes only arithmetic and / or bitwise operations. The arithmetic and / or bitwise expression 1101B of the boolean condition is z = 1 << (x - y)) % 2. Thus, if x is equal to y, then z = 1 << (x - y)) % 2 = 1, and if x is not equal to y, then z = 1 << (x - y)) % 2 = 0.
[0123] Execution of the arithmetic and / or bitwise expression 1101B of the conditional statement thus provides the same result as execution of the conditional statement 1110A, but does not require comparison of variables x and y.
[0124] Figure 11C Example of an assembly language computer program 1100C that includes a conditional statement with an arithmetic body. Figure 11D is generated by Figure 11C Example of an assembly language computer program 1100D generated by transformation of a computer program.
[0125] Figure 12A Example of a C++ computer program that includes a conditional statement 1210A with a non-arithmetic body.
[0126] The boolean condition 1201A of the conditional statement 1210A is whether x is equal to y. The subsequent task 1201 is to output "equal". The alternative task 1202 is to output "not equal". The conditional statement 1210A can be expressed as follows. If x is equal to y, then the program outputs "equal". If x is not equal to y, then the program outputs "not equal".
[0127] Figure 12B is generated by Figure 12A Example of a C++ computer program generated by transformation of a computer program.
[0128] The conditional statement 1210A has been transformed into an arithmetic and / or bitwise expression 1210B that includes only arithmetic and / or bitwise operations. The arithmetic and / or bitwise expression of the boolean condition 1201B is res = (1 << k) % 2, where k = x - y. Thus, if x = y, then res = (1 << k) % 2 = 1, and if x ≠ y, then res = (1 << k) % 2 = 0. The unconditional jump 1204 is initialized in the initialization statement 1205. The unconditional jump provides an unconditional jump to the label ("condition[res]").
[0129] When the arithmetic and / or bitwise expression of the conditional statement equals 1 (res = 1), the label ("condition[1]") equals the start statement ("to_do") 1201 of the subsequent task. The unconditional jump statement points to the subsequent task 1201. During execution, when the processor finds the unconditional jump statement 1204, the processor executes the subsequent task 1201.
[0130] When the arithmetic and / or bitwise expression of the conditional statement equals 0 (res = 0), the label ("condition[0]") equals the start statement ("elso_do") 1202 of the alternative task. The unconditional jump statement points to the alternative task 1202. During execution, when the processor finds the unconditional jump statement 1204, the processor executes the alternative task 1202.
[0131] Figure 13B The diagram illustrates an example of the combinational logic circuit 1310B of the ABU integrated circuit when variables A and B each consist of only one bit. The conditional logic circuit 1310B includes a NOR gate 1320 and a NOT gate 1330. The output of the NOT gate 1330 provides the evaluation of the Boolean condition A = B.
[0137] Furthermore, in some implementations, the following techniques are used when Boolean conditions are between matrix-type data (arrays, lists, vectors, etc.) whose elements are represented by numbers and / or characters. Using these techniques can improve the efficiency of comparing matrix-type data, thereby also improving the process of transforming Boolean conditions into arithmetic and / or bitwise expressions of Boolean conditions. Instead of comparing every number or character (in the same position) in matrix-type variables A and B, the size of the matrix-type objects to be compared (e.g., arrays) can be reduced, thus improving the efficiency of transforming Boolean conditions into arithmetic and / or bitwise expressions of Boolean conditions, such as in combination with... Figure 14 As described.
[0138] Figure 14 This is a flowchart of an example process for reducing the size of data of the type of matrix to be compared, for example. This process can be implemented by one or more computer programs installed on one or more computers in one or more locations and programmed according to this specification. For example, the process can be performed by… Figure 1 The process is executed by system 100 as shown. For convenience, this process will be described as being executed by a system of one or more computers, but it should be noted that... Figure 14 The process can be part of the computer program preprocessing for transformation, therefore it does not need to be executed on the same computer system that executes the transformed computer program. Furthermore, although... Figure 14 The process is described in conjunction with a single variable that has matrix-type data, such as data objects like arrays, lists, vectors, etc., but it should be understood that the process is performed on each variable (e.g., variable A and variable B) to be compared in the Boolean condition.
[0139] The system determines whether variable (1400) has an odd number of elements. If so, a single element (1405) can be removed from the variable before splitting it (1410) during subsequent processing, and this single element can be added to a smaller version of the resulting variable. For example, a new matrix-type variable can be instantiated for the smaller version of the variable, and the data value of an element (e.g., the last element) of the input variable can be added to the new variable (e.g., in the first element of the new variable), and that element can then be removed from the initial variable, resulting in an even number of elements for splitting (1410). Note that the same single element (in terms of position, e.g., in an array) should be removed (1405) from each corresponding variable to be compared (to add to the smaller version of the variable). Additionally, some implementations handle the appropriate variable and do not involve instantiating a new version of the variable; therefore, references to the variable below include implementations that instantiate new variables and implementations that do not instantiate them. Finally, note that multidimensional arrays can be handled by recursively performing the same process described herein.
[0140] The variables are split (1410) into pairs of two elements, where the data value in each pair is used to form the data value of the smaller variable. For example, the first pair of two elements could be the first and second elements of the input variable, the second pair of two elements could be the third and fourth elements of the input variable, the third pair of two elements could be the fifth and sixth elements of the input variable, and so on. Moreover, pairs of two elements can be formed in other suitable ways (where each element of the variable is only part of a pair). Note that for each set of compared variables, such as all compared variables of a given type, they should be split (1410) into pairs in the same way. Generally, the smaller version of each variable to be compared via Boolean conditions is formed using representative numbers in a mathematical sequence, with increasing differences between members of the sequence, where each representative number is a number representing a pair of numbers or characters from the pair of two elements, and when the input variable has an odd number of data elements, the smaller version of each variable will also include a single element from the input variable (e.g., the last data element). Furthermore, in some implementations, all optimization steps for each compared (matrix type) variable are performed in exactly the same way.
[0141] To represent a pair of numbers or characters as a single number, the property of mathematical sequences with increasing differences between their members can be used, meaning that the sum of the two members of a mathematical sequence with increasing differences (geometric sequences, etc.) is unique. Therefore, for each pair of elements in a pair of bi-elements of the variable, the corresponding members of the mathematical sequence are summed (1415), where the members of the mathematical sequence correspond to the element pairs in the pair of bi-elements of the variable, and each data value in that pair is used as the position index of the corresponding member of the mathematical sequence. This can be understood as replacing each element in the pair with a member of the mathematical sequence whose index in the sequence equals the data value of the element in the pair, and then summing the two members of the mathematical sequence for each element pair in the pair of bi-elements of the variable to form each corresponding representative number in the smaller (reduced-size) variable. Note that the same (selected) mathematical sequence is applied to derive the representative number (1415) for the compared (matrix-type) variable; and in some implementations, the same mathematical sequence is applied to all compared (matrix-type) variables (when deriving the representative number).
[0142] The system can also determine whether the position of an element in a variable (1420) is significant. For example, position is not significant when dealing with a sorted array (because the position of the elements in the sorted array is already known), and position is not significant when dealing with the logical condition that a pair [2,3] is considered equal to a pair [3,2]. In other cases, position is significant, for example, when a pair [2,3] is not considered equal to a pair [3,2]. If position is not significant, then each representative number of each corresponding sum from the member numbering of the mathematical sequence can be used as is. However, if the position of an element in a variable is significant, then position variables (1425) are calculated for the pairs of elements in the pair of elements of the variable. The calculation (1425) of position variables for each pair of elements can involve raising the result of the Boolean condition Y>X to the power of -1, where X is the first element in the pair and Y is the second element in the pair. Thus, if Y>X, then the position variable is -1, and if Y≤X, then the position variable is +1. Moreover, it should be noted that inverse Boolean conditions can also be used in some implementations.
[0143] For the positionally important comparison variable, a representative number is further formed by multiplying the sum of each member of the mathematical sequence by the positional variable of the corresponding element pair in the pair of variables (1430). Therefore, using F(n) as a function to determine the number by its index in the chosen mathematical sequence (where the differences between members of the sequence increase), x can be the first number, y can be the second number, and z can be the unique number formed therefrom (the representative number). The formula for the positional importance of the elements in a pair is:
[0144] Z=((-1)^condition(y>x) )*F(x)+F(y)
[0145] or
[0146]
[0147] The formula in which the position of the elements in the pair is not important is:
[0148] Z = F(x) + F(y)
[0149] Note that the mathematical sequences in which the differences between members of these sequences increase are those where |a (i+1) –a (i) |>|a (i) –a (i-1) Sequences of |, such as geometric sequences, exponential sequences, etc. Where a n It is a member of the sequence whose index (position) is equal to n. Moreover, the Fibonacci sequence inherits this property, starting from the third member of the series.
[0150] Additionally, representative numbers (1435) are stored in a smaller (reduced-size) version of the variables to evaluate the Boolean condition between the original variables A and B, or to further reduce the size of the variables before evaluating the Boolean condition between the original variables A and B. For example, representative numbers for each new pair can be added to a new array, which is a smaller (reduced) version of the previous array. Note that representative numbers should be stored (1435) in the smaller version of the variables, concatenating any single element (1405) removed from the initial variables, and all compared variables should be in the same order.
[0151] The system can determine (1440) whether further reduction of the variable size is desired. For example, if further reduction would not improve efficiency, it is unnecessary because of (1) the amount of time spent performing additional size reduction (the greater the number of elements in the variable and the number of variables being compared, the greater the time advantage of reduction over normal comparison) and / or (2) the amount of memory consumed (due to the rapid growth of the series, the element values in the reduced variable will grow without supporting long arithmetic, and to save memory, the system may round the element values, which can lead to conflicts with numbers that are very large or small compared to traditional comparisons (where each corresponding number or character in matrix-type variables A and B is in the same position)). Therefore, if further reduction is not desired, then Figure 14 The process ends. If the expectation is to be further reduced, then repeat. Figure 14 The process is to further reduce the size of the variables.
[0152] Note that, Figure 14The process is performed on variables A and B (which are matrix-type data) to be compared under Boolean conditions. Using... Figure 14 The process of reducing the size of variables allows the data values of the elements to be numbers and / or characters, and the result of reducing the size of variables A and B is that the efficiency of transforming Boolean conditions into Boolean arithmetic and / or bitwise expressions is improved.
[0153] Furthermore, as mentioned above, when processing sorted arrays, the position of elements in the matrix-type variables to be compared is not important. Therefore, in some implementations, each matrix-type variable (array, list, vector, etc.) to be compared is sorted to avoid one or more parts (or all) of the determination (1420), computation (1425), and multiplication (1430) operations. The following sorting techniques can provide improved efficiency by combining arithmetic and / or bitwise expressions that transform Boolean conditions into Boolean conditions. For example, instead of sorting the entire array on a single thread using modern sorting techniques (e.g., quicksort or qsort, bubble sort, selection sort, insertion sort, etc.), the array can be split into multiple smaller subarrays corresponding to the number of available threads, where processing of each smaller subarray can be performed in parallel by separate threads, and where the (searched) position index of each element in the original array is determined by comparing the value of each element with the values of other elements in the initial array.
[0154] Figure 15 This is a flowchart of an example process for parallel sorting of matrix-type data (e.g., matrix-type data to be compared), which can be used in conjunction with arithmetic and / or bitwise expressions that transform Boolean conditions into Boolean conditions. The process can be implemented by one or more computer programs installed on one or more computers in one or more locations and programmed according to this specification. For example, the process can be performed by… Figure 1 The process is executed by system 100 as shown. For convenience, this process will be described as being executed by a system of one or more computers, but it should be noted that... Figure 15 The process can be part of the preprocessing of a computer program to perform the transformation, so it does not need to be executed on the same computer system that executes the transformed computer program. In any case, this parallel sorting scheme can improve the overall computational efficiency of the processing operations.
[0155] Based on the initial (selected for sorting) matrix-type data variable, the system can instantiate (1500) new variables with the same number of elements as the matrix-type data variable. For example, a new array with the same number of elements as the initial (unsorted) array can be created, and all element positions in the new array can be filled with null values. The system allocates the necessary amount of memory to store the new variables.
[0156] Matrix-type data variables are divided by the system into (1505) sub-parts, the number of which equals the number of processing threads to be used to perform the sorting. For example, the initial (unsorted) array can be split into sub-arrays equal to the number of threads allocated to the sorting task. Note that the sub-parts of a matrix-type data variable do not need to be equal in dimensions.
[0157] Each of the corresponding processing threads in the system determines (1510) the position index of each element in the sub-part that is handled by that processing thread. This may involve comparing the value of each element in the sub-part with all other values in a matrix-type data variable and counting how much smaller (or how much larger for inverse position indices) the element in the matrix-type data variable is than the compared element in the sub-part. For example, at the level of each thread, the system can determine the position index of each element in each sub-array of the sorted array by comparing the value of each element in the sub-array with the values of the remaining elements in the initial array and counting the number of elements in the initial array whose values are greater than (or less than) the compared element.
[0158] When counting the number of elements whose values are less than the compared element, the resulting count is a position index. That is, a count of zero indicates that no other value in the matrix-type data variable is less than the compared value in its sub-component, so this compared value appears first in the sorted variable (when sorted in ascending order). Conversely, when counting the number of elements whose values are greater than the compared element, the resulting count is a reverse position index. That is, a count of zero indicates that no other value in the matrix-type data variable is greater than the compared value in its sub-component, so this compared value appears last in the sorted variable (when sorted in ascending order).
[0159] In some implementations, the system determines (1515) whether the sorting is in ascending or descending order. In other implementations, the sorting is always performed in one order or another, so the system does not need to determine (1515).
[0160] When sorting in ascending order, the system replaces the values in the new variable (1520) with values from the matrix-type data variable in ascending order based on the position indices determined by the processing thread. Therefore, for regular position indices (when counting smaller numbers of elements), the value at position index zero in the matrix-type data variable goes to the first position in the new variable, the value at position index one in the matrix-type data variable goes to the second position, the value at position index two in the matrix-type data variable goes to the third position, and so on. For example, by replacing empty values in the new array with corresponding values from the initial array that have the same position indices in ascending order, the results of subarray-level position index counts in the initial array can be combined into the new array.
[0161] The system then checks (1525) to see if any remaining unchanged values exist in the new variable. For example, since there are equal elements in the initial array, the system can check if there are any elements with null values in the new array. If there are no null elements in the new array at this stage, the new array can be considered an equivalent of the sorted (initial) array. Note that each element in the initial variable whose value is equal to the value of another element in the initial variable will receive the same position index as that other element, so one or more elements in the new variable will remain unchanged after replacement (1520) when the values in the initial variable are equal.
[0162] When this occurs, the system replaces any remaining unchanged values in the new variable (1530) with the left-adjacent element value from the new variable. For example, all remaining null elements in the new array can be replaced by the first (non-null) value found from the null elements, after which the new array can be considered an equivalent of the sorted (initial) array. These replacements are performed multiple times as needed, taking into account the number of equal values in the elements of the initial matrix-type data variable.
[0163] Similarly, when sorting in descending order, the system replaces the values in the new variable (1535) with values from the matrix-type data variables in descending order, based on the position indices determined by the processing thread. Therefore, for inverted position indices (when the count is the number of larger elements), the value at position index zero in the matrix-type data variable goes to the first position in the new variable, the value at position index one in the matrix-type data variable goes to the second position, the value at position index er in the matrix-type data variable goes to the third position, and so on. For example, by replacing empty values in the new array with corresponding values with the same position indices in the initial array in descending order, the results of subarray-level position index counts in the initial array can be combined into the new array.
[0164] The system then checks (1540) to see if there are any remaining unchanged values in the new variable. For example, since there are equal elements in the initial array, the system can check if there are any elements with null values in the new array. If there are no null elements in the new array at this stage, the new array can be considered an equivalent of the sorted (initial) array. Note that each element in the initial variable whose value is equal to the value of another element in the initial variable will get the same position index as that other element, so one or more elements in the new variable will remain unchanged after replacement (1535) when the values in the initial variable are equal.
[0165] When this occurs, the system replaces any remaining unchanged values in the new variable (1545) with the right-hand adjacent element value from the new variable. For example, all remaining null elements in the new array can be replaced by the first (non-null) element found from the null elements, after which the new array can be considered an equivalent of the sorted (initial) array. These replacements are performed multiple times as needed, taking into account the number of equal values in the elements of the initial matrix-type data variable.
[0166] Finally, the system uses a new variable (1550) as the sorted version of the matrix-type data variable. In some cases, this is done by... Figure 14 This is accomplished using new variables instead of the initial matrix-type data variables. In some cases, this is done by overwriting the values in the initial matrix-type data variables with the sorted values from the new variables, and... Figure 14 The process uses matrix-type data variables that are currently sorted.
[0167] In addition, it should be noted that Figure 15 Parallel sorting processes can be performed in addition to Figure 14 It is used efficiently in contexts outside of matrix optimization processes (used for comparing matrix-type data). For example, Figure 15 The parallel sorting process can also be used for efficient sorting of matrix-type data (without further matrix optimization and comparison), such as optimizing standard sorting for various tasks using methods that transform Boolean conditions into arithmetic and / or bitwise expressions of Boolean conditions, as described in this application.
[0168] In some implementations, a method for sorting a matrix-type data object may include: instantiating a new object having the same number of elements as the matrix-type data object; dividing the matrix-type data object into a plurality of sub-parts equal to the number of processing threads to be used for performing the sorting; each of the respective processing threads determining the position index of each element in the sub-part processed by the processing thread by comparing the value of each element in the sub-part with all other values in the matrix-type data object and counting how much smaller the element in the matrix-type data object is than the compared element in the sub-part or how much larger it is for the inverse position index; replacing the values in the new object with values from the matrix-type data object in either ascending or descending order according to the position index determined by the processing thread; and replacing any remaining unchanged values in the new object with the left-adjacent element value or the right-adjacent element value according to whether the sorting is ascending or descending, wherein the new object is used as a sorted version of the matrix-type data object. Note that determining the position index by comparing values can be achieved by combining... Figure 1-1 The system and techniques described in section 3 for transforming Boolean conditions into arithmetic and / or bitwise expressions of Boolean conditions result in improved efficiency of processing operations.
[0169] In addition, it should be noted that Figure 14 Optimization of the process for comparing matrix-type data (or objects) can be efficiently used in contexts other than transforming Boolean conditions into arithmetic and / or bitwise expressions of Boolean conditions. For example, this matrix variable optimization process can also be used in the context of comparisons without transforming Boolean conditions into arithmetic and / or bitwise expressions, such as in optimizing standard comparisons. Furthermore, Figure 14 The optimization process can be used independently of the comparison process. For example, Figure 14 The optimization process can be used to compress matrices into smaller matrices for efficient storage (requiring less memory).
[0170] In some implementations... Figure 14 The matrix variable optimization process is used more generally to improve the efficiency of comparing matrix type objects. Therefore, a method (according to some embodiments) may include: accessing a computer program including a conditional statement comprising a Boolean condition comparing a first variable A with a second variable B, wherein each of the first and second variables A and B includes matrix-type data; splitting each of the first and second variables A and B into a first pair of binary elements of the first variable A and a second pair of binary elements of the second variable B; and for comparison, forming a smaller version of each of the first and second variables A and B using representative numbers from mathematical sequences, wherein the differences between members of the mathematical sequences increase, wherein each representative number for the smaller version of the first variable A is calculated from the corresponding member of the mathematical sequence whose index in the mathematical sequence is equal to the data value in the first pair of binary elements of the first variable A, each representative number for the smaller version of the second variable B is calculated from the corresponding member of the mathematical sequence whose index in the mathematical sequence is equal to the data value in the second pair of binary elements of the second variable B, and wherein, when each of the first and second variables A and B has an odd number of elements, a single element is removed from each of the first and second variables A and B before splitting, and a single element from each of the first and second variables A and B is added to the smaller version of the first and second variables A and B, respectively. Additionally, this method involves comparing smaller versions of the first and second variables A and B while the computer program is running to evaluate the Boolean condition of the conditional statement.
[0171] In some embodiments, the formation operation of the above method includes: calculating a representative number for the smaller version of the first variable A by adding the two corresponding data values in the corresponding members of the mathematical sequence to the first double-element pair of the first variable A for each element of the smaller version of the first variable A; and calculating a representative number for the smaller version of the second variable B by adding the two corresponding data values in the corresponding members of the mathematical sequence to the second double-element pair of the second variable B for each element of the smaller version of the second variable B.
[0172] In some embodiments, the above method includes: calculating a first positional variable for a first pair of binary elements of a first variable A; and calculating a second positional variable for a second pair of binary elements of a second variable B; wherein calculating each positional variable for a pair of elements includes exponentiation of a number equal to negative 1 by the result of a Boolean condition Y>X, where X is the first element in the pair and Y is the second element in the pair; and wherein forming includes calculating a representative number for a smaller version of the first variable A by multiplying one of the first positional variables for each element of the smaller version of the first variable A by the sum of two corresponding data values in the first binary element pair of the first variable A from the corresponding members of the mathematical sequence, and calculating a representative number for a smaller version of the second variable B by multiplying one of the second positional variables for each element of the smaller version of the second variable B by the sum of two corresponding data values in the second binary element pair of the second variable B from the corresponding members of the mathematical sequence.
[0173] In some implementations, the same (exactly the same) steps, order, and tools (e.g., mathematical series sequences) are applied to all compared (matrix-type) variables. Furthermore, one or more of the systems described in this document can be used in one or more embodiments, wherein one or more memory units are configured to cause one or more instruction processing units to perform the operations of one or more of the methods described above. These systems and methods for comparing matrix-type objects result in improved processing speed because matrix-type objects can be compared faster on a given computer (with a given processing power) than previously possible on that computer. Moreover, these systems and methods for comparing matrix-type objects can result in less memory consumption because smaller versions of the variables can require less memory than the initial variables.
[0174] Some embodiments include a method that includes: accessing a computer program, where the computer program includes a conditional statement that includes a Boolean condition; transforming the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition; generating an arithmetic and / or bitwise expression of the computer program, including the arithmetic and / or bitwise expression of the Boolean condition in place of the Boolean condition; and providing the arithmetic and / or bitwise expression of the computer program, where the arithmetic and / or bitwise expression of the computer program is configured to be executed by an arithmetic and / or bitwise operation unit of a processor. The arithmetic and / or bitwise expression of the Boolean condition can verify the following: if the Boolean condition is verified, then the arithmetic and / or bitwise expression of the Boolean condition equals 1; and if the Boolean condition is not verified, then the arithmetic and / or bitwise expression of the Boolean condition equals 0.
[0175] In some embodiments of the above method, the Boolean condition takes a first variable A and a second variable B, and transforming the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition includes: subtracting B from A; calculating the absolute value of the result of subtracting B from A; calculating an exponent based on the absolute value of the result of subtracting B from A; calculating the exponentiation of a base by the calculated exponent; and calculating the arithmetic and / or bitwise expression of the Boolean condition based on the remainder of the exponent divided by the base. The Boolean condition can be A = B, and transforming the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition can include: calculating the exponent as the absolute value of the result of subtracting B from A; and calculating the arithmetic and / or bitwise expression of the Boolean condition as the remainder of the exponent divided by the base.
[0176] The Boolean condition can be A ≥ B, and transforming the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition can include: subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; calculating the exponent as the absolute value of the result of subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; and calculating the arithmetic and / or bitwise expression of the Boolean condition as the remainder of the exponent divided by the base.
[0177] The Boolean condition can be A < B, and transforming the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition can include: subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; calculating the exponent as the absolute value of the result of subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; calculating the exponentiation of the base by the exponent; and calculating the arithmetic and / or bitwise expression of the Boolean condition as 1 minus the remainder of the exponent divided by the base.
[0178] The first and second variables A and B can be floating-point data. In some embodiments, the boolean condition is A = B, the first and second variables A and B are floating-point data, and transforming the boolean condition into an arithmetic and / or bitwise expression of the boolean condition includes: calculating the exponent as the result of an upper bound function applied to the absolute value of the result of subtracting B from A; and calculating the arithmetic and / or bitwise expression of the boolean condition as the remainder of the exponent divided by the base. In some embodiments, the boolean condition is A ≥ B, the first and second variables A and B are floating-point data, and transforming the boolean condition into an arithmetic and / or bitwise expression of the boolean condition includes: subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; calculating the exponent as the result of an upper bound function applied to the absolute value of the result of subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; and calculating the arithmetic and / or bitwise expression of the boolean condition as the remainder of the exponent divided by the base. In some embodiments, the boolean condition is A < B, the first and second variables A and B are floating-point data, and transforming the boolean condition into an arithmetic and / or bitwise expression of the boolean condition includes: subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; calculating the exponent as the result of an upper bound function applied to the absolute value of the result of subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; calculating the exponent by raising the base to the power of the exponent; and calculating the arithmetic and / or bitwise expression of the boolean condition as 1 minus the remainder of the exponent divided by the base.
[0179] In some embodiments, the first and second variables A and B can be boolean type data (0 and 1), the boolean condition can be A = B, and transforming the boolean condition into an arithmetic and / or bitwise expression of the boolean condition can include: calculating the sum of A and B; and calculating the arithmetic and / or bitwise expression of the boolean condition as 1 minus the remainder of the sum divided by the base. [[ID=�]]
[0180] In some embodiments, the first and second variables A and B may include matrix-type data, and the method may include: splitting each of the first and second variables A and B into a first pair of binary elements of the corresponding first variable A and a second pair of binary elements of the second variable B; and for comparison, forming a smaller version of each of the first and second variables A and B using representative numbers from a mathematical sequence, wherein the differences between members of the mathematical sequence increase; wherein each representative number for the smaller version of the first variable A is calculated from the corresponding member of the mathematical sequence whose index in the mathematical sequence is equal to the data value in the first pair of binary elements of the first variable A; wherein each representative number for the smaller version of the second variable B is calculated from the corresponding member of the mathematical sequence whose index in the mathematical sequence is equal to the data value in the second pair of binary elements of the second variable B; and wherein, when each of the first and second variables A and B has an odd number of elements, a single element is removed from each of the first and second variables A and B before splitting, and a single element from each of the first and second variables A and B is added to the smaller version of the first and second variables A and B, respectively.
[0181] The formation may include: calculating a representative number for the smaller version of the first variable A by adding the corresponding two data values in the first double-element pair of the mathematical sequence to each element of the smaller version of the first variable A; and calculating a representative number for the smaller version of the second variable B by adding the corresponding two data values in the second double-element pair of the mathematical sequence to each element of the smaller version of the second variable B.
[0182] The above method may further include: sorting each of the first and second variables A and B, wherein the sorting of the matrix-type data variables includes: instantiating a new variable having the same number of elements as the matrix-type data variable; dividing the matrix-type data variable into multiple sub-parts equal to the number of processing threads to be used to perform the sorting; each of the respective processing threads determining the position index of each element in the sub-part processed by the processing thread by comparing the value of each element in the sub-part with all other values in the matrix-type data variable and counting how much smaller or larger the element in the matrix-type data variable is than the compared element in the sub-part for the inverse position index; replacing the value in the new variable with the value from the matrix-type data variable in either ascending or descending order according to the position index determined by the processing thread; and replacing any remaining unchanged values in the new variable with the left-adjacent or right-adjacent element value according to whether the sorting is ascending or descending, wherein the new variable is used as the sorted version of the matrix-type data variable.
[0183] The above method may further include: calculating a first position variable for a first pair of elements of a first variable A; and calculating a second position variable for a second pair of elements of a second variable B; wherein calculating each position variable for a pair of elements includes raising a number equal to -1 to the power of the result of a Boolean condition Y>X, where X is the first element in the pair of elements and Y is the second element in the pair of elements; and wherein forming a representative number for a smaller version of the first variable A includes calculating the sum of multiplying one of the first position variables by two corresponding members of a mathematical sequence for each element of the smaller version of the first variable A that correspond to the data values in the first pair of elements of the first variable A, and forming a representative number for a smaller version of the second variable B includes calculating the sum of multiplying one of the second position variables by two corresponding members of a mathematical sequence for each element of the smaller version of the second variable B that correspond to the data values in the second pair of elements of the second variable B.
[0184] In the above embodiments, the base may be equal to 2, where the processor uses the binary system, and where the remainder of the exponent divided by the base is extracted by taking the last bit of the exponent. Additionally, when the processor uses the binary system, raising a number to the power of the calculated exponent with respect to the base may be performed by shifting the bits equal to 1 to the left by a number of bits equal to the calculated exponent.
[0185] The Boolean condition may be A<B, and transforming the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition may include: subtracting B from A; calculating the arithmetic and / or bitwise expression of the Boolean condition as the borrow value of the result of subtracting B from A.
[0186] Providing an arithmetic and / or bitwise expression of a computer program may include: segmenting the arithmetic and / or bitwise expression of the computer program into multiple segments of the arithmetic and / or bitwise expression; and the segments of the arithmetic and / or bitwise expression may be configured to be executed in parallel.
[0187] The Boolean condition may include a subsequent task expressed as an arithmetic statement, and generating an arithmetic and / or bitwise expression of the computer program may include: multiplying the subsequent task by the arithmetic and / or bitwise expression of the Boolean condition. The Boolean condition may include an alternative task expressed as an arithmetic statement, and generating an arithmetic and / or bitwise expression of the computer program may include: multiplying the alternative task by 1 minus the arithmetic and / or bitwise expression of the Boolean condition.
[0188] Boolean conditions may include subsequent tasks expressed as non-arithmic statements, and the arithmetic and / or bitwise expressions that generate the computer program may include unconditional jumps to labels associated with the arithmetic and / or bitwise expressions of the Boolean condition within the arithmetic and / or bitwise expressions of the computer program. Furthermore, when the value of the arithmetic and / or bitwise expression of the Boolean condition is equal to 1, the label may equal the start of the statement of the subsequent task. Moreover, Boolean conditions may include alternative tasks expressed as non-arithmic statements, wherein when the value of the arithmetic and / or bitwise expression of the Boolean condition is equal to 0, the label equals the start of the statement of the alternative task.
[0189] In some embodiments, the method further includes: executing an arithmetic and / or bitwise expression of a computer program by an arithmetic and / or bitwise operation unit. In some embodiments, at least the transformation is performed by a first computer, and the execution is performed by a second computer. In some embodiments, the transformation and execution are performed by the same computer.
[0190] Some embodiments include a system comprising: one or more instruction processing units, including at least one control unit, at least one arithmetic and / or bitwise operation unit, and at least one register unit; and one or more memory units coupled to the one or more instruction processing units; wherein the system is configured to execute substantially all conditional statements in a computer program by using at least one arithmetic and / or bitwise operation unit to execute arithmetic and / or bitwise expressions of Boolean conditions for substantially all conditional statements, each conditional statement including a Boolean condition. In such system embodiments, at least one control unit or separate data processing means of the system may be configured to perform method operations of any of the above method embodiments, and at least one arithmetic and / or bitwise operation unit of the processor including one or more instruction processing units may be configured to execute arithmetic and / or bitwise expressions of the computer program. Moreover, at least one arithmetic and / or bitwise operation unit may include one or more of arithmetic blocks, bitwise shift blocks, and bitwise logic blocks, and at least one arithmetic and / or bitwise operation unit does not need to include any digital comparators.
[0191] Embodiments of the subject matter and functional operation described in this specification may be implemented in digital electronic circuits, tangibly embodied computer software or firmware, computer hardware (including the structures disclosed in this specification and their structural equivalents), or combinations thereof. Embodiments of the subject matter described in this specification may be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible, non-transient storage medium for execution by or control of the operation of a data processing apparatus. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access storage device, or combinations thereof. Alternatively or additionally, program instructions may be encoded on artificially generated propagation signals (e.g., machine-generated electrical, optical, or electromagnetic signals) that generate information for encoding and transmission to a suitable receiver device for execution by the data processing apparatus.
[0192] The term "data processing device" refers to data processing hardware and encompasses all types of apparatus, devices, and machines that are difficult to adapt for processing data, including programmable processors, computers, or multiple processors or computers. The device may also be or include special-purpose logic circuitry, such as FPGAs (Field-Programmable Gate Arrays) or ASICs (Application-Specific Integrated Circuits). In addition to hardware, the device may optionally include code that creates an execution environment for computer programs, such as code constituting processor firmware, protocol stacks, database management systems, operating systems, or combinations thereof.
[0193] A computer program (also referred to or described as a program, software, software application, app, module, software module, script, or code) can be written in any form of programming language, including compiled or interpreted languages, declarative or procedural languages, and can be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment. A program may, but does not need to, correspond to a file in a file system. A program may be stored as part of a file that holds other programs or data (e.g., one or more scripts stored in a markup language document), in a single file dedicated to the program in question, or in multiple coordinating files (e.g., a file storing one or more modules, subroutines, or portions of code). A computer program can be deployed to execute on one or more computers located at a single site or distributed across multiple sites interconnected by a data communication network.
[0194] A system of one or more computers configured to perform a specific operation or action means that the system has software, firmware, hardware, or a combination thereof installed thereon, which, in operation, cause the system to perform the operation or action. A system of one or more computer programs configured to perform a specific operation or action means that the one or more programs include instructions that, when executed by a data processing device, cause that device to perform the operation or action.
[0195] As used in this specification, "engine" or "software engine" refers to a software-implemented input / output system that provides outputs distinct from its inputs. An engine can be a coded functional block, such as a library, platform, software development kit ("SDK"), or object. Each engine can be implemented on any suitable type of computing device including one or more processors and computer-readable media, such as a server, mobile phone, tablet computer, laptop computer, music player, e-book reader, laptop or desktop computer, PDA, smartphone, or other fixed or portable device. Furthermore, two or more engines can be implemented on the same computing device or on different computing devices.
[0196] The processing and logic flows described in this specification can be executed by one or more programmable computers that execute one or more computer programs to perform functions by manipulating input data and generating output. The processing and logic flows can also be executed by a dedicated logic circuit system (e.g., an FPGA or ASIC), or by a combination of a dedicated logic circuit system and one or more programmed computers.
[0197] A computer suitable for executing computer programs can be based on a general-purpose or special-purpose microprocessor, or both, or any other type of central processing unit. Generally, the central processing unit receives instructions and data from read-only memory or random access memory, or both. The basic components of a computer are the central processing unit for executing or running instructions and one or more memory devices for storing instructions and data. The central processing unit and memory may be supplemented or integrated therein by a system of special-purpose logic circuitry. Generally, a computer will also include one or more mass storage devices (e.g., disks, magneto-optical disks, or optical disks) for storing data, or be operatively coupled to one or more mass storage devices to receive data from or transfer data to, or both. However, a computer does not require such a device. Furthermore, a computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device (e.g., a universal serial bus (USB) flash drive), to name just a few examples.
[0198] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, such as: semiconductor memory devices, such as EPROM, EEPROM, and flash memory devices; magnetic disks, such as internal hard disks or removable disks; magneto-optical disks; and CD ROMs and DVD-ROMs.
[0199] To provide interaction with the user, embodiments of the subject matter described in this specification can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display)) for displaying information to the user and a keyboard and pointing device (e.g., a mouse, trackball, or a presentation-sensitive display or other surface) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback, such as visual, auditory, or tactile feedback; and input from the user can be received in any form, including sound, speech, or tactile input. Furthermore, the computer can interact with the user by sending and receiving documents from the device used by the user; for example, by sending a webpage to a web browser on the user's device in response to a request received from a web browser. Moreover, the computer can interact with the user by sending text messages or other forms of messages to a personal device (e.g., a smartphone running a messaging application) and receiving response messages from the user.
[0200] Embodiments of the subject matter described in this specification can be implemented in a computing system that includes back-end components (e.g., as a data server), or middleware components (e.g., an application server), or front-end components (e.g., a client computer with a graphical user interface or web browser or app through which a user can interact with embodiments of the subject matter described in this specification), or any combination of one or more such back-end, middleware, or front-end components. The components of the system can be interconnected via digital data communication (e.g., a communication network) of any form or medium. Examples of communication networks include local area networks (LANs) and wide area networks (WANs), such as the Internet.
[0201] A computing system may include clients and servers. Clients and servers are typically geographically separated and usually interact via a communication network. The client-server relationship is established by computer programs running on their respective computers and having a client-server relationship with each other. In some embodiments, the server transmits data, such as HTML pages, to a user device for displaying the data to a user interacting with the device as a client and receiving user input from that user. Data generated at the user device, such as the result of user interaction, may be received from the device on the server.
[0202] While this specification contains numerous specific implementation details, these should not be construed as limiting the scope of any invention or the scope of the claims, but rather as descriptions of specific features of specific embodiments of a particular invention. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments. Moreover, although the foregoing features may be described as operating in certain combinations, or even initially claimed in this way, in some cases one or more features may be removed from the claimed combination, and the claimed combination may refer to sub-combinations or variations thereof.
[0203] Similarly, although operations are depicted in a specific order in the accompanying drawings, this should not be construed as requiring these operations to be performed in the specific order shown or in sequential order, or requiring all of the shown operations to obtain the desired result. In some cases, multitasking and parallel processing may be advantageous. Furthermore, the separation of various system modules and components in the above embodiments should not be construed as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated into a single software product or packaged into multiple software products.
[0204] Specific embodiments of this subject matter have been described. Other embodiments are within the scope of the following claims. For example, the actions recited in the claims can be performed in a different order and still achieve the desired result. As an example, the processes described in the drawings do not necessarily require the specific order or sequence shown to achieve the desired result. For example, in Figure 14 Operations 1420 and 1425 do not need to follow operation 1415; in some implementations, operations 1420 and 1425 are executed before operation 1415. Furthermore, in some cases, multitasking and parallel processing may be advantageous.
Claims
1. A method for executing conditional statements, comprising: Accessing a computer program, wherein the computer program includes the conditional statement, and the conditional statement includes a boolean condition; Transforming the boolean condition into an arithmetic and / or bitwise expression of the boolean condition; Generating an arithmetic and / or bitwise expression of the computer program, including replacing the boolean condition of the boolean condition with the arithmetic and / or bitwise expression; and Providing the arithmetic and / or bitwise expression of the computer program, wherein the arithmetic and / or bitwise expression of the computer program is configured to be executed by an arithmetic and / or bitwise operation unit of a processor without using a digital comparator, wherein the boolean condition takes a first variable A and a second variable B, and wherein transforming the boolean condition into an arithmetic and / or bitwise expression of the boolean condition includes: Subtracting B from A; Calculating the absolute value of the result of subtracting B from A; Calculating an exponent based on the absolute value of the result of subtracting B from A; Calculating the exponent by taking the power of the base by the calculated exponent; and Calculating the arithmetic and / or bitwise expression of the boolean condition based on the remainder of the exponent divided by the base.
2. The method according to claim 1, wherein the arithmetic and / or bitwise expression of the boolean condition verifies the following: If the boolean condition is verified, then the arithmetic and / or bitwise expression of the boolean condition is equal to 1; and If the boolean condition is not verified, then the arithmetic and / or bitwise expression of the boolean condition is equal to 0.
3. The method according to claim 1, wherein the boolean condition is A = B, and wherein transforming the boolean condition into an arithmetic and / or bitwise expression of the boolean condition includes: Calculating the exponent as the absolute value of the result of subtracting B from A; And Calculating the arithmetic and / or bitwise expression of the boolean condition as the remainder of the exponent divided by the base.
4. The method according to claim 1, wherein the boolean condition is A ≥ B, and wherein transforming the boolean condition into an arithmetic and / or bitwise expression of the boolean condition includes: Subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; Calculating the exponent as the absolute value of the result of subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; And Calculating the arithmetic and / or bitwise expression of the boolean condition as the remainder of the exponent divided by the base.
5. The method according to claim 1, wherein the boolean condition is A < B, and wherein transforming the boolean condition into an arithmetic and / or bitwise expression of the boolean condition includes: Subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; Calculating the exponent as the absolute value of the result of subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; Calculating the exponent by taking the power of the base by the exponent; And Calculating the arithmetic and / or bitwise expression of the boolean condition as 1 minus the remainder of the exponent divided by the base.
6. The method according to claim 1, wherein the Boolean condition is A = B, wherein the first and second variables A and B are floating-point data, and wherein transforming the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition comprises: Calculating the exponent as the result of an upper bound function applied to the absolute value of the result of subtracting B from A; And Calculating the arithmetic and / or bitwise expression of the Boolean condition as the remainder of the exponent divided by the base.
7. The method according to claim 1, wherein the Boolean condition is A ≥ B, wherein the first and second variables A and B are floating-point data, and wherein transforming the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition comprises: Subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; Calculating the exponent as the result of an upper bound function applied to the absolute value of the result of subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; And Calculating the arithmetic and / or bitwise expression of the Boolean condition as the remainder of the exponent divided by the base.
8. The method according to claim 1, wherein the Boolean condition is A < B, wherein the first and second variables A and B are floating-point data, and wherein transforming the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition comprises: Subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; Calculating the exponent as the result of an upper bound function applied to the absolute value of the result of subtracting the result of subtracting B from A from the absolute value of the result of subtracting B from A; Calculating the exponent by raising the base to the power of the exponent; And Calculating the arithmetic and / or bitwise expression of the Boolean condition as 1 minus the remainder of the exponent divided by the base.
9. The method according to claim 1, wherein the first and second variables A and B are Boolean data types, wherein the Boolean condition is A = B, and wherein transforming the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition comprises: Calculating the sum of A and B; And Calculating the arithmetic and / or bitwise expression of the Boolean condition as 1 minus the remainder of the sum divided by the base.
10. The method according to claim 1, wherein the first and second variables A and B comprise matrix type data, and the method comprises: Splitting each of the first and second variables A and B into a first pair of two elements of the corresponding first variable A and a second pair of two elements of the second variable B; And For comparison, forming a smaller version of each of the first and second variables A and B using representative numbers from a mathematical sequence, wherein the difference between members of the mathematical sequence increases; Wherein each representative number for the smaller version of the first variable A is calculated from the corresponding member of the mathematical sequence whose index in the mathematical sequence is equal to the data value in the first pair of two elements of the first variable A; Each representative number used for the smaller version of the second variable B is calculated from the corresponding member of the mathematical sequence whose index in the mathematical sequence is equal to the data value in the second two-element pair of the second variable B; and Wherein, when each of the first and second variables A and B has an odd number of elements, a single element is removed from each of the first and second variables A and B before the split, and a single element from each of the first and second variables A and B is added to the smaller version of the first and second variables A and B respectively.
11. The method of claim 10, wherein the forming comprises: The representative number for the smaller version of the first variable A is calculated by adding the two values corresponding to the data values in the first pair of elements of the mathematical sequence for each element of the smaller version of the first variable A; and The representative number for the smaller version of the second variable B is calculated by adding the two corresponding data values in the second pair of elements of the mathematical sequence to each element of the smaller version of the second variable B.
12. The method of claim 10, further comprising sorting each of the first and second variables A and B, wherein the sorting of the matrix-type data variables includes: Instantiate a new variable with the same number of elements as the matrix type data variable; The matrix-type data variable is divided into multiple sub-parts equal to the number of processing threads to be used to perform the sorting; Each of the corresponding processing threads determines the position index of each element in the sub-part processed by the processing thread by comparing the value of each element in the sub-part with all other values in the matrix-type data variable, and counts how much smaller the element in the matrix-type data variable is than the compared element in the sub-part, or how much larger it is for the inverse position index. Based on the position index determined by the processing thread, the values in the new variable are replaced with values from the matrix-type data variable in either ascending or descending order; as well as Depending on whether the sorting is ascending or descending, replace any remaining unchanged values in the new variable with the values of the left or right adjacent elements in the new variable; The new variable is used as a sorted version of the matrix-type data variable.
13. The method of claim 10, comprising: Calculate the first positional variable for the first bi-element pair of the first variable A; as well as Calculate the second positional variable for the second bi-element pair of the second variable B; The calculation of each positional variable for a pair of elements includes raising the result of the Boolean condition Y > X to the power of a number equal to negative 1, where X is the first element of the pair and Y is the second element of the pair; and The formation includes Calculating a representative number for the smaller version of the first variable A by multiplying one of the first position variables by the sum of two corresponding members of the mathematical sequence that correspond to the data values in the first double-element pair of the first variable A for each element of the smaller version of the first variable A, and Calculating a representative number for the smaller version of the second variable B by multiplying one of the second position variables by the sum of two corresponding members of the mathematical sequence that correspond to the data values in the second double-element pair of the second variable B for each element of the smaller version of the second variable B.
14. The method according to claim 1, wherein the base is equal to 2, wherein the processor uses the binary system, and wherein the remainder of the exponent divided by the base is extracted by taking the last bit of the exponent.
15. The method according to claim 1, wherein the processor uses the binary system, and wherein the exponentiation of the base by the calculated exponent is performed by shifting the bit equal to 1 to the left by the number of bits equal to the calculated exponent.
16. The method according to claim 1, wherein the Boolean condition is A < B, and wherein transforming the Boolean condition into an arithmetic and / or bitwise expression of the Boolean condition includes: Subtracting B from A; Calculating the arithmetic and / or bitwise expression of the Boolean condition as the borrow value of the result of subtracting B from A.
17. The method according to claim 1, wherein providing the arithmetic and / or bitwise expression of the computer program includes: Segmenting the arithmetic and / or bitwise expression of the computer program into a plurality of segments of arithmetic and / or bitwise expressions; And wherein the segments of the arithmetic and / or bitwise expressions are configured to be executed in parallel.
18. The method according to claim 2, wherein the Boolean condition includes a subsequent task expressed as an arithmetic statement, and wherein generating the arithmetic and / or bitwise expression of the computer program includes: Multiplying the subsequent task by the arithmetic and / or bitwise expression of the Boolean condition.
19. The method according to claim 18, wherein the Boolean condition includes an alternative task expressed as an arithmetic statement, and wherein generating the arithmetic and / or bitwise expression of the computer program includes: Multiplying the alternative task by 1 minus the arithmetic and / or bitwise expression of the Boolean condition.
20. The method according to claim 2, wherein the Boolean condition includes a subsequent task expressed as a non-arithmetic statement, and wherein generating the arithmetic and / or bitwise expression of the computer program includes: Including an unconditional jump to a label associated with the arithmetic and / or bitwise expression of the Boolean condition in the arithmetic and / or bitwise expression of the computer program.
21. The method according to claim 20, wherein when the value of the arithmetic and / or bitwise expression of the Boolean condition is equal to 1, the label is equal to the start of the statement of the subsequent task.
22. The method of claim 21, wherein the Boolean condition comprises an alternative task expressed as a non-arithmic statement, wherein the label equals the start of the statement of the alternative task when the value of the arithmetic and / or bitwise expression of the Boolean condition is equal to 0.
23. The method of claim 1, wherein the method further comprises: The arithmetic and / or bitwise expression of the computer program is executed by the arithmetic and / or bitwise operation unit.
24. The method of claim 23, wherein at least the transformation is performed by a first computer, and the execution is performed by a second computer.
25. The method of claim 23, wherein the transformation and the execution are performed by the same computer.
26. A system for executing conditional statements, comprising: One or more instruction processing units, including at least one control unit, at least one arithmetic and / or bitwise operation unit, and at least one register unit; as well as One or more memory units coupled to the one or more instruction processing units; The system is configured to execute substantially all conditional statements in a computer program by using the at least one arithmetic and / or bitwise operation unit to execute the arithmetic and / or bitwise expressions of the Boolean conditions of substantially all conditional statements without using a numeric comparator, each of the conditional statements including a Boolean condition. The Boolean condition takes the first variable A and the second variable B, and the arithmetic and / or bitwise expression of the Boolean condition is obtained through the following: Subtract B from A; Calculate the absolute value of the result of subtracting B from A; The exponent is calculated based on the absolute value of the result of subtracting B from A; The exponent is calculated by raising the calculated exponent to the power of the base; and The arithmetic and / or bitwise expression of the Boolean condition is calculated based on the remainder when the exponent is divided by the base.
27. The system of claim 26, wherein the at least one control unit or separate data processing device of the system is configured to perform the operation of the method as described in any one of claims 1-25, and wherein the at least one arithmetic and / or bitwise operation unit of the processor, including the one or more instruction processing units, is configured to execute arithmetic and / or bitwise expressions of the computer program.
28. The system of claim 26, wherein the at least one arithmetic and / or bitwise operation unit comprises one or more of an arithmetic block, a bitwise shift block, and a bitwise logic block, and wherein the at least one arithmetic and / or bitwise operation unit does not include any digital comparator.
29. A method for evaluating Boolean conditions in a conditional statement, comprising: The processor accesses a computer program from a memory unit that includes the conditional statement, the conditional statement including the Boolean condition comparing a first variable A with a second variable B, wherein each of the first and second variables A and B includes matrix type data; The processor splits each of the first and second variables A and B into a first pair of double elements of the first variable A and a second pair of double elements of the second variable B, and writes the first pair of double elements and the second pair of double elements into a register or memory unit. as well as For comparison, the processor uses representative numbers from mathematical sequences to form smaller versions of each of the first and second variables A and B and writes the smaller versions of each of the first and second variables A and B into the register or the memory unit, wherein the differences between the members of the mathematical sequences are increased, wherein each representative number for the smaller version of the first variable A is calculated from the corresponding member of the mathematical sequence whose index in the mathematical sequence is equal to the data value in the first double-element pair of the first variable A, and each representative number for the smaller version of the second variable B is calculated from the corresponding member of the mathematical sequence whose index in the mathematical sequence is equal to the data value in the second double-element pair of the second variable B, and wherein when each of the first and second variables A and B has an odd number of elements, Before the split, remove a single element from each of the first and second variables A and B, and Each individual element from each of the first and second variables A and B is added to the smaller version of the first and second variables A and B, respectively; The processor compares the smaller versions of the first and second variables A and B to evaluate the Boolean condition of the conditional statement when the computer program is run.
30. The method of claim 29, wherein the forming comprises: The representative number for the smaller version of the first variable A is calculated by adding the two values corresponding to the data values in the first pair of elements of the mathematical sequence for each element of the smaller version of the first variable A; and The representative number for the smaller version of the second variable B is calculated by adding the two corresponding data values in the second pair of elements of the mathematical sequence to each element of the smaller version of the second variable B.
31. The method of claim 29, comprising: Calculate the first positional variable for the first bi-element pair of the first variable A; as well as Calculate the second positional variable for the second bi-element pair of the second variable B; The calculation of each positional variable for a pair of elements includes raising the result of the Boolean condition Y > X to the power of a number equal to negative 1, where X is the first element of the pair and Y is the second element of the pair; and The formation includes A representative number for the smaller version of the first variable A is calculated by multiplying one of the first positional variables for each element of the smaller version of the first variable A by the sum of the two corresponding data values in the first pair of elements of the mathematical sequence that correspond to the data values in the first pair of elements of the first variable A. A representative number for the smaller version of the second variable B is calculated by multiplying one of the second positional variables for each element of the smaller version of the second variable B by the sum of the two corresponding data values in the second pair of the second variable B from the corresponding member of the mathematical sequence.
32. A Boolean condition system for evaluating conditional statements, comprising: One or more instruction processing units, including at least one control unit, at least one arithmetic and / or bitwise operation unit, and at least one register unit; as well as One or more memory units coupled to the one or more instruction processing units; The one or more memory units are configured to cause the one or more instruction processing units to perform the operation of the method as described in any one of claims 29-31.
33. A method for sorting matrix-type data objects, the method comprising: Instantiate a new object with the same number of elements as the matrix type data object; Divide the matrix-type data object into multiple sub-parts equal to the number of processing threads to be used to perform the sorting; Each of the corresponding processing threads determines the position index of each element in the sub-part processed by the processing thread by comparing the value of each element in the sub-part with all other values in the matrix-type data object, and counts how much smaller the element in the matrix-type data object is than the compared element in the sub-part, or how much larger it is for the inverse position index, wherein determining includes performing the method described in any one of claims 1-11 and 13-25; Based on the position index determined by the processing thread, the values in the new object are replaced with values from the matrix type data object in either ascending or descending order; as well as Depending on whether the sorting is ascending or descending, any remaining unchanged values in the new object are replaced with the left or right adjacent element values, wherein the new object is used as a sorted version of the matrix-type data object.
34. A system for sorting matrix-type data objects, comprising: One or more instruction processing units, including at least one control unit, at least one arithmetic and / or bitwise operation unit, and at least one register unit; as well as One or more memory units coupled to the one or more instruction processing units; The one or more memory units are configured to cause the one or more instruction processing units to perform the operation of the method as described in any one of claims 33.