CN109460296A - A kind of resource allocation methods of processor, device and storage medium - Google Patents

A kind of resource allocation methods of processor, device and storage medium Download PDF

Info

Publication number
CN109460296A
CN109460296A CN201811236176.1A CN201811236176A CN109460296A CN 109460296 A CN109460296 A CN 109460296A CN 201811236176 A CN201811236176 A CN 201811236176A CN 109460296 A CN109460296 A CN 109460296A
Authority
CN
China
Prior art keywords
sentence
hardware
resource
hardware resource
execution
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN201811236176.1A
Other languages
Chinese (zh)
Other versions
CN109460296B (en
Inventor
江树浩
李家军
龚施俊
鄢贵海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongke Yuanshu (beijing) Technology Co Ltd
Original Assignee
Zhongke Yuanshu (beijing) Technology Co Ltd
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 Zhongke Yuanshu (beijing) Technology Co Ltd filed Critical Zhongke Yuanshu (beijing) Technology Co Ltd
Priority to CN201811236176.1A priority Critical patent/CN109460296B/en
Publication of CN109460296A publication Critical patent/CN109460296A/en
Application granted granted Critical
Publication of CN109460296B publication Critical patent/CN109460296B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • 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/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses a kind of resource allocation methods of processor, device and storage mediums, this method comprises: determining hardware initial resource;The execution sentence is read and analyzed, is established for the abstract syntax tree for executing sentence;Hardware resource requirements are counted according to the abstract syntax tree;According to the hardware resource requirements and the corresponding target hardware resource of the hardware initial resource allocation.The embodiment of the present invention can simplify hardware design difficulty, reduce hardware spending and processor area, power consumption etc..

Description

A kind of resource allocation methods of processor, device and storage medium
Technical field
The present invention relates to computer technology more particularly to a kind of resource allocation methods, device and computer-readable storage medium Matter.
Background technique
The hardware resource of processor is limited, and the task of upper layer operation system before starting to execute needs for each task point With reasonable resource quantity, in order to avoid result in waste of resources or insufficient.For general processor, since its versatility and random ordering are held The design such as row, processor need to design for every class basic hardware unit (such as floating number computing unit, integer computational units) special Resource allocation unit, and realize within hardware.
Application specific processor is designed towards specific area, and hardware resource and quantity above is more limited, if lacking conjunction The resource allocation system of reason, it is easier to the decline that obstruction causes system performance occur.
How for the simplified hardware design difficulty of resource allocation, and application specific processor resource allocation performance is improved, at present still It does not put forward effective solutions.
Summary of the invention
In view of this, the main purpose of the present invention is to provide a kind of resource allocation methods, device and computer-readable depositing Storage media.
In order to achieve the above objectives, the technical scheme of the present invention is realized as follows:
The embodiment of the invention provides a kind of resource allocation methods, which comprises
Determine hardware initial resource;
The execution sentence is read and analyzed, is established for the abstract syntax tree for executing sentence;
Hardware resource requirements are counted according to the abstract syntax tree;And
According to the hardware resource requirements and the corresponding target hardware resource of the hardware initial resource allocation.
In above scheme, described determine based on the analysis results includes: for the step of abstract syntax tree for executing sentence
The execution sentence is read by way of character string, based on context Grammars analyze the execution sentence, It establishes for the abstract syntax tree for executing sentence.
In above scheme, the execution sentence includes nested statement;
Correspondingly, the based on context Grammars analyze the execution sentence, establish for the execution sentence The step of abstract syntax tree includes:
Determine whether the execution sentence includes nested parts, is determining that the execution sentence includes the nested parts When, using the nested parts as independent sentence, establish the corresponding temporary variable of the independent sector;
Using the temporary variable as original nested parts in the execution sentence, establishes and be directed to the execution language The abstract syntax tree of sentence.
In above scheme, the abstract syntax tree described in breadth first traversal since the root node of the abstract syntax tree;
According to the data type that the node traversed is stored, hardware resource requirements needed for counting the execution sentence.
In above scheme, inquire whether the hardware initial resource has enough hardware to provide according to the hardware resource requirements Source;When determination there are enough hardware resources, then corresponding target hardware resource is distributed to execute sentence;
After the corresponding target hardware resource of distribution, the method also includes: determine that the execution sentence has executed It finishes, discharges the target hardware resource.
It is described to determine based on the analysis results for the abstract syntax tree for executing sentence, comprising: to be held to described in above scheme Line statement is split, and is obtained at least one member and is executed sentence;Determine that at least one described member executes the corresponding abstract language of sentence Method tree;
Described determine based on the analysis results is directed to after the abstract syntax tree of execution sentence, the method also includes: building Execute sentence vector;The building executes sentence vector, comprising: executes the corresponding abstract language of sentence according at least one described member Method tree counts hardware resource requirements, and building executes sentence vector;The execution sentence vector includes at least: at least one member executes Sentence and member execute the matching status and hardware resource requirements of sentence;
It is described according to the hardware resource requirements and the corresponding target hardware resource of the hardware initial resource allocation, packet Include: at least one member executes in the execution sentence vector according to hardware initial resource allocation described in the execution sentence vector sum Each member executes the corresponding target hardware resource of sentence in sentence.
The embodiment of the invention provides a kind of resource allocation device, described device includes: first processing module, second processing Module and third processing module;Wherein,
The first processing module, for determining hardware initial resource;
The Second processing module is established for reading and analyzing the execution sentence for the abstract language for executing sentence Method tree;
The third processing module, for counting hardware resource requirements according to the abstract syntax tree;According to the hardware Resource requirement and the corresponding target hardware resource of the hardware initial resource allocation.
In above scheme, the execution sentence includes nested statement;
Correspondingly, the Second processing module is also used to: whether the detection execution sentence includes nested parts, determines institute When stating execution sentence comprising the nested parts, using the nested parts as independent sentence, it is corresponding to establish the independent sector Temporary variable;Using the temporary variable as original nested parts in the execution sentence, establishes and held for described The abstract syntax tree of line statement.
The embodiment of the invention provides a kind of resource allocation device, described device includes: processor and can for storing The memory of the computer program run on a processor;Wherein, the processor is for holding when running the computer program The step of row any one resource allocation methods of the above.
The embodiment of the invention provides a kind of computer readable storage mediums, are stored thereon with computer program, the meter The step of any one resource allocation methods described above are realized when calculation machine program is executed by processor.
Resource allocation methods, device provided by the embodiment of the present invention and computer readable storage medium, at the beginning of determining hardware Beginning resource;It obtains and executes sentence, analyze the execution sentence, determined based on the analysis results for the abstract syntax for executing sentence Tree;Hardware resource requirements are counted according to the abstract syntax tree;According to the hardware resource requirements and the hardware initial resource Distribute corresponding target hardware resource.The resource allocation for passing through software definition application specific processor in the embodiment of the present invention, by appointing The distribution of application specific processor hardware resource is realized in the operations such as business is abstract, resource requirement counts, the release of resource matched and resource, is simplified Hardware design difficulty reduces hardware spending and processor area, power consumption etc..
Detailed description of the invention
Fig. 1 is a kind of flow diagram of hardware resource distribution method provided in an embodiment of the present invention;
Fig. 2 is the flow diagram of another hardware resource distribution method provided in an embodiment of the present invention;
Fig. 3 is a kind of structural schematic diagram of the abstract syntax tree of basic statement provided in an embodiment of the present invention;
Fig. 4 is a kind of structural schematic diagram of the abstract syntax tree comprising nested statement provided in an embodiment of the present invention;
Fig. 5 is a kind of implementation flow chart of resource requirement statistics provided in an embodiment of the present invention;
Fig. 6 is the resource matched implementation flow chart of one kind provided in an embodiment of the present invention;
Fig. 7 is a kind of implementation flow chart of resource release provided in an embodiment of the present invention;
Fig. 8 is a kind of structural schematic diagram of hardware resource distribution system provided in an embodiment of the present invention;
Fig. 9 is a kind of implementation process signal of hardware resource distributor of software definition provided in an embodiment of the present invention Figure;
Figure 10 is a kind of structural schematic diagram of hardware resource distributor provided in an embodiment of the present invention;
Figure 11 is the structural schematic diagram of another hardware resource distributor provided in an embodiment of the present invention.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, right below with reference to embodiment and attached drawing The present invention is described in further details.Here, exemplary embodiment and its explanation of the invention is used to explain the present invention, but simultaneously It is not as a limitation of the invention.
It should be noted that for purposes of clarity, unrelated to the invention, the common skill in this field is omitted in attached drawing and explanation The expression and description of component known to art personnel and processing.
In addition, it should be noted that, in the absence of conflict, the features in the embodiments and the embodiments of the present application can To be combined with each other.
It should be emphasized that term "comprises/comprising" refers to the presence of feature, element, step or component when using herein, but simultaneously It is not excluded for the presence or additional of one or more other features, element, step or component.
Application specific processor is different from general processor namely application specific processor and executes particular task type, control logic compared with To be simple, therefore special resource allocation unit may not necessarily be realized on hardware as general processor, the present invention passes through Software definition resource allocation unit can reduce hardware spending and processor area, power consumption in the case where not reducing performance Deng.The concept of software definition has proven to relatively effective design methodology in some special dimensions.Such as software definition Network (SDN, Software-DefinedNetwork), software definition are wirelessly transferred (SDR, Software-Defined Radio) etc., but there has been no distribute for processor resource.
The present invention provides a kind of resource allocation methods and device towards application specific processor, based on software definition.Below The present invention is described in detail in conjunction with the embodiments.
Fig. 1 is a kind of flow diagram of hardware resource distribution method provided in an embodiment of the present invention, and this method is applied to Application specific processor is realized by this method and is distributed the hardware resource of the application specific processor.As shown in Figure 1, this method includes Following steps:
Step S101, hardware initial resource is determined.
Specifically, step S101 can include: the hardware resource for obtaining application specific processor currently available (can distribute), as Hardware initial resource.Wherein, available hardware resource can include: caching, FIFO (first infirst out, first in, first out), meter Unit etc. is calculated, but the present invention is not limited thereto.
In an embodiment of the present invention, it can use hardware resource table to record hardware initial resource information.
Step S102, reading and execution sentence is analyzed, established for the abstract syntax tree for executing sentence.
This step is task abstract operation step.Sentence is executed for example, can read by way of character string, according to upper and lower Literary Grammars analysis executes sentence and establishes for the abstract syntax tree for executing sentence.
In an embodiment of the present invention, there is a situation where nesting for executing in sentence, may be selected to execute in sentence Nested parts (i.e. internal layer nested statement) are used as independent sentence, and suggest temporary variable for independent sentence.That is, at this point, analysis Sentence is executed, establishing the step of being directed to the abstract syntax tree for executing sentence includes: to execute sentence by analysis to determine execution sentence When comprising nested parts, using nested parts as independent sentence, the corresponding temporary variable of independent sentence is established, instead of original embedding Set part (i.e. internal layer nested statement), and thus establish for the abstract syntax tree for executing sentence.
That is, in the present embodiment, when having nested between executing sentence, first (i.e. by nested execution sentence expansion Using internal layer nested statement as independent sentence, and suggest temporary variable for independent sentence), this have the advantage that can be most Smallization executes the granularity of sentence, and the smallest execution granularity can make execution sentence be assigned to resource as much as possible, make sentence as early as possible The time of resource free time is executed and reduces, the execution sentence of minimum particle size is referred to as that member executes sentence in the embodiment of the present invention.
Abstract syntax tree can be used for parsing original program and record executes sentence, and each tree represents a member and executes language Sentence.Abstract syntax tree has recorded the logic and necessary data that every member executes sentence.In the embodiment of the present invention, abstract syntax tree branch Hold nested expansion operation and traversal statistical operation.
As above the operation of nested execution sentence expansion also can be regarded as to the cutting operation for executing sentence.In this hair In bright some embodiments, establishing, which may also include that for the step of abstract syntax tree for executing sentence, is split execution sentence, It obtains member and executes sentence, so that establishing member executes the corresponding abstract syntax tree of sentence.
In a preferred embodiment of the invention, the member after segmentation executes sentence and can arrange and save according to execution order, such as It records in vector form, each element in vector represents a member and executes sentence, which can be described as executing sentence vector.
Step S103, hardware resource requirements are counted according to abstract syntax tree.
Specifically, the step can include: ergodic abstract syntax tree, according to the corresponding data type of the node traversed, system Hardware resource requirements needed for meter executes sentence.
As an example, in this step, can since the root node of abstract syntax tree breadth first traversal abstract syntax tree;Root According to the data type that the node traversed is stored, statistics executes the quantity of various types of hardware resource involved in sentence, to unite Count out hardware resource requirements needed for executing sentence.For example, this is held if what certain node stored is oeprator "+" The addition unit of line statement will add 1.
In an embodiment of the present invention, resource requirement statistical operation may also include that in the money for counting every execution sentence After the demand of source, its resource requirement can be added in step S102 execution sentence vector produced.
Step S104 is to execute sentence to distribute corresponding hardware resource according to hardware resource requirements and hardware initial resource.
The step is also referred to as resource matched step.Specifically, step can include: according to the hardware resource need for executing sentence Ask whether determining hardware initial resource there are enough hardware resources;When determination there are enough hardware resources, then hardware resource is distributed The corresponding hardware resource of demand is to sentence is executed, in other words, to execute sentence distribution or having matched corresponding hardware resource.It is based on The resource of distribution can execute each member and execute sentence.
Using hardware resource table record hardware state, after being assigned with hardware resource for execution sentence, Hardware resource status information in resource table, which will do it, to be updated accordingly.
In the case where executing sentence to execute sentence vector form record, step S104 can include: according to execution language Sentence vector sum hardware initial resource allocation executes each of sentence vector member and executes the corresponding hardware resource of sentence.
It executes in sentence vector and is also provided with flag bit to show the execution state or matching of wherein Statement element State executes state for example can include: do not match, matched, be completed.At this point, each element in execution sentence vector is extremely Less include following information: member executes sentence, member executes the hardware resource requirements of sentence and executes state.
In one embodiment of the invention, sentence vector is executed for resource matched and record and occupies resource.Sentence is executed to pass through Task abstract operation generates, and is counted by resource requirement and required resource quantity information is added, then added by resource matched operation Enter resource occupation information, such as resource ID.The execution state that flag bit shows wherein Statement element can be equipped with by executing sentence vector, Execution state includes: not match, matched, being completed.
In embodiments of the present invention, after to execute the corresponding hardware resource of sentence distribution, the hardware resource distribution method It may also include that after determining that executing sentence has been finished, discharge the hardware resource of execution sentence occupancy.
The application compared with prior art, passes through the resource allocation of software definition application specific processor, money abstract by task The distribution of application specific processor hardware resource is realized in the operations such as source demand statistics, the release of resource matched and resource, simplifies hardware design Difficulty reduces hardware spending and processor area, power consumption etc..
Fig. 2 be another embodiment of the present invention provides hardware resource distribution method flow diagram.As shown in Fig. 2, should Method the following steps are included:
Step S201, hardware resource initializes.
Specifically, step can include: establish hardware resource table, count the available hardware resource of application specific processor and with complete The case where portion's idle state, initializes its quantity, and is recorded in hardware resource table.
Available hardware resource for example, caching, FIFO, computing unit etc., but the present invention is not limited thereto.
Table 1, which gives a kind of hardware resource provided in an embodiment of the present invention, indicates example, and in table 1, resource status is 1 to indicate hard Part resource is idle state, and it is busy condition that resource status, which is 0,.The name of resource and the merely illustrative explanation of value in table, He also should belong to the scope of the present invention by the naming method of mode.
The example of 1. hardware resource table of table
Table 1 can be seen that hardware resource table is used to record the service condition of hardware resource, and hardware resource table is in initial stage quilt It is initialized as all hardware resource, dynamic change, hardware provide according to the executive condition of program statement in program process Source table mainly stores quantity, resource ID and the resource status of various types of hardware resource.
Step S202, reading and execution sentence is analyzed, establishes the abstract syntax tree for every execution sentence.
This step is task abstract operation process.Specifically, this step S202 can include: read by way of character string Sentence is executed, based on context Grammars anolytic sentence, establishes and execute the corresponding abstract syntax tree of sentence.
Here, there is a situation where nesting for executing in sentence, nested statement need to first be unfolded, executed so as to minimize The granularity of sentence, and the smallest execution granularity can make execute sentence be assigned to resource as much as possible, make execute sentence as early as possible by The time of resource free time is executed and reduces, the execution sentence of minimum particle size is referred to as member and executes sentence.
The operation of expansion nested statement may include: to determine whether execute sentence during establishing abstract syntax tree Comprising nested parts, when determining comprising nested parts, nested parts (i.e. internal layer nested statement) is used as an independent sentence, Thus a newly-built temporary variable instead of original nested parts (i.e. internal layer nested statement), and is established and executes the corresponding pumping of sentence As syntax tree.
Abstract syntax tree is described further below in conjunction with Fig. 3 and Fig. 4.
Fig. 3 is a kind of structural schematic diagram of the abstract syntax tree for basic statement that one embodiment of the invention provides;Such as Fig. 3 institute Show, for one, nested execution sentence X=A+B, abstract syntax tree do not construct syntax tree using reverse Polish notation, that is, grasp It counts before being located at operator, the reverse Polish notation of above-mentioned execution sentence is X A B+=, then constructs, obtains from bottom to top Abstract syntax tree shown in Fig. 3.
Fig. 4 is a kind of structural schematic diagram for abstract syntax tree comprising nested statement that one embodiment of the invention provides;Such as Shown in Fig. 4, there is nested execution sentence X=C* (A+B) for one, establish the corresponding temporary variable T of internal layer nested statement, then Nested statement can be broken down into: T=A+B;Then X=C*T obtains Fig. 4 institute according to syntax tree Fundamental construction approach shown in Fig. 3 The abstract syntax tree shown.
This method can guarantee to first carry out first addition when hardware lacks idle multiplier and available free adder Sentence judges that multiplication sentence avoids having to multiplication and ability in the case where the adder free time simultaneously again after add statement matching Sentence can be executed, to improve the execution possibility of sentence.
It should be noted that foregoing description only as an example, the execution sentence of more complicated (if any more multinest) or More complicated operator (such as customized kernel function), can be parsed according to this method.
As above the operation of nested execution sentence expansion also can be regarded as to the cutting operation for executing sentence.After segmentation Member execute sentence can be recorded according to the form of vector.At this point, step S202 may also include that building execute sentence to Amount.
Building executes the step of sentence vector can include: segmentation executes sentence, obtains more than one member and executes sentence;It will divide Member after cutting executes sentence and arranges and save according to execution order, such as records in vector form, each element in vector It represents a member and executes sentence, formed and execute sentence vector.Executing sentence vector may include the information for executing sentence, such as wrap It includes: the matching status of result information, hardware resource requirements information and each element, wherein result information refers to implementing result phase The information of pass, such as: result name or result ID.Hardware resource requirements information may include resource type, resource quantity and resource ID.Table 2 is a kind of sample table for executing sentence vector provided in an embodiment of the present invention.
The sample table of the execution sentence vector of table 2.
Step S203, hardware resource requirements are counted according to abstract syntax tree.
Specifically, step S203 can include: corresponding abstract by traversing its for every execution sentence after being abstracted Syntax tree, statistics execute the quantity for the various types of hardware resource for including in sentence.
The step of ergodic abstract syntax tree can include: since root node, breadth first traversal abstract syntax tree, according to time The data type that the node gone through is stored, hardware resource requirements needed for statistics executes sentence.
Fig. 5 is a kind of implementation flow chart for counting resource requirement provided in an embodiment of the present invention.As shown in figure 5, statistics is held The step of hardware resource requirements needed for line statement includes: to access since abstract syntax root vertex, obtains node resource class Type, and matched with the resource type in hardware resource table, if it fails to match, continue to match next type;Otherwise, should Such resource+1 for executing Statement element, then proceedes to match next type, until the matching of all resource types finishes;Then sentence The disconnected all nodes for whether having traversed abstract syntax tree, if it is not, then continue to access next grammer tree node, if it is, time Go through next abstract syntax tree.
In the embodiment of the present invention, statistics execute sentence needed for hardware resource requirements the step of may also include that
After the hardware resource requirements for counting every execution sentence, its hardware resource requirements is added to corresponding execution In sentence vector.
Step S204, corresponding hardware resource is distributed according to hardware resource requirements.
The step is also referred to as resource matched step.Specifically, the step 204 can include:
Resource request process, it is corresponding to the request of hardware resource table according to the hardware resource requirements executed in sentence vector Hardware resource, hardware resource table complete the execution of execution sentence to whether its return has enough hardware resources;
If hardware resource table is returned as very, i.e. the enough current statements of hardware resource execute, then distribute phase to execute sentence The hardware resource answered.
It should be noted that the above resource matched operation is a polling procedure, when some Statement element is determined matching Or when cannot temporarily match, software systems will continue to execute the judgement of next sentence, until all execution sentences are all sentenced Surely it finishes, matched execution sentence is enabled to be assigned to resource.
Specifically, after to execute the corresponding hardware resource of sentence distribution, method of the invention further include: update hardware money Source.The step of updating hardware resource can include: resource needed for the distribution of hardware resource table executes sentence, return resource ID, which is given, to be corresponded to The vertex ticks is to have distributed, while the available mode of these hardware resources being marked by the correspondence Statement element of sentence vector It is 0, indicates unavailable.
Fig. 6 is the resource matched implementation flow chart of one kind provided in an embodiment of the present invention.As shown in fig. 6, system is from execution Statement element is obtained in sentence vector, and obtains its required hardware asset information, then checks that hardware resource table can satisfy this Hardware resource requirements continue the hardware resource matching of next statement if be not able to satisfy;Otherwise, hardware resource table is more Newly, and return can matched signal and matching resource information.Hardware is written according to the information update self information of return in Statement element Resource information updates and executes sentence state to have distributed.Then it checks whether that all execution sentences are allocated to finish, if It is assigned, then terminates, otherwise continue the resource allocation of next-executable statement.
In the embodiment of the present invention, hardware resource distribution method further include:
Step 205 after determining that executing sentence has been finished, discharges the hardware resource of execution sentence occupancy.
The step is hardware resource release steps.Specifically, the execution sentence of hardware resource has been had matched when one After being performed, software systems by poll detect whether its implementing result returns, if its implementing result returns, release is corresponding Hardware resource.
The step of discharging hardware resource further include: read the occupancy resource information of the execution sentence, more using these information The available mode of these resources is labeled as 1, while the Statement element being labeled as being completed by new hardware resource table.
For example, the execution sentence for having had matched hardware resource when one is identified after being finished, then carries out resource and release Operation is put, which includes: to read the occupancy resource information of the execution sentence, is provided using these information update hardware The available mode of these resources is labeled as 1, while the Statement element being labeled as being completed by source table.
Fig. 7 is a kind of flow diagram for discharging hardware resource provided in an embodiment of the present invention.As shown in fig. 7, release is hard Part resource process includes: software systems from the corresponding result information of acquisition execution sentence in sentence vector is executed, then to dedicated Processor request results state, if result phase be it is unfinished, continue next-executable statement resource release;It is no Then, Statement element state is updated to be completed, and hardware resource table updates, and discharges the occupied hardware resource of the sentence.Then it looks into See whether all execution sentences have all executed completion, if executing completion, terminate, otherwise continues the hard of next-executable statement The release of part resource.
In the present embodiment, by the resource allocation of software definition application specific processor, be abstracted by initializing resource, task, The distribution of application specific processor hardware resource is realized in the operations such as resource requirement statistics, the release of resource matched and resource, is simplified hardware and is set Difficulty is counted, hardware spending and processor area, power consumption etc. are reduced.
Correspondingly, the present invention also provides a kind of hardware resource distribution systems for executing foregoing hardware resource distribution method System.Fig. 8 is a kind of structural schematic diagram of hardware resource distribution system provided in an embodiment of the present invention;As shown in figure 8, can be based on master The structural schematic diagram of the particular hardware resource allocation system of the embodiment of the present application is realized from device structure.Wherein, hardware resource point It is realized, and operated on the main equipment being made of CPU and storage unit by code with unit, main equipment is by CPU and storage unit Composition is programmed by hardware FPGA from equipment and is realized, is docked between master-slave equipment by PCIE interface.Program flow executes required money Source information is mapped to from the FPGA of equipment by hardware resource allocation unit, and program stream instructions are by master transmissions from setting Standby upper execution finally returns that as a result, completing program.
Fig. 9 is a kind of implementation process signal of hardware resource distributor of software definition provided in an embodiment of the present invention Figure.The device can correspond to the hardware resource allocation unit in Fig. 8.As shown in figure 9, the hardware resource distributor includes: money Source initialization module, task abstract module, resource requirement statistical module, resource matched module, resource release module.
Initializing resource module, task abstract module, resource requirement statistical module, resource matched module, resource discharge mould Block can respectively correspond the method and step for executing step S201-S205 shown in Fig. 2.
Figure 10 is a kind of structural schematic diagram for hardware resource distributor that one embodiment of the invention provides;Such as Figure 10 institute Show, the hardware resource distributor can include: first processing module, Second processing module and third processing module.
First processing module is for determining hardware initial resource;
Second processing module is established for reading and analyzing execution sentence for the abstract syntax tree for executing sentence;
Third processing module is used to count hardware resource requirements according to abstract syntax tree, and according to hardware resource requirements and firmly The corresponding target hardware resource of part initial resource allocation.
Specifically, Second processing module can be specifically used for reading by way of character string executing sentence, based on context Grammars analysis executes sentence, establishes for the abstract syntax tree for executing sentence.
In addition, Second processing module, which can be specifically used for detection, executes whether sentence includes nested parts, language is executed determining When in sentence including nested parts, using nested parts as independent sentence, the corresponding temporary variable of independent sector is established.Also, it can Using temporary variable as original nested parts in sentence are executed, establish for the abstract syntax tree for executing sentence.
Specifically, third processing module can be specifically used for: breadth first traversal is taken out since the root node of abstract syntax tree As syntax tree;According to the data type that the node traversed is stored, hardware resource requirements needed for statistics executes sentence.
Third processing module can also be used to inquire whether have enough hardware resources according to hardware resource requirements;Determination has foot When enough hardware resources, then corresponding target hardware resource is distributed to execute sentence.
Third processing module can also be used to determine that executing sentence has been finished, and discharges target hardware resource.
Specifically, Second processing module can also be used to be split execution sentence, obtains at least one member and executes sentence; Determine that at least one member executes the corresponding abstract syntax tree of sentence.
Second processing module can also be used in building and execute sentence vector.Specifically, Second processing module is according at least one Member executes the corresponding abstract syntax tree of sentence and counts hardware resource requirements, and building executes sentence vector;Execute sentence vector at least It include: the matching status and hardware resource requirements that member executes sentence and member executes sentence.
Correspondingly, third processing module can also be used to execute sentence according to execution sentence vector sum hardware initial resource allocation At least one member executes each member in sentence and executes the corresponding target hardware resource of sentence in vector.
It should be understood that above-mentioned first processing module to third processing module may be integrally incorporated to a processing module (such as Processor) in, it can also be realized by more processing modules.
Figure 11 is the structural schematic diagram of another hardware resource distributor provided in an embodiment of the present invention;Resource allocation dress Set can be applied to include application specific processor equipment, such as server;As shown in figure 11, device 40 includes: processor 401 and uses In the memory 402 for the computer program that storage can be run on a processor;Wherein, processor 401 is for running computer When program, each step of foregoing hardware resource distribution method is executed, will not repeat them here.
When practical application, hardware resource distributor 40 can also include: at least one network interface 403.Resource allocation Various components in device 40 are coupled by bus system 404.It is understood that bus system 404 is for realizing these groups Connection communication between part.Bus system 404 further includes power bus, control bus and state in addition to including data/address bus Signal bus.But for the sake of clear explanation, various buses are all designated as bus system 404 in Figure 11.Wherein, processor 404 number can be at least one.Network interface 403 is for wired or wireless between resource allocation device 40 and other equipment The communication of mode.
The method that the embodiments of the present invention disclose can be applied in processor 401, or by the processor 401 of Figure 11 It realizes.Processor 401 may be a kind of IC chip, the processing capacity with signal.During realization, the above method Each step can be completed by the instruction of the integrated logic circuit of the hardware in processor 401 or software form.In example In property embodiment, resource allocation device 40 can be by one or more application specific integrated circuit (ASIC, Application Specific Integrated Circuit), DSP, programmable logic device (PLD, Programmable Logic Device), Complex Programmable Logic Devices (CPLD, Complex Programmable Logic Device), field-programmable Gate array (FPGA, Field-Programmable Gate Array), general processor, controller, microcontroller (MCU, Micro Controller Unit), microprocessor (Microprocessor) or other electronic components realize, before executing State method.
The embodiment of the invention also provides a kind of computer readable storage mediums, are stored thereon with computer program, calculate When machine program is run by processor, each step of foregoing hardware resource distribution method is executed, will not repeat them here.
It should be understood by those skilled in the art that, the embodiment of the present invention can provide as method, system or computer program Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the present invention Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the present invention, which can be used in one or more, The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) produces The form of product.
The present invention be referring to according to the method for the embodiment of the present invention, the process of equipment (system) and computer program product Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates, Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one The step of function of being specified in a box or multiple boxes.
Particular embodiments described above has carried out further in detail the purpose of the present invention, technical scheme and beneficial effects Describe in detail it is bright, it should be understood that the above is only a specific embodiment of the present invention, the guarantor being not intended to limit the present invention Range is protected, all within the spirits and principles of the present invention, any modification, equivalent substitution, improvement and etc. done should be included in this Within the protection scope of invention.

Claims (10)

1. a kind of resource allocation methods of processor, which is characterized in that the described method comprises the following steps:
Determine hardware initial resource;
Execution sentence is read and analyzed, is established for the abstract syntax tree for executing sentence;
Hardware resource requirements are counted according to the abstract syntax tree;And
According to the hardware resource requirements and the corresponding target hardware resource of the hardware initial resource allocation.
2. the method according to claim 1, wherein described determine based on the analysis results for the pumping for executing sentence As the step of syntax tree includes:
The execution sentence is read by way of character string, based on context Grammars analyze the execution sentence, establish For the abstract syntax tree for executing sentence.
3. according to the method described in claim 2, it is characterized in that, the execution sentence includes nested statement;
Based on context the Grammars analyze the execution sentence, establish for the abstract syntax tree for executing sentence Step includes:
Determine whether the execution sentence includes nested parts, it, will when determining that the execution sentence includes the nested parts The nested parts establish the corresponding temporary variable of the independent sector as independent sentence;
Using the temporary variable as original nested parts in the execution sentence, establish for the execution sentence Abstract syntax tree.
4. the method according to claim 1, wherein described count hardware resource need according to the abstract syntax tree The step of asking include:
The abstract syntax tree described in breadth first traversal since the root node of the abstract syntax tree;
According to the data type that the node traversed is stored, hardware resource requirements needed for counting the execution sentence.
5. the method according to claim 1, wherein described according at the beginning of the hardware resource requirements and the hardware The step of beginning resource allocation corresponding target hardware resource includes: to inquire the hardware according to the hardware resource requirements initially to provide Whether source has enough hardware resources;When determination there are enough hardware resources, then corresponding target hardware resource is distributed to execute Sentence;
After the corresponding target hardware resource of distribution, the method also includes: determine that the execution sentence has been finished, Discharge the target hardware resource.
6. the method according to claim 1, wherein described determine based on the analysis results for the pumping for executing sentence As the step of syntax tree includes: to be split to the execution sentence, obtain at least one member and execute sentence, determine it is described at least One member executes the corresponding abstract syntax tree of sentence;
Described determine based on the analysis results is directed to after the abstract syntax tree of execution sentence, the method also includes: building executes Sentence vector;It includes: that execute sentence according at least one described member corresponding abstract that the building, which executes the step of sentence vector, Syntax tree counts hardware resource requirements, and building executes sentence vector;The execution sentence vector includes at least: at least one member is held Line statement and member execute the matching status and hardware resource requirements of sentence;
It is described to be wrapped according to the step of hardware resource requirements and the hardware initial resource allocation corresponding target hardware resource Include: at least one member executes in the execution sentence vector according to hardware initial resource allocation described in the execution sentence vector sum Each member executes the corresponding target hardware resource of sentence in sentence.
7. a kind of resource allocation device, which is characterized in that described device includes: first processing module, Second processing module and Three processing modules;Wherein,
The first processing module, for determining hardware initial resource;
The Second processing module is established for reading and analyzing the execution sentence for the abstract syntax tree for executing sentence;
The third processing module, for counting hardware resource requirements according to the abstract syntax tree;According to the hardware resource Demand and the corresponding target hardware resource of the hardware initial resource allocation.
8. device according to claim 7, which is characterized in that the execution sentence includes: nested statement;
The Second processing module is also used to:
Detect whether the execution sentence includes nested parts, when determining that the execution sentence includes the nested parts, by institute Nested parts are stated as independent sentence, establish the corresponding temporary variable of the independent sector;
Using the temporary variable as original nested parts in the execution sentence, establish for the execution sentence Abstract syntax tree.
9. a kind of resource allocation device, which is characterized in that described device includes: processor and can be on a processor for storing The memory of the computer program of operation;Wherein,
The processor is for the step of when running the computer program, perform claim requires 1 to 5 any the method.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program The step of claim 1 to 5 any the method is realized when being executed by processor.
CN201811236176.1A 2018-10-23 2018-10-23 Resource allocation method and device of processor and storage medium Active CN109460296B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811236176.1A CN109460296B (en) 2018-10-23 2018-10-23 Resource allocation method and device of processor and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811236176.1A CN109460296B (en) 2018-10-23 2018-10-23 Resource allocation method and device of processor and storage medium

Publications (2)

Publication Number Publication Date
CN109460296A true CN109460296A (en) 2019-03-12
CN109460296B CN109460296B (en) 2019-12-27

Family

ID=65608197

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811236176.1A Active CN109460296B (en) 2018-10-23 2018-10-23 Resource allocation method and device of processor and storage medium

Country Status (1)

Country Link
CN (1) CN109460296B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111031011A (en) * 2019-11-26 2020-04-17 中科驭数(北京)科技有限公司 Interaction method and device of TCP/IP accelerator

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1661558A (en) * 2004-02-24 2005-08-31 何积丰 Method of designing hardware compiler based on program algebra
CN101489302A (en) * 2008-01-16 2009-07-22 中兴通讯股份有限公司 Resource allocation method
CN103617091A (en) * 2013-12-18 2014-03-05 深圳市道通科技有限公司 Implementation method and device for dynamic allocation of hardware resources
CN107797866A (en) * 2016-05-31 2018-03-13 广东欧珀移动通信有限公司 The distribution method and mobile terminal and medium product of processor resource
CN107832151A (en) * 2017-11-10 2018-03-23 东软集团股份有限公司 A kind of cpu resource distribution method, device and equipment
CN108052394A (en) * 2017-12-27 2018-05-18 福建星瑞格软件有限公司 The method and computer equipment of resource allocation based on SQL statement run time

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1661558A (en) * 2004-02-24 2005-08-31 何积丰 Method of designing hardware compiler based on program algebra
CN101489302A (en) * 2008-01-16 2009-07-22 中兴通讯股份有限公司 Resource allocation method
CN103617091A (en) * 2013-12-18 2014-03-05 深圳市道通科技有限公司 Implementation method and device for dynamic allocation of hardware resources
CN107797866A (en) * 2016-05-31 2018-03-13 广东欧珀移动通信有限公司 The distribution method and mobile terminal and medium product of processor resource
CN107832151A (en) * 2017-11-10 2018-03-23 东软集团股份有限公司 A kind of cpu resource distribution method, device and equipment
CN108052394A (en) * 2017-12-27 2018-05-18 福建星瑞格软件有限公司 The method and computer equipment of resource allocation based on SQL statement run time

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111031011A (en) * 2019-11-26 2020-04-17 中科驭数(北京)科技有限公司 Interaction method and device of TCP/IP accelerator
CN111031011B (en) * 2019-11-26 2020-12-25 中科驭数(北京)科技有限公司 Interaction method and device of TCP/IP accelerator

Also Published As

Publication number Publication date
CN109460296B (en) 2019-12-27

Similar Documents

Publication Publication Date Title
CN109995677B (en) Resource allocation method, device and storage medium
US10303628B2 (en) Reordering responses in a high performance on-chip network
EP3861489A1 (en) Parcelled quantum resources
WO2008148132A1 (en) Shared storage for multi-threaded ordered queues in an interconnect
CN110908697A (en) Resource packaging method, device, server and storage medium
CN110908707B (en) Resource packaging method, device, server and storage medium
CN114327861B (en) Method, device, system and storage medium for executing EDA task
CN106095563B (en) Flexible physical function and virtual function mapping
CN114416352A (en) Computing resource allocation method and device, electronic equipment and storage medium
CN103049328A (en) Distribution method of internal memory resources in computer system
US8671379B1 (en) Multi-threaded deterministic router
US20200371827A1 (en) Method, Apparatus, Device and Medium for Processing Data
US10255399B2 (en) Method, apparatus and system for automatically performing end-to-end channel mapping for an interconnect
CN109614263A (en) A kind of disaster tolerance data processing method, apparatus and system
CN109460296A (en) A kind of resource allocation methods of processor, device and storage medium
CN104657216A (en) Resource allocation method and device for resource pool
US11954419B2 (en) Dynamic allocation of computing resources for electronic design automation operations
US7925490B2 (en) Method of transactional simulation of a generic communication node model, and the corresponding computer program product and storage means
CN110780992B (en) Cloud computing platform optimized deployment method, system, terminal and storage medium
CN113377652A (en) Test data generation method and device
CN114138484A (en) Resource allocation method, device and medium
US7945433B2 (en) Hardware simulation accelerator design and method that exploits a parallel structure of user models to support a larger user model size
CN104111868A (en) Scheduling method and device for speculative multithreading
CN115809620B (en) Method for simulating logic system design, electronic device and storage medium
JP2014225134A (en) Nonvolatile logic integrated circuit design support system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant