WO2014131317A1 - 一种核资源分配方法、装置及众核系统 - Google Patents

一种核资源分配方法、装置及众核系统 Download PDF

Info

Publication number
WO2014131317A1
WO2014131317A1 PCT/CN2014/070061 CN2014070061W WO2014131317A1 WO 2014131317 A1 WO2014131317 A1 WO 2014131317A1 CN 2014070061 W CN2014070061 W CN 2014070061W WO 2014131317 A1 WO2014131317 A1 WO 2014131317A1
Authority
WO
WIPO (PCT)
Prior art keywords
core
partition
partitions
cores
migration
Prior art date
Application number
PCT/CN2014/070061
Other languages
English (en)
French (fr)
Inventor
吴小科
王伟
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP14756339.9A priority Critical patent/EP2921957A4/en
Publication of WO2014131317A1 publication Critical patent/WO2014131317A1/zh
Priority to US14/791,730 priority patent/US20150309842A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a method, a device, and a core system for allocating a nuclear resource.
  • the processor has entered the multi-core/many-core era, increasing the number of schedulable cores in the computer system, and assigning multiple threads in the same process to different cores to run, so that multi-core parallel cooperation is completed. Specific tasks.
  • the cores can be physically partitioned to form multiple domains (representing core partitions). Each domain can contain multiple locations that are contiguous or A decentralized core can provide a set of nuclear resources of different domains to different applications to alleviate resource competition.
  • a current core core is determined from the current domain, and the current core traversal detects the load of each core in the current domain, and finds the busiest core;
  • the busiest core determines if the busiest core is the current core, and if so, terminate the operation; otherwise, traverse the load condition of each run queue in the busiest core and find the busiest run queue of the busiest core; then, combine with the current core
  • the load condition determines the number of processes that can be moved, and moves a certain number of processes from the above-mentioned busiest running queue to the current core running queue to implement load balancing of the current domain.
  • the current domain is used as a child node, and it is switched to the parent node to which it belongs, and the parent node is load-balanced according to the above method.
  • this method lacks global unified management of the core, which will generate a large number of scattered cores, so that the nuclear resource partitions containing fewer core resources cannot be allocated, and each core cannot be used to respond to the application, resulting in a core.
  • the waste of resources affects the parallel processing power of multi-core/many-core processors.
  • the method, device and multi-core system for allocating a nuclear resource are used to improve communication efficiency between processes and parallel processing capability of a processor.
  • an embodiment of the present invention provides a method for allocating a core resource, which is used to allocate a core resource in a many-core platform, where the method includes:
  • each core partition is a set of one or more cores and all cores in each core partition are idle cores;
  • the successive core partitions formed are assigned to the user process.
  • the acquiring the number of idle cores required by the user process includes:
  • the database stores a correspondence between the user process and the number of idle cores.
  • the at least two distributed core partitions are formed into a continuous core partition, including:
  • the remaining other core partitions are migrated, and the reference core partitions are merged with other core partitions to form the consecutive core partitions.
  • the remaining other core partitions of the migration include:
  • the at least two distributed core partitions are formed into a continuous core partition, including:
  • one reference core partition and one core partition migration are determined from the merged core partition and the remaining other core partitions until the at least two distributed core partitions are merged Form a continuous nuclear partition.
  • the migration cost is determined according to the length of the migration path and/or the number of migration cores, where the migration path is long. The migration cost is large, and if the number of migration cores is large, the migration cost is large.
  • the migrating the slave core partition includes:
  • the allocated The number of cores in the core partition is the same as the number of cores in the slave core partition;
  • the assigning the task to the slave core partition includes:
  • the task is transferred to the slave core partition according to the shortest migration path.
  • an eighth possible implementation manner if there are at least two shortest migration paths, the number of cores included in the core partition according to the shortest migration path, The shortest migration path is weighted, and the shortest path with the smallest weight is determined as the optimal path, and the task is transferred according to the optimal path.
  • the manner of the weighting processing is:
  • Adding the weights of the core partitions through which the shortest path passes is the weight of the shortest path; wherein the weight of the core partition is the number of cores included in the core partition, or the weight of the core partition A weight determined according to the number of cores included in the core partition.
  • a tenth possible implementation if there are at least two optimal paths, calculating at least one of the consecutive core partitions formed by the optimal path migration The nuclear distribution of the two nuclear partitions is dense, and the secondary nuclear partitions are migrated, so that the nuclear distribution of the continuous nuclear partitions is the most dense.
  • the manner of calculating the density of the core distribution is:
  • any one of the first to the eleventh possible implementation manners of the first aspect in the twelfth possible implementation, at least two dispersed core partitions satisfying the number request As a combination, if there are at least two combinations satisfying the number request, calculating the density of the core partition distribution of each combination, and determining the combination with the highest density of the core partition as the optimal combination, and then forming the most At least two discrete core partitions of the good combination constitute the continuous core Area.
  • the manner of calculating the density of the core partition distribution is:
  • the method further includes:
  • Determining whether there is a continuous core partition satisfying the number request in the many-core platform if yes, assigning the continuous core partition to the user process; if not, performing the finding to satisfy the number request.
  • an embodiment of the present invention provides a core resource allocation apparatus, configured to allocate a core resource in a many-core platform, where the apparatus includes:
  • An obtaining unit configured to obtain a number of idle cores required by a user process
  • a searching unit configured to find at least two dispersed core partitions satisfying the number request, where each core partition is a set of one or more cores and all cores in each core partition are idle cores; And arranging, by the at least two distributed cores, a contiguous core partition; and an allocating unit, configured to allocate the consecutive core partition formed by the combining unit to the user process.
  • the acquiring unit is specifically configured to receive a request sent by the user process, and parse the request to obtain a number of idle cores required by the user process; or
  • the obtaining unit is specifically configured to search for an idle core number configuration database, and obtain a number of idle cores required by the user process, where the database stores a correspondence between the user process and the number of idle cores.
  • the combining unit includes:
  • a first selecting unit configured to select a reference core partition from the at least two dispersed core partitions
  • a first migration unit configured to migrate the remaining other core partitions, and merge the reference core partitions with other core partitions to form the consecutive core partitions.
  • the first migration unit includes:
  • a first saving unit configured to save a running task of an allocated core partition adjacent to the reference core partition, where the number of cores in the allocated core partition is the same as the number of cores in the other core partitions;
  • An allocating unit configured to allocate the task to the other core partition to run.
  • the combining unit includes:
  • a second selecting unit configured to select one reference core partition and one slave core partition from the at least two distributed core partitions according to a core partition migration cost, so as to minimize a total core partition migration cost, where the total The nuclear partition migration cost is the sum of the migration costs of each discrete core partition;
  • a second migration unit configured to migrate the slave core partition, and merge the slave core partition with the reference core partition; if there are remaining other core partitions, then from the merged core partition and remaining other cores A partition core partition and a core partition migration from the core partition are determined in the partition until the at least two distributed core partitions are merged to form a continuous core partition.
  • the second migration unit includes:
  • a second saving unit configured to save a running task of the allocated core partition adjacent to the reference core partition, where the number of cores in the allocated core partition is the same as the number of cores in the slave core partition;
  • An allocating unit configured to allocate the task to the slave core partition to run.
  • the second task allocation unit includes:
  • a first determining unit configured to determine a shortest migration path between the slave core partition and the reference core partition
  • a first allocation subunit configured to transfer the task to the slave core partition according to the shortest migration path.
  • a weighting processing unit configured to perform weighting processing on the shortest migration path according to the number of cores included in the core partition through which the shortest migration path passes, and determine the shortest path with the smallest weight when there are at least two shortest migration paths For the best path, the first allocation subunit is caused to relay the task according to the optimal path.
  • the second task allocation unit further includes:
  • a kernel density calculation unit configured to calculate a nuclear distribution density of at least two of the consecutive core partitions formed by migration according to an optimal path, and to migrate the slaves when there are at least two optimal paths
  • the nuclear partitioning makes the nuclear distribution of the continuous nuclear partitions the most dense.
  • the device further includes:
  • a core partition density calculation unit configured to use at least two distributed core partitions satisfying the number request as one combination, and if there are at least two combinations satisfying the number request, calculate a kernel partition distribution intensively for each combination The extent, and the combination with the highest degree of kernel partitioning is determined as the optimal combination, such that the combining unit makes up the continuous nuclear partition using at least two dispersed core partitions forming the optimal combination.
  • the apparatus further includes:
  • a determining unit configured to determine whether there is a continuous core partition that satisfies the number request in the many-core platform, if yes, assign the continuous core partition to the user process; if not, notify the search
  • the unit finds at least two scattered core partitions that satisfy the number request.
  • an embodiment of the present invention provides a many-core system, where the system includes multiple cores, and the multiple cores include one execution core, and the execution core is used to perform the multiple cores according to the foregoing method. Other multiple cores in the resource allocation.
  • the method, device and the many-core system for implementing the nuclear resource according to the present invention after obtaining the number of idle cores required by the user process, first finding and determining at least two dispersed core partitions, and then migrating the dispersed core partitions to form a A continuous core partition, and assigned to the user process to run.
  • Process interactions can be directly performed between different cores in a continuous core partition allocated to the user process, which improves the efficiency of inter-process communication.
  • it can effectively avoid waste of nuclear resources and improve the overall utilization of the processor and parallel processing capability.
  • Figure 1 is a schematic diagram of task assignment of a multi-core/many-core processor
  • Embodiment 1 is a flowchart of Embodiment 1 of a method for allocating a nuclear resource according to the present invention
  • FIG. 3 is a schematic diagram of a core area linked list and a connectivity diagram in an embodiment of the present invention
  • Figure 5 is a flowchart of Embodiment 2 of the step 103 combination process in the embodiment of the present invention.
  • FIG. 6 is a schematic diagram showing a distribution of dispersed core partition nodes in an embodiment of the present invention.
  • FIG. 7a is a schematic diagram of an example 1 of continuous core partitioning in an embodiment of the present invention.
  • FIG. 7b is a schematic diagram of a second example of continuous core partitioning in an embodiment of the present invention.
  • Embodiment 8 is a flowchart of Embodiment 2 of a method for allocating a nuclear resource according to the present invention
  • Embodiment 9 is a flowchart of Embodiment 3 of a method for allocating a nuclear resource according to the present invention.
  • FIG. 10 is a first distribution diagram of a pre-migration kernel partition in an embodiment of the present invention.
  • FIG. 11 is a first distribution diagram of a nuclear partition after migration in an embodiment of the present invention.
  • FIG. 12 is a second schematic diagram of a distribution of a pre-migration kernel partition in an embodiment of the present invention.
  • FIG. 13 is a second schematic diagram of a distribution of a nuclear partition after migration in an embodiment of the present invention.
  • FIG. 14 is a schematic diagram of Embodiment 1 of a nuclear resource allocation apparatus according to an embodiment of the present invention.
  • Figure 15 is a schematic diagram of Embodiment 1 of the combining unit 603 in the embodiment of the present invention.
  • Figure 16 is a schematic diagram of Embodiment 2 of the combining unit 603 in the embodiment of the present invention.
  • FIG. 17 is a schematic diagram of Embodiment 2 of a nuclear resource allocation apparatus according to an embodiment of the present invention.
  • FIG. 18 is a schematic diagram of Embodiment 3 of a nuclear resource allocation apparatus according to an embodiment of the present invention
  • FIG. FIG. 19 is a schematic diagram showing the hardware configuration of a core resource allocation apparatus according to an embodiment of the present invention.
  • the process of multi-core collaborative cooperation to complete the task is first introduced.
  • Multiple threads in the same process can be assigned to run on different cores, specifically can be assigned to run on consecutive cores, that is, multiple cores are located in a contiguous area, for example, see app3 in Figure 1; can also be assigned to Run on a decentralized core, see for example Task FS in Figure 1.
  • FS is located in a contiguous core resource partition.
  • the message exchange process between cores is fast and efficient.
  • FS is located in a distributed core. In order to complete the file system service, all FSs need to cooperate, and then pass between FS.
  • IPC communication implements message interaction, one FS needs to go through the core that is running other tasks to realize message communication with another FS, resulting in inefficient communication.
  • a large number of dispersed cores may be generated as shown in FIG. 1, which may also reduce the overall utilization of the processor and affect the parallel processing capability of the processor.
  • the current task requires 4 cores to run in parallel.
  • continuous resource partitioning should be allocated for the current task, in this case, between app2 and app4.
  • they will not be allocated because they do not meet the current task requirements, resulting in a waste of nuclear resources.
  • the present invention provides a new method for allocating nuclear resources for allocating nuclear resources in a multi-core platform, in order to improve the efficiency of inter-process communication, avoid waste of nuclear resources, improve overall utilization of the processor, and parallel Processing capacity.
  • FIG. 2 a flowchart of Embodiment 1 of a method for allocating a nuclear resource according to the present invention is shown, where the method includes:
  • Step 101 Obtain the number of idle cores required by the user process.
  • the technical solution of the present invention uniformly manages all cores in the processor from a global perspective.
  • the core resource allocation device starts resource allocation under the trigger of the user process.
  • the user process in the present invention may be a system service of an OS (Operating System).
  • OS Operating System
  • the core resource allocation device may apply for a core required for service initiation, and the nuclear resource allocation device may follow the solution of the present invention. Assign a contiguous core resource partition to the system service. In this way, system services can run in the core resource partitions assigned to them to provide specific services such as process services, device drivers, file services, virtual memory, and more.
  • the user process in the present invention may also be an application.
  • the core resource allocation device After receiving the application of the application, the core resource allocation device also allocates a continuous core resource partitioning program to run according to the solution of the present invention.
  • This step provides the following two specific implementations:
  • Manner 1 Receive a request sent by the user process, and parse the request to obtain a number of idle cores required by the user process.
  • the purpose of the user process sending a request to the nuclear resource allocation device is to apply for the core for its operation, so the request should include the number of cores required for the user process to run, so that the nuclear resource allocation device can resolve the request to know the number of idle cores required by the user process. .
  • Manner 2 Find an idle core number configuration database, obtain the number of idle cores required by the user process, and the database stores a correspondence between the user process and the number of idle cores.
  • the mapping relationship between the user process and the number of idle cores is pre-configured.
  • the configuration database (which can be embodied as a configuration file) is read to determine the number of idle cores required by the current user process.
  • the execution entity of the number of idle cores is obtained. From the software level, it may be embodied as the chip management module of the OS. From the hardware level, it may be embodied as running the chips management module. Core.
  • Step 102 Find at least two dispersed core partitions that satisfy the number request, where each A core partition is a collection of one or more cores and all cores in each core partition are idle cores.
  • the at least two scattered core partitions satisfying the number request means that the found at least two distributed core partitions contain the same total number of idle cores as the number of idle cores required by the user process. If several core partitions are referred to as decentralized core partitions, then it is indicated that the cores in any of the core partitions must communicate with other cores in the other core partitions.
  • the nuclear resource allocation device maintains a nuclear area linked list and a nuclear area connected graph, and can find a distributed nuclear partition by searching a linked list of the nuclear area.
  • the core area connectivity graph is drawn according to the location of all the core partitions (including the idle core partition and the allocated core partition) included in the processor, and is used to indicate the positional relationship between different core partitions and the number of cores included in different core partitions. See section I in the diagram shown in Figure 3. Where region0 ⁇ regionl4 represents 15 core partitions that have been allocated, and the black nodes circled by the dotted line represent two free core partitions (one containing two free cores, defined as the first idle core partition; one containing 4 An idle core, defined as the second idle core partition).
  • the core area linked list is used to store the nodes pointing to the idle core partitions in the connectivity diagram of the core area.
  • the nuclear resource allocation device traverses the core area linked list to determine the dispersed core partitions through the corresponding nodes. For details, refer to the schematic diagram shown in FIG. Part II. Where free core region1 is a node that can point to the first idle core partition in the connected graph, and free core region 2 is a node that can point to the second idle core partition in the connected graph.
  • the nuclear resource allocation device maintains the linked list and connectivity diagram shown in Figure 3, and can traverse the linked list to find at least two discrete core partitions that meet the needs of the user process when needed.
  • step 102 it may be determined whether the total number of current idle cores in the lower processor meets the needs of the user process, that is, the total number of current idle cores is not less than that required by the user program. If the number of cores is satisfied, step 102 is performed. Otherwise, the request of the user process may be temporarily cached.
  • the processor is capable of running the user process, the user process is allocated a continuous core partition according to the solution of the present invention. Still taking the linked list shown in Figure 3 as an example, if the user process requests 8 core resources, then as shown in Figure 3, the processor currently has only 6 idle cores, The user process requirements can be met, so the request for applying for 8 core resources can be temporarily cached.
  • step 102 it is also feasible to perform the above-described judging process before step 102, because two results are also generated after step 102, one is to find at least two scattered core partitions satisfying the number request, and can continue according to the present invention.
  • the solution allocates resources; the other is not found (that is, the current number of idle cores does not meet the requirements of the user process), and the request of the user process can also be cached, and then processed when the processor has the capability.
  • Step 103 Partition the at least two dispersed cores into one continuous core partition.
  • the at least two distributed kernel partitions may be merged into one continuous core partition by migrating the core partitions, that is, the distributed kernel partitions are changed.
  • the location, the different partitions to be assigned to the user process are merged together, so that during the running of the user process, different cores can directly exchange messages through IPC communication without going through any core running other tasks. There is no need to wait for the core of other tasks to idle before performing message interaction, which can improve the communication efficiency of the processor and maximize the parallel processing capability of the processor.
  • Step 104 Assign the formed consecutive core partitions to the user process.
  • Step 103 After the combination forms a continuous core partition, the core resource allocating device can allocate the continuous core partition to the user process, so that all the cores included in the continuous core partition run in parallel and cooperate to complete the task.
  • continuous nuclear partitioning can be understood as that any two cores in the partition can exchange information without using other cores other than the partition, that is, when any one of the partitions communicates with other cores in the partition, there is no need to go through A core outside the partition.
  • the technical object of the present invention can be achieved by forming at least two dispersed core partitions into one continuous core partition. More preferably, the cost of dispersing the core partition to form a continuous core partitioning process can be considered, and Make the cost as small as possible, and this will be explained in the next one.
  • the cost in the present invention can be understood from the following two aspects: on the one hand, the length of the migration path and the number of migration cores, the path length is costly, and the number is large and costly; It is the cost of saving the task in the migration process, which can be embodied as the cost of saving the context, such as the process control block part that saves the processor state information, and can include the program. Counters, other processor registers, and stack information, when the process is migrated to another core resource partition, the process control block portion of the previously saved processor state information needs to be loaded.
  • step 103 The implementation of the process of forming at least two discrete core partitions into a contiguous core partition in step 103 is explained below.
  • Embodiment 1 of the combining process may include:
  • Step 201 Select a reference core partition from the at least two dispersed core partitions.
  • Step 202 Migrate the remaining other core partitions, and merge the reference core partition with other core partitions to form the consecutive core partitions.
  • the method of selecting the reference core partition it may be a random selection; or the migration cost may be considered, which will be located in the central area (the central area here is determined according to the actual distribution position of at least two dispersed nuclear partitions).
  • the core partition of a relatively central area is determined as the reference core partition, so that the migration path of the remaining other core partitions is as short as possible (the shorter the migration path, the smaller the migration cost;); or it may be the one with the largest number of cores.
  • the partition is determined to be the reference core partition, so that the number of migrated cores is as small as possible (the nuclear migration is the same as the migration of the entire partition, but the migration cost of each partition is affected by the number of migrated cores. The more the number of cores participating in the migration, the more the migration cost. Big) .
  • the migration in the present invention refers to vacating the cores of some allocated partitions around the reference core partition, that is, adjusting the cores of some running tasks around the reference core partition to idle cores.
  • the process of assigning tasks to other core partitions in step 202 can be implemented as follows:
  • the present invention also provides continuous
  • Step 301 Select a reference core partition and a slave from the at least two distributed core partitions according to a core partition migration cost. Core partitioning to minimize the total core partition migration cost, wherein the total core partition migration cost is the sum of the migration costs of the respective dispersed core partitions;
  • Step 302 The slave core partition is migrated, and the slave core partition is merged with the reference core partition.
  • Step 303 if there are remaining other core partitions, then the merged core partition and the remaining other core partitions Determining a reference core partition and a core partition migration from the core partition until the at least two core partitions are merged to form a continuous core partition.
  • the reference core partition is re-determined according to the actual situation.
  • the reference core partition is re-determined according to the actual situation.
  • the reference core partition is re-determined according to the actual situation.
  • the baseline core partition can be redefined before the next migration process based on the actual migration.
  • the baseline core partition re-determined for this migration is the baseline core partition of the last migration process.
  • a continuous kernel partition can be formed by performing a migration from the core partition according to the method of this embodiment.
  • the reference core partition and the slave core partition need to be re-determined for the second and more core partitions. Migration, no more details here.
  • the reference core partition and the slave core partition are selected according to the core partition migration cost, so that the total core partition migration cost is minimized, and the explanation is explained.
  • the total core partition migration cost refers to the sum of the costs of each migration process in the process of forming a distributed core partition into a continuous core partition.
  • the cost of migration is mainly The impact of the migration path and the number of migration cores, that is, the migration cost is determined by the length of the migration path and/or the number of migration cores.
  • the cost of each migration should be as small as possible.
  • a decentralized kernel partition, or two remaining core partitions after multiple migrations, the reference core partition and the slave core partition may be determined by the number of cores included in the core partition, and the above description of the migration cost may be known to include the core.
  • a large number should be used as the reference core partition, including a small number of cores as a slave core partition.
  • the edge partition should be selected as much as possible (the edge partition can be understood as the partition farthest from the reference core partition, that is, the migration path).
  • the partition with the most partition nodes In general, the number of nodes between two adjacent partitions is defined as 1. If there is more than one partition between the two, the number of nodes is increased by 1. For example, there is one partition node in the middle interval. The number of nodes between two partitions is 2, the number of nodes between two partitions with 3 partition nodes is 4, the more nodes, the farther the distance between the two partitions or the core A small number of partitions. Still taking the schematic diagram shown in FIG.
  • the most edged partition D is determined to be from the core partition, so that the partition (AB) after the first migration can be concentrated as much as possible, and then in the second time.
  • B is determined as the reference core partition, and the migration distribution is more densely A and C', which minimizes the migration cost.
  • the migration distribution is relatively dispersed A and D, with the above migration A and The path is more than 4 miles longer, and the cost is much larger.
  • the process of migrating from the core partition in step 302 can be embodied as:
  • steps 302 and 303 are the same as the process of migrating the remaining core partitions in step 202 above, which is to make the allocated core partitions around the reference core partition idle, but the process is To reduce the migration cost, you need to pay attention to the order of partition migration. That is to say, in step 202, it is not limited to which partition in the remaining core partitions to migrate first and then which partition to migrate. Steps 302 and 303 migrate the kernel partitions, that is, the kernel partitions, which are determined according to the migration cost. There are order requirements. In addition, there is a different point to be noted.
  • steps 302 and 303 may re-determine a reference core partition before the next migration according to the actual situation after the migration.
  • the redefined baseline core partition may not be the same as the baseline core partition determined during the last migration.
  • the migration from the core partition is taken as an example to introduce the task to the implementation of the operation from the core partition.
  • the core partition c is to be migrated from the core partition to the reference core partition b, then it can be found that the core partition c contains two idle cores, and the allocated nuclear partition region9 is also Contains 2 cores. Without splitting region9, you can directly load the region9 task to the core partition c, freeing region9 and realizing the migration of core partition c.
  • the core partition d contains two idle cores, and the core partition regionl is allocated. It contains 8 cores. If some of the tasks of regionl l are directly loaded into the kernel partition d, the splitting of regionl l will occur, which will result in low efficiency of inter-process interaction between regionl 1 and therefore In the case where it is necessary to split the allocated core partition, the present invention implements the migration by means of task transfer.
  • the core partition d is transferred to the periphery of the core partition e through the paths regionl 0 and regionl 1, that is, some tasks of the regionlO are first loaded and run on the d, because d is adjacent to the regionlO, so There is no case of splitting regionlO; then some of the tasks of regionl l are loaded into d after the transfer, and the schematic shown in Figure 13 is formed, so that the combined core is realized without splitting any region.
  • the purpose of partitioning d and e In this embodiment, from the operation result, it is equivalent to shifting region1O first, and then shifting regionl1 to the right. Of course, it is not such a single kernel partition movement, which also includes complex task assignment and migration relay. process.
  • the task assignment when the task assignment is performed, if it is not necessary to split the allocated core partition around the reference core partition, the task assignment and loading are directly performed; if the split core partition needs to be split, press A certain migration path performs the transfer allocation of tasks.
  • the migration path will be transferred from the core partition to the reference core partition, which will also affect the migration cost.
  • the present invention also provides the following scheme to further reduce the migration cost.
  • a shortest migration path between the slave core partition and the reference core partition is determined; and the task is transited to the slave core partition according to the shortest migration path.
  • the length of the migration path directly affects the size of the migration cost. Therefore, before migrating from the core partition to the reference core partition, all paths that can be migrated from the core partition to the reference core partition should be determined.
  • the shortest path is found, that is, the path with the least cost of migration, and the migration of the core partition is performed according to the shortest path, that is, the saved task is allocated to run from the core partition according to the shortest path.
  • the core partition d is to be migrated from the core partition to the reference core partition e, in addition to the regionl0, regionl 1 path transit, and also through region6, region5, region8, region7 The path is transited.
  • the shortest migration path between the core partition and the reference core partition is determined. If there are at least two shortest migration paths, the shortest migration path is weighted according to the number of cores included in the core partition through which the shortest migration path passes. Processing, and determining the shortest path with the smallest weight as the best path, and transferring the task according to the best path.
  • the scheme is based on the first scheme. When more than one shortest migration path is determined, a best path is determined from the shortest migration path by weighting, and then the saved task is transferred to the slave according to the optimal path. Nuclear partition migration.
  • the so-called weighting process according to the number of cores included in the zoning means that the number of nucleus is used as the basis for determining the weight, and the least migrating cost is found as the best path from the at least two shortest migration paths by weighting processing. That is to say, in the case of the same migration path, there is another factor that affects the migration cost, that is, the number of cores participating in the task transfer, if the migration path passes If the number of core partition nodes is the same, the more the number of cores participating in the task transfer, the greater the migration cost, and vice versa.
  • the specific method of the weighting process in this solution is to add the weights of the core partition through which the shortest path passes as the weight of the shortest path.
  • there are several core partition nodes between two scattered core partitions, and these core partition nodes are regarded as " ⁇ , here, in order to have the same number of core partition nodes from the interval Selecting an optimal path in the path, no longer treats a core partition node as " ⁇ ", but adds the weight of the number of cores it contains, and finally obtains the value indicating the path migration cost. .
  • the number of cores included in the core partition node may be directly determined as a weight. For example, if one core partition node includes 4 cores, the weight of the core partition node is 4, if included. 2 cores, then the weight is 2. Alternatively, you can set different weights for partitions with different core numbers. For example, the partitions with 4 cores and the partitions with 2 cores can be set to 40% and 20%, respectively. Regardless of the above-mentioned way of determining the weight, it is to distinguish the core partition nodes containing different number of cores, so as to select the best path with the least migration cost by the number of cores when the number of nodes passing through the migration path is the same . The present invention does not limit the manner of determining the weight as long as the above object can be achieved.
  • the shortest migration path between the core partition and the reference core partition is determined. If there are at least two shortest paths, each shortest path is weighted separately, and the minimum value is determined as the best path; if at least And two optimal paths, respectively calculating a nuclear distribution density of at least two of the consecutive nuclear partitions formed by the migration of the at least two optimal paths, and migrating the secondary core partition to make the continuous core
  • the partition has the highest density of nuclear distribution.
  • the scheme is based on scheme 2, and when determining more than one optimal path, selecting one path from the best path for core partitioning by calculating the intensity of the nuclear distribution in the successive nuclear partitions. Migration.
  • the intensity of the scheme is mainly used to indicate the position distribution of multiple cores in a continuous nuclear partition. If the distribution of each core is more concentrated, the density is higher, and the distribution is more dispersed. As the most simple way to express the degree of intensity, it is to calculate the sum of the distances between the two cores; in order to more clearly reflect the fluctuation of the distribution relationship between different cores, it can also benefit
  • the degree of density is expressed by the sum of the squares of the distance between the two cores.
  • the density of the core can be clearly expressed by other alternatives, such as the number of cores distributed in the same size nuclear partition, and the distribution in the nuclear partition. The density of the core, etc.
  • the communication efficiency of the combined continuous core partition can also be considered.
  • the eight cores shown in Fig. 7a are highly dense, and can directly realize the message interaction between processes, and the communication efficiency is high; correspondingly, the eight cores shown in Fig. 7b are less dense, and include in I, II, III.
  • the core can directly realize the message interaction between processes, and the cores included in I and II respectively interact with the core contained in the IV, and may also be implemented by other cores (not shown), which will affect The communication efficiency of the processor.
  • FIG. 8 a flowchart of Embodiment 2 of a method for allocating a nuclear resource according to the present invention is shown. The method includes:
  • Step 401 Obtain the number of idle cores required by the user process.
  • Step 402 Find at least two dispersed core partitions satisfying the number request, wherein each core partition is a set of one or more cores and all cores in each core partition are idle cores.
  • Step 403 The at least two distributed core partitions that meet the number request are used as a combination, and it is determined whether there are at least two combinations that satisfy the number request. If yes, step 404 is performed; otherwise, step 405 is directly performed.
  • Step 404 Calculate the density of the core partition distribution of each combination, and determine the combination with the highest density of the core partition as the optimal combination, and then form the continuous by using at least two dispersed core partitions forming the optimal combination. Nuclear partition.
  • Step 405 Partition the at least two dispersed cores into one continuous core partition.
  • Step 406 Assign the formed consecutive core partitions to the user process. Different from the allocation method embodiment 1, after finding at least two scattered kernel partitions in this embodiment, it can be regarded as a combination, and before decentralized kernel partitions are formed into a continuous core partition, it can be determined first. There are several such combinations in the lower processor, and then one of the multiple combinations is determined as the optimal core partition combination, which can satisfy the number of idle cores required by the user process and ensure the migration cost as much as possible. small.
  • the user process needs a partition containing 8 cores
  • the kernel resource allocation device determines two combinations satisfying the requirements of the user process in the search process, one combination includes three core partitions, and each core partition separately contains 2 One, four, two cores; the other combination also contains three core partitions, but each core partition includes two, three, three cores, at which point one of the two combinations can be selected (device random To determine or choose the user to perform the migration process, you can also choose an optimal core partition combination from the two combinations (the so-called optimal kernel partition combination refers to the combination with the lowest total migration cost).
  • the method for determining the optimal kernel partition combination provided by the present invention is to calculate the density between the core partition nodes included in each combination, and the high degree of density indicates that the core partition nodes are concentrated, and the total migration cost is correspondingly small.
  • the way to calculate the degree of density between nodes in the nuclear partition is similar to the way in which the core density is calculated in the above scheme 3. It can be realized by calculating the sum of the distances between the nodes of the two cores or the sum of the squares of the distances. Narration. It should be noted that, except that the calculation objects are different (the calculation object in the third embodiment is a core included in the continuous kernel partition, and the calculation object in this embodiment is a distributed kernel partition for forming a continuous nuclear partition), There are also the following differences:
  • the communication efficiency of the core in the continuous nuclear partition is mainly reflected by the intensity.
  • the density is used to reflect the distribution between the nuclear partition nodes, and the migration cost of the nuclear partition nodes is reflected.
  • the migration path may also be implemented by using the third solution, that is, it may be required to calculate the intensity of the two times in a complete set of allocation processes: once there are at least two nuclear partitions.
  • Embodiment 3 of a method for allocating a nuclear resource according to the present invention is shown, where the method includes:
  • Step 501 Obtain a number of idle cores required by the user process.
  • Step 502 Determine whether there is a contiguous core partition that satisfies the number request in the many-core platform. If yes, perform step 503 to allocate the contiguous core partition to the user process. If not, perform step 504. .
  • Step 504 Find at least two dispersed core partitions that satisfy the number request, where each core partition is a set of one or more cores and all cores in each core partition are idle cores.
  • Step 505 Partition the at least two dispersed cores into one continuous core partition.
  • Step 506 Assign the formed consecutive core partitions to the user process.
  • the core resource allocation device before finding at least two dispersed core partitions, it is determined whether there is a continuous core partition in the many-core platform (that is, the processor) that satisfies both the user process requirements and the locations, if present
  • the contiguous core partition can be directly assigned to the user process without using a decentralized kernel partition to form a contiguous core partition. That is, after obtaining the number of idle cores required by the user process, the core resource allocation device directly searches for a continuous core partition that satisfies the number requirement, and only migrates the partition according to the present invention when the continuous core partition cannot be found. Merge a contiguous core partition for the user process.
  • the nuclear resource allocation device maintains the linked list of the nuclear area and the connected graph as an example, and introduces the process of the nuclear resource allocation process of the present invention.
  • the nuclear resource allocation device After the OS is started, the nuclear resource allocation device first starts to acquire information about all the cores of the processor (ie, the many-core platform), and then manages all the cores in a unified manner. When the user process starts, it will apply to the nuclear resource allocation device for the required nuclear partition, for example, 8 cores need to be applied.
  • the specific allocation process is as follows:
  • the core resource allocation device determines whether the total number of idle cores currently existing by the processor meets the number of idle cores required by the user process, and if not, caches the request of the user process; otherwise, the following allocation process is continued.
  • the search list determines whether there is a continuous core partition that satisfies the requirements of the user process, and if so, directly allocates the continuous core partition to the user. The process is running for it, and the status of the contiguous core partition in the connected graph is also updated, and the node corresponding to the contiguous core partition is removed from the linked list; otherwise, the following allocation process is continued.
  • the core resource allocation device traverses the linked list to find at least two distributed core partitions satisfying the number of user processes. For example, three partition nodes abc are determined from the processor core partition map shown in FIG. 10 (where a contains 3) Idle core, b contains 3 free cores, c contains 2 free cores, and partition node b is selected as the reference core partition. It is determined that the migration path of a is region3 and the migration path of c is region9 and regionl0. It should be noted that the black node in the figure represents the idle core, and the white node represents the allocated core.
  • c is selected as the slave core partition, and c is moved to b according to the migration path determined above, and the positional relationship of the partitions 13, 12, 10, 9, 5, a, c in the connected graph is updated.
  • a is selected as the slave core partition, and a is migrated to b according to the migration path determined above, so that the abc three are combined to form a continuous core partition 14, as shown in the migrated core shown in FIG.
  • the partition map and also update the location relationship of the partitions 0, 1, 5, 2, 3, 6, a, b in the connected graph, and update the partition abc in the connected graph that was originally idle to the allocated state.
  • Partition 14 removes the node corresponding to the original partition abc from the linked list.
  • Figure 3 shows the linked list after migration and update.
  • the priority of the task that is allocated to the allocated core partition and the user process that requests the allocation of the core resource can be determined.
  • Priority if the priority of the user process is lower, then the core partition migration is performed after the task of the allocated core partition is completed; if the priority of the user process is higher, the task of the allocated core partition is split. , free the partition to form a continuous core partition for the user process to run.
  • the present invention does not limit the circumstances under which the nuclear partition is migrated and the strategy for determining the migration (the priority described above is a strategy for determining migration), as long as the normal nuclear platform is working properly. , at least two discrete core partitions can be formed into a continuous core partition.
  • the present invention further provides a nuclear resource allocation device. Referring to FIG. 14, a schematic diagram of a device embodiment 1 is shown. The device includes:
  • the obtaining unit 601 is configured to acquire the number of idle cores required by the user process.
  • the acquiring unit is specifically configured to receive a request sent by the user process, and parse the request to obtain a number of idle cores required by the user process; or, the acquiring unit is specifically configured to find the number of idle cores.
  • the database is configured to obtain the number of idle cores required by the user process, and the database stores a correspondence between the user process and the number of idle cores.
  • the searching unit 602 is configured to find at least two dispersed core partitions satisfying the number request, wherein each core partition is a set of one or more cores and all cores in each core partition are idle cores.
  • the combining unit 603 is configured to partition the at least two dispersed cores into one continuous core partition.
  • the allocating unit 604 is configured to allocate the consecutive core partitions formed by the combining unit to the user process.
  • the present invention further provides a schematic diagram of the configuration of the embodiment 1 of the combination unit 603, as shown in FIG. 15 , corresponding to the combination process embodiment 1 shown in FIG.
  • the first selecting unit 6031 is configured to select one reference core partition from the at least two dispersed core partitions.
  • the first migration unit 6032 is configured to migrate the remaining other core partitions, and merge the reference core partitions with other core partitions to form the consecutive core partitions.
  • the first migration unit includes:
  • a first saving unit configured to save a running task of an allocated core partition adjacent to the reference core partition, where the number of cores in the allocated core partition is the same as the number of cores in the other core partitions;
  • An allocating unit configured to allocate the task to the other core partition to run.
  • the present invention further provides a schematic diagram of the configuration of Embodiment 2 of the combining unit 603.
  • the method includes:
  • a second selecting unit 6033 configured to remove from the at least two dispersed cores according to a core partition migration cost A reference core partition and a secondary core partition are selected in the partition to minimize the total core partition migration cost, wherein the total core partition migration cost is the sum of the migration costs of the respective dispersed core partitions.
  • a second migration unit 6034 configured to migrate the slave core partition, and merge the slave core partition with the reference core partition; if there are remaining other core partitions, then from the merged core partition and remaining others A core partition is determined in the core partition and a core partition migration is performed from the core partition until the at least two dispersed core partitions are merged to form a continuous core partition.
  • the second migration unit includes:
  • a second saving unit configured to save a running task of the allocated core partition adjacent to the reference core partition, where the number of cores in the allocated core partition is the same as the number of cores in the slave core partition;
  • An allocating unit configured to allocate the task to the slave core partition to run.
  • a first determining unit configured to determine a shortest migration path between the slave core partition and the reference core partition
  • a first allocation subunit configured to transfer the task to the slave core partition according to the shortest migration path.
  • the second task allocation unit further includes:
  • a weighting processing unit configured to perform weighting processing on the shortest migration path according to the number of cores included in the core partition through which the shortest migration path passes, and determine the shortest path with the smallest weight when there are at least two shortest migration paths For the best path, the first allocation subunit is caused to relay the task according to the optimal path.
  • the second task allocation unit further includes:
  • a kernel density calculation unit configured to calculate a nuclear distribution density of at least two of the consecutive core partitions formed by migration according to an optimal path, and to migrate the slaves when there are at least two optimal paths
  • the nuclear partitioning makes the nuclear distribution of the continuous nuclear partitions the most dense.
  • FIG. 17 a schematic diagram of Embodiment 2 of a core resource allocation apparatus is shown.
  • the apparatus includes: an obtaining unit 701, configured to acquire a number of idle cores required by a user process.
  • the searching unit 702 is configured to find at least two dispersed core partitions satisfying the number request, wherein each core partition is a set of one or more cores and all cores in each core partition are idle cores.
  • a core partition density calculation unit 703 configured to use at least two distributed core partitions satisfying the number request as one combination, and if there are at least two combinations satisfying the number request, calculate a kernel partition distribution of each combination The intensity is dense, and the combination with the highest density of nuclear partitions is determined as the best combination.
  • the combining unit 704 is configured to form at least two dispersed core partitions of the optimal combination into one continuous core partition.
  • the allocating unit 705 is configured to allocate the consecutive core partitions formed by the combining unit to the user process.
  • FIG. 18 a schematic diagram of Embodiment 3 of a nuclear resource allocation apparatus is shown.
  • the apparatus includes: an obtaining unit 801, configured to acquire a number of idle cores required by a user process.
  • the determining unit 802 is configured to determine whether there is a continuous core partition that satisfies the number request in the many-core platform, and if yes, allocate the continuous core partition to the user process.
  • the searching unit 803 is configured to: when the determining unit determines that the continuous core partition does not exist, find at least two dispersed core partitions that satisfy the number request, where each core partition is a set of one or more cores And all cores in each core partition are idle cores.
  • the combining unit 804 is configured to partition the at least two dispersed cores into one continuous core partition.
  • the allocating unit 805 is configured to allocate the consecutive core partition formed by the combining unit to the user process.
  • the present invention also provides a many-core system, the system comprising a plurality of cores, Each core includes an execution core for resource allocation to other ones of the plurality of cores in accordance with an allocation method provided by the present invention.
  • the execution core is the execution body of the allocation method of the present invention.
  • the embodiment of the present invention further provides a hardware configuration of the nuclear resource allocation device.
  • At least one processor e.g., a CPU
  • at least one network interface or other communication interface may be included for enabling connection communication between the devices.
  • the processor is configured to execute an executable module, such as a computer program, stored in the memory.
  • the memory may include a high speed random access memory (RAM: Random Access Memory), and may also include a non-volatile memory, such as at least one disk storage device.
  • the communication connection between the system gateway and at least one other network element is implemented by at least one network interface (which may be wired or wireless), and may use an Internet, a wide area network, a local network, a metropolitan area network, or the like.
  • program instructions are stored in a memory, and the program instructions may be executed by a processor, where the program instructions include an obtaining unit 601, a searching unit 602, a combining unit 603, an allocating unit 604, and specific Implementation can be seen in the corresponding unit disclosed in FIG.
  • the program instructions may include other units as disclosed in FIG. 17 or 18, and are not described herein again.
  • inventive arrangements may be described in the general context of computer-executable instructions executed by a computer, such as a program element.
  • program elements include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types.
  • inventive arrangements can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network.
  • program units can be located in both local and remote computer storage media including storage devices.
  • the various embodiments in the specification are described in a progressive manner, and the same or similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments.
  • the device embodiment since it is basically similar to the method embodiment, it is described in a relatively simple manner, and the relevant parts can be referred to the description of the method embodiment.
  • the device embodiments described above are merely illustrative, wherein the unit described as a separate component may be or They may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without any creative effort.

Abstract

本发明提供一种核资源分配方法、装置及众核系统,用于对众核平台中的核资源进行分配,所述方法包括:获取用户进程所需的空闲核数目;找到满足所述数目请求的至少两个分散的核分区,其中,每个核分区为一个或多个核的集合并且每个核分区中的所有核都是空闲核;将所述至少两个分散的核分区组成一个连续的核分区;将形成的所述连续的核分区分配给所述用户进程。这样,分配给用户进程的连续的核分区内的不同核之间就可以直接进行进程交互,提高了进程间通信的效率;同时还可以有效避免核资源浪费,提升处理器的整体利用率以及并行处理能力。

Description

一种核资源分配方法、 装置及众核系统 本申请要求于 2013 年 2 月 26 日提交中国专利局、 申请号为 201310059705.6、 发明名称为"一种核资源分配方法、 装置及众核系统"的中国 专利申请的优先权, 上述专利申请的全部内容通过引用结合在本申请中。
技术领域
本发明涉及通信技术领域, 具体涉及一种核资源分配方法、 装置及众核系 统。
背景技术
随着计算机技术的不断发展, 处理器已经迈入多核 /众核时代, 增加计算 机系统中可调度的核数, 将同一进程中的多个线程分配到不同的核上运行, 使多核并行合作完成特定任务。 为了提升多核 /众核处理器的使用效率, 降低 应用对核资源的竟争, 可以对核进行物理分区, 形成多个 domain (表示核分 区), 每个 domain可包含多个在位置上连续或分散的核, 可将不同 domain的 核资源集提供给不同应用来緩解资源竟争。
一般情况下, 在进行核分区之后, 还需要通过负载均衡机制实现对核的 管理和分配, 用以提升多核 /众核处理器的整体利用率, 充分发挥处理器的并 行处理能力。 目前的均衡方式可描述如下:
首先, 从当前 domain中确定出一个当前核 core, 并由该当前 core遍历检 测当前 domain中每个 core的负载情况, 找到最忙的 core;
其次, 判断最忙的 core是否是当前 core, 如果是则终止操作; 否则遍历 检测最忙 core中每个运行队列的负载情况,并找到最忙 core的最忙运行队列; 接着, 结合当前 core的负载情况确定出可挪动的进程数量, 并从上述最 忙运行队列中挪动确定数量的进程到当前 core 的运行队列中, 实现当前 domain的负载均衡。 最后, 将当前 domain作为子节点, 切换到其所属的父节点, 按照上述方 法对父节点进行负载均衡。
这种负载均衡方法就存在如下缺点:
经过核资源调度之后, 同一进程中的不同线程可能会被分配在距离较远 的分散 core上运行, 当线程间需要进行信息交互时, 可能要经过多个正在运 行其它任务的 core, 导致进程中的线程间通信发生冲突, 大大降低通信效率。 另外, 线程间的通信要等运行其它任务的 core空闲之后才能进行, 这也会导 致通信效率低下。
除此之外, 这种方式还缺乏对 core的全局统一管理, 会产生大量分散的 core , 致使包含较少核资源的核资源分区无法被分配出去, 无法利用每个 core 来响应应用, 造成核资源的浪费, 影响多核 /众核处理器的并行处理能力。
发明内容
本发明实施例的核资源分配方法、 装置及众核系统, 用以实现提高进程 间的通信效率以及处理器的并行处理能力。
为此, 本发明实施例提供如下技术方案:
第一方面, 本发明实施例提供了一种核资源分配方法, 用于对众核平台 中的核资源进行分配, 所述方法包括:
获取用户进程所需的空闲核数目;
找到满足所述数目请求的至少两个分散的核分区, 其中, 每个核分区为 一个或多个核的集合并且每个核分区中的所有核都是空闲核;
将所述至少两个分散的核分区组成一个连续的核分区;
将形成的所述连续的核分区分配给所述用户进程。
在第一方面的第一种可能的实现方式中, 所述获取用户进程所需的空闲 核数目, 包括:
接收所述用户进程发送的请求, 解析所述请求获得所述用户进程所需的 空闲核数目; 或者,
查找空闲核数目配置数据库, 获得所述用户进程所需的空闲核数目, 所 述数据库保存有所述用户进程与所述空闲核数目的对应关系。
结合第一方面以及第一方面的第一种可能的实现方式, 在第二种可能的 实现方式中, 所述将所述至少两个分散的核分区组成一个连续的核分区, 包 括:
从所述至少两个分散的核分区中选取一个基准核分区;
迁移剩余的其它核分区, 使所述基准核分区与其它核分区合并形成所述 连续的核分区。
结合第一方面的第二种可能的实现方式, 在第三种可能的实现方式中, 所述迁移剩余的其它核分区, 包括:
保存所述基准核分区相邻的已分配核分区正在运行的任务, 所述已分配 核分区中的核数目与所述其它核分区中的核数目相同;
将所述任务分配到所述其它核分区运行。
结合第一方面以及第一方面的第一种可能的实现方式, 在第四种可能的 实现方式中, 所述将所述至少两个分散的核分区组成一个连续的核分区, 包 括:
根据核分区迁移代价, 从所述至少两个分散核分区中选取一个基准核分 区和一个从核分区, 以使总的核分区迁移代价最小, 其中, 所述总的核分区 迁移代价为各个分散的核分区的迁移代价之和;
迁移所述从核分区, 使所述从核分区与所述基准核分区合并;
如果还有剩余的其它核分区, 则再从合并后的核分区和剩余的其它核分 区中确定一个基准核分区和一个从核分区进行核分区迁移, 直至将所述至少 两个分散核分区合并形成一个连续的核分区。
结合第一方面的第四种可能的实现方式, 在第五种可能的实现方式中, 根据迁移路径的长短和 /或迁移核数目的多少确定所述迁移代价, 其中, 所述 迁移路径长则迁移代价大, 所述迁移核数目多则迁移代价大。
结合第一方面的第四种可能的实现方式, 在第六种可能的实现方式中, 所述迁移所述从核分区, 包括:
保存所述基准核分区相邻的已分配核分区正在运行的任务, 所述已分配 核分区中的核数目与所述从核分区中的核数目相同;
将所述任务分配到所述从核分区运行。
结合第一方面的第四种可能的实现方式, 在第七种可能的实现方式中, 所述将所述任务分配到所述从核分区运行包括:
确定所述从核分区与所述基准核分区之间的最短迁移路径;
按照所述最短迁移路径将所述任务中转到所述从核分区运行。
结合第一方面的第七种可能的实现方式, 在第八种可能的实现方式中, 如果存在至少两个最短迁移路径, 则依据所述最短迁移路径经过的核分区包 含的核数目, 对所述最短迁移路径进行加权处理, 并将权值最小的最短路径 确定为最佳路径, 按照所述最佳路径中转所述任务。
结合第一方面的第八种可能的实现方式, 在第九种可能的实现方式中, 所述加权处理的方式为:
将所述最短路径经过的核分区的权值相加作为所述最短路径的权值; 其 中, 所述核分区的权值为所述核分区包含的核数目, 或者所述核分区的权值 为依据所述核分区包含的核数目多少确定的权重。
结合第一方面的第八种可能的实现方式, 在第十种可能的实现方式中, 如果存在至少两个最佳路径, 则计算按照最佳路径迁移形成的所述连续的核 分区中的至少两个核分区的核分布密集程度, 并迁移所述从核分区, 使所述 连续的核分区的核分布密集程度最高。
结合第一方面的第十种可能的实现方式, 在第十一种可能的实现方式中, 计算所述核分布密集程度的方式为:
计算所述连续的核分区中两两核之间的距离之和; 或者,
计算所述连续的核分区中两两核之间的距离平方之和。
结合第一方面、 第一方面的第一种至第十一种任一种可能的实现方式, 在第十二种可能的实现方式中, 将满足所述数目请求的至少两个分散的核分 区作为一个组合, 如果存在至少两个满足所述数目请求的组合, 则计算每个 组合的核分区分布密集程度, 并将核分区密集程度最高的组合确定为最佳组 合, 再利用形成所述最佳组合的至少两个分散的核分区组成所述连续的核分 区。
结合第一方面的第十二种可能的实现方式, 在第十三种可能的实现方式 中, 计算所述核分区分布密集程度的方式为:
计算所述组合中两两核分区之间的距离之和; 或者,
计算所述组合中两两核分区之间的距离平方之和。
结合第一方面、 第一方面的第一种至第十一种任一种可能的实现方式, 在第十四种可能的实现方式中, 在所述找到满足所述数目请求的至少两个分 散的核分区之前, 所述方法还包括:
判断所述众核平台中是否存在满足所述数目请求的连续核分区, 如果存 在, 则将所述连续核分区分配给所述用户进程; 如果不存在, 再执行所述找 到满足所述数目请求的至少两个分散的核分区的步骤。
第二方面, 本发明实施例提供了一种核资源分配装置, 用于对众核平台 中的核资源进行分配, 所述装置包括:
获取单元, 用于获取用户进程所需的空闲核数目;
查找单元, 用于找到满足所述数目请求的至少两个分散的核分区, 其中, 每个核分区为一个或多个核的集合并且每个核分区中的所有核都是空闲核; 组合单元, 用于将所述至少两个分散的核分区组成一个连续的核分区; 分配单元, 用于将所述组合单元形成的所述连续的核分区分配给所述用 户进程。
在第二方面的第一种可能的实现方式中, 所述获取单元, 具体用于接收 所述用户进程发送的请求, 并解析所述请求获得所述用户进程所需的空闲核 数目; 或者, 所述获取单元, 具体用于查找空闲核数目配置数据库, 获得所 述用户进程所需的空闲核数目, 所述数据库保存有所述用户进程与所述空闲 核数目的对应关系。
结合第二方面以及第二方面的第一种可能的实现方式, 在第二种可能的 实现方式中, 所述组合单元包括:
第一选取单元, 用于从所述至少两个分散的核分区中选取一个基准核分 区; 第一迁移单元, 用于迁移剩余的其它核分区, 使所述基准核分区与其它 核分区合并形成所述连续的核分区。
结合第二方面的第二种可能的实现方式, 在第三种可能的实现方式中, 所述第一迁移单元包括:
第一保存单元, 用于保存所述基准核分区相邻的已分配核分区正在运行 的任务, 所述已分配核分区中的核数目与所述其它核分区中的核数目相同; 第一任务分配单元, 用于将所述任务分配到所述其它核分区运行。
结合第二方面以及第二方面的第一种可能的实现方式, 在第四种可能的 实现方式中, 所述组合单元包括:
第二选取单元, 用于根据核分区迁移代价, 从所述至少两个分散核分区 中选取一个基准核分区和一个从核分区, 以使总的核分区迁移代价最小, 其 中, 所述总的核分区迁移代价为各个分散的核分区的迁移代价之和;
第二迁移单元, 用于迁移所述从核分区, 使所述从核分区与所述基准核 分区合并; 如果还有剩余的其它核分区, 则再从合并后的核分区和剩余的其 它核分区中确定一个基准核分区和一个从核分区进行核分区迁移, 直至将所 述至少两个分散核分区合并形成一个连续的核分区。
结合第二方面的第四种可能的实现方式, 在第五种可能的实现方式中, 所述第二迁移单元包括:
第二保存单元, 用于保存所述基准核分区相邻的已分配核分区正在运行 的任务, 所述已分配核分区中的核数目与所述从核分区中的核数目相同; 第二任务分配单元, 用于将所述任务分配到所述从核分区运行。
结合第二方面的第五种可能的实现方式, 在第六种可能的实现方式中, 所述第二任务分配单元包括:
第一确定单元, 用于确定所述从核分区与所述基准核分区之间的最短迁 移路径;
第一分配子单元, 用于按照所述最短迁移路径将所述任务中转到所述从 核分区运行。
结合第二方面的第六种可能的实现方式, 在第七种可能的实现方式中, 加权处理单元, 用于在存在至少两个最短迁移路径时, 依据所述最短迁 移路径经过的核分区包含的核数目, 对所述最短迁移路径进行加权处理, 并 将权值最小的最短路径确定为最佳路径, 使所述第一分配子单元按照所述最 佳路径中转所述任务。
结合第二方面的第七种可能的实现方式, 在第八种可能的实现方式中, 所述第二任务分配单元还包括:
核密集度计算单元, 用于在存在至少两个最佳路径时, 计算按照最佳路 径迁移形成的所述连续的核分区中的至少两个核分区的核分布密集程度, 并 迁移所述从核分区, 使所述连续的核分区的核分布密集程度最高。
结合第二方面、 第二方面的第一种至第八种任一种可能的实现方式, 在 第九种可能的实现方式中, 所述装置还包括:
核分区密集度计算单元, 用于将满足所述数目请求的至少两个分散的核 分区作为一个组合, 如果存在至少两个满足所述数目请求的组合, 则计算每 个组合的核分区分布密集程度, 并将核分区密集程度最高的组合确定为最佳 组合, 使所述组合单元利用形成所述最佳组合的至少两个分散的核分区组成 所述连续的核分区。
结合第二方面、 第二方面的第一种至第八种任一种可能的实现方式, 在 第十种可能的实现方式中, 所述装置还包括:
判定单元, 用于判断所述众核平台中是否存在满足所述数目请求的连续 核分区, 如果存在, 则将所述连续核分区分配给所述用户进程; 如果不存在, 再通知所述查找单元找到满足所述数目请求的至少两个分散的核分区。
第三方面, 本发明实施例提供了一种众核系统, 所述系统包括多个核, 所述多个核中包含一个执行核, 所述执行核用于按照上述方法对所述多个核 中的其它多个核进行资源分配。
本发明实施的核资源分配方法、 装置及众核系统, 获取到用户进程需要 的空闲核数目之后, 先查找确定至少两个分散的核分区, 然后再迁移所述分 散的核分区使之组成一个连续的核分区, 并分配给用户进程运行。 这样, 分 配给用户进程的连续的核分区内的不同核之间就可以直接进行进程交互, 提 高了进程间通信的效率; 同时还可以有效避免核资源浪费, 提升处理器的整 体利用率以及并行处理能力。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案, 下面将对实 施例或现有技术描述中所需要使用的附图作筒单地介绍, 显而易见地, 下面 描述中的附图仅仅是本申请中记载的一些实施例, 对于本领域普通技术人员 来讲, 还可以根据这些附图获得其它的附图。
图 1是多核 /众核处理器的任务分配示意图;
图 2是本发明核资源分配方法实施例 1的流程图;
图 3是本发明实施例中核区域链表与连通图的示意图;
图 4是本发明实施例中步骤 103组合过程实施例 1的流程图;
图 5是本发明实施例中步骤 103组合过程实施例 2的流程图;
图 6是本发明实施例中分散的核分区节点的一种分布示意图;
图 7a是本发明实施例中连续核分区示例一的示意图;
图 7b是本发明实施例中连续核分区示例二的示意图;
图 8是本发明核资源分配方法实施例 2的流程图;
图 9是本发明核资源分配方法实施例 3的流程图;
图 10是本发明实施例中迁移前核分区的第一种分布示意图;
图 11是本发明实施例中迁移后核分区的第一种分布示意图;
图 12是本发明实施例中迁移前核分区的第二种分布示意图;
图 13是本发明实施例中迁移后核分区的第二种分布示意图;
图 14是本发明实施例核资源分配装置实施例 1的示意图;
图 15是本发明实施例中组合单元 603实施例 1的示意图;
图 16是本发明实施例中组合单元 603实施例 2的示意图;
图 17是本发明实施例核资源分配装置实施例 2的示意图;
图 18是本发明实施例核资源分配装置实施例 3的示意图; 图 19是本发明实施例核资源分配装置的硬件构成示意图。
具体实施方式
为了使本技术领域的人员更好地理解本发明方案, 下面结合附图和实施 方式对本发明实施例作进一步的详细说明。
在介绍本发明核资源分配方法之前, 先对多核协同合作完成任务的过程 进行筒单介绍。 同一进程中的多个线程可以被分配到不同的 core上运行, 具 体可以被分配到连续的 core上运行, 即多个 core位于一个连续区域, 例如参 见图 1中的 app3; 也可以被分配到分散的 core上运行, 例如可参见图 1中的 任务 FS。
对于 app3来说,其位于连续的核资源分区内, core间的消息交互过程快、 效率高; FS位于分散的 core中, 为了完成文件系统服务, 需要所有 FS协同 合作, 则在 FS之间通过 IPC通信实现消息交互时, 一个 FS需要经过正在运 行其它任务的 core, 才可以实现与另一个 FS间的消息通信, 导致通信效率低 下。
另外, 采用现有技术进行核资源分配后即可能如图 1 所示产生大量分散 的 core, 对于这种情况还可能会降低处理器的整体利用率, 影响处理器的并 行处理能力。 例如, 当前任务需要 4个 core并行运行, 由上述分析可知, 为 了避免 core分散导致的通信效率低下, 应尽量为当前任务分配连续的核资源 分区, 在这种情况下, 对于 app2和 app4之间的 2个 core来说 , 就会因为不 满足当前任务需求而分配不出去, 导致核资源的浪费。 或者, 又例如, 预先 规定 6个 core为一个核资源分区, 且每个分区只负责管理其拥有的 core, 若 当前任务需要申请 5个 core并行运行, 那么将该任务分配到一个核资源分区 后, 该分区就会剩余一个 core, 同样造成了核资源的浪费。
为此, 本发明提供一种新的核资源分配方法, 用于对众核平台中的核资 源进行分配, 以期提高进程间通信的效率, 避免核资源浪费, 提升处理器的 整体利用率以及并行处理能力。 参见图 2, 示出了本发明核资源分配方法实施例 1的流程图, 所述方法包 括:
步骤 101 , 获取用户进程所需的空闲核数目。
本发明技术方案从全局角度统一管理处理器中所有的 core, 本步骤即是 核资源分配装置在用户进程的触发下开始进行资源分配。
本发明中的用户进程可以是 OS ( Operating System, 操作系统 )的系统服 务, 在系统服务启动时, 可以向核资源分配装置申请服务启动所需的 core, 核资源分配装置即会按照本发明方案将一块连续的 core资源分区分配给系统 服务。 这样, 系统服务便可运行在为其分配的 core资源分区中, 来提供特定 的服务, 例如进程服务、 设备驱动、 文件服务、 虚拟内存等。
另外, 本发明中的用户进程还可以是应用程序, 核资源分配装置在接收 到应用程序的申请之后, 同样会按照本发明方案分配一块连续的 core资源分 区供应用程序运行。
本步骤提供了以下两种具体实现方式:
方式一, 接收所述用户进程发送的请求, 解析所述请求获得所述用户进 程所需的空闲核数目。
用户进程向核资源分配装置发送请求的目的就是为了申请供其运行的 核, 因此请求中应包含用户进程运行需要的核数目, 这样核资源分配装置才 能解析请求获知用户进程所需的空闲核数目。
方式二, 查找空闲核数目配置数据库, 获得所述用户进程所需的空闲核 数目, 所述数据库保存有所述用户进程与所述空闲核数目的对应关系。
本方式中, 预先配置好用户进程与空闲核数目之间的映射关系, 当用户 进程启动的时候, 读取配置数据库 (可以体现为配置文件)确定出当前用户 进程所需的空闲核数目。
需要说明的是, 本步骤获取空闲核数目的执行主体, 从软件层面来说, 其可具体体现为是 OS的 chips管理模块, 从硬件层面来说, 其可具体体现为 是运行 chips管理模块的 core。
步骤 102, 找到满足所述数目请求的至少两个分散的核分区, 其中, 每个 核分区为一个或多个核的集合并且每个核分区中的所有核都是空闲核。
需要说明的是, 满足所述数目请求的至少两个分散的核分区是指, 找到 的至少两个分散的核分区包含的空闲核总数与用户进程所需的空闲核数目相 同。 而若将几个核分区称为分散的核分区, 那么就表示这些核分区中的任何 一个核分区中的核要与其它核分区中的核通信时, 必须经过不属于这些分区 的其它核。
作为本发明技术方案的一种实现方式, 核资源分配装置维护着一个核区 域链表和一个核区域连通图, 可以通过查找核区域链表的方式来查找分散的 核分区。
核区域连通图是按照处理器包含的所有核分区 (包括空闲核分区和已分 配核分区) 的位置绘制而成, 用于表示不同核分区间的位置关系、 不同核分 区包含的核数目 , 具体可参见图 3 所示示意图中的第 I部分。 其中 region0~regionl4表示的是 15个已被分配的核分区,虚线框圈起的黑色节点表 示的是 2个空闲核分区 (一个包含 2个空闲核, 定义为第一空闲核分区; 一 个包含 4个空闲核, 定义为第二空闲核分区) 。
核区域链表用于存放指向核区域连通图中空闲核分区的节点, 核资源分 配装置遍历核区域链表就能通过相应的节点确定出上述分散的核分区, 具体 可参见图 3所示示意图的第 II部分。 其中, free core regionl是能够指向连通 图中第一空闲核分区的节点, free core region2是能够指向连通图中第二空闲 核分区的节点。
核资源分配装置维护着图 3 所示的链表与连通图, 就可以在需要时遍历 链表查找满足用户进程需求的至少两个分散核分区。
需要说明的是, 为了提高本发明的分配效率, 在执行步骤 102之前, 可 以先判断下处理器中当前空闲 core的总数是否满足用户进程的需要, 即当前 空闲 core总数应不小于用户程序需要的核数目, 如果满足, 则执行步骤 102, 否则可暂时緩存用户进程的请求, 待到处理器有能力运行用户进程时, 再按 照本发明方案为用户进程分配连续的核分区。 仍以图 3 所示链表为例, 如果 用户进程请求 8个核资源, 则参见图 3可知处理器当前只有 6个空闲核, 不 能满足用户进程需求, 因此可暂时緩存该申请 8个核资源的请求。 当然, 不在步骤 102之前执行上述判断过程亦是可行的, 因为经步骤 102 之后也会产生两种结果, 一是查找到满足所述数目请求的至少两个分散的核 分区, 可继续按本发明方案进行资源分配; 另一是未查找到 (即当前空闲核 数目不满足用户进程的需求) , 同样可緩存用户进程的请求, 待处理器有能 力时再做处理。
步骤 103 , 将所述至少两个分散的核分区组成一个连续的核分区。
在步骤 102找到至少两个分散的核分区之后, 就可以通过迁移核分区的 方式, 使所述至少两个分散的核分区合并为一个连续的核分区, 也就是说, 要改变分散核分区的位置, 使将要分配给用户进程的不同分区合并到一起, 这样, 在用户进程运行过程中, 不同 core之间就可以直接通过 IPC通信进行 消息交互, 而无需经过任何运行其它任务的 core, 也就无需等待运行其它任 务的 core空闲后再进行消息交互, 从而可以提高处理器的通信效率, 使处理 器最大程度的发挥其并行处理能力。
步骤 104, 将形成的所述连续的核分区分配给所述用户进程。
步骤 103 组合形成一个连续核分区之后, 核资源分配装置即可将该连续 核分区分配给用户进程, 使该连续核分区中包含的所有 core并行运行, 协同 合作完成任务。 其中, 连续的核分区可以理解为, 分区中任意两个核不经过 分区之外的其它核即可进行信息交互, 也就是说, 分区中的任何一个核与分 区中其它核通信时, 无需经过分区之外的核。 对于步骤 103 来说, 只要将至少两个分散的核分区组成一个连续的核分 区即可实现本发明技术目的, 更优的, 还可考虑分散核分区组成连续核分区 过程中花费的代价, 并使代价尽量小, 对此将在后续一一展开说明。
需要说明的是, 本发明中花费的代价, 可从以下两个方面来理解, 一方 面是迁移路径的长短以及迁移核数目的多少, 路径长则代价大, 数目多代价 也大; 另一方面是迁移过程保存任务花费的代价, 具体可体现为保存上下文 环境花费的代价, 例如保存处理器状态信息的进程控制块部分, 可包括程序 计数器、 其它处理器寄存器和栈信息, 当进程迁移到另一个核资源分区上运 行时, 需要载入之前保存的处理器状态信息的进程控制块部分。
下面对步骤 103 中将至少两个分散的核分区组成一个连续的核分区的实 现过程进行解释说明。
参见图 4, 示出了组合过程实施例 1的流程图, 可包括:
步骤 201 , 从所述至少两个分散的核分区中选取一个基准核分区; 步骤 202, 迁移剩余的其它核分区,使所述基准核分区与其它核分区合并 形成所述连续的核分区。
也就是说, 要先确定一个分区作为基准核分区, 然后控制使剩余的其它 核分区分别迁移到该基准核分区附近, 从而使分散的分区合并组成一个连续 的核分区。
对于选取确定基准核分区的方式, 可以是随机的择一选定; 也可以考虑 迁移代价, 将位于中心区域(此处的中心区域, 是依据至少两个分散的核分 区的实际分布位置确定出的一个相对中心的区域) 的核分区确定为基准核分 区,使剩余其它核分区的迁移路径尽量短(迁移路径越短迁移代价也就越小;); 或者也可以是将包含核数目最多的分区确定为基准核分区, 使迁移的核数目 尽量少 (核迁移虽然是整个分区一起迁移, 但是每个分区的迁移代价又受迁 移的核数目影响, 参与迁移的核数目越多迁移代价就越大) 。
需要说明的是, 本发明中的迁移是指, 空出基准核分区周围的一些正在 使用的已分配分区的核, 也就是说, 将基准核分区周围的一些正在运行任务 的核调整为空闲核。 具体地, 步骤 202将任务分配到其它核分区的过程可体 现如下:
保存所述基准核分区相邻的已分配核分区正在运行的任务, 所述已分配 核分区中的核数目与所述其它核分区中的核数目相同; 将所述任务分配到所 述其它核分区运行。 在上述通过分区所处位置或者分区包含的核数目确定基准核分区, 使迁 移代价尽量小的基础之上, 为了进一步降低迁移代价, 本发明还提供了连续 的核分区的组合过程的实施例 2, 具体可参见图 5所示流程图, 包括: 步骤 301 ,根据核分区迁移代价, 从所述至少两个分散核分区中选取一个 基准核分区和一个从核分区, 以使总的核分区迁移代价最小, 其中, 所述总 的核分区迁移代价为各个分散的核分区的迁移代价之和;
步骤 302, 迁移所述从核分区, 使所述从核分区与所述基准核分区合并; 步骤 303 , 如果还有剩余的其它核分区, 则再从合并后的核分区和剩余的 其它核分区中确定一个基准核分区和一个从核分区进行核分区迁移, 直至将 所述至少两个核分区合并形成一个连续的核分区。
与上述实施例 1 不同的是, 本实施例中在每次迁移之后都会根据实际情 况重新确定一下基准核分区, 参见图 6所示示意图, 找到四个分散的核分区 ABCD, 在第一次迁移过程中将位于中心区域的 C确定为基准核分区, D确 定为从核分区, 并将 D迁移至 C处形成新的分区 C' , 如果在第二次迁移过 程中仍将 C' (也就是原来的 C所处的位置)作为基准核分区, 将 Α和 Β分 别迁移到 C' 处, 则迁移代价会较大, 这是因为在分区 AB C' 三者之中, 显 然 B是位于中心区域的,将 A和 C' 分别迁移到 B处,相对于将 A和 B迁移 到 C' 的代价要小。 因此可以根据实际迁移情况在执行下一次迁移过程之前 重新确定下基准核分区。 当然, 也可能本次迁移重新确定的基准核分区还是 上次迁移过程的基准核分区。
另外, 需要说明的是, 如果找到的满足用户进程数目请求的是两个分散 的核分区, 则按本实施例的方法进行一次从核分区迁移即可形成一个连续的 核分区。 但是, 如若找到的是至少三个分散的核分区, 则在确定一个从核分 区进行一次迁移之后, 还需要再重新确定基准核分区和从核分区, 进行第二 次以至更多次的核分区迁移, 此处不再赘述。 下面对步骤 301 中提及的, 根据核分区迁移代价选取基准核分区和从核 分区, 使总的核分区迁移代价最小, 进行解释说明。
首先, 需要说明的是, 总的核分区迁移代价指的是在将分散的核分区组 成连续的核分区的过程中每次迁移过程花费的代价的总和。 迁移代价主要受 迁移路径、 迁移核数目两方面因素的影响, 也就是说, 迁移代价是由迁移路 径长短和 /或迁移核数目多少来确定的。
为了使总的迁移代价最小就要使每次迁移的代价都尽量小, 一般情况下, 在分散的核分区较多时, 优选通过分区所处位置确定基准核分区和从核分区; 如果只找到两个分散的核分区, 或者是经过多次迁移后剩余两个分散的核分 区, 则可通过核分区包含的核数目确定基准核分区和从核分区, 居上述对 迁移代价的介绍可知, 包含核数目多的应作为基准核分区, 包含核数目少的 作为从核分区。
所谓使总的核分区迁移代价最小, 可以理解为在确定从核分区时, 应尽 量选取较为边缘的分区 (较为边缘的分区可以理解为距离基准核分区最远的 分区, 也即迁移路径中经过分区节点最多的分区。 一般情况下, 两个相邻分 区之间的节点数定义为 1 ,若二者之间多间隔一个分区则节点数就相应的加 1 , 例如中间间隔有 1个分区节点的两个分区之间的节点数为 2 ,间隔有 3个分区 节点的两个分区之间的节点数为 4, 节点数越多, 则说明两个分区之间的距离 越远)或含核数目少的分区。 仍以图 6所示示意图为例, 第一次迁移过程中 将最边缘的分区 D确定为从核分区, 就可使第一次迁移后的分区 (AB ) 都尽量集中, 进而在第二次迁移时将 B确定为基准核分区, 迁移分布密集程 度较高的 A和 C' , 使迁移代价最小。 相比较的, 如果在第一次迁移过程中 将 B确定为从核分区, 并将其迁移到 C处形成新的分区 C〃 , 然后迁移分布 相对分散的 A和 D, 与上述迁移 A和 的路径相比要长 4艮多, 相应地代价 也就要大很多。 步骤 302中迁移从核分区的过程, 可具体体现为:
保存所述基准核分区相邻的已分配核分区正在运行的任务, 所述已分配 核分区中的核数目与所述从核分区中的核数目相同; 将所述任务分配到所述 从核分区运行。
步骤 302和 303的迁移过程与上述步骤 202中迁移剩余的其它核分区的 过程相同, 均是使基准核分区周围的已分配核分区空闲出来, 只是本过程为 了降低迁移代价, 需要注意分区迁移的顺序。 也就是说, 步骤 202 中对剩余 其它核分区中先迁移哪个分区再迁移哪个分区并不做限定, 步骤 302和步骤 303则迁移的是根据迁移代价确定好的从核分区,也即核分区迁移存在顺序要 求。 此外, 还有一点不同需要说明的是, 步骤 202 中只存在唯——个基准核 分区, 步骤 302和步骤 303则可能要根据迁移后的实际情况在下次迁移之前 重新确定一个基准核分区, 而重新确定的基准核分区可能与上次迁移过程中 确定的基准核分区并不相同。
下面以迁移从核分区为例, 对将任务分配到从核分区运行的实现方式进 行筒单介绍。
第一种情况, 参见图 10所示示意图, 若要将核分区 c作为从核分区迁移 到基准核分区 b处, 则经过判断可发现核分区 c含有 2个空闲核, 已分配核 分区 region9也包含 2个核,在不需拆分 region9的情况下,即可直接将 region9 的任务加载到核分区 c上运行, 使 region9空闲出来, 实现核分区 c的迁移。
第二种情况, 参见图 12所示示意图, 若要将核分区 d作为从核分区迁移 到基准核分区 e处, 则经过判断可发现核分区 d含有 2个空闲核, 已分配核 分区 regionl l含有 8个核, 如果采用上述方式直接将 regionl l的部分任务加 载到核分区 d上运行, 则会出现拆分 regionl l的情况, 就会导致 regionl 1运 行的任务进程间交互效率低, 因此在需要拆分已分配核分区的情况下, 本发 明通过任务中转的方式实现迁移。具体体现为:将核分区 d通过路径 regionl 0、 regionl 1中转至核分区 e周围, 也就是说, 先将 regionlO的部分任务加载到 d 上运行, 因为 d与 regionlO相邻, 因此如此操作后也不会出现拆分 regionlO 的情况; 然后再将 regionl l的部分任务加载到中转后的 d上运行, 形成图 13 所示示意图, 这样在不拆分任何一个 region的情况下, 就实现了组合核分区 d 与 e的目的。 本实施例中, 从操作结果来说, 相当于先将 regionlO上移, 再 将 regionl l 右移, 当然, 其并不是如此筒单的核分区移动, 其中还包含着复 杂的任务分配与迁移中转过程。
也就是说, 在进行任务分配时, 如果无需拆分基准核分区周围的已分配 核分区, 则直接进行任务的分配与加载; 如果需要拆分已分配核分区, 则按 一定的迁移路径进行任务的中转分配。 在上述第二种情况下, 且依据本发明方法确定好最佳的基准核分区和从 核分区之后, 通过什么样的路径将从核分区中转迁移到基准核分区周围, 也 会影响到迁移代价, 对此, 本发明还提供了如下方案来进一步降低迁移代价。
方案一, 确定所述从核分区与所述基准核分区之间的最短迁移路径; 按 照所述最短迁移路径将所述任务中转迁移到所述从核分区运行。
如前文所说, 迁移路径的长短直接影响着迁移代价的大小, 因此在将从 核分区迁移到基准核分区之前, 应先确定出能够使从核分区迁移到基准核分 区的所有路径, 并从中找到最短的路径, 也就是迁移代价最小的路径, 按照 该最短路径进行核分区的迁移, 也即按照该最短路径将保存的任务分配到从 核分区运行。 仍以图 12所示示意图为例, 若要将核分区 d作为从核分区迁移 到基准核分区 e处, 除了可以通过 regionl0、 regionl 1路径中转之外, 还可通 过 region6、 region5、 region8、 region7路径中转, 然而通过比较就会发现 , 这 两条迁移路径的长短不同, 即路径经过的核分区节点数不同, 因此在上面的 示例中, 我们选取路径较短的 regionl 0、 regionl 1进行任务的中转迁移, 以使 本次迁移的代价最小。
方案二, 确定从核分区和基准核分区间的最短迁移路径, 如果存在至少 两个最短迁移路径, 则依据所述最短迁移路径经过的核分区包含的核数目, 对所述最短迁移路径进行加权处理, 并将权值最小的最短路径确定为最佳路 径, 按照所述最佳路径中转所述任务。
本方案即是在方案一的基础之上, 在确定出不止一个最短迁移路径时, 通过加权的方式从最短迁移路径中确定出一个最佳路径, 然后按照最佳路径 将保存的任务中转到从核分区迁移。
所谓依据经过的分区包含的核数目进行加权处理是指, 以核数目作为确 定权重的依据, 通过加权处理的方式从至少两个最短迁移路径中找到一个迁 移代价最小的作为最佳路径。 也就是说, 在迁移路径相同的情况下, 还有一 个因素会影响迁移代价, 就是参与任务中转的核数目, 如果迁移路径经过的 核分区节点数相同, 则参与任务中转的核数目越多, 迁移代价就越大, 反之 迁移代价就小。
本方案中加权处理的具体方式为, 将最短路径经过的核分区的权值相加 作为该最短路径的权值。 一般情况下, 在计算迁移路径时, 两个分散的核分 区之间间隔有几个核分区节点, 则将这些核分区节点视为 "Γ , 此处, 为了 从间隔有相同核分区节点数的路径中选择一个最佳路径, 不再筒单的将一个 核分区节点视为 "Γ , 而是视其包含的核数目取其权值相加, 并以此最终得 到表示该路径迁移代价的值。
对于核分区节点对应的权值来说, 可以直接将核分区节点包含的核数目 确定为权值, 例如, 一个核分区节点包含 4个核, 则该核分区节点的权值就 是 4, 如果包含 2个核, 则权值为 2。 或者, 还可为具有不同核数目的分区预 先设置不同的权值, 例如, 包含 4个核的分区和包含 2个核的分区的权值可 分别设置为 40%和 20%。 无论是上述哪种确定权值的方式, 其均是为了对包 含不同核数目的核分区节点加以区分, 以在迁移路径经过的节点数相同时, 通过核数目选择一个迁移代价最小的最佳路径。 本发明对确定权值的方式不 做限定, 只要能实现上述目的即可。
方案三, 确定从核分区和基准核分区间的最短迁移路径, 如果存在至少 两个最短路径, 则分别对每个最短路径进行加权处理, 将权值最小的确定为 最佳路径; 如果存在至少两个最佳路径, 则分别计算按照至少两个最佳路径 迁移形成的连续的核分区中的至少两个核分区的核分布密集程度, 并迁移所 述从核分区, 使所述连续的核分区的核分布密集程度最高。
本方案即是在方案二的基础之上, 在确定出不止一个最佳路径时, 通过 计算组成的连续核分区中的核分布的密集程度的方式, 从最佳路径中选择一 个路径进行核分区的迁移。
本方案中的密集程度主要用来表示连续的核分区中多个核间的位置分布 情况, 如果各个核分布的越集中则密集程度就越高, 分布的越分散密集程度 就越低。 作为表示密集程度的一种最筒单的实现方式, 就是统计两两核之间 的距离之和; 为了更明显的体现出不同核之间分布关系的波动情况, 还可利 用两两核间的距离平方和来表示密集程度, 除此之外, 通过其它可替换方式 亦可清楚体现出核的密集程度, 例如相同大小核分区中分布的核的数量、 核 分区中分布的核的密度等。
对于组合而成的连续核分区的密集程度来说, 可以参见图 7a和图 7b, 两 个连续的核分区同样是由 I 、 II、 III、 IV四个分散的核分区迁移形成, 且均 包含 8个 core, 然而通过计算两两核之间的距离平方和就会发现, 图 7a的密 集程度要高于图 7b (即与图 7b相比, 图 7a中 8个 core间的距离平方和要小 一些) , 因此在确定好基准核分区和从核分区, 且存在至少两个最佳路径时, 应迁移从核分区, 使之形成图 7a所示的连续核分区。
本方案中, 通过迁移路径和参与迁移的核数目无法确定迁移方式时, 还 可考虑组合而成的连续核分区的通信效率。 图 7a所示的 8个 core的密集程度 高, 可直接实现进程间的消息交互, 通信效率高; 相应地, 图 7b所示的 8个 core的密集程度较低, 在 I 、 II、 III包含的 core之间可以直接实现进程间的 消息交互, 而 I 、 II包含的 core分别与 IV包含的 core进行消息交互时, 可能 还要经过其它 core (图中未示出) 才能实现, 就会影响处理器的通信效率。 参见图 8, 示出了本发明核资源分配方法实施例 2的流程图, 所述方法包 括:
步骤 401 , 获取用户进程所需的空闲核数目。
步骤 402, 找到满足所述数目请求的至少两个分散的核分区, 其中, 每个 核分区为一个或多个核的集合并且每个核分区中的所有核都是空闲核。
步骤 403 , 将满足所述数目请求的至少两个分散的核分区作为一个组合, 判断是否存在至少两个满足所述数目请求的组合, 如果是, 则执行步骤 404, 否则直接执行步骤 405。
步骤 404, 计算每个组合的核分区分布密集程度, 并将核分区密集程度最 高的组合确定为最佳组合, 再利用形成所述最佳组合的至少两个分散的核分 区组成所述连续的核分区。
步骤 405 , 将所述至少两个分散的核分区组成一个连续的核分区。 步骤 406, 将形成的所述连续的核分区分配给所述用户进程。 与分配方法实施例 1 所不同的是, 本实施例中找到至少两个分散的核分 区之后, 可将其视为一个组合, 在将分散的核分区组成一个连续的核分区之 前, 可以先判断下处理器中存在几个这样的组合, 然后从多个组合中确定一 个作为最佳核分区组合, 该最佳核分区组合既能够满足用户进程所需的空闲 核数目, 又能保证迁移代价尽量小。
例如, 用户进程需要的是包含 8个核的分区, 核资源分配装置在查找过 程中确定了 2个满足用户进程需求的组合, 一个组合包含 3个核分区, 且每 个核分区又分别包含 2个、 4个、 2个 core; 另一个组合也包含 3个核分区, 但是每个核分区分别包括 2个、 3个、 3个 core, 此时可以从这两个组合中择 一(装置随机确定或者用户自主选择) 进行迁移处理, 也可以从这两个组合 中选取一个最佳核分区组合(所谓最佳核分区组合是指总的迁移代价最小的 组合) 。 本发明提供的确定最佳核分区组合的方式为, 计算每个组合包含的 核分区节点间的密集程度, 密集程度高就表示核分区节点分布集中, 相应地 总的迁移代价也就小。
计算核分区节点间密集程度的方式与上述方案三中介绍计算 core密集程 度的方式相类似, 可通过计算两两核分区节点间的距离之和或者距离的平方 和的方式实现, 此处不再赘述。 需要说明的是, 二者除了计算对象有所不同 之外 (方案三中计算对象是连续的核分区包含的 core, 本实施例中计算对象 是用于形成连续的核分区的分散核分区) , 还存在以下区别:
方案三中主要是利用密集程度反映连续的核分区中 core的通信效率, 本 实施例中主要是利用密集程度反映核分区节点间的分布情况, 进而反映出核 分区节点的迁移代价。 当然, 在本实施例任务分配过程中需要确定迁移路径 时, 也可能会利用方案三来实现, 也就是说在一整套分配流程中可能需要计 算两次密集程度: 一次是存在至少两个核分区组合时, 通过计算组合中至少 两个分散的核分区节点 (迁移前) 间密集程度的方式找到一个最佳核分区组 合; 一次是存在至少两个最佳路径时, 通过计算组合而成的连续的核分区(迁 移后) 中 core间密集程度的方式找到一个路径完成任务分配。 参见图 9 , 示出了本发明核资源分配方法实施例 3的流程图, 所述方法包 括:
步骤 501 , 获取用户进程所需的空闲核数目。
步骤 502 , 判断所述众核平台中是否存在满足所述数目请求的连续核分 区, 如果存在, 则执行步骤 503 将所述连续核分区分配给所述用户进程; 如 果不存在, 则执行步骤 504。
步骤 504, 找到满足所述数目请求的至少两个分散的核分区, 其中, 每个 核分区为一个或多个核的集合并且每个核分区中的所有核都是空闲核。
步骤 505 , 将所述至少两个分散的核分区组成一个连续的核分区。
步骤 506, 将形成的所述连续的核分区分配给所述用户进程。
本实施例中, 在找到至少两个分散的核分区之前, 先判断众核平台 (也 即处理器) 中是否存在既能满足用户进程需求, 又在位置上相邻的连续核分 区, 如果存在即可直接将该连续核分区分配给用户进程, 无需利用分散核分 区组成一个连续核分区。 也就是说, 核资源分配装置获取用户进程所需的空 闲核数目之后, 直接查找满足该数目要求的连续核分区, 只有在查找不到这 种连续核分区时才按本发明迁移分区的方案, 为用户进程合并一个连续的核 分区。 如此方案, 既能保证处理器的整体利用率以及通信效率, 又能提高本 发明核资源分配的效率。 下面以核资源分配装置维护核区域链表和连通图的方式为例, 对本发明 核资源分配的过程进行筒单介绍。
在 OS启动后, 核资源分配装置会首先启动获取处理器(即众核平台 )所 有核的信息, 然后统一管理所有的核。 在用户进程启动时, 会向核资源分配 装置申请所需要的核分区, 例如需要申请 8个核。 具体分配过程如下:
首先, 核资源分配装置判断处理器当前存在的空闲核总数是否满足用户 进程所需的空闲核数目, 如果不满足, 则緩存用户进程的请求; 否则继续下 述分配流程。 其次, 在核资源分配装置确定处理器当前的空闲核满足用户进程所需时, 查找链表判断是否存在一块连续核分区能满足用户进程的需求, 如果存在, 则直接将该连续核分区分配给用户进程供其运行, 同时还要更新连通图中该 连续核分区的状态为已分配, 并将该连续核分区对应的节点从链表中移除; 否则继续下述分配流程。
接着, 核资源分配装置遍历链表找到满足用户进程数目请求的至少两个 分散的核分区, 例如, 从图 10所示的处理器核分区分布图中确定了三个分区 节点 abc (其中 a包含 3个空闲 core, b包含 3个空闲 core, c包含 2个空闲 core ) , 并将分区节点 b选定为基准核分区, 确定好 a的迁移路径为 region3 , c的迁移路径为 region9、 regionl0。 需要说明的是, 图中黑色节点表示的是空 闲核, 白色节点表示的是已分配核。
然后, 将 c选定为从核分区, 并按上述确定的迁移路径将 c迁移至 b处, 同时更新连通图中分区 13、 12、 10、 9、 5、 a、 c 的位置关系。
最后, 将 a选定为从核分区, 并按上述确定的迁移路径将 a迁移至 b处, 使 abc三者组合形成一个连续的核分区 14,具体可参见图 11所示的迁移后的 核分区分布图, 同时还要更新连通图中分区 0、 1、 5、 2、 3、 6、 a、 b的位置 关系,并将连通图中原来为空闲状态的分区 abc更新为处于已分配状态的分区 14, 同时将原分区 abc对应的节点从链表中移除, 图 3即为迁移并更新后的链 表。
需要说明的是, 如果无法在不拆分基准核分区周围的已分配核分区的情 况下进行任务分配, 则可通过判断该已分配核分区运行的任务的优先级与请 求核资源分配的用户进程的优先级, 如果用户进程的优先级较低, 则等已分 配核分区运行的任务完成后, 再进行核分区迁移; 如果用户进程的优先级较 高, 则拆分已分配核分区运行的任务, 使该分区空闲出来形成连续核分区供 用户进程运行。 当然, 本发明对在什么情况下迁移核分区以及决定迁移的策 略(上述介绍的优先级即为一种决定迁移的策略) 方面并不做限定, 只要能 在保证众核平台正常工作的情况下, 将至少两个分散的核分区组成一个连续 的核分区即可。 相应地, 本发明还提供一种核资源分配装置, 参见图 14, 示出了装置实 施例 1的示意图, 所述装置包括:
获取单元 601 , 用于获取用户进程所需的空闲核数目。
其中, 所述获取单元, 具体用于接收所述用户进程发送的请求, 并解析 所述请求获得所述用户进程所需的空闲核数目; 或者, 所述获取单元, 具体 用于查找空闲核数目配置数据库, 获得所述用户进程所需的空闲核数目, 所 述数据库保存有所述用户进程与所述空闲核数目的对应关系。
查找单元 602 , 用于找到满足所述数目请求的至少两个分散的核分区, 其 中, 每个核分区为一个或多个核的集合并且每个核分区中的所有核都是空闲 核。
组合单元 603 , 用于将所述至少两个分散的核分区组成一个连续的核分 区。
分配单元 604,用于将所述组合单元形成的所述连续的核分区分配给所述 用户进程。
进一步地, 与图 4所示组合过程实施例 1相对应地, 本发明还提供组合 单元 603实施例 1的构成示意图, 参见图 15 , 包括:
第一选取单元 6031 , 用于从所述至少两个分散的核分区中选取一个基准 核分区。
第一迁移单元 6032, 用于迁移剩余的其它核分区, 使所述基准核分区与 其它核分区合并形成所述连续的核分区。
其中, 所述第一迁移单元包括:
第一保存单元, 用于保存所述基准核分区相邻的已分配核分区正在运行 的任务, 所述已分配核分区中的核数目与所述其它核分区中的核数目相同; 第一任务分配单元, 用于将所述任务分配到所述其它核分区运行。
进一步地, 与图 5所示组合过程实施例 2相对应地, 本发明还提供组合 单元 603实施例 2的构成示意图, 参见图 16, 包括:
第二选取单元 6033 , 用于根据核分区迁移代价, 从所述至少两个分散核 分区中选取一个基准核分区和一个从核分区, 以使总的核分区迁移代价最小, 其中, 所述总的核分区迁移代价为各个分散的核分区的迁移代价之和。
第二迁移单元 6034, 用于迁移所述从核分区, 使所述从核分区与所述基 准核分区合并; 如果还有剩余的其它核分区, 则再从合并后的核分区和剩余 的其它核分区中确定一个基准核分区和一个从核分区进行核分区迁移, 直至 将所述至少两个分散核分区合并形成一个连续的核分区。
其中, 所述第二迁移单元包括:
第二保存单元, 用于保存所述基准核分区相邻的已分配核分区正在运行 的任务, 所述已分配核分区中的核数目与所述从核分区中的核数目相同; 第二任务分配单元, 用于将所述任务分配到所述从核分区运行。
进一步地, 为了降低核分区的迁移代价, 在第二任务分配单元迁移从核 分区时, 还应选择一个合理的迁移路径, 对此本发明提供了以下三个方案: 方案一, 所述第二任务分配单元包括:
第一确定单元, 用于确定所述从核分区与所述基准核分区之间的最短迁 移路径;
第一分配子单元, 用于按照所述最短迁移路径将所述任务中转到所述从 核分区运行。
在上述方案一的基础上, 还提供如下方案二, 所述第二任务分配单元还 包括:
加权处理单元, 用于在存在至少两个最短迁移路径时, 依据所述最短迁 移路径经过的核分区包含的核数目, 对所述最短迁移路径进行加权处理, 并 将权值最小的最短路径确定为最佳路径, 使所述第一分配子单元按照所述最 佳路径中转所述任务。
在上述方案二的基础上, 还提供如下方案三, 所述第二任务分配单元还 包括:
核密集度计算单元, 用于在存在至少两个最佳路径时, 计算按照最佳路 径迁移形成的所述连续的核分区中的至少两个核分区的核分布密集程度, 并 迁移所述从核分区, 使所述连续的核分区的核分布密集程度最高。 参见图 17, 示出了核资源分配装置实施例 2的示意图, 所述装置包括: 获取单元 701 , 用于获取用户进程所需的空闲核数目。
查找单元 702 , 用于找到满足所述数目请求的至少两个分散的核分区, 其 中, 每个核分区为一个或多个核的集合并且每个核分区中的所有核都是空闲 核。
核分区密集度计算单元 703 ,用于将满足所述数目请求的至少两个分散的 核分区作为一个组合, 如果存在至少两个满足所述数目请求的组合, 则计算 每个组合的核分区分布密集程度, 并将核分区密集程度最高的组合确定为最 佳组合。
组合单元 704,用于将所述最佳组合的至少两个分散的核分区组成一个连 续的核分区。
分配单元 705 ,用于将所述组合单元形成的所述连续的核分区分配给所述 用户进程。 参见图 18, 示出了核资源分配装置实施例 3的示意图, 所述装置包括: 获取单元 801 , 用于获取用户进程所需的空闲核数目。
判定单元 802 ,用于判断所述众核平台中是否存在满足所述数目请求的连 续核分区, 如果存在, 则将所述连续核分区分配给所述用户进程。
查找单元 803 , 用于在所述判定单元判断不存在所述连续核分区时, 找到 满足所述数目请求的至少两个分散的核分区, 其中, 每个核分区为一个或多 个核的集合并且每个核分区中的所有核都是空闲核。
组合单元 804, 用于将所述至少两个分散的核分区组成一个连续的核分 区。
分配单元 805 ,用于将所述组合单元形成的所述连续的核分区分配给所述 用户进程。 除此之外, 本发明还提供一种众核系统, 所述系统包括多个核, 所述多 个核中包含一个执行核, 所述执行核用于按照本发明提供的分配方法对所述 多个核中的其它多个核进行资源分配。 需要说明的是, 执行核即是本发明分 配方法的执行主体, 在用户进程申请核资源时, 由执行核负责对系统中的其 它核进行资源分配, 以供用户进程运行。 进一步地, 本发明实施例还分别提供了核资源分配装置的硬件构成。 可 包括至少一个处理器(例如 CPU ) , 至少一个网络接口或者其它通信接口, 存储器, 和至少一个通信总线, 用于实现这些装置之间的连接通信。 处理器 用于执行存储器中存储的可执行模块, 例如计算机程序。 存储器可能包含高 速随机存取存储器 ( RAM: Random Access Memory ) , 也可能还包括非不稳 定的存 4诸器( non- volatile memory ) , 例如至少一个磁盘存 4诸器。 通过至少一 个网络接口 (可以是有线或者无线) 实现该系统网关与至少一个其它网元之 间的通信连接, 可以使用互联网, 广域网, 本地网, 城域网等。
参见图 19 , 在一些实施方式中, 存储器中存储了程序指令, 程序指令可 以被处理器执行, 其中, 程序指令包括获取单元 601、 查找单元 602、 组合单 元 603、 分配单元 604, 各单元的具体实现可参见图 14所揭示的相应单元。 或者程序指令还可包括图 17或 18所揭示的其它单元, 这里不再赘述。
本发明方案可以在由计算机执行的计算机可执行指令的一般上下文中描 述, 例如程序单元。 一般地, 程序单元包括执行特定任务或实现特定抽象数 据类型的例程、 程序、 对象、 组件、 数据结构等等。 也可以在分布式计算环 境中实践本发明方案, 在这些分布式计算环境中, 由通过通信网络而被连接 的远程处理设备来执行任务。 在分布式计算环境中, 程序单元可以位于包括 存储设备在内的本地和远程计算机存储介质中。
本说明书中的各个实施例均采用递进的方式描述, 各个实施例之间相同 相似的部分互相参见即可, 每个实施例重点说明的都是与其它实施例的不同 之处。 尤其, 对于装置实施例而言, 由于其基本相似于方法实施例, 所以描 述得比较筒单, 相关之处参见方法实施例的部分说明即可。 以上所描述的装 置实施例仅仅是示意性的, 其中所述作为分离部件说明的单元可以是或者也 可以不是物理上分开的, 作为单元显示的部件可以是或者也可以不是物理单 元, 即可以位于一个地方, 或者也可以分布到多个网络单元上。 可以根据实 际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。 本领域 普通技术人员在不付出创造性劳动的情况下, 即可以理解并实施。
以上对本发明实施例进行了详细介绍, 本文中应用了具体实施方式对本 发明进行了阐述, 以上实施例的说明只是用于帮助理解本发明的方法及设备; 同时, 对于本领域的一般技术人员, 依据本发明的思想, 在具体实施方式及 应用范围上均会有改变之处, 综上所述, 本说明书内容不应理解为对本发明 的限制。

Claims

权利要求 书
1、 一种核资源分配方法, 其特征在于, 用于对众核平台中的核资源进行分 配, 所述方法包括:
获取用户进程所需的空闲核数目;
找到满足所述数目请求的至少两个分散的核分区, 其中, 每个核分区为一 个或多个核的集合并且每个核分区中的所有核都是空闲核;
将所述至少两个分散的核分区组成一个连续的核分区;
将形成的所述连续的核分区分配给所述用户进程。
2、 根据权利要求 1所述的方法, 其特征在于, 所述获取用户进程所需的空 闲核数目, 包括:
接收所述用户进程发送的请求, 解析所述请求获得所述用户进程所需的空 闲核数目; 或者,
查找空闲核数目配置数据库, 获得所述用户进程所需的空闲核数目, 所述 数据库保存有所述用户进程与所述空闲核数目的对应关系。
3、 根据权利要求 1-2任一所述的方法, 其特征在于, 所述将所述至少两个 分散的核分区组成一个连续的核分区, 包括:
从所述至少两个分散的核分区中选取一个基准核分区;
迁移剩余的其它核分区, 使所述基准核分区与其它核分区合并形成所述连 续的核分区。
4、根据权利要求 3所述的方法, 其特征在于, 所述迁移剩余的其它核分区, 包括:
保存所述基准核分区相邻的已分配核分区正在运行的任务, 所述已分配核 分区中的核数目与所述其它核分区中的核数目相同;
将所述任务分配到所述其它核分区运行。
5、 根据权利要求 1-2任一所述的方法, 其特征在于, 所述将所述至少两个 分散的核分区组成一个连续的核分区, 包括:
根据核分区迁移代价, 从所述至少两个分散核分区中选取一个基准核分区 和一个从核分区, 以使总的核分区迁移代价最小, 其中, 所述总的核分区迁移 代价为各个分散的核分区的迁移代价之和;
迁移所述从核分区, 使所述从核分区与所述基准核分区合并;
如果还有剩余的其它核分区, 则再从合并后的核分区和剩余的其它核分区 中确定一个基准核分区和一个从核分区进行核分区迁移, 直至将所述至少两个 分散核分区合并形成一个连续的核分区。
6、 根据权利要求 5所述的方法, 其特征在于,
根据迁移路径的长短和 /或迁移核数目的多少确定所述迁移代价, 其中, 所 述迁移路径长则迁移代价大, 所述迁移核数目多则迁移代价大。
7、 根据权利要求 5所述的方法, 其特征在于, 所述迁移所述从核分区, 包 括:
保存所述基准核分区相邻的已分配核分区正在运行的任务, 所述已分配核 分区中的核数目与所述从核分区中的核数目相同;
将所述任务分配到所述从核分区运行。
8、 根据权利要求 5所述的方法, 其特征在于, 所述将所述任务分配到所述 从核分区运行包括:
确定所述从核分区与所述基准核分区之间的最短迁移路径;
按照所述最短迁移路径将所述任务中转到所述从核分区运行。
9、 根据权利要求 8所述的方法, 其特征在于, 如果存在至少两个最短迁移 路径, 则依据所述最短迁移路径经过的核分区包含的核数目, 对所述最短迁移 路径进行加权处理, 并将权值最小的最短路径确定为最佳路径, 按照所述最佳 路径中转所述任务。
10、 根据权利要求 9所述的方法, 其特征在于, 所述加权处理的方式为: 将所述最短路径经过的核分区的权值相加作为所述最短路径的权值; 其中, 所述核分区的权值为所述核分区包含的核数目, 或者所述核分区的权值为依据 所述核分区包含的核数目多少确定的权重。
1 1、 根据权利要求 9 所述的方法, 其特征在于, 如果存在至少两个最佳路 径, 则计算按照最佳路径迁移形成的所述连续的核分区中的至少两个核分区的 核分布密集程度, 并迁移所述从核分区, 使所述连续的核分区的核分布密集程 度最高。
12、 根据权利要求 11所述的方法, 其特征在于, 计算所述核分布密集程度 的方式为:
计算所述连续的核分区中两两核之间的距离之和; 或者,
计算所述连续的核分区中两两核之间的距离平方之和。
13、 根据权利要求 1-12任一项所述的方法, 其特征在于,
将满足所述数目请求的至少两个分散的核分区作为一个组合, 如果存在至 少两个满足所述数目请求的组合, 则计算每个组合的核分区分布密集程度, 并 将核分区密集程度最高的组合确定为最佳组合, 再利用形成所述最佳组合的至 少两个分散的核分区组成所述连续的核分区。
14、 根据权利要求 13所述的方法, 其特征在于, 计算所述核分区分布密集 程度的方式为:
计算所述组合中两两核分区之间的距离之和; 或者,
计算所述组合中两两核分区之间的距离平方之和。
15、 根据权利要求 1-12任一项所述的方法, 其特征在于, 在所述找到满足 所述数目请求的至少两个分散的核分区之前, 所述方法还包括:
判断所述众核平台中是否存在满足所述数目请求的连续核分区, 如果存在, 则将所述连续核分区分配给所述用户进程; 如果不存在, 再执行所述找到满足 所述数目请求的至少两个分散的核分区的步骤。
16、 一种核资源分配装置, 其特征在于, 用于对众核平台中的核资源进行 分配, 所述装置包括:
获取单元, 用于获取用户进程所需的空闲核数目;
查找单元, 用于找到满足所述数目请求的至少两个分散的核分区, 其中, 每个核分区为一个或多个核的集合并且每个核分区中的所有核都是空闲核; 组合单元, 用于将所述至少两个分散的核分区组成一个连续的核分区; 分配单元, 用于将所述组合单元形成的所述连续的核分区分配给所述用户 进程。
17、 根据权利要求 16所述的装置, 其特征在于, 所述获取单元, 具体用于接收所述用户进程发送的请求, 并解析所述请求 获得所述用户进程所需的空闲核数目; 或者,
所述获取单元, 具体用于查找空闲核数目配置数据库, 获得所述用户进程 所需的空闲核数目, 所述数据库保存有所述用户进程与所述空闲核数目的对应 关系。
18、根据权利要求 16-17任一所述的装置,其特征在于,所述组合单元包括: 第一选取单元, 用于从所述至少两个分散的核分区中选取一个基准核分区; 第一迁移单元, 用于迁移剩余的其它核分区, 使所述基准核分区与其它核 分区合并形成所述连续的核分区。
19、 根据权利要求 18所述的装置, 其特征在于, 所述第一迁移单元包括: 第一保存单元, 用于保存所述基准核分区相邻的已分配核分区正在运行的 任务, 所述已分配核分区中的核数目与所述其它核分区中的核数目相同;
第一任务分配单元, 用于将所述任务分配到所述其它核分区运行。
20、根据权利要求 16-17任一所述的装置,其特征在于,所述组合单元包括: 第二选取单元, 用于根据核分区迁移代价, 从所述至少两个分散核分区中 选取一个基准核分区和一个从核分区, 以使总的核分区迁移代价最小, 其中, 所述总的核分区迁移代价为各个分散的核分区的迁移代价之和;
第二迁移单元, 用于迁移所述从核分区, 使所述从核分区与所述基准核分 区合并; 如果还有剩余的其它核分区, 则再从合并后的核分区和剩余的其它核 分区中确定一个基准核分区和一个从核分区进行核分区迁移, 直至将所述至少 两个分散核分区合并形成一个连续的核分区。
21、 根据权利要求 20所述的装置, 其特征在于, 所述第二迁移单元包括: 第二保存单元, 用于保存所述基准核分区相邻的已分配核分区正在运行的 任务, 所述已分配核分区中的核数目与所述从核分区中的核数目相同;
第二任务分配单元, 用于将所述任务分配到所述从核分区运行。
22、 根据权利要求 21所述的装置, 其特征在于, 所述第二任务分配单元包 括:
第一确定单元, 用于确定所述从核分区与所述基准核分区之间的最短迁移 路径;
第一分配子单元, 用于按照所述最短迁移路径将所述任务中转到所述从核 分区运行。
23、 根据权利要求 22所述的装置, 其特征在于, 所述第二任务分配单元还 包括:
加权处理单元, 用于在存在至少两个最短迁移路径时, 依据所述最短迁移 路径经过的核分区包含的核数目, 对所述最短迁移路径进行加权处理, 并将权 值最小的最短路径确定为最佳路径, 使所述第一分配子单元按照所述最佳路径 中转所述任务。
24、 根据权利要求 23所述的装置, 其特征在于, 所述第二任务分配单元还 包括:
核密集度计算单元, 用于在存在至少两个最佳路径时, 计算按照最佳路径 迁移形成的所述连续的核分区中的至少两个核分区的核分布密集程度, 并迁移 所述从核分区, 使所述连续的核分区的核分布密集程度最高。
25、根据权利要求 16-24任一项所述的装置,其特征在于,所述装置还包括: 核分区密集度计算单元, 用于将满足所述数目请求的至少两个分散的核分 区作为一个组合, 如果存在至少两个满足所述数目请求的组合, 则计算每个组 合的核分区分布密集程度, 并将核分区密集程度最高的组合确定为最佳组合, 使所述组合单元利用形成所述最佳组合的至少两个分散的核分区组成所述连续 的核分区。
26、根据权利要求 16-24任一项所述的装置,其特征在于,所述装置还包括: 判定单元, 用于判断所述众核平台中是否存在满足所述数目请求的连续核 分区, 如果存在, 则将所述连续核分区分配给所述用户进程; 如果不存在, 再 通知所述查找单元找到满足所述数目请求的至少两个分散的核分区。
27、 一种众核系统, 其特征在于, 所述系统包括多个核, 所述多个核中包 含一个执行核, 所述执行核用于按照权利要求 1-15任一项所述的方法对所述多 个核中的其它多个核进行资源分配。
PCT/CN2014/070061 2013-02-26 2014-01-03 一种核资源分配方法、装置及众核系统 WO2014131317A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP14756339.9A EP2921957A4 (en) 2013-02-26 2014-01-03 METHOD AND APPARATUS FOR ALLOCATING A HEART RESOURCE, AND MULTICOVER SYSTEM
US14/791,730 US20150309842A1 (en) 2013-02-26 2015-07-06 Core Resource Allocation Method and Apparatus, and Many-Core System

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310059705.6A CN104008013B (zh) 2013-02-26 2013-02-26 一种核资源分配方法、装置及众核系统
CN201310059705.6 2013-02-26

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US14/791,730 Continuation US20150309842A1 (en) 2013-02-26 2015-07-06 Core Resource Allocation Method and Apparatus, and Many-Core System

Publications (1)

Publication Number Publication Date
WO2014131317A1 true WO2014131317A1 (zh) 2014-09-04

Family

ID=51368678

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/070061 WO2014131317A1 (zh) 2013-02-26 2014-01-03 一种核资源分配方法、装置及众核系统

Country Status (4)

Country Link
US (1) US20150309842A1 (zh)
EP (1) EP2921957A4 (zh)
CN (1) CN104008013B (zh)
WO (1) WO2014131317A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110750363A (zh) * 2019-12-26 2020-02-04 中科寒武纪科技股份有限公司 计算机存储管理方法和装置、电子设备和存储介质
CN111966479A (zh) * 2020-08-19 2020-11-20 支付宝(杭州)信息技术有限公司 业务处理、风险识别业务处理方法、装置及电子设备

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016074179A1 (zh) * 2014-11-12 2016-05-19 华为技术有限公司 一种数据处理方法及多核处理器系统
CN105808328B (zh) * 2014-12-31 2019-05-17 杭州华为数字技术有限公司 任务调度的方法、装置和系统
JP6666553B2 (ja) * 2016-05-10 2020-03-18 富士通株式会社 情報処理装置、ジョブ管理方法およびジョブ管理プログラム
US10691502B2 (en) 2016-06-03 2020-06-23 International Business Machines Corporation Task queuing and dispatching mechanisms in a computational device
US11029998B2 (en) 2016-06-03 2021-06-08 International Business Machines Corporation Grouping of tasks for distribution among processing entities
US10185593B2 (en) * 2016-06-03 2019-01-22 International Business Machines Corporation Balancing categorized task queues in a plurality of processing entities of a computational device
JP2018092311A (ja) * 2016-12-01 2018-06-14 キヤノン株式会社 情報処理装置、その制御方法、及びプログラム
TWI693548B (zh) * 2016-12-07 2020-05-11 聯發科技股份有限公司 動態調整多核心處理器的任務負載配置的裝置以及方法
CN107193656B (zh) * 2017-05-17 2020-01-10 深圳先进技术研究院 多核系统的资源管理方法、终端设备及计算机可读存储介质
US11150944B2 (en) 2017-08-18 2021-10-19 International Business Machines Corporation Balancing mechanisms in ordered lists of dispatch queues in a computational device
CN109558248B (zh) * 2018-12-11 2020-06-02 中国海洋大学 一种用于确定面向海洋模式计算的资源分配参数的方法及系统
WO2020150728A1 (en) 2019-01-18 2020-07-23 Quadric. Io, Inc. Systems and methods for virtually partitioning a machine perception and dense algorithm integrated circuit
CN111488216B (zh) * 2019-01-28 2024-04-30 北京灵汐科技有限公司 一种数据处理的方法、装置及电子设备
WO2020168505A1 (zh) * 2019-02-21 2020-08-27 华为技术有限公司 一种在多个处理器之间调度软件任务的方法和装置
CN110795385B (zh) * 2019-10-29 2023-11-03 飞腾信息技术有限公司 片上系统的可信核与计算核核资源分配方法及装置
CN113157427B (zh) * 2020-01-07 2024-03-15 中科寒武纪科技股份有限公司 任务迁移的方法、装置、计算机设备及可读存储介质
CN114546640A (zh) * 2022-02-14 2022-05-27 北京灵汐科技有限公司 数据处理方法、装置、芯片及介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090165016A1 (en) * 2007-12-19 2009-06-25 International Business Machines Corporation Method for Parallelizing Execution of Single Thread Programs
CN101499020A (zh) * 2008-01-28 2009-08-05 财团法人工业技术研究院 具有动态工作管理能力的多处理器界面及其程序载卸方法
CN102831011A (zh) * 2012-08-10 2012-12-19 上海交通大学 一种基于众核系统的任务调度方法及装置

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007099181A1 (es) * 2006-02-28 2007-09-07 Intel Corporation Mejora de la fiabilidad de un procesador de muchos nucleos
US20080229065A1 (en) * 2007-03-13 2008-09-18 Hung Qui Le Configurable Microprocessor
US20090089792A1 (en) * 2007-09-27 2009-04-02 Sun Microsystems, Inc. Method and system for managing thermal asymmetries in a multi-core processor
KR101366075B1 (ko) * 2007-12-20 2014-02-21 삼성전자주식회사 멀티코어 플랫폼에서의 태스크 이동 방법 및 장치
US8645965B2 (en) * 2007-12-31 2014-02-04 Intel Corporation Supporting metered clients with manycore through time-limited partitioning
US8180604B2 (en) * 2008-09-30 2012-05-15 Hewlett-Packard Development Company, L.P. Optimizing a prediction of resource usage of multiple applications in a virtual environment
US8495342B2 (en) * 2008-12-16 2013-07-23 International Business Machines Corporation Configuring plural cores to perform an instruction having a multi-core characteristic
US8056080B2 (en) * 2009-08-31 2011-11-08 International Business Machines Corporation Multi-core/thread work-group computation scheduler
US8904154B2 (en) * 2010-04-16 2014-12-02 Massachusetts Institute Of Technology Execution migration
US20120079501A1 (en) * 2010-09-27 2012-03-29 Mark Henrik Sandstrom Application Load Adaptive Processing Resource Allocation
CN102622208B (zh) * 2011-01-27 2015-06-10 中兴通讯股份有限公司 一种多核可重构处理器簇及其实现重构的方法
KR101859188B1 (ko) * 2011-09-26 2018-06-29 삼성전자주식회사 매니코어 시스템에서의 파티션 스케줄링 장치 및 방법

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090165016A1 (en) * 2007-12-19 2009-06-25 International Business Machines Corporation Method for Parallelizing Execution of Single Thread Programs
CN101499020A (zh) * 2008-01-28 2009-08-05 财团法人工业技术研究院 具有动态工作管理能力的多处理器界面及其程序载卸方法
CN102831011A (zh) * 2012-08-10 2012-12-19 上海交通大学 一种基于众核系统的任务调度方法及装置

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110750363A (zh) * 2019-12-26 2020-02-04 中科寒武纪科技股份有限公司 计算机存储管理方法和装置、电子设备和存储介质
CN111966479A (zh) * 2020-08-19 2020-11-20 支付宝(杭州)信息技术有限公司 业务处理、风险识别业务处理方法、装置及电子设备
CN111966479B (zh) * 2020-08-19 2024-03-29 支付宝(杭州)信息技术有限公司 业务处理、风险识别业务处理方法、装置及电子设备

Also Published As

Publication number Publication date
EP2921957A1 (en) 2015-09-23
CN104008013A (zh) 2014-08-27
EP2921957A4 (en) 2015-12-30
US20150309842A1 (en) 2015-10-29
CN104008013B (zh) 2018-02-09

Similar Documents

Publication Publication Date Title
WO2014131317A1 (zh) 一种核资源分配方法、装置及众核系统
TWI723459B (zh) 統一資源調度協調器及其創建虛擬機和/或容器的方法、統一資源調度系統
Devipriya et al. Improved max-min heuristic model for task scheduling in cloud
Singh et al. Task scheduling in cloud computing
JP4569846B2 (ja) I/oノード制御方式及び方法
CN101452406B (zh) 一种对操作系统透明的机群负载平衡方法
KR101850318B1 (ko) 가상 메모리 관리 장치 및 방법
Kaur et al. Analysis of job scheduling algorithms in cloud computing
WO2014032287A1 (zh) 中央处理器资源分配方法和计算节点
WO2013029487A1 (zh) 一种资源分配方法及资源管理平台
KR101859188B1 (ko) 매니코어 시스템에서의 파티션 스케줄링 장치 및 방법
WO2012100544A1 (zh) 基于网络数据流向的虚拟机迁移方法、设备和集群系统
CN110166507B (zh) 多资源调度方法和装置
CN103297499A (zh) 一种基于云平台的调度方法及系统
CN110990154B (zh) 一种大数据应用优化方法、装置及存储介质
Prajapati et al. Comparison of virtual machine scheduling algorithms in cloud computing
WO2013123650A1 (zh) 虚拟机分配方法和虚拟机分配装置
Yun et al. An integrated approach to workflow mapping and task scheduling for delay minimization in distributed environments
Fan et al. A live migration algorithm for containers based on resource locality
WO2024022142A1 (zh) 资源使用方法和装置
Johora et al. A load balancing strategy for reducing data loss risk on cloud using remodified throttled algorithm
CN105988856A (zh) 解释器访存优化方法及装置
Sharma et al. A review of cloud computing scheduling algorithms
Asan Baker Kanbar Modern load balancing techniques and their effects on cloud computing
Brandenburg Blocking optimality in distributed real-time locking protocols

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14756339

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2014756339

Country of ref document: EP

NENP Non-entry into the national phase

Ref country code: DE