Single-threaded program parallel processing method

By marking and translating code segments, the control blocks are generated to achieve parallel execution, which solves the problem of low computing speed of single-threaded programs and improves the computing efficiency.

WO2025036095A1PCT designated stage expired Publication Date: 2025-02-20TAIZHOU ASKPOWER ELECTRONICS CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/106716
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-07-16
Filing Date
2024-07-22
Publication Date
2025-02-20

AI Technical Summary

Technical Problem

During the operation execution of a single-threaded program, the program paths are arranged in a continuous order, which causes the previous tasks to be processed before the subsequent tasks are executed, resulting in a low operation speed.

Method used

N code segments are identified by tagging code segments and translated into executable codes, and a control block is generated for controlling parallel execution, so as to realize parallel execution of code segments.

Benefits of technology

By processing code segments in parallel, the computing speed of a single-threaded program is improved and the execution efficiency of the program is optimized.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024106716_20022025_PF_FP_ABST
    Figure CN2024106716_20022025_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to a single-threaded program parallel processing method, which comprises the following steps: identifying N code segments on the basis of a marker for marking code segments, wherein the N code segments are configured to be executed in parallel; and translating the identified N code segments into executable codes, and generating a control block for controlling the parallel execution of the N code segments. By means of marking a source code of a single-threaded program to obtain a plurality of code segments which can be executed in parallel, and translating the N code segments into the executable codes, so as to control the parallel execution of the N code segments, single-threaded program parallel processing is realized, thus helping to reduce the program operation time.
Need to check novelty before this filing date? Find Prior Art

Description

Parallel processing method for single-threaded programs Technical Field

[0001] The present application relates to a method for parallel processing of single-threaded programs. Background Art

[0002] Single-threaded programs have the characteristics of system stability and strong scalability.

[0003] However, during the execution of a single-threaded program, the program paths taken are arranged in a continuous order, and the previous ones must be processed before the latter ones can be executed.

[0004] This results in a lower execution speed of single-threaded programs. Summary of the Invention

[0005] In order to improve the operation speed of single-threaded programs, the present application provides a single-threaded program parallel processing method.

[0006] This application provides a single-threaded program parallel processing method, which adopts the following technical solutions:

[0007] A single-threaded program parallel processing method comprises the following steps:

[0008] Identifying N code segments based on the markers for marking the code segments, the N code segments being configured to be executed in parallel;

[0009] The identified N code segments are translated into executable codes, and a control block for controlling the parallel execution of the N code segments is generated.

[0010] By adopting the above technical solution, the source code of the single-threaded program is marked to obtain multiple code segments that can be executed in parallel, and the N code segments are translated into executable code to control the parallel execution of the N code segments, thereby realizing parallel processing of the single-threaded program, which is beneficial to improving the operation speed of the single-threaded program.

[0011] Preferably, the method further comprises the following steps:

[0012] Based on the dependencies between code segments, determine whether code segments can be executed in parallel;

[0013] When it is determined that the code segment can be executed in parallel, a marker is added.

[0014] Preferably, the dependency relationship includes whether there are mutually dependent parameters, whether operations must be executed sequentially, and whether there is a causal relationship.

[0015] Preferably, the control block is used to mark when the code segment completes the operation.

[0016] By adopting the above technical solution, after the parallel processing of N code segments is completed based on the identification, the parallel processing of the next group of N code segments is executed.

[0017] Preferably, the control block is used to control the execution of a specific code segment, and the specific code segment is any executable code segment among all code segments to be executed.

[0018] By adopting the above technical solution, the time required for each operation module to execute different code segments may vary. If any operation module is idle, the idle operation module will immediately execute the subsequent code segment, thereby reducing the program operation time.

[0019] Preferably, the control block is used to determine whether the code segment is executable based on the code segment execution condition.

[0020] By adopting the above technical solution, it is possible to control the execution of a specific code segment.

[0021] In summary, this application includes at least one of the following beneficial technical effects:

[0022] 1. Mark the source code of a single-threaded program to obtain multiple code segments that can be executed in parallel, and translate N code segments into executable code to control the parallel execution of N code segments, thus realizing parallel processing of single-threaded programs and improving the operation speed of single-threaded programs;

[0023] 2. After the parallel processing of the N code segments is completed based on the identification, the parallel processing of the next group of N code segments is executed. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] FIG1 is a flow chart of a method for parallel processing of a single-threaded program in Example 1. DETAILED DESCRIPTION

[0025] The present application is further described in detail below with reference to FIG1 .

[0026] The embodiment of the present application discloses a method for parallel processing of single-threaded programs. Example 1

[0027] 1 , the single-thread program parallel processing method includes the following steps:

[0028] S10 , identifying N code segments based on the markers marking the code segments, where the N code segments are used to be executed in parallel.

[0029] Before step S10, the following steps are included:

[0030] S01, judging whether the code segments can be executed in parallel based on the dependency relationship between the code segments.

[0031] Dependencies include whether there are mutually dependent parameters, whether operations must be performed one after another, whether there is a causal relationship, etc.

[0032] For example, in a single-threaded program, it includes code segment 1: A=a1+a2; code segment 2: B=b1+b2; code segment 3: C=A+…;…

[0033] If a1 and a2 are not associated with b1 and b2 respectively, it is determined that there is no dependency between code segment 1 and code segment 2, and furthermore, it is determined that code segment 1 and code segment 2 can be executed in parallel.

[0034] For example: In a single-threaded program, it includes code segment 1: A=a1+a2; code segment 2: B=A+b2; code segment 3: C=A+…;…

[0035] It is determined that there is a dependency relationship between code segment 1 and code segment 2, and further determined that code segment 1 and code segment 2 cannot be executed in parallel.

[0036] Moreover, when making judgments, the system mainly relies on automatic judgment by the program; if necessary, it can be assisted by manual judgment.

[0037] S02: When it is determined that the code segments can be executed in parallel, a marker is added.

[0038] For example, you can use the coroutine marker to mark code segments that can be executed in parallel; you can also use async, etc., as long as you can mark these code segments as being able to be executed in parallel.

[0039] S20 , translating the identified N code segments into executable codes, and generating a control block for controlling the parallel execution of the N code segments.

[0040] Specifically, multiple cores of the control processor are controlled to execute N code segments respectively, so as to realize the control of parallel execution of N code segments.

[0041] At the same time, the control block is used to mark when the code segment completes the operation, and when the number of marks is equal to N, it is determined that all N code segments have completed the operation.

[0042] It is used to implement parallel processing of the next group of N code segments after completing the parallel processing of N code segments.

[0043] The implementation principle of a single-threaded program parallel processing method in an embodiment of the present application is: based on the dependency relationship between code segments, the source code of the single-threaded program is marked to obtain multiple code segments that can be executed in parallel, and the N code segments are translated into executable code to control the parallel execution of the N code segments, thereby realizing the parallel processing of the single-threaded program, which is beneficial to improving the operation speed of the single-threaded program. Example 2

[0044] The difference between this embodiment and embodiment 1 is that the control block is used to determine whether the code segment is executable based on the code segment execution condition. The control block is used to control the execution of a specific code segment, which is any executable code segment among all code segments to be executed.

[0045] The execution conditions of a code segment include dependency, causal relationship, data relationship, etc. with the executing code segment.

[0046] Specifically, the control block controls multiple cores of the processor to execute N code segments respectively;

[0047] When a core is in an idle state (or ready to execute the next code segment), the control block is used to control the core to execute any executable code segment among all the code segments to be executed.

[0048] The control block is used to mark when the code segment completes the operation, and whether the core is in an idle state can be determined based on the mark. Example 3

[0049] The difference between this embodiment and embodiment 2 is that:

[0050] The control block is used to control the execution of a specific code segment when M identifiers are detected, where 1≤M<N;

[0051] The control block is used to control the execution of the next group of N specific code segments in a parallel processing manner when N identifiers are detected.

[0052] The above are all preferred embodiments of the present application, and are not intended to limit the scope of protection of the present application. Therefore, any equivalent changes made based on the structure, shape, and principle of the present application should be included in the scope of protection of the present application.

Claims

1. A single-thread program parallel processing method, characterized in that: The following steps are involved: Identify N code segments based on the markers marking the code segments, and the N code segments are used to be executed in parallel; The identified N code segments are translated into executable codes, and a control block for controlling the parallel execution of the N code segments is generated.

2. The single-thread program parallel processing method according to claim 1, characterized in that: The following steps are also included: Based on the dependencies between code segments, determine whether the code segments can be executed in parallel; When it is determined that the code segments can be executed in parallel, the marker is added.

3. The single-thread program parallel processing method according to claim 2, characterized in that: The dependency relationship includes whether there are mutually dependent parameters, whether operations must be performed one after another, and whether there is a causal relationship.

4. The single-thread program parallel processing method according to claim 1, characterized in that: The control block is used to mark when the code segment completes the operation.

5. The single-thread program parallel processing method according to claim 1, characterized in that: The control block is used to control the execution of a specific code segment, where the specific code segment is any executable code segment among all code segments to be executed.

6. The single-thread program parallel processing method according to claim 5, characterized in that: The control block is used to determine whether the code segment is executable based on the code segment execution condition.

Citation Information

Patent Citations

  • Realization method for parallelization of single-threading program based on analysis of data flow

    CN101515231A

  • Deeply parallel source code compilation

    CN105308565A

  • Code compiler, code compiling method, code compiling system and computer medium

    CN113791770A

  • Method for Parallelizing Execution of Single Thread Programs

    US20090165016A1

  • System and Method of Automatically Transforming Serial Streaming Programs Into Parallel Streaming Programs

    US20110010690A1