A shared memory allocation method, device, equipment and storage medium
By matching the thread block feature table and execution time statistics table in a general graphics processor, it is solved by solving the problem of waste and low utilization of shared memory resources in the prior art, and achieving more efficient resource allocation.
Patent Information
- Application Number
- CN202510246272.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2045-03-04
AI Technical Summary
In the prior art, stream multiprocessors only rely on the order of computing tasks when allocating shared memory, resulting in waste of shared memory resources and low utilization.
By implementing a shared memory allocation method in a general graphics processor, the thread block feature table and execution time statistics table are used to perform feature matching and time matching, and determine whether the shared memory preemption operation is triggered to reasonably allocate shared memory resources.
This improves the utilization rate of shared memory resources, reduces resource waste, and avoids the low utilization rate of shared memory caused by allocation problems.
Smart Images

Figure CN119759584B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of general-purpose graphics processor chip design, and in particular to a shared memory allocation method, device, equipment and storage medium. Background Art
[0002] Shared memory is an on-chip memory located in the streaming multiprocessors (SM) of the GPGPU (General-Purpose computing on Graphics Processing Units) and can be shared by threads in the same thread block.
[0003] In the current implementation process, the streaming multiprocessor often allocates shared memory to the thread blocks of the computing tasks in sequence only according to the sequence of the computing tasks. However, due to the different sizes of shared memory and the different occupancy rates of the shared memory corresponding to the computing tasks of different thread blocks, if it only relies on the sequence, then when the thread blocks with low shared memory occupancy rate and long execution time are allocated to the streaming multiprocessor for execution, the shared memory resources will be occupied in vain and cannot be released for a long time, resulting in low utilization of the shared memory and waste of shared memory resources. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a shared memory allocation method, device, equipment and storage medium, which can realize the reasonable allocation of shared memory resources, avoid the situation where the shared memory utilization rate is low due to allocation problems, and reduce the waste of shared memory resources. The specific scheme is as follows:
[0005] In a first aspect, the present application provides a shared memory allocation method, which is applied to a general-purpose graphics processor, comprising:
[0006] When receiving a computing task to be executed sent by the host, determining whether there is a characteristic value table entry in the current thread block characteristic table to obtain a characteristic table determination result;
[0007] If the feature table judgment result is yes, matching the thread block feature table based on a preset feature matching rule and the thread block feature information corresponding to the to-be-executed computing task to complete a feature table matching operation;
[0008] If the thread block feature information is matched successfully, the thread block execution time statistics table is matched based on the obtained first feature table matching result and the target thread block currently in operation to complete the execution time matching operation; the first feature table matching result is a feature value table item corresponding to the thread block feature information matched from the thread block feature table;
[0009] If the first feature table matching result and the time matching operation of the target thread block are successfully matched, the execution time matching results are compared to determine whether the shared memory preemption operation corresponding to the target thread block is currently triggered so as to complete the shared memory allocation operation corresponding to the computing task to be executed.
[0010] Optionally, after obtaining the feature table judgment result, the method further includes:
[0011] If the feature table judgment result indicates that there is no feature value table entry in the current thread block feature table, triggering a thread block feature extraction operation corresponding to the to-be-executed computing task to obtain corresponding thread block feature information;
[0012] Based on the thread block feature information, a new feature value table entry is created in the thread block feature table, and the thread block corresponding to the to-be-executed computing task is sent to the thread block run queue of the streaming multiprocessor, so that each streaming multiprocessor completes the shared memory allocation operation corresponding to the thread block based on the sequence in the thread block run queue.
[0013] Optionally, matching the thread block feature table based on a preset feature matching rule and thread block feature information corresponding to the computing task to be executed includes:
[0014] The feature table matching operation is completed by determining the difference information between each feature value table item in the thread block feature table and the thread block feature information corresponding to the to-be-executed computing task, and matching and comparing the difference information with a preset threshold.
[0015] Optionally, if the thread block feature information is matched successfully, matching the thread block execution time statistics table based on the obtained first feature table matching result and the target thread block currently in running state includes:
[0016] If the thread block feature table contains the feature value entry whose corresponding gap information is not greater than the preset threshold, it indicates that the thread block feature information is matched successfully, and the corresponding first feature table matching result is determined;
[0017] Determine the first thread block identification information based on the feature value table entry with the smallest difference information between the first feature table matching result and the thread block feature information;
[0018] Matching the thread block execution time statistics table based on the preset feature matching rule and the target thread block currently in operation to obtain a corresponding second feature table matching result;
[0019] Determine the second thread block identification information based on the feature value table entry with the smallest difference information between the second feature table matching result and the target thread block;
[0020] The first thread block identification information and the second thread block identification information are used to match the thread block execution time statistics table to complete the execution time matching operation.
[0021] Optionally, if the first feature table matching result and the time matching operation of the target thread block are both matched successfully, then comparing the obtained execution time matching results to determine whether a shared memory preemption operation corresponding to the target thread block is currently triggered includes:
[0022] If a first execution time corresponding to the first thread block identification information and a second execution time corresponding to the second thread block identification information are found in the thread block execution time statistics table, it is determined that both the first feature table matching result and the time matching operation of the target thread block are successfully matched;
[0023] Comparing the first execution time with the second execution time to obtain a corresponding execution time comparison result;
[0024] Comparing the thread block feature information with the feature value table entry corresponding to the target thread block in the thread block feature table to obtain a corresponding shared memory occupancy comparison result;
[0025] The execution time comparison result and the shared memory occupancy rate comparison result are used to determine whether a shared memory preemption operation corresponding to the target thread block is currently triggered.
[0026] Optionally, the determining whether to trigger a shared memory preemption operation corresponding to the target thread block by using the execution time comparison result and the shared memory occupancy rate comparison result includes:
[0027] If, compared with the thread block corresponding to the computing task to be executed, the execution time of the target thread block is longer and the shared memory occupancy rate is lower, the target thread block is paused, and the shared memory resources corresponding to the target thread block are allocated to the thread block corresponding to the computing task to be executed, so as to complete the task execution operation corresponding to the computing task to be executed based on the shared memory resources.
[0028] Optionally, also include:
[0029] If there is no corresponding feature value table entry in the thread block feature table whose gap information is not greater than the preset threshold, or if the matching result of the first feature table and / or the time matching operation of the target thread block fails, the thread block corresponding to the computing task to be executed is sent to the thread block running queue of the stream multiprocessor, so that each of the stream multiprocessors completes the shared memory allocation operation corresponding to the thread block based on the sequence in the thread block running queue.
[0030] In a second aspect, the present application provides a shared memory allocation device, applied to a general-purpose graphics processor, comprising:
[0031] The feature table determination module is used to determine whether there is a feature value table entry in the feature table of the current thread block when receiving a to-be-executed computing task sent by the host, so as to obtain a feature table determination result;
[0032] A feature table matching module, configured to match the thread block feature table based on a preset feature matching rule and thread block feature information corresponding to the to-be-executed computing task if the feature table judgment result is yes, so as to complete a feature table matching operation;
[0033] A time matching module, configured to match the thread block execution time statistics table based on the obtained first feature table matching result and the target thread block currently in operation to complete the execution time matching operation if the thread block feature information is matched successfully; the first feature table matching result is a feature value table item corresponding to the thread block feature information matched from the thread block feature table;
[0034] A shared memory allocation module is used to determine whether to trigger a shared memory preemption operation corresponding to the target thread block by comparing the execution time matching results obtained if the first feature table matching results and the time matching operations of the target thread block are successfully matched, so as to complete the shared memory allocation operation corresponding to the computing task to be executed.
[0035] In a third aspect, the present application provides an electronic device, including:
[0036] Memory, used to store computer programs;
[0037] The processor is used to execute the computer program to implement the steps of the aforementioned shared memory allocation method.
[0038] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, which implements the steps of the aforementioned shared memory allocation method when executed by a processor.
[0039] It can be seen that in the present application, in a general-purpose graphics processor, when a computing task to be executed sent by a host is received, it is determined whether there is a characteristic value table entry in the current thread block characteristic table to obtain a characteristic table judgment result; if the characteristic table judgment result is yes, the thread block characteristic table is matched based on a preset characteristic matching rule and the thread block characteristic information corresponding to the computing task to be executed to complete the characteristic table matching operation; if the thread block characteristic information is matched successfully, the thread block execution time statistics table is matched based on the obtained first characteristic table matching result and the target thread block currently in running state to complete the execution time matching operation; if the first characteristic table matching result and the time matching operation of the target thread block are both matched successfully, then the execution time matching result obtained is compared to determine whether the shared memory preemption operation corresponding to the target thread block is currently triggered, so as to complete the shared memory allocation operation corresponding to the computing task to be executed. That is, when the present application receives the computing task to be executed sent by the host through the general graphics processor, it first determines whether there is an entry in the current thread block feature table. If so, it matches the thread block feature information corresponding to the computing task to be executed based on the preset feature matching rules, the entry in the thread block feature table and the thread block feature information corresponding to the computing task to be executed. If the match is successful, the first feature table matching result is obtained, and the target thread block currently in operation is obtained, and the thread block execution time statistics table is matched. If both are matched successfully, the execution time matching results are compared to determine whether the shared memory preemption operation corresponding to the target thread block is currently triggered to complete the shared memory allocation. In this way, the reasonable allocation of shared memory resources can be achieved, the low utilization rate of shared memory due to allocation problems can be avoided, and the waste of shared memory resources can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0041] Figure 1 A flow chart of a shared memory allocation method provided in this application;
[0042] Figure 2 A schematic diagram of a general graphics processor architecture provided for this application;
[0043] Figure 3 A specific shared memory allocation process diagram provided for this application;
[0044] Figure 4A schematic diagram of table item changes provided for this application;
[0045] Figure 5 A schematic diagram of the structure of a shared memory allocation device provided in this application;
[0046] Figure 6 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] In the current implementation process, the stream multiprocessor often only allocates shared memory to the thread blocks of the computing tasks according to the order of the computing tasks. However, due to the different sizes of shared memory and the different occupancy rates of the computing tasks corresponding to different thread blocks, if only relying on the order, when the thread blocks with low shared memory occupancy rate and long execution time are allocated to the stream multiprocessor for execution, the shared memory resources will be occupied in vain and cannot be released for a long time, resulting in low utilization of shared memory and waste of shared memory resources. To this end, the present application provides a shared memory allocation scheme that can realize the reasonable allocation of shared memory resources, avoid the situation of low shared memory utilization rate caused by allocation problems, and reduce the waste of shared memory resources.
[0049] See also Figure 1 As shown, an embodiment of the present invention discloses a shared memory allocation method, which is applied to a general-purpose graphics processor, comprising:
[0050] Step S11: when receiving a computing task to be executed sent by the host, it is determined whether there is a characteristic value table entry in the current thread block characteristic table to obtain a characteristic table determination result.
[0051] Specific, combined Figure 2As shown, this embodiment proposes a general graphics processor architecture, which includes a shared memory preemption control component, a thread block scheduler, and a stream multiprocessor pipeline. The shared memory preemption control component includes functional components such as a table item for recording feature value collection, a table item for recording execution time statistics, resource comparison, and resource preemption. The prediction table lookup component is used to perform table-related matching query operations when receiving a computing task to be executed. The thread block scheduler can accept thread blocks sent by the shared memory preemption control component and allocate the thread blocks to the corresponding SM core for calculation. The stream multiprocessor pipeline includes instruction fetch, decoding, scoreboard, thread bundle scheduling, register file, execution, write back, shared storage, and resource temporary storage table functional components, which can accept thread blocks sent by the thread block scheduler for execution, and the resource temporary storage table can temporarily store the information related to the suspended thread blocks. The functions of the remaining components in the stream multiprocessor pipeline are consistent with the functions of the general general graphics processor pipeline.
[0052] It can be understood that in this embodiment, when the general graphics processor receives a to-be-executed computing task sent by the host (including thread block related information required for task execution), the predictive table lookup component in the shared memory preemption control component in the general graphics processor determines whether there is a feature value table entry that has been recorded in the current thread block feature table.
[0053] Step S12: If the feature table judgment result is yes, matching the thread block feature table based on a preset feature matching rule and the thread block feature information corresponding to the to-be-executed computing task is performed to complete a feature table matching operation.
[0054] Combination Figure 3 As shown, in this embodiment, if there is a feature value table item (i.e., a feature value collection table item) in the thread block feature table (i.e., a feature value collection table item), the thread block feature information corresponding to the computing task to be executed is matched with the feature value table item. When specifically matching, the difference information between each feature value table item in the thread block feature table and the thread block feature information corresponding to the computing task to be executed can be determined, and a preset threshold is used to match and compare the difference information to complete the feature table matching operation.
[0055] In addition, if there is no characteristic value table entry in the thread block feature table, a new characteristic value table entry is created, and the thread block is normally allocated to each SM computing core without resource preemption. After the operation is completed, the execution time is written back to the execution time statistics table entry. When entering a new thread block thereafter, it may be determined that a table entry exists. That is, if the characteristic table judgment result shows that there is no characteristic value table entry in the current thread block feature table, the thread block feature extraction operation corresponding to the to-be-executed computing task is triggered to obtain the corresponding thread block feature information; based on the thread block feature information, a new characteristic value table entry is created in the thread block feature table, and the thread block corresponding to the to-be-executed computing task is sent to the thread block running queue of the stream multiprocessor, so that each stream multiprocessor completes the shared memory allocation operation corresponding to the thread block based on the sequence in the thread block running queue. Combined with Figure 4 As shown, the feature value table entries may include thread block ID (Identity Document), number of threads, amount of input data, task type (if it is a convolution operation, the value is 0, if it is a vector addition operation, the value is 1), number of registers used, and size of shared memory used.
[0056] Step S13: If the thread block feature information is matched successfully, the thread block execution time statistics table is matched based on the first feature table matching result obtained and the target thread block currently in running state to complete the execution time matching operation; the first feature table matching result is the feature value table item corresponding to the thread block feature information matched from the thread block feature table.
[0057] In this embodiment, regarding the feature value table item matching, if there is a feature value table item in the thread block feature table whose corresponding difference information is not greater than the preset threshold, it indicates that the thread block feature information is successfully matched, and the corresponding first feature table matching result is determined. The preset threshold can be flexibly configured based on actual needs, for example Figure 3 It should be understood that the table items are distinguished by thread block IDs, and the thread block feature information is used to match the feature value table items such as the number of thread blocks of different thread block IDs one by one. If there is a thread block ID, the average difference information between the remaining table items and the thread block feature information does not exceed the preset threshold, then the thread block ID can be recorded in the first feature table matching result.
[0058] Further, after the feature value table item is matched successfully, the next step can be continued to perform the execution time matching operation. It can be understood that if the first feature table matching result contains multiple different thread block IDs, the thread block ID with the smallest gap is preferentially selected to perform the execution time matching operation. In the specific execution time matching process, first, the first thread block identification information (i.e., thread block ID) is determined based on the feature value table item with the smallest gap information between the thread block feature information in the first feature table matching result; then, the thread block execution time statistics table is matched based on the preset feature matching rule and the target thread block currently in operation to obtain the corresponding second feature table matching result; then, the second thread block identification information is determined based on the feature value table item with the smallest gap information between the target thread block in the second feature table matching result; then, the thread block execution time statistics table is matched using the first thread block identification information and the second thread block identification information to complete the execution time matching operation. That is to say, since the target thread block is running and has no execution time, the target thread block also needs to be matched in the feature value collection table first to determine the thread block identification information of the completed thread block that is most similar to it, and then perform the execution time matching operation.
[0059] Step S14: If the first feature table matching result and the time matching operation of the target thread block are successfully matched, then by comparing the obtained execution time matching results, it is determined whether the shared memory preemption operation corresponding to the target thread block is currently triggered, so as to complete the shared memory allocation operation corresponding to the computing task to be executed.
[0060] Combination Figure 3 and Figure 4 As shown, in this embodiment, if the running target thread block and the thread block of the newly sent to-be-executed computing task can both match the execution time statistics table, the execution time matching results are compared. That is, if the first execution time corresponding to the first thread block identification information and the second execution time corresponding to the second thread block identification information are found in the thread block execution time statistics table, it is determined that the first feature table matching result and the time matching operation of the target thread block are both successfully matched; based on the first execution time and the second execution time, a comparison is made to obtain a corresponding execution time comparison result; based on the thread block feature information and the feature value table item corresponding to the target thread block in the thread block feature table, a comparison is made to obtain a corresponding shared memory occupancy comparison result; the execution time comparison result and the shared memory occupancy comparison result are used to determine whether the shared memory preemption operation corresponding to the target thread block is currently triggered. It can be understood that the shared memory occupancy rate can be determined based on the feature value table item of the shared memory usage size.
[0061] Further, regarding whether to trigger resource preemption, in this embodiment, if the execution time of the running target thread block is relatively long and the shared memory occupancy rate is relatively low, the running target thread block will be suspended, and the running resources will be preempted by the thread block of the computing task to be executed. That is, if the execution time of the target thread block is longer and the shared memory occupancy rate is lower than that of the thread block corresponding to the computing task to be executed, the target thread block will be suspended, and the shared memory resources corresponding to the target thread block will be allocated to the thread block corresponding to the computing task to be executed, so as to complete the task execution operation corresponding to the computing task to be executed based on the shared memory resources. At the same time, for the target thread block whose execution is suspended, the instruction PC (Program Counter) being executed by each thread bundle and the value of the current register file will be stored in the resource temporary storage table, and then taken out from the resource temporary storage table when it is executed again.
[0062] In addition, it should be understood that when a thread block is preempted, the thread block of the new task sent will not be preempted, so as to avoid the overhead of data movement caused by frequent preemption. In addition, when the thread block feature table fails to match, or when the running target thread block and / or the newly sent thread block cannot match the execution time statistics table item, resource preemption will not be performed, and the new thread block will enter the sending queue in the stream multiprocessor to wait and be executed in sequence. That is, if there is no corresponding feature value table item whose gap information is not greater than the preset threshold in the thread block feature table, or if the first feature table matching result and / or the time matching operation of the target thread block fails to match, the thread block corresponding to the to-be-executed computing task will be sent to the thread block running queue of the stream multiprocessor, so that each stream multiprocessor can complete the shared memory allocation operation corresponding to the thread block based on the sequence in the thread block running queue. In addition, it can be understood that after the execution of each thread block, its execution time will be recorded in the corresponding execution time statistics table.
[0063] like Figure 3As shown, in a specific implementation, there are characteristic values of 4 thread blocks in the current characteristic value collection table, and the corresponding execution time also exists in the execution time statistics table, and the SM core is executing thread block 3 (thread ID is 3). If the host sends a new thread block (thread block 4) information, the characteristic value parameters are as shown in the attached figure. In the first step, the prediction table lookup component will match the characteristic value collection table item and match the characteristic value similar to that of thread block 0. In the second step, the execution time is matched in the execution time statistics table according to the thread block ID of thread block 0. The final matched execution time is 20,000 clock cycles. At this time, the executing thread block 3 is matched to the execution time similar to that of thread block 1, which is about 50,000 clock cycles. After that, in the third step, the two thread blocks are compared and it is found that the predicted execution time of thread block 4 is short, while the predicted execution time of thread block 3 is long and the shared storage occupancy rate is low. Therefore, the running resources of thread block 3 are preempted by thread block 4. The SM core temporarily stores the intermediate data of thread block 3, including the PC value and register information of each thread warp. The SM core will give priority to running thread 4 and will continue to run thread block 3 only after thread block 4 is completed. In addition, if Figure 3 As shown in FIG. 1 , the thread block sent first has its feature values extracted, including the thread block ID, the number of threads, the number of input data, the task type, the number of registers used, and the size of shared memory used. After the feature values are extracted, they are stored in the feature value collection table.
[0064] In summary, a GPGPU-based predictive preemptive shared memory allocation method is proposed in this embodiment. The method can collect the characteristic information of thread blocks, and perform execution time prediction and resource comparison. After comparison, thread blocks with high shared memory utilization and relatively short execution time are preferentially executed. If there are thread blocks with low shared memory utilization and long running time running on SM, they will be forced to pause and preempted by thread blocks with high shared memory utilization and short execution time. Thereby, the utilization rate of shared memory resources is effectively improved and the waste of resources is reduced.
[0065] It can be seen that when the present application receives the computing task to be executed sent by the host through the general graphics processor, it first determines whether there is an entry in the current thread block feature table. If so, it matches the thread block feature information corresponding to the computing task to be executed based on the preset feature matching rules and the entry in the thread block feature table. If the match is successful, the first feature table matching result is obtained, and the target thread block currently in operation is obtained, and the thread block execution time statistics table is matched. If both are matched successfully, the execution time matching results are compared to determine whether the shared memory preemption operation corresponding to the target thread block is currently triggered to complete the shared memory allocation. In this way, the reasonable allocation of shared memory resources can be achieved, the low utilization rate of shared memory due to allocation problems can be avoided, and the waste of shared memory resources can be reduced.
[0066] See also Figure 5 As shown, the embodiment of the present application also discloses a shared memory allocation device, which is applied to a general-purpose graphics processor, including:
[0067] The feature table determination module 11 is used to determine whether there is a feature value table entry in the current thread block feature table when receiving a to-be-executed computing task sent by the host, so as to obtain a feature table determination result;
[0068] A feature table matching module 12 is used to match the thread block feature table based on a preset feature matching rule and thread block feature information corresponding to the to-be-executed computing task if the feature table judgment result is yes, so as to complete the feature table matching operation;
[0069] A time matching module 13 is used to match the thread block execution time statistics table based on the obtained first feature table matching result and the target thread block currently in operation to complete the execution time matching operation if the thread block feature information is matched successfully; the first feature table matching result is a feature value table item corresponding to the thread block feature information matched from the thread block feature table;
[0070] The shared memory allocation module 14 is used to determine whether the shared memory preemption operation corresponding to the target thread block is currently triggered by comparing the execution time matching results if the first feature table matching results and the time matching operations of the target thread block are successfully matched, so as to complete the shared memory allocation operation corresponding to the computing task to be executed.
[0071] Among them, for more specific working processes of the above-mentioned modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0072] It can be seen that when the present application receives the computing task to be executed sent by the host through the general graphics processor, it first determines whether there is an entry in the current thread block feature table. If so, it matches the thread block feature information corresponding to the computing task to be executed based on the preset feature matching rules and the entry in the thread block feature table. If the match is successful, the first feature table matching result is obtained, and the target thread block currently in operation is obtained, and the thread block execution time statistics table is matched. If both are matched successfully, the execution time matching results are compared to determine whether the shared memory preemption operation corresponding to the target thread block is currently triggered to complete the shared memory allocation. In this way, the reasonable allocation of shared memory resources can be achieved, the low utilization rate of shared memory due to allocation problems can be avoided, and the waste of shared memory resources can be reduced.
[0073] In some specific embodiments, the shared memory allocation device may further include:
[0074] A feature extraction unit, configured to trigger a thread block feature extraction operation corresponding to the to-be-executed computing task to obtain corresponding thread block feature information if the feature table judgment result indicates that there is no feature value table entry in the current thread block feature table;
[0075] The first queue sending unit is used to create a new feature value table entry in the thread block feature table based on the thread block feature information, and send the thread block corresponding to the to-be-executed computing task to the thread block running queue of the stream multiprocessor, so that each of the stream multiprocessors completes the shared memory allocation operation corresponding to the thread block based on the sequence in the thread block running queue.
[0076] In some specific embodiments, the feature table matching module 12 may specifically include:
[0077] The feature table matching unit is used to complete the feature table matching operation by determining the difference information between each feature value table item in the thread block feature table and the thread block feature information corresponding to the to-be-executed computing task, and matching and comparing the difference information with a preset threshold.
[0078] In some specific embodiments, the time matching module 13 may specifically include:
[0079] A first feature table matching result obtaining unit, configured to indicate that the thread block feature information is successfully matched if there is a feature value table entry in the thread block feature table whose corresponding gap information is not greater than the preset threshold, and determine a corresponding first feature table matching result;
[0080] A first identification determination unit, configured to determine first thread block identification information based on the feature value table entry having the smallest difference information between the first feature table matching result and the thread block feature information;
[0081] A second feature table matching result obtaining unit, configured to match the thread block execution time statistics table based on the preset feature matching rule and the target thread block currently in operation to obtain a corresponding second feature table matching result;
[0082] A second identification determination unit, configured to determine the second thread block identification information based on the feature value table entry with the smallest difference information between the second feature table matching result and the target thread block;
[0083] The time matching unit is used to match the thread block execution time statistics table by using the first thread block identification information and the second thread block identification information to complete the execution time matching operation.
[0084] In some specific embodiments, the shared memory allocation module 14 may specifically include:
[0085] a matching success unit, configured to determine that the first feature table matching result and the time matching operation of the target thread block are both successfully matched if a first execution time corresponding to the first thread block identification information and a second execution time corresponding to the second thread block identification information are found in the thread block execution time statistics table;
[0086] a time comparison unit, configured to compare the first execution time and the second execution time to obtain a corresponding execution time comparison result;
[0087] an occupancy comparison unit, configured to compare the thread block feature information and the feature value table entry corresponding to the target thread block in the thread block feature table to obtain a corresponding shared memory occupancy comparison result;
[0088] The preemption judgment unit is used to determine whether to trigger the shared memory preemption operation corresponding to the target thread block currently by using the execution time comparison result and the shared memory occupancy rate comparison result.
[0089] In some specific embodiments, the preemption determination unit may specifically include:
[0090] The preemptive execution subunit is used to pause the target thread block if the execution time of the target thread block is longer and the shared memory occupancy rate is lower than that of the thread block corresponding to the computing task to be executed, and allocate the shared memory resources corresponding to the target thread block to the thread block corresponding to the computing task to be executed, so as to complete the task execution operation corresponding to the computing task to be executed based on the shared memory resources.
[0091] In some specific embodiments, the shared memory allocation device may further include:
[0092] The second queue sending unit is used to send the thread block corresponding to the to-be-executed computing task to the thread block running queue of the stream multiprocessor if there is no corresponding feature value table entry in the thread block feature table whose gap information is not greater than the preset threshold, or if the matching result of the first feature table and / or the time matching operation of the target thread block fails to match, so that each of the stream multiprocessors can complete the shared memory allocation operation corresponding to the thread block based on the sequence in the thread block running queue.
[0093] Furthermore, the present application also discloses an electronic device. Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0094] Figure 6 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the shared memory allocation method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0095] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0096] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0097] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the shared memory allocation method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0098] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned shared memory allocation method. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, and no further description will be given here.
[0099] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0100] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0101] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0102] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0103] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A shared memory allocation method, characterized in that: Applicable to general-purpose graphics processors, including: When receiving a computing task to be executed sent by the host, determining whether there is a characteristic value table entry in the current thread block characteristic table to obtain a characteristic table determination result; If the feature table judgment result is yes, matching the thread block feature table based on a preset feature matching rule and the thread block feature information corresponding to the to-be-executed computing task to complete a feature table matching operation; If the thread block feature information is matched successfully, the thread block execution time statistics table is matched based on the obtained first feature table matching result and the target thread block currently in operation to complete the execution time matching operation; the first feature table matching result is a feature value table item corresponding to the thread block feature information matched from the thread block feature table; If the first feature table matching result and the time matching operation of the target thread block are both matched successfully, then by comparing the obtained execution time matching results, it is determined whether the shared memory preemption operation corresponding to the target thread block is currently triggered, so as to complete the shared memory allocation operation corresponding to the computing task to be executed; The matching of the thread block feature table based on a preset feature matching rule and thread block feature information corresponding to the computing task to be executed includes: By determining the difference information between each of the feature value table items in the thread block feature table and the thread block feature information corresponding to the to-be-executed computing task, and using a preset threshold to match and compare with the difference information, a feature table matching operation is completed; The matching of the thread block execution time statistics table based on the obtained first feature table matching result and the target thread block currently in running state includes: Determine the first thread block identification information based on the feature value table entry with the smallest difference information between the feature information of the thread block and the first feature table matching result; Matching the thread block feature table based on the preset feature matching rule and the target thread block currently in operation to obtain a corresponding second feature table matching result; Determine the second thread block identification information based on the feature value table entry with the smallest difference information between the second feature table matching result and the target thread block; The first thread block identification information and the second thread block identification information are used to match the thread block execution time statistics table to complete the execution time matching operation.
2. The shared memory allocation method according to claim 1, characterized in that: After obtaining the feature table judgment result, the method further includes: If the feature table judgment result indicates that there is no feature value table entry in the current thread block feature table, triggering a thread block feature extraction operation corresponding to the to-be-executed computing task to obtain corresponding thread block feature information; Based on the thread block feature information, a new feature value table entry is created in the thread block feature table, and the thread block corresponding to the to-be-executed computing task is sent to the thread block run queue of the streaming multiprocessor, so that each streaming multiprocessor completes the shared memory allocation operation corresponding to the thread block based on the sequence in the thread block run queue.
3. The shared memory allocation method according to claim 1, characterized in that: If the thread block feature information is matched successfully, it includes: If the thread block feature table contains the feature value entry whose corresponding gap information is not greater than the preset threshold, it indicates that the thread block feature information is matched successfully, and the corresponding first feature table matching result is determined.
4. The shared memory allocation method according to claim 3, characterized in that: If the first feature table matching result and the time matching operation of the target thread block are both matched successfully, then comparing the obtained execution time matching results to determine whether the shared memory preemption operation corresponding to the target thread block is currently triggered, including: If a first execution time corresponding to the first thread block identification information and a second execution time corresponding to the second thread block identification information are found in the thread block execution time statistics table, it is determined that both the first feature table matching result and the time matching operation of the target thread block are successfully matched; Comparing the first execution time with the second execution time to obtain a corresponding execution time comparison result; Comparing the thread block feature information with the feature value table entry corresponding to the target thread block in the thread block feature table to obtain a corresponding shared memory occupancy comparison result; The execution time comparison result and the shared memory occupancy rate comparison result are used to determine whether a shared memory preemption operation corresponding to the target thread block is currently triggered.
5. The shared memory allocation method according to claim 4, characterized in that: The determining whether to trigger a shared memory preemption operation corresponding to the target thread block by using the execution time comparison result and the shared memory occupancy rate comparison result includes: If, compared with the thread block corresponding to the computing task to be executed, the execution time of the target thread block is longer and the shared memory occupancy rate is lower, the target thread block is paused, and the shared memory resources corresponding to the target thread block are allocated to the thread block corresponding to the computing task to be executed, so as to complete the task execution operation corresponding to the computing task to be executed based on the shared memory resources.
6. The shared memory allocation method according to claim 3, characterized in that: Also includes: If there is no corresponding feature value table entry in the thread block feature table whose gap information is not greater than the preset threshold, or if the matching result of the first feature table and / or the time matching operation of the target thread block fails, the thread block corresponding to the computing task to be executed is sent to the thread block running queue of the stream multiprocessor, so that each of the stream multiprocessors completes the shared memory allocation operation corresponding to the thread block based on the sequence in the thread block running queue.
7. A shared memory allocation device, characterized in that: Applicable to general-purpose graphics processors, including: The feature table determination module is used to determine whether there is a feature value table entry in the feature table of the current thread block when receiving a to-be-executed computing task sent by the host, so as to obtain a feature table determination result; A feature table matching module, configured to match the thread block feature table based on a preset feature matching rule and thread block feature information corresponding to the to-be-executed computing task if the feature table judgment result is yes, so as to complete a feature table matching operation; A time matching module, configured to match the thread block execution time statistics table based on the obtained first feature table matching result and the target thread block currently in operation to complete the execution time matching operation if the thread block feature information is matched successfully; the first feature table matching result is a feature value table item corresponding to the thread block feature information matched from the thread block feature table; A shared memory allocation module, configured to determine whether to trigger a shared memory preemption operation corresponding to the target thread block by comparing the obtained execution time matching results if the first feature table matching result and the time matching operation of the target thread block are both successfully matched, so as to complete the shared memory allocation operation corresponding to the computing task to be executed; Wherein, the feature table matching module includes: A feature table matching unit, configured to complete a feature table matching operation by determining the difference information between each feature value table item in the thread block feature table and the thread block feature information corresponding to the to-be-executed computing task, and performing matching and comparison with the difference information using a preset threshold; The time matching module comprises: A first identification determination unit, configured to determine first thread block identification information based on the feature value table entry having the smallest difference information between the feature information of the thread block and the first feature table matching result; A second feature table matching result obtaining unit, configured to match the thread block feature table based on the preset feature matching rule and the target thread block currently in operation to obtain a corresponding second feature table matching result; A second identification determination unit, configured to determine the second thread block identification information based on the feature value table entry with the smallest difference information between the second feature table matching result and the target thread block; The time matching unit is used to match the thread block execution time statistics table by using the first thread block identification information and the second thread block identification information to complete the execution time matching operation.
8. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the shared memory allocation method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, implements the shared memory allocation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Shared memory multiplexing method and device
CN110308982A
Task scheduling method based on GPU space resource sharing
CN111736987A