Thread resource application method, processor, computer device and chip

By introducing a resource allocation module into the processor, storage space can be flexibly allocated according to the thread task type, which solves the problem of low resource utilization in thread resource allocation and improves the utilization of storage space and parallelism.

CN119806830BActive Publication Date: 2026-02-17MOORE THREADS TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411877234.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2026-02-17
Estimated Expiration
2044-12-18

AI Technical Summary

Technical Problem

In existing technologies, threads often struggle to meet task execution requirements when requesting resources, resulting in low resource utilization, especially since the storage space used during thread execution is locked during thread initialization.

Method used

By introducing a resource request module into the processor, the number of resource requests is determined according to the task type corresponding to the thread, and storage space is requested from the resource management module in stages, including single or double requests, so as to flexibly adapt to the resource utilization and parallelism requirements of the thread.

Benefits of technology

It better meets the task requirements of different business scenarios, improves the utilization rate and parallelism of storage space, and avoids resource waste.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806830B_ABST
    Figure CN119806830B_ABST
Patent Text Reader

Abstract

The embodiment of the present disclosure discloses a thread resource application method, a processor, a computer device and a chip, wherein 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 following steps: the resource application module obtains the resource application times corresponding to a 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 a storage space for the thread from a memory. According to the embodiment of the present disclosure, the resource allocation for the thread can be more flexible according to the resource application times, and then the resource utilization requirement and the parallelism requirement of the thread can be flexibly adapted, and the task requirement in different business scenarios can be better met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to, but is not limited to, the field of computer technology, and in particular to a method for requesting thread resources, a processor, a computer device, and a chip. Background Technology

[0002] In chip design, tasks can be executed as threads in a stream multiprocessor (SM). Before a thread executes, it allocates resources to support its execution. However, in related technologies, resource allocation schemes for threads often fail to adequately meet the execution requirements of tasks. For example, allocating all storage space required for thread source data initialization and thread execution at once during thread initialization can lock the storage space used during the thread execution phase, resulting in low resource utilization. Summary of the Invention

[0003] In view of this, the present disclosure provides at least one method for requesting resources for a thread, a processor, a computer device, and a chip.

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

[0005] This disclosure provides a resource allocation method for a thread, applied to a processor. The processor includes an allocation configuration module, a resource allocation module, and a resource management module, comprising:

[0006] The resource request module obtains the resource request count for each thread from the request configuration module; the resource request count is determined based on the task type corresponding to the thread.

[0007] The resource request module sends a resource allocation request to the resource management module based on the number of resource requests. The resource allocation request is used to request the resource management module to allocate storage space for the thread from the memory.

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

[0009] The resource request module is used to: obtain the number of resource requests corresponding to a thread from the request configuration module; the number of resource requests is determined based on the task type corresponding to the thread;

[0010] The resource request module is also used to: send resource allocation requests to the resource management module based on the number of resource requests; the resource allocation request is used to request the resource management module to allocate storage space for the thread from the memory.

[0011] This disclosure provides a chip that includes the processor described above.

[0012] This disclosure provides a computer device including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the program, it implements some or all of the steps in the above-described method, or the processor includes all of the above-described processors.

[0013] In this embodiment, the resource request module obtains the resource request count corresponding to the thread from the request configuration module. The resource request count is determined based on the task type corresponding to the thread. Based on the resource request count, the resource request module sends a resource allocation request to the resource management module. 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 based on the resource request count, thereby flexibly adapting to the thread's resource utilization and parallelism requirements, and better meeting the task requirements under 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 this disclosure. Attached Figure Description

[0015] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the specification, serve to illustrate the technical solutions of this disclosure.

[0016] Figure 1 A schematic diagram of the implementation flow of a thread resource allocation method provided in this embodiment of the disclosure. Figure 1 ;

[0017] Figure 2 A schematic diagram of the implementation flow of a thread resource allocation method provided in this embodiment of the disclosure. Figure 2 ;

[0018] Figure 3 A schematic diagram of the implementation flow of a thread resource allocation method provided in this embodiment of the disclosure. Figure 3 ;

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

[0020] Figure 5 This is a schematic diagram illustrating the application for on-chip storage space in a related technology.

[0021] Figure 6 This is a schematic diagram of an improved on-chip storage space in a related technology.

[0022] Figure 7 A schematic diagram of the system composition structure for resource management provided in this embodiment of the disclosure;

[0023] Figure 8 A schematic diagram illustrating the thread storage space allocation for Scenario 1 provided in this embodiment of the present disclosure;

[0024] Figure 9 A schematic diagram illustrating the thread storage space allocation for Scenario 2 provided in this embodiment of the present disclosure;

[0025] Figure 10 This is a schematic diagram of the hardware entity of a computer device provided in an embodiment of this disclosure. Detailed Implementation

[0026] To make the objectives, technical solutions, and advantages of this disclosure clearer, the technical solutions of this disclosure are further described in detail below with reference to the accompanying drawings and embodiments. The described embodiments should not be regarded as limitations on this disclosure. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0027] In the following description, references to "some embodiments" describe a subset of all possible embodiments; however, 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 used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein.

[0028] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure pertains. The terminology used herein is for descriptive purposes only and is not intended to limit the scope of this disclosure.

[0029] This disclosure provides a resource request method for a thread, which can be executed by a processor, the processor including a request configuration module, a resource request module, and a resource management module. Figure 1 A schematic diagram of the implementation flow of a thread resource allocation method provided in this embodiment of the disclosure. Figure 1 ,like Figure 1 As shown, the method includes the following steps S101 and S102:

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

[0031] Here, the number of resource requests refers to the number of times the requesting thread executes the request for the required storage space. For example, the number of resource requests can include, but is not limited to, a single request (i.e., a one-time request) or two requests.

[0032] In some implementations, the resource request module can send a resource allocation request corresponding to the thread to the resource management module during the thread's execution based on the thread's new instruction. Therefore, the number of resource requests can also include, but is not limited to, three or four times.

[0033] In some implementations, the method for determining the number of resource requests may include, but is not limited to, obtaining them from the thread component module and / or from the hardware configuration module.

[0034] For example, the resource request count can be obtained from the thread composition module. Before requesting storage space from memory, the resource composition module obtains the resource request count corresponding to the currently pending thread based on the information carried in the thread composition request from the upstream data stream when the thread is composed. The thread composition request is generated through software configuration.

[0035] For example, the resource request count can be obtained from the hardware configuration module. The resource request module reads the resource request count corresponding to the currently pending thread from the hardware configuration module. The hardware configuration module can be a register configuration module. The hardware configuration module pre-configures the corresponding resource request count according to the task type of 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 computation.

[0037] In some implementations, when performing matrix operation tasks, the matrix operations in the thread need to be repeated multiple times, and the time taken for source data initialization is relatively small compared to the thread execution time. In this scenario, the number of resource requests can be a single one.

[0038] In some implementations, for threads that consume a lot of on-chip resources, if at a certain moment, the first request for on-chip storage by multiple threads exhausts the on-chip storage space, some threads that have completed the first request will be unable to complete the second request for the storage space required for thread execution, which will cause a deadlock. In this scenario, the number of resource requests can be a single request.

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

[0040] In some implementations, when performing certain graphics thread computation tasks, high resource utilization is required, and in such scenarios, the number of resource requests can be twice.

[0041] Step S102: The resource request module sends a resource allocation request to the resource management module according to the number of resource requests; 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 can be on-chip storage.

[0043] In some implementations, when the resource request count for the currently pending thread is a single request, the resource request module can request a first storage space required for thread source data initialization and a second storage space required for thread execution from memory in one go, before the thread source data is initialized. 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 resource request count for the currently pending thread is twice, the resource request module can request the first storage space and the second storage space from memory in two separate transactions. For example, the resource request module requests the first storage space from memory before the thread source data is initialized, and uses the first storage space to initialize the source data; before executing the thread, it requests the second storage space from memory, and uses the first and second storage spaces to execute the thread based on the initialized source data.

[0045] Understandably, for resources requested only once, since each thread requests all the storage space needed for thread execution at once before source data initialization, and the total storage space 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's execution. This allows for a relatively accurate prediction of parallelism. Therefore, resources requested only once are generally suitable for threads in task types that require high parallelism. For resources requested twice, the storage space needed for thread source data initialization and the storage space needed for thread execution are requested separately. Since only the storage space needed for source data initialization is requested before source data initialization, and the storage space needed for thread execution is requested after source data initialization and before thread execution, it is not necessary to lock the storage space needed for thread instruction execution before source data initialization. This storage space can be used to initialize the source data of other threads, improving the utilization of storage space.

[0046] In this embodiment, the resource request module obtains the resource request count corresponding to the thread from the request configuration module. The resource request count is determined based on the task type corresponding to the thread. Based on the resource request count, the resource request module sends a resource allocation request to the resource management module. 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 based on the resource request count, thereby flexibly adapting to the thread's resource utilization and parallelism requirements, and better meeting the task requirements under 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 from the memory for the thread. The first storage space is used to store the source data required for the thread to execute, and the second storage space is used to store the 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 the source data required for thread execution; the first storage space and the second storage space are used together for 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, and instruction execution.

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

[0051] Step S111: When the application configuration module includes a thread component module, the resource application module receives the number of resource application requests corresponding to the thread sent by the thread component module; the number of resource application requests 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;

[0052] In some implementations, the upstream module of the thread component module generates a thread component request through software configuration and sends the thread component request to the thread component module; in response to receiving the thread component request, the thread component module determines the task type corresponding to the thread based on the thread component request, determines the number of resource requests corresponding to the thread according to the task type, and sends the number of resource requests to the resource request module.

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

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

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

[0056] In some implementations, the hardware configuration module can 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 the completion of the thread execution, release the first storage space and the second storage space.

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

[0060] This disclosure provides a method for requesting resources for a thread. Figure 2 A schematic diagram of the implementation flow of a thread resource allocation method provided in this embodiment of the disclosure. Figure 2 ,like Figure 2 As shown, the method may include steps S201 and S202:

[0061] Step S201: The resource request module obtains the number of resource requests corresponding to the thread from the request configuration module;

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

[0063] In some implementations, when the resource request module requests resources only once, it 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 once.

[0064] In some implementations, 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 once. This allows the maximum number of threads running simultaneously to be determined and the parallelism of threads to be predicted more accurately, making it suitable for business scenarios that require high parallelism.

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

[0066] In some implementations, the first and second storage spaces can be requested from the memory based on the sizes of the first and second storage spaces to be requested. It should be noted that if the remaining storage space in the memory is insufficient, the resource management module can wait for other threads to finish executing and release the storage space. If the remaining storage space in the memory is greater than or equal to the sum of the sizes of the first and second storage spaces to be requested, the module can then request the first and second storage spaces from the memory for the thread.

[0067] In some implementations, in response to the successful allocation of the target storage space, the source data required for thread execution is initialized using the first storage space in the target storage space 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 the basic information of the thread in the first storage space.

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

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

[0070] In this embodiment of the disclosure, when the resource request is made in a single instance, a first resource allocation request is sent to the resource management module before the source data is initialized, so as to obtain the storage space required for source data initialization and thread execution from the memory in one go. In this way, the maximum number of threads running at the same time can be determined, and the parallelism of the threads can be predicted more accurately. The single resource request is suitable for business scenarios that require high parallelism.

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

[0072] Step S211: When the resource request is made once, the resource request module determines the first size of the first storage space to be requested and the second size of the second storage space to be requested.

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

[0074] In some implementations, after the thread is assembled, before initializing the source data, the first size of the first storage space to be requested and the second size of the second storage space to be requested are determined based on the thread's basic information.

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

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

[0077] Step S213: The resource request 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 the allocation of the target storage space for the thread from the memory in one go according to the target size.

[0078] Here, before the source data is initialized, the resource request 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 requests a target storage space from the memory that is greater than or equal to the target size for the thread. The target storage space is used to initialize the source data and execute thread instructions.

[0079] In this embodiment, when the resource request module requests resources only once, it determines the first size of the first storage space to be requested and the second size of the second storage space to be requested. Based on the sum of the first and second sizes, it determines the target 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 the allocation of the target storage space for the thread from memory in one go according to the target size. In this way, by sending a resource allocation request for the target size to the resource management module in one go, a suitable amount of storage space is allocated to the thread.

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

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

[0082] Step S221: When the resource application count is a single instance, 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, the resource management module, in response to receiving a first resource allocation request, requests a first storage space and a second storage space from memory for the thread.

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

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

[0086] In some implementations, when the resource request is made only once, the second request 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 then uses the first storage space and the second storage space to execute the thread.

[0087] In this embodiment, when the resource request is made only once, the first request module sends a first resource allocation request to the resource management module before the source data initialization module initializes the source data; when the resource request is made only once, the second request module, in response to the source data initialization module completing the initialization of the source data using the first storage space, sends a thread execution request to the thread execution module. This simplifies the resource request process and improves the parallelism of the threads.

[0088] This disclosure provides a method for requesting resources for a thread. Figure 3 A schematic diagram of the implementation flow of a thread resource allocation method provided in this embodiment of the 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 request module obtains the number of resource requests corresponding to the thread from the request configuration module;

[0090] Step S302: If the resource request number is twice, the resource request 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 the allocation of the first storage space for the thread from the memory;

[0091] In some implementations, when the resource request is made twice, after the thread is assembled but before the source data is initialized, the resource request 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 requests the first storage space required for the thread to initialize the source data from the memory.

[0092] In some implementations, in response to the completion of the first storage space allocation, the source data initialization module initializes the source data using the first storage space.

[0093] In some implementations, before the source data is initialized, the resource request module can send a second resource allocation request to the resource management module based on the size of the first storage space to be requested. Upon receiving the second resource allocation request, the resource management module requests the corresponding size of the first storage space from the memory. It should be noted that the resource management module requests the first storage space from the memory if there is sufficient remaining storage space; if there is insufficient remaining storage space, it can wait for other threads to complete execution and release the storage space, and then request the first storage space from the memory if the size of the remaining storage space is greater than or equal to the size of the first storage space to be requested.

[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 request 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 the allocation of the second storage space from the memory for the thread.

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

[0096] In some implementations, the thread execution module, in response to the completion of the third storage space allocation, executes the thread using the first and second storage spaces based on the initialized source data.

[0097] In some implementations, before the execution of a thread, the resource allocation module sends a third resource allocation request to the resource management module based on the size of the second storage space to be requested. In response to the third resource allocation request, the resource management module requests a second storage space of the corresponding size from the memory. It should be noted that the resource management module requests the second storage space from the memory if there is sufficient remaining storage space; if there is insufficient remaining storage space, it can wait for other threads to finish executing and release the storage space, and then request the second storage space from the memory if the size of the remaining storage space is greater than or equal to the size of the second storage space to be requested.

[0098] In this embodiment, when the resource request module requests resources twice, it 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 requests the allocation of a first storage space from memory for the thread. In response to the source data initialization module completing the source data initialization using the first storage space, a third resource allocation request is sent to the resource management module before the thread execution module executes the thread. This third resource allocation request requests the allocation of a second storage space from memory for the thread. This avoids locking the second storage space before source data initialization, preventing resource waste. This storage space can be used to initialize the source data of other threads, improving resource utilization.

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

[0100] Step S311: When the resource application number is twice, 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 the initialization of thread source data; the second size is the size of the second storage space required for the execution of thread instructions.

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

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

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

[0105] Step S321: When the resource application count 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 implementations, the resource management module, in response to receiving a second resource allocation request sent by the first request module, allocates a first storage space from memory for the thread to initialize source data; the source data initialization module, in response to the completion of the first storage space request, initializes the source data using the first storage space.

[0107] Step S303 above 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 implementations, in response to receiving a third resource allocation request from the second request module, the resource management module allocates a second storage space from the memory for the thread to execute; in response to the completion of the second storage space allocation, the thread execution module uses the first and second storage spaces to execute the thread based on the source data.

[0110] In this embodiment, when the first application module requests resources twice, it sends a second resource allocation request to the resource management module before the source data initialization module initializes the source data. 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 a third resource allocation request to the resource management module before the thread execution module executes the thread. This improves resource utilization by utilizing the first and second application modules to request the first storage space before source data initialization and the second storage space before thread execution, respectively.

[0111] This disclosure provides a processor, Figure 4 This is a schematic diagram of the composition structure of a processor provided in an embodiment of this disclosure, such as... Figure 4 As shown, the processor 40 includes: a request configuration module 41, a resource request module 42, and a resource management module 43; wherein:

[0112] The resource request module 42 is used to: obtain the number of resource requests corresponding to a thread from the request configuration module 41; the number of resource requests is determined according to the task type corresponding to the thread;

[0113] The resource request module 42 is further configured to: send a resource allocation request to the resource management module 43 according to the number of resource requests; 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 request module 42 may include a first request module and a second request module. In some implementations, the resource request module 42 includes a first request module.

[0115] In some implementations, when the request configuration module 41 includes a thread component module, the resource request module 42 can receive the number of resource requests sent by the thread component module after the thread component is completed.

[0116] In some implementations, where the application configuration module 41 includes a hardware configuration module, the resource application module 42 can read the pre-configured number of resource applications from the hardware configuration module.

[0117] In some implementations, the resource request module 42 sends a resource allocation request to the resource management module 43 based on the number of resource requests.

[0118] In some implementations, the resource request 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; in response to the resource allocation request, the resource management module 43 requests storage space for the thread from the memory.

[0119] In some implementations, the storage space includes a first storage space and a second storage space. In response to the completion of the first storage space allocation, the source data initialization module initializes the source data required for thread execution using the first storage space. 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 the basic information of the thread in the first storage space. In response to the completion of the second storage space allocation, the thread execution module executes the thread based on the initialized source data using the first and second storage spaces.

[0120] In some implementations, based on the thread number and other information required for thread execution, the thread execution module performs thread scheduling, instruction fetching, decoding, and instruction execution. After the thread has executed all instructions, the thread execution module sends a request to the resource management module to release the first and second storage spaces. The released storage spaces are used for the initialization of source data 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 from the memory for the thread. The first storage space is used to store the source data required for the thread to execute, and the second storage space is used to store the data generated during the execution of the thread.

[0122] In some embodiments, the resource request module is further configured to: send a first resource allocation request to the resource management module when the resource request is a single request; the first resource allocation request is configured to request the allocation of a target storage space for the thread from the memory in one go, the target storage space including the first storage space and the second storage space.

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

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

[0125] In some embodiments, the resource request module is further configured to: determine a first size of the first storage space to be requested and a second size of the second storage space to be requested when the resource request is a single request; determine a target size based on the sum of the first size and the second size; and send a 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 from the memory for the thread in one go according to the target size.

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

[0127] The first application module is used to send the first resource allocation request to the resource management module before the source data is initialized by the source data initialization module when the resource application is a single request.

[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 resource application count is a single instance.

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

[0130] The resource request module is further configured to, when the resource request count 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 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, send 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 the allocation of the second storage space for the thread from the memory.

[0131] The source data initialization module is further configured to, in response to the successful allocation of the first storage space, initialize the source data required for the thread execution using the first storage space;

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

[0133] In some embodiments, the second resource allocation request is used to request the 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 the allocation of the second storage space for the thread from the memory according to a second size;

[0134] The resource request module is further configured to determine the first size of the first storage space to be requested and the second size of the second storage space to be requested when the number of resource requests is two.

[0135] In some implementations, the thread composition module is configured to: in response to receiving a thread composition request from the thread, compose the thread based on the thread composition request, and determine a first size of the first storage space to be requested and a second size of the second storage space to be requested;

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

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

[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 resource application count is two.

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

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

[0142] The resource request module is further configured to, when the request configuration module includes a thread component module, receive the number of resource requests corresponding to the thread sent by the thread component module; the number of resource requests 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 request module is further configured to read the number of resource requests corresponding to the thread from the hardware configuration module when the request configuration module includes a hardware configuration module.

[0144] In some implementations, the thread composition module is configured to, in response to receiving a thread composition request from the thread, determine the number of resource requests corresponding to the thread based on the thread composition request, and send the number of resource requests to the resource request module.

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

[0146] In some implementations, the processor further includes a hardware configuration module;

[0147] The hardware configuration module is used to store the number of resource requests corresponding to a pre-configured thread;

[0148] The resource request module is further configured to read the resource request count corresponding to the thread from the hardware configuration module. This method for determining the resource request count 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 the completion of the thread execution.

[0150] This disclosure provides a method for a graphics processing unit (GPU) design where the number of times a thread requests the same type of resource varies. The specific implementation is as follows:

[0151] In GPU design related to this technology, tasks need to be executed in the SM (Site Management System) as threads. Before thread execution, several resources required for thread execution are allocated (hereinafter referred to as on-chip storage space, corresponding to the storage space in the aforementioned embodiments). The complete lifecycle of thread execution includes:

[0152] 1) Load initialization data from off-chip storage into the on-chip storage space belonging to these threads;

[0153] 2) Threads execute instructions (combinations of various basic operations to implement advanced algorithms; the objects involved in the read and write operations of instructions are generally on-chip memory space, because on-chip memory 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) Once the thread has finished executing, release all resources.

[0156] Regarding methods for allocating on-chip storage space, resource management in related technologies involves allocating the on-chip storage space required for the entire lifecycle of a thread in one go. For example... Figure 5 This is a schematic diagram illustrating the application for on-chip storage space in a related technology, such as... Figure 5 As shown, thread 1 requires 10% of the on-chip storage space for initializing its source data, and the execution of its instructions requires another 10% of the on-chip storage space; thread 2 requires 10% of the on-chip storage space for initializing its source data, and the execution of its instructions requires another 10% of the on-chip storage space; thread 3 requires 10% of the on-chip storage space for initializing its source data, and the execution of its instructions requires another 10% of the on-chip storage space; thread 4 requires 10% of the on-chip storage space for initializing its source data, and the execution of its instructions requires another 10% of the on-chip storage space; thread 5 requires 10% of the on-chip storage space for initializing its source data, and the execution of its instructions requires another 10% of the on-chip storage space. It can be seen that by allocating 20% ​​of the on-chip storage space required for the entire lifecycle of the thread execution before initializing its source data, the thread parallelism can reach 5.

[0157] In this resource management approach, hardware behavior is relatively simple. Software users can easily predict hardware behavior when doing multithreaded programming. That is, at a certain moment, based on the number of resources required by the current thread, they can infer the number of threads that a multiprocessor (MP) can accommodate, giving developers accurate predictive ability for thread parallelism. However, the on-chip storage space used in the thread source data initialization phase only accounts for a portion of the total on-chip storage space for the thread. This results in the locking of a portion of the on-chip storage space used in the thread execution phase during the thread data initialization phase, which is actually a waste. Some on-chip storage space stores vector data, resulting in significant hardware overhead. Therefore, improvements were later made.

[0158] In related technologies, improvements are made to the resource management method described above, allocating the on-chip storage space required by the thread in two stages. The first stage allocates the on-chip storage space needed for initializing the thread's source data, and the second stage allocates the on-chip storage space used for the execution of the thread's instructions before the thread execution phase begins. To illustrate with a simple example... Figure 6 This is a schematic diagram of an improved on-chip memory space application in a related technology, such as... Figure 6 As shown, before initializing thread source data, thread 1 requires 10% of the on-chip storage space; thread 2 requires 10% of the on-chip storage space; thread 3 requires 10% of the on-chip storage space; thread 4 requires 10% of the on-chip storage space; thread 5 requires 10% of the on-chip storage space; thread 6 requires 10% of the on-chip storage space; thread 7 requires 10% of the on-chip storage space. Before the execution of thread instructions, the execution of thread instructions by thread 1 requires 10% of the on-chip storage space; the execution of thread instructions by thread 2 requires 10% of the on-chip storage space; the execution of thread instructions by thread 3 requires 10% of the on-chip storage space. At this point, the seven threads have locked 100% of the on-chip storage space. When requesting the on-chip storage space required for the execution of thread instructions by thread 4, the request fails. It can be seen that the thread parallelism is 3.

[0159] This improved method allocates resources needed by the two phases of a thread in stages (i.e., the allocation is made twice), which makes the utilization of on-chip memory space high. However, since a thread needs to allocate on-chip memory space twice, it may lead to low parallelism. In a more extreme scenario, for threads that consume a lot of on-chip resources, at a certain moment, some threads use up all the on-chip memory space in their first allocation, and some threads that have completed their first allocation are unable to complete their second allocation for a long time, resulting in deadlock.

[0160] As GPUs are increasingly used in parallel computing, common parallel computing scenarios involve low parallelism but extremely high resource consumption per thread. Such improvement solutions sometimes fall short, and existing technologies struggle to achieve high resource utilization and high thread parallelism for all types of threads. Parallelism is sometimes a functional requirement; for example, several threads belonging to the same workgroup may share a synchronization point, requiring them to reach the synchronization point simultaneously to continue executing instructions after it. Therefore, this disclosure proposes a method for variable-frequency use of the same type of resource. Figure 7This is a schematic diagram of the system composition structure for resource management provided in this embodiment. The hardware in this embodiment provides a configuration interface that allows software users to set different resource request counts for threads based on task type. This embodiment can flexibly allocate resources to threads based on their corresponding resource request counts, thereby flexibly adapting to the resource utilization and parallelism requirements of threads and better meeting the task requirements of different business scenarios.

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

[0162] Thread composition module 701: Used to assemble threads that can be executed on the GPU based on thread composition requests;

[0163] Receive control information from the upstream module, and construct a thread that can be executed on the GPU according to the thread construction request. Because the construction process is a serial functional structure, there is a minimum time interval between the first request of each thread. Determine the first storage space required for source data initialization and the second storage space required for thread instruction execution based on the thread construction information. The information sent by this module to the first requesting module should 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 aforementioned embodiment): After the thread is assembled, it needs to process the thread's first resource application action, and after completion, send the relevant information to the source data initialization module 703;

[0165] Once the thread is assembled, its thread number is sent to the first request module. The first request module, based on the configured register information (i.e., the number of times the thread requests on-chip resources), makes the thread's first or only resource request. The difference lies in the calculation of the storage space for this request. If it is a phased request, the first storage space is used directly. If it is a single request, the storage space value is the sum of the first and second storage spaces. Once the on-chip storage management module responds to this request, the request is complete, 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 execution;

[0167] This module initializes the source data required for thread execution. This 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. After initialization is complete, the thread number and the second storage space are sent to the second application module 704.

[0168] The second resource request module 704 (corresponding to the second resource request module in the aforementioned embodiment) is used to determine whether to make a second resource request after the thread initialization is completed, based on the number of requests configured by the register configuration module 706. If a request is required, the thread will make a second resource request; if a second request is not required, the thread will proceed to the thread execution module 705.

[0169] After successfully allocating the storage space required for thread execution, 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.). After the thread finishes execution, it issues a request to release on-chip memory space (including the first and second on-chip memory space requests).

[0171] Based on the thread number and other information required by the executing thread, thread scheduling, instruction fetching, and instruction decoding and execution are performed; once the thread has completed all instruction execution, a request is issued to release all memory space allocated by the thread.

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

[0173] Before the thread starts running, the number of requests is pre-configured in the register configuration module 706; this register is a 1-bit wide signal; setting the register to 0 indicates a single request; setting the register to 1 indicates two requests.

[0174] The on-chip storage management module 707 (corresponding to the resource management module in the aforementioned embodiments) is used to manage the on-chip storage space according to the request for release, that is, to allocate storage space according to the request for on-chip storage space and to release storage space according to the request for release. After processing the received resource allocation request, the on-chip storage management module 707 returns a successful application flag to the sender of the resource allocation request.

[0175] The allocation of storage space includes a first allocation and a second allocation, with the second allocation having higher priority. The allocation and release of space can be performed in parallel and independently, and the space after being released can be used by other threads.

[0176] In this embodiment of the disclosure, the process of executing a thread based on applying for a method of the same type with a variable number of requests may include steps S1201 to S1207:

[0177] Step S1201: The system starts up and decides whether to request on-chip storage space in one go or in stages, depending on the type and characteristics of the task to be started, and then waits for subsequent operations.

[0178] Step S1202: The thread component module receives data from the upstream, and according to the thread component request, it calls the space required for the initialization of the source data as the first storage space and the space required for the thread execution phase as the second storage space, and sends the first storage space and the first storage space to the downstream first request module.

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

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

[0181] When the storage space is requested once, the size of the requested storage space is the first storage space + the second storage space; when the storage space is requested twice, the size of the requested storage space 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 the thread to execute in the first storage space specified by the source data requested by the thread. After the initialization is completed, the thread number is sent to the second request module.

[0183] Step S1205: The second application module determines whether to make a second application based on the configured number of storage space applications. If not, it sends the thread number to the thread execution module; if so, it sends the second storage space to the on-chip storage management module and waits for feedback until it receives a successful application response, then sends the thread number to the thread execution module.

[0184] Step S1206: The thread execution module executes the instructions of the thread (including multi-threaded scheduling, instruction fetching, decoding, instruction execution, etc.). After the thread finishes execution, it sends a request to the on-chip memory management module to release all the memory 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. At this point, a thread has completed one cycle of the complete process of this method.

[0186] Regarding the aforementioned method for varying the number of applications of the same type, this disclosure provides an explanation in conjunction with implementation schemes for 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 data being processed, each thread requires 25% of the on-chip storage space (i.e., first storage space + second storage space). Therefore, the maximum parallelism of a task on a single SM can only reach 4. Since such threads have a characteristic of repeating matrix operations multiple times, the time required for the initial source data initialization is relatively small compared to the thread execution time. It should also be noted that the scenario provided in this embodiment is a simplified scenario. In actual thread execution, different tasks may be executed on a single SM, the storage space required for each thread may vary, and the time required for source data initialization and thread instruction execution time may also differ.

[0188] This scenario uses a single-application method for storage space. Figure 8 A schematic diagram illustrating the thread storage space allocation in Scenario 1 provided by this embodiment of the present disclosure, as shown below. Figure 8 As shown, before initializing the thread source data, thread 1 requests the first storage space required for initializing the thread source data and the second storage space required for executing thread instructions in one go; before initializing the thread source data, thread 2 requests the first storage space required for initializing the thread source data and the second storage space required for executing thread instructions in one go; before initializing the thread source data, thread 3 requests the first storage space required for initializing the thread source data and the second storage space required for executing thread instructions in one go; before initializing the thread source data, thread 4 requests the first storage space required for initializing the thread source data and the second storage space required for executing thread instructions in one go.

[0189] like Figure 8 As shown, threads 1, 2, 3, and 4 request 25% (including the first and second storage spaces) of on-chip storage space at times 0, t, 2t, and 3t, respectively; threads 1, 2, 3, and 4 begin executing thread instructions at times T, T+t, T+2t, and T+3t, respectively; and threads 1, 2, 3, and 4 terminate at times nT, nT+t, nT+2t, and nT+3t, respectively (assuming the thread execution time is (n-1)*T). It can be seen that the parallelism of thread execution can reach 4 between times T+3t and nT.

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

[0191] This scenario involves requesting storage space twice. Figure 9 A schematic diagram illustrating the thread storage space allocation for Scenario 2 provided in this embodiment of the present disclosure, as shown below. Figure 9 As shown, assume that the source data initialization and instruction execution phases of a certain thread each require 20% of the on-chip storage space; the thread component module's assembly delay is 0.5T, the source data initialization phase requires a duration of T, and the thread instruction execution phase requires a duration of 2T. Thread 1 requests 20% of the on-chip storage space at time 0 to initialize thread source data, and requests another 20% at time T to execute thread instructions. Thread 2 requests 20% of the on-chip storage space at time 0.5T to initialize thread source data, and requests another 20% at time 1.5T to execute thread instructions. Thread 3 requests 20% of the on-chip storage space at time T to initialize thread source data, at which point it has used up 100% of the on-chip storage space. Therefore, after Thread 1 completes its thread instruction execution and releases the storage space, it needs to request the remaining 20% ​​at time 3T to execute thread instructions. Thread 4 requests 20% of the on-chip storage space at time 3T to initialize thread source data, and requests another 20% at time 4T to execute thread instructions. Thread 5 requests 20% of the on-chip storage space at time 3.5T. Please initialize 20% of the on-chip storage space required for thread source data. After the source data initialization is completed at time 4.5T, there is no remaining space to request the storage space required for thread instruction execution. After thread 3 completes instruction execution and releases the storage space, request the 20% of the on-chip storage space required for thread instruction execution at time 5T. Thread 6 requests the 20% of the on-chip storage space required for initializing thread source data at time 5T and the 20% of the on-chip storage space required for thread instruction execution at time 6T. Thread 7 requests the 20% of the on-chip storage space required for initializing thread source data at time 5.5T and the 20% of the on-chip storage space required for thread instruction execution at time 6.5T. Thread 8 requests the 20% of the on-chip storage space required for initializing thread source data at time 7T and the 20% of the on-chip storage space required for thread instruction execution at time 8T.

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

[0193] This disclosure proposes a method for allowing a thread to request a uniform type of resource a variable number of times. It provides an open control interface and, in the register configuration module, pre-configures the number of resource requests for a thread based on the thread's task type, allowing for single or double requests. This flexibly adapts to the processor's thread parallelism and resource utilization requirements based on different resource request counts. It provides selectable resource request counts for scenarios with varying thread parallelism, resource utilization efficiency, and functional requirements. This allows for more flexible selection of resource request counts based on task needs, and compared to improved on-chip memory allocation methods in related technologies, it can mitigate some system deadlock risks (i.e., deadlock caused by insufficient thread parallelism).

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

[0195] This disclosure provides a computer device including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the program, it implements some or all of the steps in the above-described method, or the processor includes the chip described in the above embodiments.

[0196] This disclosure provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements some or all of the steps in the above-described method. The computer-readable storage medium may be transient or non-transient.

[0197] This disclosure provides a computer program including computer-readable code, wherein when the computer-readable code is executed in a computer device, a processor in the computer device performs some or all of the steps in the above-described method.

[0198] This disclosure provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. When the computer program is read and executed by a computer, it implements some or all of the steps in the above-described method. This computer program product can be implemented specifically through hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium; 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 that the descriptions of the various embodiments above tend to emphasize the differences between them, while their similarities or commonalities can be referenced interchangeably. The descriptions of the above embodiments of the device, storage medium, computer program, and computer program product are similar to the descriptions of the above method embodiments and have similar beneficial effects. For technical details not disclosed in the embodiments of the device, storage medium, computer program, and computer program product of this disclosure, please refer to the descriptions of the method embodiments of this disclosure for understanding.

[0200] Figure 10 This is a schematic diagram of the hardware entity of a computer device provided in an embodiment of the present disclosure, such as... Figure 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 run on the processor 1001, and the processor 1001 executes the program to implement the steps in the method of any of the above embodiments.

[0201] The memory 1002 stores computer programs that can run on the processor. The memory 1002 is configured to store instructions and applications that can be executed by the processor 1001. It can also cache data to be processed or already processed (e.g., image data, audio data, voice communication data, and video communication data) in the processor 1001 and various modules in the computer device 1000. It can be implemented by flash memory or random access memory (RAM).

[0202] The processor 1001 executes the data reading method steps described above when executing the program. The processor 1001 typically controls the overall operation of the computer device 1000.

[0203] This disclosure provides a computer storage medium storing one or more programs that can be executed by one or more processors to implement the steps of the data reading method as described in any of the above embodiments.

[0204] It should be noted that the descriptions of the storage medium and device embodiments above are similar to those of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium and device embodiments of this disclosure, please refer to the descriptions of the method embodiments of this disclosure for understanding.

[0205] The aforementioned processor can be at least one of the following: Application Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), Central Processing Unit (CPU), Controller, Microcontroller, and Microprocessor. It is understood that other electronic devices can also implement the functions of the aforementioned processor, and this disclosure does not specifically limit the specific implementation.

[0206] The aforementioned computer storage media / memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM), etc.; or it can be various terminals that include 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 the phrase "an embodiment" or "one embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this disclosure. Therefore, "in one embodiment" or "one embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this disclosure, the sequence numbers of the above steps / processes do not imply a sequential 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 this disclosure. The sequence numbers of the above embodiments of this disclosure are merely descriptive and do not represent the superiority or inferiority of the embodiments.

[0208] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

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

[0210] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.

[0211] Furthermore, in the various embodiments of this disclosure, all functional units can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units. Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.

[0212] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, or the part that contributes to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, magnetic disks, or optical disks.

[0213] The above description is merely an embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A method for requesting resources for a thread, characterized in that, Applied to a processor, the processor including a configuration request module, a resource request module, and a resource management module, the method includes: The resource request module obtains the number of resource requests corresponding to the thread from the request configuration module; the number of resource requests is determined according to the task type corresponding to the thread. The resource request module sends a resource allocation request to the resource management module based on the number of resource requests. The resource allocation request requests the resource management module to allocate storage space for the thread from memory. The storage space includes a first storage space and a second storage space. The first storage space is used to store the source data required for the thread's execution, and the second storage space is used to store data generated during the thread's execution. When the resource request is made once, the first and second storage spaces required by the thread are allocated before the source data is initialized. When the resource request is made multiple times, the first storage space required by the thread is allocated before the source data is initialized, and the second storage space required by the thread is allocated after the source data is initialized and before the thread is executed.

2. The method based on claim 1, characterized in that, The resource request module sends a resource allocation request to the resource management module based on the number of resource requests, including: When the resource request module requests resources only once, it sends a first resource allocation request to the resource management module. The first resource allocation request is used to request the allocation of target storage space for the thread from the memory in one go. The target storage space includes the first storage space and the second storage space.

3. The method based on claim 2, characterized in that, When the resource request module requests resources only once, it sends a first resource allocation request to the resource management module, including: When the resource request is made only once, the resource request module determines the first size of the first storage space to be requested and the second size of the second storage space to be requested. The resource request module determines the target size based on the sum of the first size and the second size; The resource request 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 the allocation of the target storage space for the thread from the memory in one go according to the target size.

4. The method based on claim 2, characterized in that, The resource request module includes a first request module and a second request module; the processor also includes a source data initialization module and a thread execution module. When the resource request module requests resources only once, it sends a first resource allocation request to the resource management module, including: In the case where the resource application is a single request, 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 resource request is made once, the second request module, in response to the source data initialization module completing the initialization of the source data using the first storage space, sends a thread execution request to the thread execution module.

5. The method according to claim 1, characterized in that, The processor also includes a source data initialization module and a thread execution module; The resource request module sends a resource allocation request to the resource management module based on the number of resource requests, including: If the resource request number is twice, the resource request 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 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, the resource request 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 the allocation of the second storage space from the memory for the thread.

6. The method based on claim 5, characterized in that, The second resource allocation request is used to request the allocation of the first storage space for the thread from the memory according to the first size, and the third resource allocation request is used to request the allocation of the second storage space for the thread from the memory according to the second size; the method further includes: When the resource request module has requested resources twice, it determines the first size of the first storage space to be requested and the second size of the second storage space to be requested.

7. The method based on claim 5, characterized in that, The resource application module includes a first application module and a second application module; When the resource request module requests resources twice, before the source data initialization module initializes the source data, it sends a second resource allocation request to the resource management module, including: If the number of resource requests 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; In response to the source data initialization module completing the initialization of the source data using the first storage space, the resource request module 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.

8. The method based on any one of claims 1 to 7, characterized in that, The resource request module obtains the number of resource requests corresponding to the thread from the request configuration module, including at least one of the following: When the application configuration module includes a thread component module, the resource application module receives the number of resource application requests corresponding to the thread sent by the thread component module; the number of resource application requests 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; When the application configuration module includes a hardware configuration module, the resource application module reads the number of resource applications corresponding to the thread from the hardware configuration module.

9. The method based on any one of claims 1 to 7, characterized in that, The method further includes: The resource management module releases the first and second storage spaces in response to the completion of the thread execution.

10. A processor, characterized in that, include: The application configuration module, resource application module, and resource management module are included, among which: The resource request module is used to: obtain the number of resource requests corresponding to a thread from the request configuration module; the number of resource requests is determined according to the task type corresponding to the thread; The resource request module is further configured to: send a resource allocation request to the resource management module according to the number of resource requests; the resource allocation request is used to request the resource management module to allocate storage space for the thread from the memory; the storage space includes a first storage space and a second storage space; the first storage space is used to store the source data required for the thread execution, and the second storage space is used to store the data generated during the thread execution; when the number of resource requests is a single request, the first and second storage spaces required by the thread are requested before the source data is initialized; when the number of resource requests is multiple requests, the first storage space required by the thread is requested before the source data is initialized, and the second storage space required by the thread is requested after the source data is initialized and before the thread is executed.

11. A chip, characterized in that, The chip includes the processor as described in claim 10.

12. A computer device comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 9, or the processor includes the processor according to claim 10.

Citation Information

Patent Citations

  • Query request processing method and device

    CN105574009A

  • Resource allocation method on cloud computing platform

    CN116962312A