Task allocation method and device, readable storage medium and program product
By customizing the specified task flow and flow configuration information, the problem of poor task allocation flexibility in asynchronous execution is solved, and tasks are flexibly allocated and efficiently executed on the specified task flow.
Patent Information
- Application Number
- CN202410688432.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2025-12-02
AI Technical Summary
The existing asynchronous execution process suffers from poor task allocation flexibility, leading to resource waste and low execution efficiency.
By obtaining the file to be executed, and determining that the target task supports asynchronous execution, a custom task flow is specified. The flow configuration information and runtime data are determined based on the file to be executed and sent to the second processor to execute the task on the specified task flow.
It enables flexible task allocation, avoiding the problem of poor flexibility in traditional asynchronous execution where tasks can only be allocated to the default task flow, thus improving the flexibility of task allocation and execution efficiency.
Smart Images

Figure CN121050869A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a task allocation method, apparatus, readable storage medium, and program product. Background Technology
[0002] With the development of computer technology, asynchronous execution has emerged. Asynchronous execution refers to processing multiple different tasks or operations in parallel without waiting for each individual task to complete before starting the next, thus improving task execution efficiency. Taking kernel functions as an example, multiple kernel functions can be executed in parallel through asynchronous execution.
[0003] However, the current asynchronous execution process suffers from poor task allocation flexibility. Summary of the Invention
[0004] Therefore, it is necessary to provide a task allocation method, device, readable storage medium, and program product that can improve the flexibility of task allocation in response to the above-mentioned technical problems.
[0005] In a first aspect, this application provides a task allocation method for a first processor, comprising:
[0006] Obtain the executable file and determine the target task to be executed based on the executable file;
[0007] If the target task is determined to support asynchronous execution, a specified task flow corresponding to the target task is determined.
[0008] Based on the file to be executed, determine the flow configuration information of the specified task flow and the running data of the target task, and send the flow configuration information and running data to the second processor. The flow configuration information and running data are used by the second processor to execute the target task on the specified task flow.
[0009] In the above embodiments, the target task to be executed can be obtained through the file to be executed. If the target task supports asynchronous execution, a designated task flow is determined for the target task. This designated task flow can be a customized task flow based on the specific application requirements. The flow configuration information corresponding to the designated task flow and the running data corresponding to the target task are determined according to the file to be executed, so that the target task can be flexibly assigned to the designated task flow for execution. This avoids the problem of poor flexibility in traditional asynchronous execution processes where the target task can only be assigned to the default task flow for execution. The technical solution provided by the embodiments of this application has higher flexibility in task allocation.
[0010] In one embodiment, the flow configuration information of the specified task flow is determined based on the file to be executed, including:
[0011] Based on the file to be executed, determine the first stream identifier corresponding to the default task flow of the target task, and obtain the stream handle corresponding to the default task flow based on the first stream identifier;
[0012] Determine the flow configuration information based on the flow handle.
[0013] In the above embodiments, the flow configuration information is confirmed through the handle. Due to the advantages of the handle itself, such as the fact that the handle usually manages the flow resources by calling the interface, the security of task allocation is improved.
[0014] In one embodiment, determining the stream configuration information based on the stream handle includes:
[0015] Based on the preset configuration relationship, obtain the second stream identifier corresponding to the specified task flow;
[0016] If the first stream identifier is different from the second stream identifier, the stream handle is configured to the specified task stream based on the second stream identifier and the stream handle, and the stream handle is used as the stream configuration information.
[0017] In the above embodiments, when the first stream identifier and the specified task stream identifier are different, it is determined that the specified task stream is not the default task stream. At this time, the first processor configures the stream handle to the specified task stream according to the stream handle and the second stream identifier, generates stream configuration information, so that the second processor can run the target task on the specified task stream according to the stream configuration information, thereby realizing flexible task allocation.
[0018] In one embodiment, configuring a stream handle to a specified task stream based on a second stream identifier and a stream handle includes:
[0019] Store the association between the second stream identifier, stream handle, and preset label in a preset storage location;
[0020] The preset label is used to indicate that the priority of the specified task flow corresponding to the second flow identifier is higher than the priority of the default task flow.
[0021] In this way, after the second processor obtains the stream configuration information including the stream handle, it can query the task flow corresponding to the stream handle from the preset storage location. The preset storage location may be memory, the preset hard disk, etc. If the specified task flow is not the default task flow, the second processor may query the association between the stream handle and the default task flow, as well as the association between the stream handle and the specified task flow. At this time, the second processor can determine the specified task flow by judging whether the association includes a preset tag. The judgment logic is simple and improves the efficiency of determining the specified task flow.
[0022] In one embodiment, the association between the second stream identifier, the stream handle, and the preset tag is stored in a preset storage location, including:
[0023] Determine whether the stream handle is valid based on preset judgment conditions;
[0024] If the stream handle is valid, the association between the second stream identifier, the stream handle, and the preset label is stored in the preset storage location.
[0025] In the above embodiments, if the stream handle is confirmed to be valid, the association between the second stream identifier, the stream handle, and the preset tag is stored in a preset storage location, thus ensuring the correctness of the task allocation process.
[0026] In one embodiment, the method further includes:
[0027] If the first stream identifier is the same as the second stream identifier, then the stream handle is used as the stream configuration information.
[0028] In the above embodiments, when the first task flow identifier and the second task flow identifier are the same, the first processor can determine the specified task flow, i.e. the default task flow. The first processor directly uses the flow handle as the flow configuration information, avoiding the process of generating configuration information and improving the efficiency of task allocation.
[0029] In one embodiment, the method further includes:
[0030] Determine the code segment corresponding to the target task based on the file to be executed;
[0031] If the code segment includes preset fields, then the target task is determined to support asynchronous execution;
[0032] If the code segment does not include the preset fields, then the target task does not support asynchronous execution.
[0033] In the above embodiments, the determination of whether the target task supports asynchronous execution is made by judging whether the code segment corresponding to the target task includes a preset field. The judgment condition is simple and the judgment process is highly efficient.
[0034] Secondly, this application provides a task allocation method for a second processor, the method comprising:
[0035] Receive the stream configuration information and runtime data sent by the first processor. The stream configuration information and runtime data are sent by the first processor after determining that the target task supports asynchronous execution.
[0036] The specified task flow is determined based on the flow configuration information, and the target task to be executed is determined based on the runtime data.
[0037] Execute the target task on the specified task flow.
[0038] In the above embodiments, the second processor determines the designated task flow based on the flow configuration information sent by the first processor, and determines the target task to be executed based on the running data, so that the target task can be run on the designated task flow, realizing flexible allocation of the target task.
[0039] In one embodiment, the stream configuration information includes a stream handle, and determining a specified task stream based on the stream configuration information includes:
[0040] Based on the stream handle, query the association relationship corresponding to the stream handle in the preset storage location. The association relationship includes at least the correspondence between the stream handle and the stream identifier.
[0041] If there are multiple associations, then the target association including the preset label is determined from each association, and the specified task flow corresponding to the flow identifier included in the target association is taken as the specified task flow.
[0042] In the above embodiments, when there are multiple associations, it is determined that the specified task flow is different from the default task flow. At this time, the second processor filters out the target association based on whether the association includes a preset tag, thereby determining the specified task flow. The determination logic is simple and improves the efficiency of determining the specified task flow.
[0043] In one embodiment, the method further includes:
[0044] If there is only one association, then the default task flow corresponding to the flow identifier included in the association will be used as the specified task flow.
[0045] In the above embodiments, when there is only one association relationship, if the specified task flow is determined to be the same as the default task flow, the second processor directly uses the task flow corresponding to the association relationship as the specified task flow, thus avoiding the process of determining the specified task flow and improving the efficiency of determining the specified task flow.
[0046] Thirdly, this application provides a task allocation apparatus for a first processor, comprising:
[0047] The acquisition module is used to acquire the file to be executed and determine the target task to be executed based on the file.
[0048] The determination module is used to determine the specified task flow corresponding to the target task, provided that the target task supports asynchronous execution.
[0049] The allocation module is used to determine the flow configuration information of the specified task flow and the running data of the target task based on the file to be executed, and send the flow configuration information and running data to the second processor. The flow configuration information and running data are used by the second processor to execute the target task on the specified task flow.
[0050] Fourthly, this application provides a task allocation apparatus for a first server, comprising:
[0051] The receiving module is used to receive the stream configuration information and running data sent by the first processor. The stream configuration information and running data are sent by the first processor after determining that the target task supports asynchronous execution.
[0052] The configuration module is used to determine the specified task flow based on the flow configuration information and to determine the target task to be executed based on the running data.
[0053] The execution module is used to execute the target task on the specified task flow.
[0054] Fifthly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the method described in the first or second aspect above.
[0055] Sixthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the method described in the first or second aspect above.
[0056] In a seventh aspect, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the method described in the first or second aspect above.
[0057] The aforementioned task allocation method, device, readable storage medium, and program product, by acquiring an executable file, can determine the target task to be executed based on the executable file. If the target task supports asynchronous execution, a designated task flow corresponding to the target task is determined. Based on the executable file, the flow configuration information of the designated task flow and the runtime data of the target task are determined, and the flow configuration information and runtime data are sent to a second processor. The flow configuration information and runtime data are used by the second processor to execute the target task on the designated task flow. In this way, the target task to be executed can be obtained through the executable file. If the target task supports asynchronous execution, a designated task flow to be allocated to the target task is determined. This designated task flow can be a customized task flow based on the specific application requirements. Determining the flow configuration information corresponding to the designated task flow and the runtime data corresponding to the target task based on the executable file allows the target task to be flexibly allocated to the designated task flow for execution. This avoids the problem of poor flexibility in traditional asynchronous execution processes where the target task can only be allocated to the default task flow. The technical solution provided in this application provides higher flexibility in task allocation. Attached Figure Description
[0058] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0059] Figure 1 A schematic diagram of a traditional task allocation method;
[0060] Figure 2 This is an application environment diagram of the task allocation method in one embodiment;
[0061] Figure 3 This is a flowchart illustrating a task allocation method for a first processor in one embodiment;
[0062] Figure 4 This is a flowchart illustrating step 303 in another embodiment;
[0063] Figure 5 This is a flowchart illustrating step 403 in another embodiment;
[0064] Figure 6 This is a flowchart illustrating a task allocation method for a second processor in one embodiment;
[0065] Figure 7 This is a flowchart illustrating an exemplary task allocation method in one embodiment;
[0066] Figure 8 This is an illustration of the application effect of the task allocation method in another embodiment;
[0067] Figure 9 This is a structural block diagram of a task allocation device for a first processor in one embodiment;
[0068] Figure 10 This is a structural block diagram of a task allocation device for a second processor in one embodiment;
[0069] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0070] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0071] With the development of computer technology, asynchronous execution has emerged. Asynchronous execution refers to processing multiple different tasks or operations in parallel without waiting for each individual task to complete before starting the next, thus improving task execution efficiency. Taking kernel functions as an example, multiple kernel functions can be executed in parallel through asynchronous execution.
[0072] The asynchronous execution of a target often involves task allocation. Existing task allocation typically utilizes the task flow management function in CUDA (Compute Unified Device Architecture) to allocate tasks to corresponding task flows for execution, thereby enabling the asynchronous execution of multiple tasks.
[0073] However, CUDA was developed by NVIDIA and is only applicable to NVIDIA GPUs (Graphics Processing Units). In order to perform asynchronous tasks on more platforms, related technologies have introduced task flow management functions into the open MP (Open Multi-Processing) model in the LLVM compilation environment (Low Level Virtual Machine).
[0074] However, in the OpenMP model, tasks can only be assigned to the default task flow for execution, see reference. Figure 1 This diagram illustrates the asynchronous execution of tasks in the traditional OpenMP model. Taking a kernel function as an example, the task flow corresponding to each kernel function is a pre-set default task flow. Directly assigning each task flow to the default task flow results in poor task allocation flexibility. It may happen that some task flows have already completed the execution of the previous kernel function, but other kernel functions can only be executed when the next kernel function is executed, resulting in wasted resources.
[0075] In view of this, embodiments of this application provide a task allocation method, device, readable storage medium, and program product. By obtaining an executable file, the target task to be executed can be determined based on the executable file. If the target task supports asynchronous execution, a designated task flow corresponding to the target task is determined. Based on the executable file, the flow configuration information of the designated task flow and the running data of the target task are determined, and the flow configuration information and running data are sent to a second processor. The flow configuration information and running data are used by the second processor to execute the target task on the designated task flow. In this way, the target task to be executed can be obtained through the executable file. If the target task supports asynchronous execution, a designated task flow to be allocated to the target task is determined. This designated task flow can be a customized task flow based on the specific application requirements. The flow configuration information corresponding to the designated task flow and the running data corresponding to the target task are determined based on the executable file, allowing the target task to be flexibly allocated to the designated task flow for execution. This avoids the problem of poor flexibility in traditional asynchronous execution processes where the target task can only be allocated to the default task flow. The technical solution provided by embodiments of this application offers higher flexibility in task allocation.
[0076] The task allocation method provided in this application embodiment can be applied to, for example, Figure 2 In the application environment shown, the first processor 201 and the second processor 202 are deployed in the same computer device, which may be a server. The first processor 201 and the second processor 202 can communicate with each other. The first processor may be a CPU (Central Processing Unit) or other processors, and the second processor may be a processor other than the first processor.
[0077] In one exemplary embodiment, such as Figure 3 As shown, a task allocation method is provided, which can be applied to... Figure 1 Taking the first processor 201 as an example, the explanation includes the following steps 301 to 303. Wherein:
[0078] Step 301: Obtain the executable file and determine the target task to be executed based on the executable file.
[0079] The executable file may be a file containing at least one task waiting to be executed. Optionally, the first processor may obtain the executable file input to the first processor through other external input devices; alternatively, the first processor may obtain the task to be executed from a preset storage space.
[0080] The target task is the task that the first processor is currently executing. In this embodiment, the target task may be a kernel function. Optionally, the first processor may obtain a task sequence table corresponding to the executable file based on the executable file, and determine the target task to be executed from multiple tasks by looking up the table. Optionally, the first processor may determine the target task in a preset order.
[0081] Step 302: If it is determined that the target task supports asynchronous execution, determine the specified task flow corresponding to the target task.
[0082] Asynchronous execution refers to processing multiple different tasks or operations in parallel. In this embodiment, when the first processor executes the target task, it needs to determine whether the target task supports asynchronous execution.
[0083] In one possible implementation, the first processor can obtain a confirmation command input by the user through an external input device, and confirm whether the target task supports asynchronous execution based on the confirmation command.
[0084] In another possible implementation, the first processor can determine the code segment corresponding to the target task based on the file to be executed. If the code segment includes a preset field, it is determined that the target task supports asynchronous execution. If the code segment does not include the preset field, it is determined that the target task does not support asynchronous execution.
[0085] In this embodiment of the application, if the first processor determines that the target task supports asynchronous execution, it can determine the specified task flow corresponding to the target task, thereby facilitating the subsequent allocation of the target task to the specified task flow for execution.
[0086] A task flow is the execution sequence of a second processor when executing a task. In this embodiment, the second processor has established multiple preset task flows. When a target task is created, a task flow, i.e. a default task flow, is assigned to it according to the execution order of the target task. In order to achieve flexible task allocation, in one possible implementation, the first processor can reallocate a specified task flow to the target task according to the actual application requirements. The specified task flow can be the default task flow or a task flow other than the default task flow.
[0087] Regarding the method by which the first processor determines the specified task flow, optionally, the first processor can obtain an allocation instruction through an external input device, which carries a flow identifier of the specified task flow, and the first processor can determine the specified task flow based on the flow identifier; alternatively, the first processor can obtain a task configuration table from a database, which stores the configuration information of the target task, including the flow identifier of the specified task flow, and the first processor can determine the specified task flow based on the identifier.
[0088] Step 303: Based on the file to be executed, determine the flow configuration information of the specified task flow and the running data of the target task, and send the flow configuration information and running data to the second processor.
[0089] The stream configuration information and runtime data are used by the second processor to execute the target task on the specified task stream.
[0090] In one possible implementation, the stream configuration information is used by the second processor to determine the specified task stream based on the stream configuration information, and the runtime data is used by the second processor to determine the code segment and configuration parameters corresponding to the target task based on the runtime data. In this way, the second processor can execute the target task on the specified task stream based on the stream configuration information and the runtime data.
[0091] Optionally, the first processor can use the stream identifier corresponding to the specified task stream as the stream configuration information. Alternatively, the first processor can obtain the stream handle corresponding to the specified task stream from memory based on the stream identifier corresponding to the specified task stream, and use the stream handle as the stream configuration information.
[0092] In the above embodiments, the target task to be executed can be obtained through the file to be executed. If the target task supports asynchronous execution, a designated task flow is determined for the target task. This designated task flow can be a customized task flow based on the specific application requirements. The flow configuration information corresponding to the designated task flow and the running data corresponding to the target task are determined according to the file to be executed, so that the target task can be flexibly assigned to the designated task flow for execution. This avoids the problem of poor flexibility in traditional asynchronous execution processes where the target task can only be assigned to the default task flow for execution. The technical solution provided by the embodiments of this application has higher flexibility in task allocation.
[0093] In one embodiment, based on the above Figure 3 The illustrated embodiment can be found in [reference]. Figure 4 This embodiment relates to the process of determining the flow configuration information of a specified task flow based on the file to be executed. For example... Figure 4 As shown, step 303 may include steps 401 and 402.
[0094] Step 401: Based on the file to be executed, determine the first stream identifier corresponding to the default task flow of the target task, and obtain the stream handle corresponding to the default task flow based on the first stream identifier.
[0095] Different task flows correspond to different flow identifiers. The first flow identifier corresponds to the default task flow. In this embodiment, the first processor can determine the first flow identifier based on the file to be executed. Optionally, the first processor can determine the execution order of the target task by counting the number of tasks executed in the file to be executed, and determine the first flow identifier corresponding to the default task flow based on the execution order. For example, if the default task flow corresponding to the second executed task is flow 2, then the first flow identifier corresponding to the default task flow is 2. Optionally, the first processor can determine the execution order of the target task by counting the number of tasks that need to be executed before the target task in the file to be executed, and determine the first flow identifier corresponding to the default task flow based on the execution order.
[0096] After obtaining the first stream identifier, the first processor can retrieve the stream handle corresponding to the default task stream from the preset storage space based on the first stream identifier.
[0097] Step 402: Determine the flow configuration information based on the flow handle.
[0098] In one possible implementation, the designated task flow is the default task flow. In this case, the first processor can directly use the flow handle as flow configuration information. In another possible implementation, the first processor determines that the designated task flow is another task flow different from the default task flow. In this case, the first processor can establish an association between the flow handle and other task flows and use the association as flow configuration information so that the second processor can determine the designated task flow based on the association.
[0099] In the above embodiments, the flow configuration information is confirmed through the handle. Due to the advantages of the handle itself, such as the fact that the handle usually manages the flow resources by calling the interface, the security of task allocation is improved.
[0100] In one embodiment, based on the above Figure 4 The illustrated embodiment can be found in [reference]. Figure 5 This embodiment relates to the process of determining flow configuration information based on the flow handle. For example... Figure 5 As shown, step 403 may include steps 501 and 502.
[0101] Step 501: Obtain the second stream identifier corresponding to the specified task flow according to the preset configuration relationship.
[0102] Step 502: If the first stream identifier is different from the second stream identifier, then the stream handle is configured to the specified task stream according to the second stream identifier and the stream handle, and the stream handle is used as the stream configuration information.
[0103] The first processor needs to determine whether the specified task flow is the default task flow. Regarding the determination process, in this embodiment, the first processor can obtain a preset configuration relationship, which includes the second flow identifier corresponding to the target task and the specified task flow. Optionally, the first processor can obtain a configuration instruction through an external input device, which includes the configuration relationship. Optionally, the first processor can obtain a task configuration table from a database, which stores the configuration relationship corresponding to the target task.
[0104] After the first processor obtains the configuration relationship, it can determine the second stream identifier corresponding to the specified task flow.
[0105] In one possible implementation, if the first stream identifier is the same as the second stream identifier, then the stream handle is used as stream configuration information.
[0106] If the first task flow identifier and the second task flow identifier are the same, the first processor can determine the specified task flow, i.e. the default task flow, and the first processor can directly use the flow handle as the flow configuration information.
[0107] In another possible implementation, if the first stream identifier is different from the second stream identifier, the first processor can determine that the specified task flow is not the default task flow. In this case, the first processor can configure the stream handle to the specified task flow according to the second stream identifier and the stream handle.
[0108] Optionally, the first processor may store the association between the second stream identifier, the stream handle, and the preset label in a preset storage location, wherein the preset label is used to indicate that the priority of the specified task stream corresponding to the second stream identifier is higher than the priority of the default task stream.
[0109] In this way, after the second processor obtains the stream configuration information including the stream handle, it can query the task stream corresponding to the stream handle from the preset storage location. The preset storage location may be memory, or a preset hard disk, etc.
[0110] If the specified task flow is not the default task flow, the second processor may query the association between the flow handle and the default task flow, as well as the association between the flow handle and the specified task flow. At this time, the second processor can determine whether the association includes a preset tag. If it does, the second processor can determine that the task flow corresponding to the association is the specified task flow and has a higher priority. The second processor can then run the target task on the specified personnel flow according to the association.
[0111] In one possible implementation, in order to ensure the correctness of the task allocation process, the first processor may also determine whether the stream handle is valid according to a preset judgment condition. If the stream handle is valid, the association between the second stream identifier, the stream handle and the preset label is stored in a preset storage location.
[0112] The preset judgment condition can be a preset field format. Optionally, if the stream handle conforms to the preset field format, the first processor can determine that the stream handle is valid; alternatively, if it does not conform, the first processor determines that the stream handle is invalid. In one possible implementation, the first processor can also generate an error message, which is used to indicate that the stream handle is invalid.
[0113] In the above embodiments, when the first stream identifier and the specified task stream identifier are different, it is determined that the specified task stream is not the default task stream. At this time, the first processor configures the stream handle to the specified task stream according to the stream handle and the second stream identifier, generates stream configuration information, so that the second processor can run the target task on the specified task stream according to the stream configuration information, thereby realizing flexible task allocation.
[0114] In one embodiment, such as Figure 6 As shown, a task allocation method is provided, which can be applied to... Figure 2 Taking the second processor 202 as an example, the explanation includes the following steps:
[0115] Step 601: Receive the stream configuration information and running data sent by the first processor.
[0116] Among them, the stream configuration information and runtime data are sent by the first processor after determining that the target task supports asynchronous execution.
[0117] Step 602: Determine the specified task flow based on the flow configuration information, and determine the target task to be executed based on the running data.
[0118] Step 603: Execute the target task on the specified task flow.
[0119] The stream configuration information is used by the second processor to determine the specified task stream based on the stream configuration information, and the runtime data is used by the second processor to determine the code segment and configuration parameters corresponding to the target task based on the runtime data. The process of determining the stream configuration information and runtime data can be referred to the above embodiment, and will not be repeated here.
[0120] After receiving the stream configuration information and running data, the second processor can determine the specified task stream based on the stream configuration information. In this embodiment, the stream configuration information includes a stream handle. The second processor can query the association relationship corresponding to the stream handle in a preset storage location based on the stream handle. The association relationship includes at least the correspondence between the stream handle and the stream identifier. The second processor can determine the stream identifier corresponding to the stream handle based on the stream handle, and then determine the specified task stream corresponding to the stream identifier based on the stream identifier.
[0121] In one possible implementation, if there are multiple associations, it indicates that the specified task flow is different from the default task flow. The second processor can determine the target association including the preset tag from each association and use the specified task flow corresponding to the flow identifier included in the target association as the specified task flow. The preset tag is used to give the priority of the task flow corresponding to the target association higher than the priority of other task flows.
[0122] In another possible implementation, if the number of associations is one, it means that the specified task flow is the same as the default task flow, and the second processor will use the default task flow corresponding to the flow identifier included in the association as the specified task flow.
[0123] In the above embodiments, the second processor determines the designated task flow based on the flow configuration information sent by the first processor, and determines the target task to be executed based on the running data, so that the target task can be run on the designated task flow, realizing flexible allocation of the target task.
[0124] In one embodiment, please refer to Figure 7 It illustrates a flowchart of an exemplary task allocation method provided in an embodiment of this application, which can be applied to... Figure 2 The implementation environment shown.
[0125] Step 701: The first processor obtains the executable file and determines the target task to be executed based on the executable file.
[0126] Step 702: The first processor determines the code segment corresponding to the target task based on the file to be executed.
[0127] Step 703: If the code segment of the first processor includes a preset field, then it is determined that the target task supports asynchronous execution.
[0128] Step 704: If the first processor determines that the target task supports asynchronous execution, it determines the specified task flow corresponding to the target task.
[0129] Step 705: The first processor determines the first stream identifier corresponding to the default task flow of the target task based on the file to be executed, and obtains the stream handle corresponding to the default task flow based on the first stream identifier.
[0130] Step 706: The first processor obtains the second stream identifier corresponding to the specified task stream according to the preset configuration relationship.
[0131] Step 707: If the first stream identifier is different from the second stream identifier, the first processor determines whether the stream handle is valid according to preset judgment conditions.
[0132] Step 708: If the stream handle is valid, the first processor stores the association between the second stream identifier, the stream handle, and the preset tag in a preset storage location.
[0133] The preset label is used to indicate that the priority of the specified task flow corresponding to the second flow identifier is higher than the priority of the default task flow.
[0134] Step 709: The first processor uses the stream handle as stream configuration information.
[0135] Step 710: If the first stream identifier is the same as the second stream identifier, the first processor uses the stream handle as stream configuration information.
[0136] Step 711: The first processor determines the running data of the target task based on the file to be executed, and sends the stream configuration information and running data to the second processor.
[0137] The stream configuration information and runtime data are used by the second processor to execute the target task on the specified task stream.
[0138] Step 712: The second processor receives the stream configuration information and running data sent by the first processor.
[0139] Among them, the stream configuration information and runtime data are sent by the first processor after determining that the target task supports asynchronous execution.
[0140] The stream configuration information includes the stream handle.
[0141] Step 713: The second processor queries the association relationship corresponding to the stream handle in a preset storage location based on the stream handle. The association relationship includes at least the correspondence between the stream handle and the stream identifier.
[0142] Step 714: If there are multiple associations, the second processor determines the target association including the preset label from each association and uses the task flow corresponding to the flow identifier included in the target association as the specified task flow.
[0143] Step 715: If the number of associations is one, the second processor will use the default task flow corresponding to the flow identifier included in the association as the specified task flow.
[0144] Step 716: The second processor determines the target task to be executed based on the running data.
[0145] Step 717: The second processor executes the target task on the specified task flow.
[0146] Based on the above Figure 7 The illustrated embodiment refers to Figure 8 To illustrate the execution process of the stream after task allocation using the task allocation method provided in this application embodiment, it can be seen that, compared with... Figure 1 Unlike traditional allocation methods, the task allocation method provided in this application embodiment enables tasks to run flexibly on a specified flow.
[0147] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0148] Based on the same inventive concept, this application also provides a task allocation device for implementing the task allocation method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more task allocation device embodiments provided below can be found in the limitations of the task allocation method described above, and will not be repeated here.
[0149] In one exemplary embodiment, such as Figure 9 As shown, a task allocation device is provided for a first processor, comprising: an acquisition module 901, a determination module 902, and an allocation module 903, wherein:
[0150] The acquisition module 901 is used to acquire the file to be executed and determine the target task to be executed based on the file to be executed;
[0151] The determining module 902 is used to determine a specified task flow corresponding to the target task when it is determined that the target task supports asynchronous execution;
[0152] The allocation module 903 is used to determine the flow configuration information of the specified task flow and the running data of the target task according to the file to be executed, and send the flow configuration information and the running data to the second processor. The flow configuration information and the running data are used by the second processor to execute the target task on the specified task flow.
[0153] In one embodiment, the allocation module 903 includes:
[0154] The handle determination unit is used to determine the first stream identifier corresponding to the default task flow of the target task based on the file to be executed, and to obtain the stream handle corresponding to the default task flow based on the first stream identifier.
[0155] The configuration information determination unit is used to determine the flow configuration information based on the flow handle.
[0156] In one embodiment, the configuration information determining unit is further configured to perform the following steps:
[0157] Based on the preset configuration relationship, obtain the second stream identifier corresponding to the specified task stream;
[0158] If the first stream identifier is different from the second stream identifier, then the stream handle is configured to the specified task stream according to the second stream identifier and the stream handle, and the stream handle is used as the stream configuration information.
[0159] In one embodiment, the configuration information determining unit is further configured to perform the following steps:
[0160] The association between the second stream identifier, the stream handle, and the preset tag is stored in a preset storage location;
[0161] The preset label is used to indicate that the priority of the specified task flow corresponding to the second flow identifier is higher than the priority of the default task flow.
[0162] In one embodiment, the configuration information determining unit is further configured to perform the following steps:
[0163] The validity of the stream handle is determined based on preset judgment conditions.
[0164] If the stream handle is valid, the association between the second stream identifier, the stream handle, and the preset tag is stored in the preset storage location.
[0165] In one embodiment, the configuration information determining unit is further configured to perform the following steps:
[0166] If the first stream identifier is the same as the second stream identifier, then the stream handle is used as the stream configuration information.
[0167] In one embodiment, the apparatus further includes:
[0168] The code segment determination module is used to determine the code segment corresponding to the target task based on the file to be executed.
[0169] An asynchronous execution determination module is used to determine that the target task supports asynchronous execution if the code segment includes a preset field.
[0170] A non-asynchronous execution module is used to determine that the target task does not support asynchronous execution if the preset field is not included in the code segment.
[0171] Each module in the aforementioned task allocation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0172] In one exemplary embodiment, such as Figure 10 As shown, a task allocation device is provided for a second processor, comprising: a receiving module 1001, a configuration module 1002, and an execution module 1003, wherein:
[0173] The receiving module 1001 is used to receive stream configuration information and running data sent by the first processor, wherein the stream configuration information and the running data are sent by the first processor when it is determined that the target task supports asynchronous execution;
[0174] The configuration module 1002 is used to determine a specified task flow based on the flow configuration information and to determine the target task to be executed based on the running data.
[0175] The execution module 1003 is used to execute the target task on the specified task flow.
[0176] In one embodiment, the stream configuration information includes a stream handle, and the configuration module 1002 includes:
[0177] The relationship query unit is used to query the association relationship corresponding to the stream handle in a preset storage location based on the stream handle, and the association relationship includes at least the correspondence between the stream handle and the stream identifier;
[0178] The target relationship determination unit is used to determine, if there are multiple relationships, a target relationship including a preset label from each of the relationships, and to use the task flow corresponding to the flow identifier included in the target relationship as the designated task flow.
[0179] In one embodiment, the configuration module 1002 further includes:
[0180] A default unit is used to select the default task flow corresponding to the flow identifier included in the association as the specified task flow if the number of associations is one.
[0181] Each module in the aforementioned task allocation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0182] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores task allocation data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a task allocation method.
[0183] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0184] In one exemplary embodiment, a computer device is provided, including a memory and a processor, the processor being a first processor, and the memory storing a computer program, the processor executing the computer program to perform the following steps:
[0185] Obtain the executable file and determine the target task to be executed based on the executable file;
[0186] If it is determined that the target task supports asynchronous execution, a specified task flow corresponding to the target task is determined;
[0187] Based on the file to be executed, the flow configuration information of the specified task flow and the running data of the target task are determined, and the flow configuration information and the running data are sent to the second processor. The flow configuration information and the running data are used by the second processor to execute the target task on the specified task flow.
[0188] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0189] Based on the file to be executed, determine the first stream identifier corresponding to the default task flow of the target task, and obtain the stream handle corresponding to the default task flow based on the first stream identifier;
[0190] The flow configuration information is determined based on the flow handle.
[0191] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0192] Based on the preset configuration relationship, obtain the second stream identifier corresponding to the specified task stream;
[0193] If the first stream identifier is different from the second stream identifier, then the stream handle is configured to the specified task stream according to the second stream identifier and the stream handle, and the stream handle is used as the stream configuration information.
[0194] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0195] The association between the second stream identifier, the stream handle, and the preset tag is stored in a preset storage location;
[0196] The preset label is used to indicate that the priority of the specified task flow corresponding to the second flow identifier is higher than the priority of the default task flow.
[0197] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0198] The validity of the stream handle is determined based on preset judgment conditions.
[0199] If the stream handle is valid, the association between the second stream identifier, the stream handle, and the preset tag is stored in the preset storage location.
[0200] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0201] If the first stream identifier is the same as the second stream identifier, then the stream handle is used as the stream configuration information.
[0202] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0203] The code segment corresponding to the target task is determined based on the file to be executed;
[0204] If the code segment includes a preset field, then the target task is determined to support asynchronous execution;
[0205] If the preset field is not included in the code segment, then the target task is determined to be non-asynchronous.
[0206] In one exemplary embodiment, a computer device is provided, including a memory and a processor, the processor being a second processor, and the memory storing a computer program, the processor executing the computer program to perform the following steps:
[0207] The system receives stream configuration information and runtime data sent by a first processor, wherein the stream configuration information and runtime data are sent by the first processor after determining that the target task supports asynchronous execution.
[0208] The specified task flow is determined based on the flow configuration information, and the target task to be executed is determined based on the running data;
[0209] Execute the target task on the specified task flow.
[0210] In one embodiment, the stream configuration information includes a stream handle, and the processor, when executing a computer program, further implements the following steps:
[0211] Based on the stream handle, query the association relationship corresponding to the stream handle in a preset storage location. The association relationship includes at least the correspondence between the stream handle and the stream identifier.
[0212] If there are multiple associations, then a target association including a preset label is determined from each association, and the task flow corresponding to the flow identifier included in the target association is taken as the designated task flow.
[0213] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0214] If the number of associations is one, then the default task flow corresponding to the flow identifier included in the association is used as the specified task flow.
[0215] In one embodiment, a computer-readable storage medium is provided for a first processor, having a computer program stored thereon, the computer program performing the following steps when executed by the processor:
[0216] Obtain the executable file and determine the target task to be executed based on the executable file;
[0217] If it is determined that the target task supports asynchronous execution, a specified task flow corresponding to the target task is determined;
[0218] Based on the file to be executed, the flow configuration information of the specified task flow and the running data of the target task are determined, and the flow configuration information and the running data are sent to the second processor. The flow configuration information and the running data are used by the second processor to execute the target task on the specified task flow.
[0219] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0220] Based on the file to be executed, determine the first stream identifier corresponding to the default task flow of the target task, and obtain the stream handle corresponding to the default task flow based on the first stream identifier;
[0221] The flow configuration information is determined based on the flow handle.
[0222] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0223] Based on the preset configuration relationship, obtain the second stream identifier corresponding to the specified task stream;
[0224] If the first stream identifier is different from the second stream identifier, then the stream handle is configured to the specified task stream according to the second stream identifier and the stream handle, and the stream handle is used as the stream configuration information.
[0225] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0226] The association between the second stream identifier, the stream handle, and the preset tag is stored in a preset storage location;
[0227] The preset label is used to indicate that the priority of the specified task flow corresponding to the second flow identifier is higher than the priority of the default task flow.
[0228] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0229] The validity of the stream handle is determined based on preset judgment conditions.
[0230] If the stream handle is valid, the association between the second stream identifier, the stream handle, and the preset tag is stored in the preset storage location.
[0231] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0232] If the first stream identifier is the same as the second stream identifier, then the stream handle is used as the stream configuration information.
[0233] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0234] The code segment corresponding to the target task is determined based on the file to be executed;
[0235] If the code segment includes a preset field, then the target task is determined to support asynchronous execution;
[0236] If the preset field is not included in the code segment, then the target task is determined to be non-asynchronous.
[0237] In one embodiment, a computer-readable storage medium is provided for a second processor, having a computer program stored thereon, the computer program performing the following steps when executed by the processor:
[0238] The system receives stream configuration information and runtime data sent by a first processor, wherein the stream configuration information and runtime data are sent by the first processor after determining that the target task supports asynchronous execution.
[0239] The specified task flow is determined based on the flow configuration information, and the target task to be executed is determined based on the running data;
[0240] Execute the target task on the specified task flow.
[0241] In one embodiment, the stream configuration information includes a stream handle, and the computer program, when executed by a processor, further implements the following steps:
[0242] Based on the stream handle, query the association relationship corresponding to the stream handle in a preset storage location. The association relationship includes at least the correspondence between the stream handle and the stream identifier.
[0243] If there are multiple associations, then a target association including a preset label is determined from each association, and the task flow corresponding to the flow identifier included in the target association is taken as the designated task flow.
[0244] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0245] If the number of associations is one, then the default task flow corresponding to the flow identifier included in the association is used as the specified task flow.
[0246] In one embodiment, a computer program product is provided for a first processor, comprising a computer program that, when executed by the processor, performs the following steps:
[0247] Obtain the executable file and determine the target task to be executed based on the executable file;
[0248] If it is determined that the target task supports asynchronous execution, a specified task flow corresponding to the target task is determined;
[0249] Based on the file to be executed, the flow configuration information of the specified task flow and the running data of the target task are determined, and the flow configuration information and the running data are sent to the second processor. The flow configuration information and the running data are used by the second processor to execute the target task on the specified task flow.
[0250] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0251] Based on the file to be executed, determine the first stream identifier corresponding to the default task flow of the target task, and obtain the stream handle corresponding to the default task flow based on the first stream identifier;
[0252] The flow configuration information is determined based on the flow handle.
[0253] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0254] Based on the preset configuration relationship, obtain the second stream identifier corresponding to the specified task stream;
[0255] If the first stream identifier is different from the second stream identifier, then the stream handle is configured to the specified task stream according to the second stream identifier and the stream handle, and the stream handle is used as the stream configuration information.
[0256] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0257] The association between the second stream identifier, the stream handle, and the preset tag is stored in a preset storage location;
[0258] The preset label is used to indicate that the priority of the specified task flow corresponding to the second flow identifier is higher than the priority of the default task flow.
[0259] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0260] The validity of the stream handle is determined based on preset judgment conditions.
[0261] If the stream handle is valid, the association between the second stream identifier, the stream handle, and the preset tag is stored in the preset storage location.
[0262] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0263] If the first stream identifier is the same as the second stream identifier, then the stream handle is used as the stream configuration information.
[0264] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0265] The code segment corresponding to the target task is determined based on the file to be executed;
[0266] If the code segment includes a preset field, then the target task is determined to support asynchronous execution;
[0267] If the preset field is not included in the code segment, then the target task is determined to be non-asynchronous.
[0268] In one embodiment, a computer program product is provided for a second processor, comprising a computer program that, when executed by the processor, performs the following steps:
[0269] The system receives stream configuration information and runtime data sent by a first processor, wherein the stream configuration information and runtime data are sent by the first processor after determining that the target task supports asynchronous execution.
[0270] The specified task flow is determined based on the flow configuration information, and the target task to be executed is determined based on the running data;
[0271] Execute the target task on the specified task flow.
[0272] In one embodiment, the stream configuration information includes a stream handle, and the computer program, when executed by a processor, further implements the following steps:
[0273] Based on the stream handle, query the association relationship corresponding to the stream handle in a preset storage location. The association relationship includes at least the correspondence between the stream handle and the stream identifier.
[0274] If there are multiple associations, then a target association including a preset label is determined from each association, and the task flow corresponding to the flow identifier included in the target association is taken as the designated task flow.
[0275] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0276] If the number of associations is one, then the default task flow corresponding to the flow identifier included in the association is used as the specified task flow.
[0277] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0278] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0279] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0280] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A task allocation method, characterized in that, For a first processor, the method includes: Obtain the executable file and determine the target task to be executed based on the executable file; If it is determined that the target task supports asynchronous execution, a specified task flow corresponding to the target task is determined; Based on the file to be executed, the flow configuration information of the specified task flow and the running data of the target task are determined, and the flow configuration information and the running data are sent to the second processor. The flow configuration information and the running data are used by the second processor to execute the target task on the specified task flow.
2. The method according to claim 1, characterized in that, The step of determining the flow configuration information of the specified task flow based on the file to be executed includes: Based on the file to be executed, determine the first stream identifier corresponding to the default task flow of the target task, and obtain the stream handle corresponding to the default task flow based on the first stream identifier; The flow configuration information is determined based on the flow handle.
3. The method according to claim 2, characterized in that, Determining the flow configuration information based on the flow handle includes: Based on the preset configuration relationship, obtain the second stream identifier corresponding to the specified task stream; If the first stream identifier is different from the second stream identifier, then based on the second stream identifier and the stream handle, the stream handle is configured to the specified task stream, and the stream handle is used as the stream configuration information; If the first stream identifier is the same as the second stream identifier, then the stream handle is used as the stream configuration information.
4. The method according to claim 3, characterized in that, The step of configuring the stream handle to the specified task stream based on the second stream identifier and the stream handle includes: The association between the second stream identifier, the stream handle, and the preset tag is stored in a preset storage location; The preset label is used to indicate that the priority of the specified task flow corresponding to the second flow identifier is higher than the priority of the default task flow.
5. The method according to claim 4, characterized in that, The step of storing the association between the second stream identifier, the stream handle, and the preset tag in a preset storage location includes: The validity of the stream handle is determined based on preset judgment conditions. If the stream handle is valid, the association between the second stream identifier, the stream handle, and the preset tag is stored in the preset storage location.
6. A task allocation method, characterized in that, For a second processor, the method includes: The system receives stream configuration information and runtime data sent by a first processor, wherein the stream configuration information and runtime data are sent by the first processor after determining that the target task supports asynchronous execution. The specified task flow is determined based on the flow configuration information, and the target task to be executed is determined based on the running data; Execute the target task on the specified task flow.
7. The method according to claim 6, characterized in that, The stream configuration information includes a stream handle, and determining the specified task stream based on the stream configuration information includes: Based on the stream handle, query the association relationship corresponding to the stream handle in a preset storage location. The association relationship includes at least the correspondence between the stream handle and the stream identifier. If there are multiple associations, then a target association including a preset tag is determined from each association, and the task flow corresponding to the flow identifier included in the target association is taken as the specified task flow; If the number of associations is one, then the default task flow corresponding to the flow identifier included in the association is used as the specified task flow.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.