Resource application method of thread, processor, computer equipment and chip

By introducing a resource application module into the processor, flexibly allocating storage space according to the task type of thread, the problem of low resource utilization and difficulty in meeting the needs of different business scenarios in the existing technology is solved, and more efficient resource utilization and parallelism are achieved.

CN119806830AActive Publication Date: 2025-04-11MOORE THREADS TECH CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202411877234.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-11
Estimated Expiration
2044-12-18

AI Technical Summary

Technical Problem

The prior art applications for thread source data initialization and thread execution at one time when thread initialization is performed, resulting in low resource utilization and difficult to meet task requirements in different business scenarios.

Method used

By introducing a resource application module into the processor, the number of resource applications is determined according to the task type of the thread, and a resource allocation request is sent to the resource management module to flexibly allocate storage space.

Benefits of technology

It realizes flexible resource allocation to threads based on the number of resource applications of threads, adapts to resource utilization and parallelism requirements, and meets task requirements in different business scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806830A_ABST
    Figure CN119806830A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a thread resource application method, a processor, computer equipment and a chip, the method is applied to the processor, the processor comprises an application configuration module, a resource application module and a resource management module, and the method comprises the steps that the resource application module obtains resource application times corresponding to a thread from the application configuration module; the resource application times are determined according to task types corresponding to the threads; the resource application module sends a resource allocation request to the resource management module according to the resource application times; the resource allocation request is used for requesting the resource management module to allocate storage space for the thread from the memory. According to the embodiment of the invention, resource allocation can be more flexibly carried out on the thread according to the resource application times, so that the resource utilization rate requirement and the parallelism degree requirement of the thread can be flexibly adapted, and the task requirements in different business scenes can be better met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to, but is not limited to, the field of computer technology, and in particular to a thread resource application method, a processor, a computer device, and a chip. Background Art

[0002] In chip design, tasks can be executed in a stream multiprocessor (SM) in the form of threads. Before a thread is executed, a number of resources are applied for the thread to support the execution of the thread. In the related art, the solution for applying for resources for threads is difficult to meet the execution requirements of tasks. For example, when the thread is initialized, the storage space required for initializing the thread source data and the storage space required for thread execution are applied for at one time, which will cause the storage space used in the thread execution phase to be locked when the thread is initialized, resulting in low resource utilization. Summary of the invention

[0003] In view of this, the embodiments of the present disclosure at least provide a thread resource application method, a processor, a computer device, and a chip.

[0004] The technical solution of the embodiment of the present disclosure is implemented as follows:

[0005] The embodiment of the present disclosure provides a thread resource application method, which is applied to a processor, wherein the processor includes an application configuration module, a resource application module, and a resource management module, including:

[0006] The resource application module obtains the resource application times corresponding to the thread from the application configuration module; the resource application times are determined according to the task type corresponding to the thread;

[0007] The resource application module sends a resource allocation request to the resource management module according to the number of resource applications; the resource allocation request is used to request the resource management module to allocate storage space for the thread from the memory.

[0008] The present disclosure provides a processor, which includes: an application configuration module, a resource application module, and a resource management module, wherein:

[0009] The resource application module is used to: obtain the resource application times corresponding to the thread from the application configuration module; the resource application times are determined according to the task type corresponding to the thread;

[0010] The resource application module is also used to: send a resource allocation request to the resource management module according to the number of resource applications; the resource allocation request is used to request the resource management module to allocate storage space for the thread from the memory.

[0011] An embodiment of the present disclosure provides a chip, which includes the above-mentioned processor.

[0012] An embodiment of the present disclosure provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented, or the processor includes all of the above processors.

[0013] In the disclosed embodiment, the resource application module obtains the resource application times corresponding to the thread from the application configuration module; the resource application times are determined according to the task type corresponding to the thread; the resource application module sends a resource allocation request to the resource management module according to the resource application times; the resource allocation request is used to request the resource management module to allocate storage space for the thread from the memory. In this way, resources can be flexibly allocated to the thread according to the resource application times corresponding to the thread, and then the resource utilization and parallelism requirements of the thread can be flexibly adapted to better meet the task requirements in different business scenarios.

[0014] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used to illustrate the technical solutions of the present disclosure together with the specification.

[0016] Figure 1 A schematic diagram of the implementation process of a thread resource application method provided in an embodiment of the present disclosure Figure 1 ;

[0017] Figure 2 A schematic diagram of the implementation process of a thread resource application method provided in an embodiment of the present disclosure Figure 2 ;

[0018] Figure 3 A schematic diagram of the implementation process of a thread resource application method provided in an embodiment of the present disclosure Figure 3 ;

[0019] Figure 4 A schematic diagram of the composition structure of a processor provided in an embodiment of the present disclosure;

[0020] Figure 5 A schematic diagram of an on-chip storage space for a related technology application;

[0021] Figure 6 A schematic diagram of an improved on-chip storage space application in a related art;

[0022] Figure 7 A schematic diagram of the system structure of resource management provided by the embodiment of the present disclosure;

[0023] Figure 8 A schematic diagram of thread storage space application in scenario 1 provided by an embodiment of the present disclosure;

[0024] Fig. 9 A schematic diagram of thread storage space application in scenario 2 provided by an embodiment of the present disclosure;

[0025] Fig.10 A hardware entity schematic diagram of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solutions and advantages of the present disclosure clearer, the technical solutions of the present disclosure are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present disclosure. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.

[0027] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. The terms "first / second / third" are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It is understood that "first / second / third" may be interchanged in a specific order or sequential order where permitted, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.

[0028] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present disclosure belongs. The terms used herein are only for the purpose of describing the present disclosure and are not intended to limit the present disclosure.

[0029] An embodiment of the present disclosure provides a thread resource application method, which can be executed by a processor. The processor includes an application configuration module, a resource application module and a resource management module. Figure 1 A schematic diagram of the implementation process of a thread resource application method provided in an embodiment of the present disclosure Figure 1 ,like Figure 1 As shown, the method includes the following steps S101 and S102:

[0030] Step S101: the resource application module obtains the resource application times corresponding to the thread from the application configuration module; the resource application times is determined according to the task type corresponding to the thread;

[0031] Here, the resource application times refers to the times of applying for the storage space required for thread execution. For example, the resource application times may include but are not limited to a single time (i.e., a one-time application), or two times, etc.

[0032] In some implementations, the resource application module may send a resource allocation request corresponding to the thread to the resource management module during the thread execution according to the newly added instruction of the thread. Therefore, the number of resource applications may also include but is not limited to three times, four times, etc.

[0033] In some implementations, the method for determining the number of resource application times may include, but is not limited to: obtaining from a thread building module and / or obtaining from a hardware configuration module.

[0034] For example, the resource application count can be obtained from the thread building module. Before applying for storage space from the memory, the resource application module obtains the resource application count corresponding to the current thread to be executed according to the information carried in the thread building request of the upstream data flow when building the thread. The thread building request is generated by software configuration.

[0035] For example, the resource application times can be obtained from the hardware configuration module, which reads the resource application times corresponding to the currently executed thread from the hardware configuration module, and the hardware configuration module can be a register configuration module. The hardware configuration module pre-configures the corresponding resource application times according to the task type corresponding to the thread.

[0036] In some implementations, the task type may include, but is not limited to, at least one of matrix operations and graphics thread calculations.

[0037] In some implementations, when executing a matrix operation task, the matrix operation in the thread needs to be repeated multiple times, and the time occupied by the source data initialization is small relative to the thread execution time. In this scenario, the number of resource application times may be single.

[0038] In some implementations, for threads that consume large amounts of on-chip resources, at a certain moment, the first on-chip storage applications of multiple threads use up all the on-chip storage space, and some threads that have completed the first application are unable to complete the second application for the storage space required for thread execution, which will cause a deadlock. In this scenario, the number of resource applications can be a single time.

[0039] In some implementations, during the execution of a task, multiple threads are required to belong to the same workgroup. During the execution of instructions, multiple threads are required to execute a certain section of code. If a thread cannot execute this section of code, subsequent instructions cannot be executed, resulting in a deadlock. In order to ensure the parallelism of multiple threads, the number of resource requests can be twice in this scenario.

[0040] In some implementations, when performing some graphics thread computing tasks, high resource utilization is required. In this scenario, the number of resource applications may be twice.

[0041] Step S102: the resource application module sends a resource allocation request to the resource management module according to the resource application times; the resource allocation request is used to request the resource management module to allocate storage space for the thread from the memory.

[0042] In some implementations, the memory may be an on-chip storage space.

[0043] In some implementations, when the number of resource applications corresponding to the currently executed thread is a single one, before the thread source data is initialized, the resource application module may apply from the memory at one time for the first storage space required for thread source data initialization and the second storage space required for thread execution. The first storage space may include the storage space required for source data initialization; the second storage space may include the storage space required for thread execution.

[0044] In some implementations, when the number of resource applications corresponding to the currently executed thread is two, the resource application module may apply for the first storage space and the second storage space from the memory in two times. For example, the resource application module applies for the first storage space from the memory before the thread source data is initialized, and uses the first storage space to initialize the source data; applies for the second storage space from the memory before executing the thread, and uses the first storage space and the second storage space to execute the thread based on the initialized source data.

[0045] It can be understood that for a single resource application, since each thread applies for all the storage space required for thread execution at one time before the source data is initialized, and the total storage space of the memory is fixed, the maximum number of threads that can run simultaneously can be determined based on the total storage space and the storage space required for each thread execution, and a more accurate prediction of the degree of parallelism can be made. Therefore, a single resource application is usually suitable for threads in task types that require high parallelism; for a double application, the storage space used for thread source data initialization and the storage space used for thread execution are applied for twice. Since only the storage space required for source data initialization is applied before source data initialization, after the source data initialization is completed, the storage space required for thread execution is applied again before the thread execution, so there is no need to lock the storage space required for thread instruction execution before source data initialization. This part of the storage space can be used to initialize the source data of other threads, thereby improving the utilization of storage space.

[0046] In the disclosed embodiment, the resource application module obtains the resource application times corresponding to the thread from the application configuration module; the resource application times are determined according to the task type corresponding to the thread; the resource application module sends a resource allocation request to the resource management module according to the resource application times; the resource allocation request is used to request the resource management module to allocate storage space for the thread from the memory. In this way, resources can be flexibly allocated to the thread according to the resource application times corresponding to the thread, and then the resource utilization and parallelism requirements of the thread can be flexibly adapted to better meet the task requirements in different business scenarios.

[0047] In some embodiments, the resource allocation request is used to request the resource management module to allocate a first storage space and a second storage space for the thread from the memory, wherein the first storage space is used to store source data required for the execution of the thread, and the second storage space is used to store data generated during the execution of the thread. For example, the generated data may include but is not limited to at least one of intermediate data, result data, etc.

[0048] In some implementations, the first storage space is used for the processor to initialize source data required for thread execution; the first storage space and the second storage space are used together by the processor to execute the thread based on the source data.

[0049] In some implementations, thread execution may include, but is not limited to, thread scheduling, instruction fetching, decoding, instruction execution, etc.

[0050] In some embodiments, step S101 may include at least one of the following steps S111 and S112:

[0051] Step S111: in the case where the application configuration module includes a thread building module, the resource application module receives the number of resource applications corresponding to the thread sent by the thread building module; the number of resource applications is determined by the thread building module based on the task type corresponding to the thread, the task type corresponding to the thread is determined by the thread building module based on the thread building request of the thread, and the thread component request is generated by software configuration;

[0052] In some embodiments, an upstream module of the thread building module generates a thread building request through software configuration, and sends the thread building request to the thread building module; the thread building module responds to receiving the thread building request, determines the task type corresponding to the thread based on the thread building request, and determines the number of resource applications corresponding to the thread according to the task type, and sends the number of resource applications to the resource application module.

[0053] In some embodiments, the upstream module may be a main processor, such as a central processing unit (CPU).

[0054] Step S112: when the application configuration module includes a hardware configuration module, the resource application module reads the resource application times corresponding to the thread from the hardware configuration module.

[0055] In some implementations, the hardware configuration module may pre-store the number of resource applications, which may be configured according to the task type corresponding to the thread; the resource application module may read the number of resource applications corresponding to the thread from the hardware configuration module.

[0056] In some implementations, the hardware configuration module may be a register configuration module.

[0057] In some embodiments, the above method may further include the following step S131:

[0058] Step S131: in response to completion of the thread execution, releasing the first storage space and the second storage space.

[0059] In some implementations, after the thread execution is completed, the first storage space and the second storage space are released, and the released storage space can be used for instruction execution and source data initialization of subsequent threads.

[0060] The present disclosure provides a thread resource application method. Figure 2 A schematic diagram of the implementation process of a thread resource application method provided in an embodiment of the present disclosure Figure 2 ,like Figure 2 As shown, the method may include step S201 and step S202:

[0061] Step S201: the resource application module obtains the resource application times corresponding to the thread from the application configuration module;

[0062] Step S202: When the resource application number is a single time, the resource application module sends a first resource allocation request to the resource management module; the first resource allocation request is used to request a one-time allocation of a target storage space for the thread from the memory, and the target storage space includes the first storage space and the second storage space.

[0063] In some embodiments, when the resource application number is single, the resource application module sends a first resource allocation request to the resource management module before the source data is initialized; in response to receiving the first resource allocation request, the resource management module allocates a first storage space required for source data initialization and a second storage space required for thread execution from the memory at one time for the thread.

[0064] In some embodiments, before the source data is initialized, the first storage space required for source data initialization and the second storage space required for thread execution are requested from the memory at one time. In this way, the maximum number of threads running simultaneously can be determined, and the parallelism of the threads can be predicted more accurately, which is suitable for business scenarios requiring high parallelism.

[0065] In some implementations, the resource application module sends a resource allocation request to the resource management module based on the number of resource applications, and the resource management module allocates corresponding storage space for the thread from the memory in response to receiving the resource allocation request based on the resource allocation request.

[0066] In some implementations, the first storage space and the second storage space may be applied for from the memory according to the size of the first storage space and the size of the second storage space to be applied for. It should be noted that, when the remaining storage space in the memory is insufficient, the resource management module may wait for other threads to complete the execution and release the storage space, and when the remaining storage space in the memory is greater than or equal to the sum of the size of the first storage space and the size of the second storage space to be applied for, the first storage space and the second storage space may be applied for from the memory for the thread.

[0067] In some embodiments, in response to a successful application for the target storage space, the first storage space in the target storage space is used to initialize the source data required for thread execution for subsequent thread instruction execution; here, initializing the source data required for thread execution may include but is not limited to loading the source data required for thread execution into the first storage space, and / or initializing basic information of the thread in the first storage space, etc.

[0068] In response to the completion of the initialization of the source data, the thread is executed based on the source data using the first storage space and the second storage space in the target storage space.

[0069] In some implementations, when the resource application is single, after the thread source data is initialized, there is no need to apply for storage space a second time; based on the initialized source data, thread instructions are executed in the first storage space and the second storage space.

[0070] In the embodiment of the present disclosure, when the number of resource applications is one time, before the source data is initialized, a first resource allocation request is sent to the resource management module to implement a one-time application from the memory for the storage space required for the source data initialization and thread execution. In this way, the maximum number of threads running simultaneously can be determined, and the parallelism of the threads can be predicted more accurately. The number of resource applications being one time is suitable for business scenarios that require high parallelism.

[0071] In some embodiments, the above step S202 may include the following steps S211 to S213:

[0072] Step S211: the resource application module determines a first size of the first storage space to be applied for and a second size of the second storage space to be applied for when the number of resource applications is single.

[0073] In some implementations, when forming a thread, the received upstream data information determines a first size of a first storage space to be applied for, and a second size of a second storage space to be applied for.

[0074] In some implementations, after the thread is formed and before the source data is initialized, a first size of the first storage space to be applied for and a second size of the second storage space to be applied for are determined based on basic information of the thread.

[0075] Step S212: the resource application module determines a target size based on the sum of the first size and the second size;

[0076] In some implementations, the target size may be equal to the sum of the first size and the second size, or may be greater than the sum of the first size and the second size.

[0077] Step S213: the resource application module sends the first resource allocation request to the resource management module based on the target size; the first resource allocation request is used to request to allocate the target storage space for the thread from the memory at one time according to the target size.

[0078] Here, before the source data is initialized, the resource application module sends a first resource allocation request to the resource management module. In response to receiving the first resource allocation request, the resource management module applies for a target storage space greater than or equal to the target size from the memory for the thread; the target storage space is used to initialize the source data and execute thread instructions.

[0079] In the disclosed embodiment, when the resource application number is a single time, the resource application module determines the first size of the first storage space to be applied for and the second size of the second storage space to be applied for; determines the target size according to the sum of the first size and the second size, and sends a first resource allocation request to the resource management module according to the target size; the first resource allocation request is used to request to allocate the target storage space for the thread from the memory at one time according to the target size. In this way, a resource allocation request for applying for the target size is sent to the resource management module at one time, and a storage space of a suitable size is reasonably allocated to the thread.

[0080] In some embodiments, the resource application module includes a first application module and a second application module; the processor also includes a source data initialization module and a thread execution module;

[0081] The above step S202 may include the following steps S221 and S222:

[0082] Step S221: when the number of resource applications is single, the first application module sends the first resource allocation request to the resource management module before the source data initialization module initializes the source data;

[0083] In some implementations, in response to receiving the first resource allocation request, the resource management module applies for a first storage space and a second storage space for the thread from a memory.

[0084] In some implementations, in response to the application of the first storage space and the second storage space being completed, the source data initialization module initializes the source data using the first storage space.

[0085] Step S222: when the number of resource applications is single, the second application module sends a thread execution request to the thread execution module in response to the source data initialization module completing the initialization of the source data using the first storage space.

[0086] In some implementations, when the resource application times are single, the second application module sends a thread execution request to the thread execution module in response to completing the initialization of the source data; the thread execution module executes the thread using the first storage space and the second storage space.

[0087] In the disclosed embodiment, when the number of resource applications is one, the first application module sends a first resource allocation request to the resource management module before the source data initialization module initializes the source data; when the number of resource applications is one, the second application module sends a thread execution request to the thread execution module in response to the source data initialization module completing the initialization of the source data using the first storage space. In this way, the resource application process is simplified and the parallelism of threads is improved.

[0088] The present disclosure provides a thread resource application method. Figure 3 A schematic diagram of the implementation process of a thread resource application method provided in an embodiment of the present disclosure Figure 3 ,like Figure 3 As shown, the processor further includes a source data initialization module and a thread execution module; the method may include steps S301 to S303:

[0089] Step S301: the resource application module obtains the resource application times corresponding to the thread from the application configuration module;

[0090] Step S302: when the number of resource applications is two, the resource application module sends a second resource allocation request to the resource management module before the source data initialization module initializes the source data; the second resource allocation request is used to request allocation of the first storage space from the memory to the thread;

[0091] In some embodiments, when the number of resource applications is twice, after the thread formation is completed and before the source data is initialized, the resource application module sends a second resource allocation request to the resource management module; in response to receiving the second resource allocation request, the resource management module applies for the first storage space required for source data initialization for the thread from the memory.

[0092] In some implementations, in response to the first storage space application being completed, the source data initialization module initializes the source data using the first storage space.

[0093] In some embodiments, before the source data is initialized, the resource application module may send a second resource allocation request to the resource management module according to the size of the first storage space to be applied for; the resource management module applies for the first storage space of the corresponding size from the memory in response to receiving the second resource allocation request. It should be noted that the resource management module applies for the first storage space from the memory when the remaining storage space in the memory is sufficient; when the remaining storage space in the memory is insufficient, it may wait for other threads to complete execution and release storage space, and apply for the first storage space from the memory when the size of the remaining storage space in the memory is greater than or equal to the size of the first storage space to be applied for.

[0094] Step S303: In response to the source data initialization module completing the initialization of the source data using the first storage space, the resource application module sends a third resource allocation request to the resource management module before the thread execution module executes the thread; the third resource allocation request is used to request that the second storage space be allocated to the thread from the memory.

[0095] In some embodiments, in response to completion of the initialization of the source data, before the thread execution module executes the thread, the resource application module sends a third resource allocation request to the resource management module, and the resource management module applies for the second storage space required for thread execution from the memory in response to receiving the third resource allocation request.

[0096] In some implementations, in response to the completion of the application for the third storage space, the thread execution module utilizes the first storage space and the second storage space to execute the thread based on the initialized source data.

[0097] In some embodiments, before executing a thread, the resource application module sends a third resource allocation request to the resource management module according to the size of the second storage space to be applied for, and the resource management module applies for a second storage space of a corresponding size from the memory in response to the third resource allocation request. It should be noted that the resource management module applies for the second storage space from the memory when the remaining storage space in the memory is sufficient; when the remaining storage space is insufficient, the storage space can be released after other threads are executed, and the second storage space can be applied from the memory when the size of the remaining storage space in the memory is greater than or equal to the size of the second storage space to be applied for.

[0098] In the disclosed embodiment, when the resource application module applies for resources twice, before the source data initialization module initializes the source data, the resource application module sends a second resource allocation request to the resource management module; the second resource allocation request is used to request the allocation of the first storage space for the thread from the memory; in response to the source data initialization module completing the initialization of the source data using the first storage space, before the thread execution module executes the thread, the resource application module sends a third resource allocation request to the resource management module; the third resource allocation request is used to request the allocation of the second storage space for the thread from the memory. In this way, there is no need to lock the second storage space in advance before the source data is initialized, which causes a waste of resources. This part of the storage space can be used to initialize the source data of other threads first, thereby improving the utilization rate of resources.

[0099] In some embodiments, the second resource allocation request is used to request allocation of the first storage space for the thread from the memory according to a first size, and the third resource allocation request is used to request allocation of the second storage space for the thread from the memory according to a second size. The method may further include the following step S311:

[0100] Step S311: When the number of resource applications is two, the resource application module determines the first size of the first storage space to be applied for and the second size of the second storage space to be applied for.

[0101] Here, the first size is the size of the first storage space required for initializing thread source data; the second size is the size of the second storage space required for executing thread instructions.

[0102] In some implementations, when forming a thread, the received upstream data information determines a first size of a first storage space to be applied for, and a second size of a second storage space to be applied for.

[0103] In some embodiments, after the thread is formed, the resource application module determines the first size of the first storage space to be applied for and the second size of the second storage space to be applied for based on the basic information of the thread before sending the second resource allocation request and the third resource allocation request to the resource management module.

[0104] In some embodiments, the resource application module includes a first application module and a second application module; the above step S302 includes the following step S321:

[0105] Step S321: when the number of resource applications is twice, the first application module sends the second resource allocation request to the resource management module before the source data initialization module initializes the source data.

[0106] In some embodiments, the resource management module allocates a first storage space required for source data initialization to the thread from the memory in response to receiving a second resource allocation request sent by the first application module; the source data initialization module initializes the source data using the first storage space in response to completion of the first storage space application.

[0107] The above step S303 includes the following step S322:

[0108] Step S322: in response to the source data initialization module completing the initialization of the source data using the first storage space, the second application module sends the third resource allocation request to the resource management module before the thread execution module executes the thread.

[0109] In some embodiments, the resource management module allocates a second storage space required for thread execution from the memory to the thread in response to receiving a third resource allocation request sent by the second application module; the thread execution module executes the thread based on the source data using the first storage space and the second storage space in response to completion of the second storage space application.

[0110] In the disclosed embodiment, when the number of resource applications is two, the first application module sends a second resource allocation request to the resource management module before the source data initialization module initializes the source data; the second application module responds to the source data initialization module using the first storage space to complete the initialization of the source data, and before the thread execution module executes the thread, sends a third resource allocation request to the resource management module. In this way, the first application module and the second application module are used to apply for the first storage space before the source data is initialized, and the second storage space is applied before the thread is executed, respectively, to improve resource utilization.

[0111] The present disclosure provides a processor. Figure 4 A schematic diagram of the structure of a processor provided in an embodiment of the present disclosure is shown in FIG. Figure 4 As shown, the processor 40 includes: an application configuration module 41, a resource application module 42 and a resource management module 43; wherein:

[0112] The resource application module 42 is used to: obtain the resource application times corresponding to the thread from the application configuration module 41; the resource application times are determined according to the task type corresponding to the thread;

[0113] The resource application module 42 is further used to: send a resource allocation request to the resource management module 43 according to the resource application times; the resource allocation request is used to request the resource management module 43 to allocate storage space for the thread from the memory.

[0114] In some implementations, the resource application module 42 may include a first application module and a second application module. In some implementations, the resource application module 42 may include a first application module.

[0115] In some implementations, when the application configuration module 41 includes a thread building module, the resource application module 42 may receive the resource application times sent by the thread building module after the thread building is completed.

[0116] In some implementations, when the application configuration module 41 includes a hardware configuration module, the resource application module 42 may read a preconfigured resource application number from the hardware configuration module.

[0117] In some implementations, the resource application module 42 sends a resource allocation request to the resource management module 43 according to different resource application times.

[0118] In some implementations, the resource application module 42 sends a resource allocation request to the resource management module 43 and then waits for a response from the resource management module 43; the resource management module 43 applies for storage space for the thread from the memory in response to the resource allocation request.

[0119] In some embodiments, the storage space includes a first storage space and a second storage space. The source data initialization module responds to the completion of the application for the first storage space by using the first storage space to initialize the source data required for the thread running. The initialization of the source data required for the thread execution may include but is not limited to loading the source data required for the thread execution into the first storage space, and / or initializing the basic information of the thread in the first storage space; the thread execution module responds to the completion of the application for the second storage space by using the first storage space and the second storage space to execute the thread based on the initialized source data.

[0120] In some embodiments, the thread execution module performs thread scheduling, instruction fetching, decoding, instruction execution, etc. according to the thread number and other information required for thread execution; after the thread has executed all instructions, the thread execution module sends a request to the resource management module to release the first storage space and the second storage space, and the released storage space is used for source data initialization and thread execution of subsequent threads.

[0121] In some embodiments, the resource allocation request is used to request the resource management module to allocate a first storage space and a second storage space for the thread from the memory, the first storage space is used to store source data required for the thread execution, and the second storage space is used to store data generated during the thread execution.

[0122] In some embodiments, the resource application module is also used to: send a first resource allocation request to the resource management module when the resource application number is a single time; the first resource allocation request is used to request a one-time allocation of a target storage space for the thread from the memory, and the target storage space includes the first storage space and the second storage space.

[0123] In some implementations, a source data initialization module is used to initialize source data required for the thread execution using the first storage space in the target storage space in response to the target storage space application being successful;

[0124] The thread execution module is configured to execute the thread based on the source data by utilizing the first storage space and the second storage space in the target storage space in response to completion of initialization of the source data.

[0125] In some embodiments, the resource application module is also used to: determine the first size of the first storage space to be applied for and the second size of the second storage space to be applied for when the number of resource applications is single; determine the target size based on the sum of the first size and the second size; send the first resource allocation request to the resource management module based on the target size; the first resource allocation request is used to request that the target storage space be allocated to the thread from the memory at one time according to the target size.

[0126] In some embodiments, the resource application module includes a first application module and a second application module; the processor also includes a source data initialization module and a thread execution module;

[0127] The first application module is configured to send the first resource allocation request to the resource management module before the source data initialization module initializes the source data when the number of resource applications is single;

[0128] The second application module is used to send a thread execution request to the thread execution module in response to the source data initialization module completing the initialization of the source data using the first storage space when the number of resource applications is single.

[0129] In some embodiments, the processor further includes a source data initialization module and a thread execution module;

[0130] The resource application module is also used to, when the number of resource applications is twice, send a second resource allocation request to the resource management module before the source data initialization module initializes the source data; the second resource allocation request is used to request allocation of the first storage space for the thread from the memory; in response to the source data initialization module completing the initialization of the source data using the first storage space, before the thread execution module executes the thread, send a third resource allocation request to the resource management module; the third resource allocation request is used to request allocation of the second storage space for the thread from the memory.

[0131] The source data initialization module is further configured to initialize the source data required for the thread execution by using the first storage space in response to the first storage space being successfully applied for;

[0132] The thread execution module is further configured to execute the thread based on the source data by utilizing the first storage space and the second storage space in response to a successful application for the second storage space.

[0133] In some embodiments, the second resource allocation request is used to request allocation of the first storage space for the thread from the memory according to a first size, and the third resource allocation request is used to request allocation of the second storage space for the thread from the memory according to a second size;

[0134] The resource application module is further configured to determine, when the number of resource applications is twice, the first size of the first storage space to be applied for and the second size of the second storage space to be applied for.

[0135] In some implementations, the thread building module is configured to: in response to receiving a thread building request for the thread, build the thread based on the thread building request, and determine a first size of the first storage space to be applied for, and a second size of the second storage space to be applied for;

[0136] In some implementations, the resource application module sends a second resource allocation request to the resource management module based on the first size, and the resource management module allocates a first storage space of the first size to the thread in response to receiving the second resource allocation request.

[0137] In some implementations, the resource application module sends a third resource allocation request to the resource management module based on the second size, and the resource management module allocates a second storage space of a second size to the thread in response to receiving the third resource allocation request.

[0138] In some embodiments, the resource application module includes a first application module and a second application module;

[0139] The first application module is further configured to send the second resource allocation request to the resource management module before the source data initialization module initializes the source data when the number of resource applications is twice;

[0140] The second application module is further configured to send the third resource allocation request to the resource management module in response to the source data initialization module completing the initialization of the source data using the first storage space and before the thread execution module executes the thread.

[0141] In some embodiments, the resource application module is further used for at least one of the following:

[0142] The resource application module is further used to receive the number of resource applications corresponding to the thread sent by the thread component module when the application configuration module includes a thread component module; the number of resource applications is determined by the thread component module based on the task type corresponding to the thread, the task type corresponding to the thread is determined by the thread component module based on the thread component request of the thread, and the thread component request is generated by software configuration;

[0143] The resource application module is further configured to read the resource application times corresponding to the thread from the hardware configuration module when the application configuration module includes a hardware configuration module.

[0144] In some implementations, the thread building module is used to determine the number of resource applications corresponding to the thread based on the thread building request in response to receiving the thread building request of the thread; and send the number of resource applications to the resource application module.

[0145] In some implementations, the thread building module is further used to: determine the task type corresponding to the thread based on the thread building request; and determine the resource application times corresponding to the thread based on the task type. This method of determining the resource application times is a software configuration method.

[0146] In some embodiments, the processor further comprises a hardware configuration module;

[0147] The hardware configuration module is used to store the resource application times corresponding to the pre-configured threads;

[0148] The resource application module is also used to read the resource application times corresponding to the thread from the hardware configuration module. This method for determining the resource application times is a hardware configuration method.

[0149] In some embodiments, the resource management module is further configured to release the first storage space and the second storage space in response to completion of execution of the thread.

[0150] The present disclosure provides a method for a thread to apply for a resource of the same type a variable number of times in a graphics processing unit (GPU) design, and the specific implementation method is as follows:

[0151] In the GPU design of the related art, tasks need to be executed in the form of threads in the SM; before the thread is executed, several resources required for the thread execution are requested (hereinafter replaced by the term on-chip storage space, corresponding to the storage space in the above embodiment). The complete life cycle of thread execution includes:

[0152] 1) Loading initialization data from the off-chip storage space to the on-chip storage space to which the threads belong;

[0153] 2) Thread execution instructions (a combination of various basic operations to implement advanced algorithms. The objects involved in the read and write operations of instructions are generally on-chip storage space, because on-chip storage space has low latency and high bandwidth);

[0154] 3) The thread stores the calculation results recorded in the on-chip storage space to the off-chip storage space;

[0155] 4) The thread is executed and all resources are released.

[0156] Regarding the method of applying for on-chip storage space, the resource management in the related technology is to apply for the on-chip storage space required for the complete life cycle of the thread at one time. For a simple example, Figure 5 A schematic diagram of an on-chip storage space for a related technology application is shown in FIG. Figure 5 As shown in the figure, the initialization thread source data of thread 1 needs to occupy 10% of the on-chip storage space, and the thread instruction execution also needs 10% of the on-chip storage space; the initialization thread source data of thread 2 needs to occupy 10% of the on-chip storage space, and the thread instruction execution also needs 10% of the on-chip storage space; the initialization thread source data of thread 3 needs to occupy 10% of the on-chip storage space, and the thread instruction execution also needs 10% of the on-chip storage space; the initialization thread source data of thread 4 needs to occupy 10% of the on-chip storage space, and the thread instruction execution also needs 10% of the on-chip storage space; the initialization thread source data of thread 5 needs to occupy 10% of the on-chip storage space, and the thread instruction execution also needs 10% of the on-chip storage space. It can be seen that before the thread initializes the source data, the 20% on-chip storage space required for the entire life cycle of the thread execution is applied for at one time, and the thread parallelism can reach 5.

[0157] In this resource management mode, the hardware behavior is relatively simple. When doing multi-threaded programming, software users can easily predict the hardware behavior. That is, at a certain moment, based on the number of resources required by the current thread, the number of threads that a multiprocessor (MP) can accommodate can be inferred, so that developers can accurately predict the parallelism of threads. However, the on-chip storage space used in the thread source data initialization phase only accounts for a part of the total on-chip storage space of the thread. The impact is that part of the on-chip storage space used in the thread execution phase will also be locked in the thread data initialization phase, which is actually a waste. Some on-chip storage spaces store vector data, and the hardware overhead is extremely large, so improvements were made later.

[0158] In the related art, based on the above resource management method, the on-chip storage space required by the thread is applied for twice. The first time is based on the on-chip storage space required for initializing the thread source data, and the second time is before the thread execution phase begins, to apply for the on-chip storage space used for the thread instruction execution. For example, a simple particle, Figure 6 A schematic diagram of an improved on-chip storage space application in a related technology, such as Figure 6 As shown, before initializing the thread source data, thread 1 needs to occupy 10% of the on-chip storage space to initialize the thread source data; thread 2 needs to occupy 10% of the on-chip storage space to initialize the thread source data; thread 3 needs to occupy 10% of the on-chip storage space to initialize the thread source data; thread 4 needs to occupy 10% of the on-chip storage space to initialize the thread source data; thread 5 needs to occupy 10% of the on-chip storage space to initialize the thread source data; thread 6 needs to occupy 10% of the on-chip storage space to initialize the thread source data; thread 7 needs to occupy 10% of the on-chip storage space to initialize the thread source data; before the thread instruction is executed, the thread instruction execution of thread 1 needs to occupy 10% of the on-chip storage space; before the thread instruction is executed, the thread instruction execution of thread 2 needs to occupy 10% of the on-chip storage space; before the thread instruction is executed, the thread instruction execution of thread 3 needs to occupy 10% of the on-chip storage space. At this time, 7 threads have locked 100% of the on-chip storage space. When applying for the on-chip storage space required for the thread instruction execution of thread 4, the application fails. It can be seen that the thread parallelism is 3.

[0159] This improved method applies for the resources to be used in the two stages of the thread in stages (that is, the number of applications is twice), so that the on-chip storage space utilization rate is high; however, since a thread has to apply for on-chip storage space twice, it may lead to low parallelism; a more extreme scenario is that for threads that consume a lot of on-chip resources, at a certain moment, the first on-chip storage application of some threads uses up the on-chip storage space, and some threads that have completed the first application are unable to complete the second application, resulting in deadlock.

[0160] As GPUs are increasingly used in parallel computing, common parallel computing scenarios are low parallelism, but extremely high resource consumption of a single thread. This improvement solution is sometimes insufficient, and it is difficult for existing technologies to achieve high resource utilization and high thread parallelism for all types of threads. Parallelism is sometimes a necessary functional requirement. For example, if several threads belong to the same workgroup and have a synchronization point inside, they must reach the synchronization point at the same time to continue executing instructions after the synchronization point. Therefore, the disclosed embodiment proposes a variable number of times for the same type of resources, Figure 7This is a schematic diagram of the system composition structure of the resource management provided by the embodiment of the present disclosure. The hardware of the embodiment of the present disclosure provides a configuration interface, allowing software users to set different resource application times for threads according to task types. The embodiment of the present disclosure can flexibly allocate resources to threads according to the resource application times corresponding to the threads, and can further flexibly adapt the resource utilization requirements and parallelism requirements of the threads to better meet the task requirements in different business scenarios.

[0161] In the embodiment of the present disclosure, thread execution based on applying a method of the same type with a variable number of times may include the following modules:

[0162] Thread building module 701: used to build threads that can be executed on the GPU according to the thread building request;

[0163] Receive control information from the upstream module, and build threads that can be executed on the GPU according to the thread building request; because the building process is a serial functional structure, there is a minimum time interval between the first application of each thread; determine the first storage space required for source data initialization and the second storage space required for thread instruction execution according to the thread building information; the information sent by this module to the first application module must include the thread number, the first storage space and the second storage space.

[0164] First application module 702 (corresponding to the first application module in the above embodiment): after the thread is formed, it is necessary to process the first resource application action of the thread, and after completion, send the relevant information to the source data initialization module 703;

[0165] After the thread is formed, the thread number is sent to the first application module. The first application module makes the first or only resource application for the thread based on the configured register information (i.e. the number of times the thread applies for on-chip resources). The difference lies in the storage space calculation for this application. If it is a phased application, the first storage space is used directly. If it is a single application, the value of the storage space is the sum of the first storage space and the second storage space. When the on-chip storage management module responds to this request, the application is completed and the thread number and the second storage space are sent to the source data initialization module 703.

[0166] Source data initialization module 703: used to initialize the source data required for thread operation;

[0167] This module initializes the source data required for thread execution. The initialization may include but is not limited to loading the source data required for thread execution into the first storage space, and / or initializing the basic information of the thread in the first storage space, etc. After the initialization is completed, the thread number and the second storage space are sent to the second application module 704.

[0168] The second application module 704 (corresponding to the second application module in the aforementioned embodiment) is used to determine whether to make a second resource application after the thread initialization is completed according to the application number configured by the register configuration module 706. If an application is required, the second resource application of the thread is made; if a second application is not required, the thread execution module 705 is entered;

[0169] After the storage space required for thread execution is successfully applied for, the thread number is sent to the thread execution module 705 .

[0170] Thread execution module 705: used to execute thread instructions, mainly various calculations (including multi-threaded scheduling, instruction fetching, decoding, instruction execution, etc.), and after the thread execution is completed, a request to release the on-chip storage space (including the on-chip storage space applied for the first time and the on-chip storage space applied for the second time) is issued;

[0171] According to the thread number and other information required for executing the thread, thread scheduling, instruction fetching, and instruction decoding are performed; after the thread completes the execution of all instructions, a request is issued to release all storage space applied for by the thread.

[0172] Register configuration module 706 (corresponding to the hardware configuration module in the above embodiment): used to configure the number of times a thread applies for on-chip resources, and pre-configured before the thread starts;

[0173] Before the thread starts running, the application times are pre-configured in the register configuration module 706; the register is a 1-bit wide signal; when the register is set to 0, it indicates that the application times are single; when the register is set to 1, it indicates that the application times are two.

[0174] The on-chip storage management module 707 (corresponding to the resource management module in the above embodiment) is used to manage the on-chip storage space according to the application release request, that is, to allocate the storage space according to the application request of the on-chip storage space; and to release the storage space according to the release request of the on-chip storage space. After processing the received resource allocation request, the on-chip storage management module 707 returns an application success flag to the sender of the resource allocation request.

[0175] The application of storage space includes the first application and the second application, among which the second application has a higher priority; the application and release of application space can be performed independently in parallel, and the released space can be used by other threads.

[0176] In the embodiment of the present disclosure, the process based on the thread execution of applying for the same type of variable number of methods may include steps S1201 to S1207:

[0177] Step S1201: the system starts up and decides whether to apply for on-chip storage space once or in stages according to the task type and characteristics of the thread to be started, and then waits for subsequent operations;

[0178] Step S1202: the thread building module receives upstream data, and according to the thread building request, the space required for the source data initialization is called the first storage space, and the space required for the thread execution phase is called the second storage space, and the first storage space and the second storage space are sent to the downstream first application module;

[0179] Step S1203: The first application module receives the thread request and sends a resource allocation request to the on-chip storage management module according to the register configuration information. The request includes the thread number and the storage space (the first storage space or the first storage space + the second storage space).

[0180] The resource application times are transparent to the on-chip storage management module, that is, the on-chip storage management module allocates storage space according to the received resource allocation request. The on-chip storage management module performs the on-chip storage application operation according to the specific management method implemented, and returns the relevant information to the first application module after the operation is completed; after receiving the response from the on-chip storage management module, the first application module sends the thread number to the source data initialization module.

[0181] When the storage space is applied for once, the size of the storage space applied for is the first storage space + the second storage space; when the storage space is applied for twice, the size of the storage space applied for is the first storage space.

[0182] Step S1204: the source data initialization module sets the basic information of the thread and the initial data required for initializing the thread execution in the first storage space specified by the source data of the thread application, and after the initialization is completed, sends the thread number to the second application module;

[0183] Step S1205: the second application module determines whether to make a second application according to the configured number of applications for the storage space. If not, the thread number is sent to the thread execution module. If necessary, the second storage space is sent to the on-chip storage management module and waits for feedback until a response indicating a successful application is received, and then the thread number is sent to the thread execution module.

[0184] Step S1206: The thread execution module executes the thread's instructions (including multi-thread scheduling, instruction fetching, decoding, instruction execution, etc.), and when the thread execution is completed, sends a request to the on-chip storage management module to release all storage space of the thread;

[0185] Step S1207: the on-chip storage management module unlocks the storage space requested by this thread so that it can be reused by subsequent threads. Thus, one thread has completed the entire process of this method.

[0186] With respect to the above-mentioned variable number method of the same type of application, the present disclosure is described in conjunction with two exemplary scenarios:

[0187] Scenario 1: Data centers need to use GPUs for matrix operations. Due to the matrix size, computational complexity, and the amount of computational data, each thread uses 25% of the on-chip storage space (i.e., the first storage space + the second storage space). Therefore, the maximum task parallelism on an SM can only reach 4. Since this type of thread has a characteristic that the matrix operations in the thread must be repeated many times, the time taken for the first source data initialization is relatively small relative to the thread execution time. It should also be noted that the scenario provided in the embodiments of the present disclosure is a simplified scenario. When the actual thread is executed, different tasks may be executed on an SM, and the storage space required for each thread is also different. The time required for source data initialization and the thread instruction execution time may also be different.

[0188] This scenario uses a single storage space application method. Figure 8 A schematic diagram of thread storage space application in scenario 1 provided by an embodiment of the present disclosure, such as Figure 8 As shown, before initializing the thread source data, thread 1 applies for the first storage space required for initializing the thread source data and the second storage space required for thread instruction execution at one time; before initializing the thread source data, thread 2 applies for the first storage space required for initializing the thread source data and the second storage space required for thread instruction execution at one time; before initializing the thread source data, thread 3 applies for the first storage space required for initializing the thread source data and the second storage space required for thread instruction execution at one time; before initializing the thread source data, thread 4 applies for the first storage space required for initializing the thread source data and the second storage space required for thread instruction execution at one time.

[0189] like Figure 8 As shown, thread 1, thread 2, thread 3, and thread 4 apply for 25% (including the first storage space + the second storage space) of the on-chip storage space at time 0, t, 2t, and 3t respectively; thread 1, thread 2, thread 3, and thread 4 start to execute thread instructions at time T, T+t, T+2t, and T+3t respectively; thread 1, thread 2, thread 3, and thread 4 end at time nT, nT+t, nT+2t, and nT+3t respectively; (assuming that the time required for thread execution is: (n-1)*T). It can be seen that the parallelism of thread execution can reach 4 between time T+3t and nT.

[0190] Scenario 2: The GPU performs some graphics thread calculations. The initialization of a thread source data requires 20% of the on-chip storage, and the thread instruction execution requires 20% of the on-chip storage. This scenario requires high resource utilization efficiency.

[0191] The method for applying for storage space twice in this scenario. Fig. 9 A schematic diagram of thread storage space application in scenario 2 provided by an embodiment of the present disclosure, such as Fig. 9 As shown, assuming that the source data initialization and instruction execution phases of a certain thread each require 20% of the on-chip storage space; the assembly delay of the thread assembly module is 0.5T, the source data initialization phase requires a duration of T, and the thread instruction execution duration is 2T. Thread 1 applies for 20% of the on-chip storage space required for initializing thread source data at time 0, and applies for 20% of the on-chip storage space required for thread instruction execution at time T; Thread 2 applies for 20% of the on-chip storage space required for initializing thread source data at time 0.5T, and applies for 20% of the on-chip storage space required for thread instruction execution at time 1.5T; Thread 3 applies for 20% of the on-chip storage space required for initializing thread source data at time T, and 100% of the on-chip storage space is used up at this time. Therefore, it is necessary to apply for 20% of the on-chip storage space required for thread instruction execution at time 3T after thread 1's thread instruction execution is completed and the storage space is released; Thread 4 applies for 20% of the on-chip storage space required for initializing thread source data at time 3T, and applies for 20% of the on-chip storage space required for thread instruction execution at time 4T; Thread 5 applies for 20% of the on-chip storage space required for initializing thread source data at time 3.5T. Please initialize 20% of the on-chip storage space required for the thread source data. After the source data initialization is completed at 4.5T, there is no remaining space to apply for the storage space required for the thread instruction execution. After waiting for thread 3 to complete the instruction execution and release the storage space, apply for 20% of the on-chip storage space required for the thread instruction execution at 5T; thread 6 applies for 20% of the on-chip storage space required for initializing the thread source data at 5T, and applies for 20% of the on-chip storage space required for the thread instruction execution at 6T; thread 7 applies for 20% of the on-chip storage space required for initializing the thread source data at 5.5T, and applies for 20% of the on-chip storage space required for the thread instruction execution at 6.5T; thread 8 applies for 20% of the on-chip storage space required for initializing the thread source data at 7T, and applies for 20% of the on-chip storage space required for the thread instruction execution at 8T.

[0192] It can be seen that starting from the 5T moment, if there are sufficient thread tasks later, the utilization rate of the on-chip storage space can reach 100%.

[0193] The disclosed embodiment proposes a method for allowing a thread to apply for a resource of the same type with a variable number of times, opens a control interface, and pre-configures the number of resource applications of a thread in a register configuration module according to the task type of the thread, which can be configured as a single application or two applications. The processor can flexibly adapt the execution thread parallelism requirements and resource utilization requirements according to different resource application times; and provides selectable resource application times for scenarios with different thread parallelism requirements, resource utilization efficiency requirements, and functional requirements. In this way, the number of resource applications can be selected more flexibly according to task requirements, and compared with the improved method of applying for on-chip storage space in related technologies, the risk of some system deadlocks (i.e., deadlocks caused by insufficient thread parallelism) can be resolved.

[0194] The description of the above processor embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the processor provided in the embodiments of the present disclosure can be used to execute the method described in the above method embodiment. For technical details not disclosed in the processor embodiment of the present disclosure, please refer to the description of the method embodiment of the present disclosure for understanding.

[0195] An embodiment of the present disclosure provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements part or all of the steps in the above method when executing the program, or the processor includes the chip described in the above embodiment.

[0196] The embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.

[0197] An embodiment of the present disclosure provides a computer program, including a computer-readable code. When the computer-readable code is executed in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.

[0198] The present disclosure provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented specifically by hardware, software or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.

[0199] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product disclosed in the present invention, please refer to the description of the method embodiment disclosed in the present invention for understanding.

[0200] Fig.10 A hardware entity diagram of a computer device provided in an embodiment of the present disclosure, such as Fig.10 As shown, the hardware entity of the computer device 1000 includes: a processor 1001 and a memory 1002, wherein the memory 1002 stores a computer program that can be run on the processor 1001, and the processor 1001 implements the steps in the method of any of the above embodiments when executing the program.

[0201] The memory 1002 stores computer programs that can be run on the processor. The memory 1002 is configured to store instructions and applications executable by the processor 1001. It can also cache data to be processed or processed by the processor 1001 and various modules in the computer device 1000 (for example, image data, audio data, voice communication data, and video communication data). This can be achieved through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0202] When the processor 1001 executes the program, the steps of any of the above data reading methods are implemented. The processor 1001 generally controls the overall operation of the computer device 1000.

[0203] An embodiment of the present disclosure provides a computer storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the data reading method in any of the above embodiments.

[0204] It should be noted that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of the present disclosure, please refer to the description of the method embodiments of the present disclosure for understanding.

[0205] The processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that the electronic device that implements the functions of the processor may also be other, which is not specifically limited in the embodiments of the present disclosure.

[0206] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.

[0207] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present disclosure. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in the various embodiments of the present disclosure, the size of the serial numbers of the above-mentioned steps / processes does not mean the order of execution. The execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure. The serial numbers of the embodiments of the present disclosure are for description only and do not represent the advantages and disadvantages of the embodiments.

[0208] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0209] In the several embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0210] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0211] In addition, all functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units. A person of ordinary skill in the art may understand that all or part of the steps of implementing the above method embodiments may be completed by hardware related to program instructions, and the aforementioned program may be stored in a computer-readable storage medium, which, when executed, executes the steps of the above method embodiments; and the aforementioned storage medium includes various media that can store program codes, such as mobile storage devices, read-only memories (ROM), magnetic disks or optical disks.

[0212] Alternatively, if the above-mentioned integrated unit of the present disclosure is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0213] The above description is only an implementation mode of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed in the present disclosure should be included in the protection scope of the present disclosure.

Claims

1. A thread resource application method, characterized in that: Applied to a processor, the processor includes an application configuration module, a resource application module and a resource management module, the method includes: The resource application module obtains the resource application times corresponding to the thread from the application configuration module; the resource application times is determined according to the task type corresponding to the thread; The resource application module sends a resource allocation request to the resource management module according to the resource application times; the resource allocation request is used to request the resource management module to allocate storage space for the thread from a memory.

2. The method according to claim 1, characterized in that: The resource allocation request is used to request the resource management module to allocate a first storage space and a second storage space from the memory for the thread, the first storage space is used to store source data required for the thread execution, and the second storage space is used to store data generated during the thread execution.

3. The method according to claim 2, characterized in that: The resource application module sends a resource allocation request to the resource management module according to the resource application number, including: The resource application module sends a first resource allocation request to the resource management module when the resource application number is single; the first resource allocation request is used to request a one-time allocation of a target storage space for the thread from the memory, and the target storage space includes the first storage space and the second storage space.

4. The method according to claim 3, characterized in that: The resource application module sends a first resource allocation request to the resource management module when the number of resource applications is a single time, including: The resource application module determines, when the number of resource applications is single, a first size of the first storage space to be applied for and a second size of the second storage space to be applied for; The resource application module determines a target size based on the sum of the first size and the second size; The resource application module sends the first resource allocation request to the resource management module based on the target size; the first resource allocation request is used to request to allocate the target storage space for the thread from the memory at one time according to the target size.

5. The method according to claim 3, characterized in that: The resource application module includes a first application module and a second application module; the processor also includes a source data initialization module and a thread execution module; The resource application module sends a first resource allocation request to the resource management module when the number of resource applications is a single time, including: The first application module sends the first resource allocation request to the resource management module before the source data initialization module initializes the source data when the number of resource applications is single; When the number of resource applications is single, the second application module sends a thread execution request to the thread execution module in response to the source data initialization module completing the initialization of the source data using the first storage space.

6. The method according to claim 2, characterized in that: The processor also includes a source data initialization module and a thread execution module; The resource application module sends a resource allocation request to the resource management module according to the resource application number, including: The resource application module sends a second resource allocation request to the resource management module before the source data initialization module initializes the source data when the number of resource applications is twice; the second resource allocation request is used to request allocation of the first storage space from the memory to the thread; The resource application module responds to the source data initialization module completing the initialization of the source data using the first storage space, and before the thread execution module executes the thread, sends a third resource allocation request to the resource management module; the third resource allocation request is used to request allocation of the second storage space for the thread from the memory.

7. The method according to claim 6, characterized in that: The second resource allocation request is used to request allocation of the first storage space for the thread from the memory according to a first size, and the third resource allocation request is used to request allocation of the second storage space for the thread from the memory according to a second size; the method further includes: The resource application module determines the first size of the first storage space to be applied for and the second size of the second storage space to be applied for when the number of resource applications is two.

8. The method according to claim 6, characterized in that: The resource application module includes a first application module and a second application module; When the number of resource applications is twice, the resource application module sends a second resource allocation request to the resource management module before the source data initialization module initializes the source data, including: When the number of resource applications is two, the first application module sends the second resource allocation request to the resource management module before the source data initialization module initializes the source data; The resource application module, in response to the source data initialization module completing the initialization of the source data using the first storage space, sends a third resource allocation request to the resource management module before the thread execution module executes the thread, including: In response to the source data initialization module completing the initialization of the source data using the first storage space, the second application module sends the third resource allocation request to the resource management module before the thread execution module executes the thread.

9. The method according to any one of claims 1 to 8, characterized in that: The resource application module obtains the resource application times corresponding to the thread from the application configuration module, including at least one of the following: In the case where the application configuration module includes a thread assembly module, the resource application module receives the number of resource applications corresponding to the thread sent by the thread assembly module; the number of resource applications is determined by the thread assembly module based on the task type corresponding to the thread, the task type corresponding to the thread is determined by the thread assembly module based on the thread assembly request of the thread, and the thread assembly request is generated by software configuration; In the case where the application configuration module includes a hardware configuration module, the resource application module reads the resource application times corresponding to the thread from the hardware configuration module.

10. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: In response to completion of the thread execution, the resource management module releases the first storage space and the second storage space.

11. A processor, characterized in that: include: Application configuration module, resource application module and resource management module, including: The resource application module is used to: obtain the resource application times corresponding to the thread from the application configuration module; the resource application times are determined according to the task type corresponding to the thread; The resource application module is further used to: send a resource allocation request to the resource management module according to the number of resource applications; the resource allocation request is used to request the resource management module to allocate storage space for the thread from the memory.

12. A chip, characterized in that: The chip includes the processor of claim 11.

13. A computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, wherein: When the processor executes the program, the steps in the method according to any one of claims 1 to 10 are implemented, or the processor includes the processor according to claim 11.

Citation Information

Patent Citations

  • Query request processing method and device

    CN105574009A

  • Memory monitoring method, terminal, server, equipment and storage medium

    CN113515428A

  • Resource allocation method and device, equipment and medium

    CN115964177A

  • Data access method and device of database, electronic equipment and storage medium

    CN116820786A

  • Resource allocation method on cloud computing platform

    CN116962312A