Resource scheduling method, electronic equipment and medium
By sorting and allocating the scheduling units in the sparse matrix, the problem of load imbalance in the sparse matrix calculation is solved, and the computing performance is improved.
Patent Information
- Application Number
- CN202411099104.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-11-22
AI Technical Summary
In sparse matrix calculation, GPUs cause unbalanced load of parallel computing units due to irregularities, resulting in resource waiting and waste, which becomes a performance bottleneck.
Load balancing is achieved by sorting according to the load size of the scheduling units in the sparse matrix and assigning the scheduling units to the calculation unit according to the sorting results to reduce the load difference between the calculation units.
The performance of sparse matrix calculation is improved, the waiting time between calculation units is reduced, and the computing efficiency is improved.
Smart Images

Figure CN119003171A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to computer information processing technology, and more particularly, to a resource scheduling method, electronic device, and medium. Background Art
[0002] GPU (Graphics Processing Unit) is widely used in matrix calculations, especially in the calculation of dense and sparse matrices. GPU can give full play to its parallel computing capabilities and accelerate matrix calculations. In dense matrix calculations, the number of elements in each row of the matrix is fixed, so GPU can easily allocate parallel computing units to perform matrix operations.
[0003] However, in sparse matrix calculations, due to the irregularity of sparse matrices, the number of elements in each row is uneven, which results in the GPU being unable to evenly allocate parallel computing resources for sparse matrix calculations. In this case of irregular calculations, the load on each parallel computing unit of the GPU is not balanced, which will lead to a certain amount of resource waiting and waste, and eventually become a performance bottleneck. Summary of the invention
[0004] In view of this, one or more embodiments of the present specification provide a resource scheduling method, an electronic device, and a medium to improve the computational efficiency of sparse matrix calculations.
[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0006] According to a first aspect of one or more embodiments of this specification, a resource scheduling method is proposed, the method is applied to a processor, the computing resources on the processor include: a plurality of computing units for parallel computing; the method includes:
[0007] Sort the multiple scheduling units according to the loads of the multiple scheduling units in the sparse matrix; the loads are used to represent the non-zero elements included in the scheduling units;
[0008] According to the sorting result, the multiple scheduling units included in the sparse matrix are allocated to the multiple computing units so that the computing units calculate the non-zero elements in the scheduling units; wherein, when allocating according to the sorting result, the allocation is performed in a manner to reduce the load difference between the various computing units.
[0009] According to a second aspect of one or more embodiments of this specification, a processor is provided, the processor comprising:
[0010] Computing resources, the computing resources comprising: a plurality of computing units for parallel computing;
[0011] A sorting module, used for sorting the multiple scheduling units according to the loads of the multiple scheduling units in the sparse matrix; the loads are used to represent the non-zero elements included in the scheduling units;
[0012] A scheduling module is used to allocate multiple scheduling units included in the sparse matrix to the multiple computing units based on the sorting result, so that the computing units calculate the non-zero elements in the scheduling units; wherein, when allocating based on the sorting result, the allocation is performed in a manner to reduce the load difference between the various computing units.
[0013] According to a third aspect of one or more embodiments of this specification, an electronic device is provided, including:
[0014] processor;
[0015] a memory for storing processor-executable instructions;
[0016] The processor implements the method of any embodiment of this specification by running the executable instructions.
[0017] According to a fourth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, a method of any embodiment of the present specification is implemented.
[0018] According to a fifth aspect of one or more embodiments of the present specification, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method of any embodiment of the present specification is implemented.
[0019] The resource scheduling method, electronic device and medium of the embodiments of this specification help to achieve load balancing of each computing unit and improve computing performance by sorting multiple scheduling units in a sparse matrix according to the size of the load of multiple scheduling units, and allocating each scheduling unit in the sparse matrix to a computing unit based on the sorting result. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in one or more embodiments of the present disclosure or related technologies, the drawings required for use in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in one or more embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0021] Figure 1 It is a schematic diagram of a dense matrix scheduling method provided by an exemplary embodiment.
[0022] Figure 2 It is a schematic diagram of a sparse matrix scheduling method provided by an exemplary embodiment.
[0023] Figure 3 It is a flowchart of a resource scheduling method provided by an exemplary embodiment.
[0024] Figure 4 It is a schematic diagram of sorting a sparse matrix provided by an exemplary embodiment.
[0025] Figure 5 It is a schematic diagram of a sparse matrix scheduling method provided by an exemplary embodiment.
[0026] Figure 6 It is a schematic diagram of another sparse matrix scheduling method provided by an exemplary embodiment.
[0027] Figure 7 It is a schematic diagram of a framework of a processor provided by an exemplary embodiment.
[0028] Figure 8 is a block diagram of a device provided by an exemplary embodiment. DETAILED DESCRIPTION
[0029] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0030] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0031] The GPU can be applied to matrix calculations on dense matrices or sparse matrices, and the matrix calculations may include but are not limited to: matrix multiplication, matrix-vector multiplication, matrix addition and subtraction, matrix decomposition, etc.
[0032] The following will briefly describe the problem to be solved by the resource scheduling method of the embodiment of this specification in conjunction with the accompanying drawings:
[0033] First, let's look at the calculation of dense matrices:
[0034] A dense matrix is a matrix in which most of its elements are non-zero. Figure 1 For example, the Figure 1 An example of a dense matrix is shown. The matrix is a matrix with 6 rows and 4 columns. Assuming that all elements in the matrix are not zero, the matrix has a total of 24 non-zero elements. In the figure, B1 to B6 are used to identify the rows in the dense matrix. For example, B1 represents the first row of the matrix, B2 represents the second row of the matrix, and so on.
[0035] When the GPU calculates dense matrices, it will perform parallel calculations through multiple SMs (Streaming Multiprocessors) included in the GPU. The multiple SMs can be called computing resources responsible for parallel calculations in the GPU. Figure 1 For example, taking three SMs as an example, it may include SM0 to SM2.
[0036] It is easy to understand that the load of each row of the dense matrix is relatively balanced, for example, Figure 1 The number of non-zero elements in each row of the dense matrix is 4, so it is easy for the GPU to achieve a more balanced distribution of computing loads on multiple SMs. For example, two rows of the dense matrix can be allocated to each SM from SM0 to SM2. For example, SM0 is responsible for calculating B1 and B4, SM1 is responsible for calculating B2 and B5, and so on. In this way, the computing load of each SM is 8 non-zero elements. In this way, the computing time of these three SMs is theoretically the same, and they will not become the time bottleneck of the operation.
[0037] Next, let's compare the calculation of sparse matrices:
[0038] A sparse matrix is a matrix that contains a large number of zero elements and a small number of non-zero elements. The number of non-zero elements in each row of a sparse matrix can be different. Figure 2 For example, the Figure 2 The following example shows a sparse matrix with 6 rows and 6 columns. The gray elements in the figure are non-zero elements, and the rest are zero elements. For example, the B1 row of the sparse matrix includes 5 non-zero elements, the B2 row includes 4 non-zero elements, and so on. The B5 row includes 1 non-zero element, and the B6 row includes 6 non-zero elements.
[0039] According to the resource scheduling method of the GPU, it can be scheduled row by row in the order of B1 to B6 by default. For example, B1 to B3 are first scheduled to SM0 to SM2 respectively, where SM0 is assigned to calculate B1, SM1 is assigned to calculate B2, and SM2 is assigned to calculate B3. Then, because B3 has the smallest load in "B1 / B2 / B3" (that is, it contains the least number of non-zero elements), SM2 will end the calculation first. Then, SM2 will still be assigned to the next B4 to be calculated in the order of B1 to B6. Similarly, when SM1 ends the calculation, it will be assigned to the next calculation B5, and when SM0 ends the calculation, it will be assigned to B6.
[0040] In this case, by Figure 2 It can be seen that SM0 is responsible for calculating the largest load, which is 11 non-zero elements. SM1 and SM2 each calculate 5 non-zero elements, and the load of computing resources is unbalanced. The unbalanced load between SMs will cause SM1 and SM2 to finish the calculation quickly, but they still need to wait for SM0 to finish the calculation before the entire calculation is completed. Therefore, the running time of SM0 becomes the performance bottleneck of sparse matrix calculation, that is, the longer calculation time of SM0 correspondingly prolongs the completion time of the entire sparse matrix calculation.
[0041] The resource scheduling method provided in the embodiments of the present application specification is to solve the above-mentioned problems, aiming to balance the computing load on each SM as much as possible, reduce the waiting time between SMs, and improve the performance of sparse matrix computing.
[0042] Figure 3 The following is a flowchart of a resource scheduling method provided by an exemplary embodiment. The method can be applied to a processor (e.g., a GPU). The computing resources in the processor may include: a plurality of computing units for parallel computing. For example, the computing unit may be a stream processor SM, such as Figure 1 or Figure 2 Multiple SMs in a GPU shown in .
[0043] The resource scheduling method of this embodiment will describe how to distribute the load of a sparse matrix to multiple computing units in a processor and balance the computing load on each computing unit as much as possible.
[0044] like Figure 3 As shown, the resource scheduling method may include the following processing:
[0045] In step 300, a plurality of scheduling units in a sparse matrix are sorted according to the size of the loads of the plurality of scheduling units. The loads are used to represent the non-zero elements included in the scheduling units.
[0046] The scheduling unit may be a row of a sparse matrix or a column of a sparse matrix.
[0047] For example, Figure 2 For example, Figure 2 The B1 row in can be called a "scheduling unit", and B2 can also be called a "scheduling unit". In the following method description, the "row" of the sparse matrix is taken as the scheduling unit as an example, but it can be understood that the method is also applicable to the case where the "column" of the sparse matrix is used as the scheduling unit.
[0048] In this step, the scheduling units of the sparse matrix can be sorted. Figure 2 B1 to B6 in the scheduling unit are sorted. Specifically, the sorting may be performed according to the size of the load of the scheduling unit, wherein the load may refer to the non-zero elements included in the scheduling unit. For example, the load of B1 is 5 non-zero elements, the load of B2 is a non-zero element, the load of B3 is 3 non-zero elements, and so on. The non-zero elements are elements that are not 0, for example, the values of the non-zero elements may be non-zero values such as 1 / 3 / 5.
[0049] See also Figure 4 As shown in the figure, after sorting multiple scheduling units according to the size of the load of the scheduling unit, the sparse matrix will form new B1 to B6. B1 is still the first row of the sparse matrix, but B1 has become the row containing 6 non-zero elements, which is equivalent to the row containing the largest number of non-zero elements in the original sparse matrix rising to the first row of the matrix. Similarly, other rows move down in sequence. The first to sixth rows of the sorted sparse matrix "B1 to B6" are arranged in order from large to small load. The first row is the row with the largest load, and the last row is the row with the smallest load.
[0050] In step 302, based on the sorting result, the plurality of scheduling units included in the sparse matrix are allocated to the plurality of computing units, so that the computing units calculate the non-zero elements in the scheduling units.
[0051] In this step, each row in the sparse matrix is assigned to multiple SMs for calculation.
[0052] When the rows of the sparse matrix are specifically scheduled to the SM, the scheduling may be performed based on the sorting result of step 300. When scheduling based on the sorting result, the allocation may be performed by reducing the load difference between the computing units, and there may be multiple specific allocation methods. Two of them are listed below:
[0053] In an exemplary implementation, it may be:
[0054] First, taking the computing resources including SM0 to SM2 as an example, the first N scheduling units in the sorting result can be allocated to each SM in descending order of load, and each SM is responsible for calculating one scheduling unit. N is equal to the number of SMs. Then, see Figure 5 As shown, in the order of load from large to small, B1 to B3 are first distributed to SM0 to SM2 in sequence, wherein SM0 is responsible for calculating B1, SM1 is responsible for calculating B2, and SM2 is responsible for calculating B3.
[0055] Next, the load on SM2 is the smallest, so it finishes the calculation first. Then, according to the sorting result, the next scheduling unit to be calculated in the sorting result is assigned to SM2. In this example, the next scheduling unit to be calculated in the sorting result is B4, so SM2 is assigned to calculate B4. Similarly, SM1 finishes the calculation and is assigned to calculate B5. Then, SM0 finishes the calculation and is assigned to calculate B6.
[0056] In this case, from Figure 5 It can be seen that the load calculated on SM0 is 7 non-zero elements, and the load calculated on SM1 and SM2 is also 7 non-zero elements. The load from SM0 to SM2 is balanced.
[0057] In addition, from the above Figure 5 From the scheduling process, we can see that this scheduling method can make the SM that finishes the calculation first be assigned to the scheduling unit with a larger load, and the SM that finishes the calculation later will be assigned to the scheduling unit with a smaller load. The SM that finishes the calculation first usually finishes the calculation first because of the smaller load, and the SM that finishes the calculation later usually finishes the calculation because of the larger load. Then, this allocation will make the SM that originally had a larger load get a smaller load in the next round of allocation, and the SM that originally had a smaller load will get a larger load in the next round of allocation, thereby achieving load balancing and reducing the load difference between each SM.
[0058] In another exemplary implementation, it may be:
[0059] First, according to the sorting result, the multiple scheduling units included in the sparse matrix are divided into multiple unit groups, each unit group includes: at least one scheduling unit; the number of the multiple unit groups is equal to the number of computing units.
[0060] For example, still Figure 4 Take the sorted sparse matrix in as an example, the matrix includes 6 scheduling units, namely 6 rows from B1 to B6. In this example, the computing resources include three SMs, namely SM0 to SM2, so the 6 rows from B1 to B6 can be divided into three unit groups, where each unit group can include two rows.
[0061] For details, please refer to Figure 5 According to the sorting result, the loads of B1 to B6 in the sorted sparse matrix are sorted from large to small, B1 includes 6 non-zero elements, B2 includes 5 non-zero elements, and so on. When dividing the unit group, the following two unit group division methods can be used:
[0062] Example of unit group division method 1:
[0063] The row with the heaviest load and the row with the least load can be grouped into a cell, namely B1+B6; and the row ranked second from the positive number and the row ranked second from the bottom can be grouped into a cell, namely B2+B5; the row ranked third from the positive number and the row ranked third from the bottom can be grouped into a cell, namely B3+B4.
[0064] This division method is similar to "size matching". For example, B1 with the largest load is combined with B6 with the smallest load. B2 has one less non-zero element than B1, that is, the load is slightly reduced. Then B5 matched with B2 has one more non-zero element than B6. Then the combined load of B2 and B5 is not much different from the combined load of B1+B6.
[0065] Example of unit group division method 2:
[0066] Since there are three SMs in total, the first three scheduling units in the sorting results can be used as the first scheduling units in multiple cell groups in order of load from large to small. For example, B1 is used as the first scheduling unit of the cell group assigned to SM0 (which can be called cell group 0), B2 is used as the first scheduling unit of the cell group assigned to SM1 (which can be called cell group 1), and similarly, B3 is used as the first scheduling unit of the cell group assigned to SM2 (which can be called cell group 2). That is, the first three in the sorting results are first determined as rows in the cell groups corresponding to each SM.
[0067] Then, starting from the 4th scheduling unit in the sorting result, that is, starting from B4, for each scheduling unit, the scheduling unit can be assigned to the unit group corresponding to the computing unit that finishes the calculation first, and the computing unit that finishes the calculation first is determined based on the load of the corresponding unit group, and can be considered to be assigned to the unit group with the smallest load.
[0068] For example, taking B4 as an example, B4 needs to be assigned to the cell group corresponding to the SM that finishes the calculation first. As mentioned above, the load of cell group 0 is 6 non-zero elements (B1 includes 6 non-zero elements), the load of cell group 1 is 5 non-zero elements, and the load of cell group 2 is 4 non-zero elements. Therefore, it is obvious that SM2 corresponding to cell group 2 will first finish the calculation of the scheduling unit before B4 is assigned, that is, the total load of cell group 2 is the smallest. Based on this, B4 can be assigned to cell group 2.
[0069] For another example, take B5 as an example. For B5, B4 has been allocated at this time. The situation of each unit group is as follows:
[0070] Unit group 0: B1—6 non-zero elements;
[0071] Unit group 1: B2—5 non-zero elements;
[0072] Unit group 2: B3+B4—7 non-zero elements;
[0073] As described above, based on the load comparison of each unit group, the load of unit group 1 is the smallest, and its corresponding SM1 will end the calculation first, so it is determined to allocate B5 to SM1.
[0074] In the same way, B6 can be assigned to unit group 0. Then, after all scheduling units of the sparse matrix are assigned, the three unit groups are as follows:
[0075] Unit group 0: B1+B6
[0076] Unit group 1: B2+B5
[0077] Unit group 2: B3+B4
[0078] Next, the above multiple cell groups are assigned to multiple computing units, and each computing unit is responsible for calculating the non-zero elements in a cell group. For example, cell group 0 can be assigned to SM0, and SM0 is responsible for calculating the non-zero elements in B1 and B6; cell group 1 can be assigned to SM1, and SM1 is responsible for calculating the non-zero elements in B2 and B5; similarly, cell group 2 can be assigned to SM2, and SM2 is responsible for calculating the non-zero elements in B3 and B4.
[0079] The difference between the above two methods of assigning scheduling units in the sparse matrix to SMs based on the sorting results is that the former method can be scheduled one by one, for example, a SM first calculates the non-zero elements of a row of the sparse matrix, and after the SM finishes calculating the row, it obtains another row of the sparse matrix for calculation, and the order of obtaining rows is in descending order of load. The latter method first determines which rows of the sparse matrix are to be assigned to the SM (these rows form a unit group), and then assigns these rows to the SM at once.
[0080] For example, according to the former method, SM first calculates B1, and after calculating B1, obtains B6 for calculation. According to the latter method, it can be determined that B1 and B6 are to be allocated to SM first, and then both B1 and B6 are allocated to SM at one time, and then SM performs calculation, for example, SM can calculate B1 first and then calculate B6.
[0081] As mentioned above, the above two scheduling methods are only examples and are not limited to them in actual implementation. Regardless of the scheduling method, when allocating each scheduling unit in the sparse matrix to the SM according to the sorting result, a principle can be followed, that is, when scheduling each scheduling unit to the SM, pay attention to making the load between each SM relatively balanced as much as possible, that is, as long as this scheduling method can make the load between each SM as balanced as possible.
[0082] It should be noted that the resource scheduling method of the embodiment of this specification may not guarantee that the load on each SM is completely equal, but it can reduce the difference in load between each SM and balance the load of each SM to the greatest extent, thereby improving the performance of sparse matrix calculation.
[0083] Here is an example application scenario:
[0084] In the scenario of graph computing, graph data can be represented by sparse matrices, the most common of which is the adjacency matrix. The nodes in the graph can correspond to the rows and columns of the matrix. For example, if there are M nodes in the graph, an M*M matrix can be created. In this matrix, the elements on the diagonal are all 0 because no node is connected to itself. The non-zero elements in the matrix indicate the existence of an edge. For example, if there is an edge between i and node j in the graph, a non-zero value is filled in the position of the i-th row and j-th column of the matrix. The non-zero value is the non-zero element, and its value can be the weight of the edge.
[0085] For example, the adjacency matrix can be in the following matrix format, which is a sparse matrix:
[0086] Table 1 Example sparse matrix
[0087] Matrix rows B1 0 1 1 1 1 B2 1 0 0 1 0 B3 1 1 0 1 1 B4 1 1 1 0 0 B5 0 0 0 1 0
[0088] When the product of the above-mentioned adjacency matrix and another matrix is to be calculated, it can be calculated by GPU, and multiple SMs included in GPU are used for parallel calculation to speed up the calculation efficiency. According to the resource scheduling method of the aforementioned embodiment of this specification, B1 to B5 will be sorted according to the load of each row (for example, the number of non-zero elements included), and after sorting, illustratively, the partial rows with the load in the first few places can be distributed to each SM according to the sorting result from large to small. Then when the SM finishes the calculation, the next row to be calculated is obtained in sequence from the sorting result. These SMs cooperate to complete the calculation of matrix multiplication. Due to the resource scheduling method according to the embodiment of this specification, the load on each SM will be relatively balanced, and there will be no long mutual waiting time between SMs, which can improve the efficiency of sparse matrix calculation.
[0089] In addition, in the above embodiments, a row of a sparse matrix is used as an example of a scheduling unit, but the actual implementation is not limited to this. For example, the scheduling unit can also be a column of a sparse matrix, see Figure 6 The indication is that Figure 6 The illustrated sparse matrix is also a matrix of 6 rows and 6 columns. During scheduling, one column is used as the scheduling unit. For example, column C1 can be assigned to a certain SM for calculation, and column C2 can be assigned to another SM for calculation. C1 to C6 represent the 6 columns in the matrix, and it can be seen that the loads of the columns of the matrix are different. For example, column C1 has 6 non-zero elements, and column C5 has 2 non-zero elements.
[0090] During scheduling, the same scheduling method as in the above embodiment can be used, first sorting the columns of the matrix according to the load size, and then scheduling according to the sorting result. For example, several columns with the largest load can be first allocated to each SM, and then when a certain SM finishes calculation, the next column to be calculated can be obtained according to the sorting result.
[0091] Figure 7 FIG. 1 is a schematic diagram of a processor framework provided by an exemplary embodiment, and the processor can execute the resource scheduling method described in any of the above embodiments. Figure 7 As shown, the processor may include:
[0092] The computing resource 71 may include: a plurality of computing units for parallel computing, such as a computing unit 711 , a computing unit 712 , and a computing unit 713 .
[0093] The sorting module 72 is used to sort the multiple scheduling units according to the size of the load of the multiple scheduling units in the sparse matrix; the load is used to represent the non-zero elements included in the scheduling unit.
[0094] The scheduling module 73 is used to allocate the multiple scheduling units included in the sparse matrix to the multiple computing units according to the sorting result, so that the computing units calculate the non-zero elements in the scheduling units. When allocating according to the sorting result, the allocation is performed in a manner that reduces the load difference between the computing units.
[0095] In an example, the above-mentioned scheduling unit may be a row or a column of a sparse matrix.
[0096] For example, the processor may be a GPU, and the computing unit may be a SM.
[0097] In one example, the scheduling module 73, when used to allocate the multiple scheduling units included in the sparse matrix to the multiple computing units according to the sorting result, includes: in the order of load from large to small, the first N scheduling units in the sorting result are respectively allocated to each computing unit, and each computing unit is responsible for calculating one scheduling unit; N is equal to the number of computing units. When a computing unit finishes calculating the previous scheduling unit, the next scheduling unit to be calculated in the sorting result is allocated to the computing unit.
[0098] In one example, the scheduling module 73, when used to allocate the multiple scheduling units included in the sparse matrix to the multiple computing units according to the sorting result, includes: dividing the multiple scheduling units included in the sparse matrix into multiple unit groups according to the sorting result, each unit group includes: at least one scheduling unit; the number of the multiple unit groups is equal to the number of computing units. The multiple unit groups are respectively allocated to the multiple computing units; each computing unit is responsible for calculating the non-zero elements in a unit group.
[0099] In one example, the scheduling module 73 is used to divide multiple scheduling units included in the sparse matrix into multiple unit groups based on the sorting result, and each unit group includes: at least one scheduling unit, including: in order of load from large to small, the first N scheduling units in the sorting result are respectively used as the first scheduling units in the multiple unit groups; N is equal to the number of computing units; starting from the N+1th scheduling unit in the sorting result, the scheduling unit is allocated to the unit group with the smallest load.
[0100] Figure 8 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 8At the hardware level, the device includes a processor 802, an internal bus 804, a network interface 806, a memory 808, and a non-volatile memory 810, and may also include hardware required for other services. One or more embodiments of this specification may be implemented based on software, such as the processor 802 reading the corresponding computer program from the non-volatile memory 810 into the memory 808 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0101] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0102] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0103] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0104] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0105] An embodiment of the present specification provides a computer-readable storage medium on which computer instructions are stored. When the instructions are executed by a processor, a method of any embodiment of the present specification is implemented.
[0106] An embodiment of the present specification provides a computer program product, including a computer program, and when the computer program is executed by a processor, the method of any embodiment of the present specification is implemented.
[0107] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0108] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0109] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0110] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0111] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.
Claims
1. A resource scheduling method, characterized in that: The method is applied to a processor, and the computing resources on the processor include: a plurality of computing units for parallel computing; The method comprises: Sort the multiple scheduling units according to the loads of the multiple scheduling units in the sparse matrix; the loads are used to represent the non-zero elements included in the scheduling units; According to the sorting result, the multiple scheduling units included in the sparse matrix are allocated to the multiple computing units so that the computing units calculate the non-zero elements in the scheduling units; wherein, when allocating according to the sorting result, the allocation is performed in a manner to reduce the load difference between the various computing units.
2. The method according to claim 1, characterized in that The scheduling unit is a row of the sparse matrix; Alternatively, the scheduling unit is a column of the sparse matrix.
3. The method according to claim 1, characterized in that The allocating the plurality of scheduling units included in the sparse matrix to the plurality of computing units according to the sorting result includes: In descending order of load, the first N scheduling units in the sorting result are respectively allocated to each computing unit, and each computing unit is responsible for calculating one scheduling unit; N is equal to the number of computing units; When a calculation unit finishes calculating a previous scheduling unit, the next scheduling unit to be calculated in the sorting result is allocated to the calculation unit.
4. The method according to claim 1, characterized in that: The allocating the plurality of scheduling units included in the sparse matrix to the plurality of computing units according to the sorting result includes: According to the sorting result, the plurality of scheduling units included in the sparse matrix are divided into a plurality of unit groups, each unit group including: at least one scheduling unit; the number of the plurality of unit groups is equal to the number of computing units; The multiple cell groups are respectively allocated to multiple computing units; each computing unit is responsible for calculating the non-zero elements in a cell group.
5. The method according to claim 4, characterized in that According to the sorting result, the plurality of scheduling units included in the sparse matrix are divided into a plurality of unit groups, each unit group including: at least one scheduling unit, including: In descending order of load, the first N scheduling units in the sorting result are respectively used as the first scheduling unit in the plurality of unit groups; N is equal to the number of computing units; Starting from the N+1th scheduling unit in the sorting result, the scheduling unit is allocated to the unit group with the smallest load.
6. A processor, characterized in that: The processor comprises: Computing resources, the computing resources comprising: a plurality of computing units for parallel computing; A sorting module, used for sorting the multiple scheduling units according to the loads of the multiple scheduling units in the sparse matrix; the loads are used to represent the non-zero elements included in the scheduling units; A scheduling module is used to allocate multiple scheduling units included in the sparse matrix to the multiple computing units based on the sorting result, so that the computing units calculate the non-zero elements in the scheduling units; wherein, when allocating based on the sorting result, the allocation is performed in a manner to reduce the load difference between the various computing units.
7. The processor according to claim 6, characterized in that The scheduling unit is a row of the sparse matrix; Alternatively, the scheduling unit is a column of the sparse matrix.
8. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 5 by running the executable instructions.
9. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the instruction is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Cited By
Data processing method, graphics processor, electronic equipment and medium
CN121903834A
Data processing method, graphics processor, electronic device, and medium
CN121903834B
