Instruction-dependent GPGPU (General Purpose Graphics Processing Unit) compiler and pipeline processing method
By introducing dependent data registers into the GPGPU pipeline and optimizing the execution of dependent instructions, the problems of dependency instruction execution delays and L1 Cache overflow in the GPGPU pipeline are solved, compilation efficiency and computing efficiency are improved, and memory competition is reduced.
Patent Information
- Application Number
- CN202410762946.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-08-27
AI Technical Summary
When the GPGPU's five-level pipeline processes instructions with dependencies, it is easy to cause pipeline stagnation due to delays in the write-back and read stages, and L1 Cache overflow increases the global memory read time, resulting in low compilation complexity and efficiency.
By introducing a dependent data register into the GPGPU pipeline, the dependency flag dependflag is determined to determine the pipeline stage, optimize instruction execution, reduce the pipeline to four levels, avoid waiting for invalid instructions, directly store intermediate results and reduce global memory access.
It improves compilation efficiency, reduces compilation complexity, saves memory read and write time in the write-back and read stages, reduces global memory bandwidth usage and memory competition probability, and avoids external memory access caused by L1 Cache overflow.
Smart Images

Figure CN118550545A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for processing an instruction-dependent GPGPU compiler and pipeline. Background Art
[0002] General-Purpose computing on Graphics Processing Units (GPGPU) is a technology that extends the computing power of graphics processing units (GPUs) to general computing tasks. Through this technology, GPUs are not only used for graphics rendering, but can also efficiently perform various general computing tasks, including scientific computing, data analysis, deep learning, etc.
[0003] GPGPU implements instruction execution through a five-stage pipeline, namely instruction fetch, decode, read, execute and write back. The five-stage pipeline can ensure that hardware instructions are executed in an orderly and efficient manner, but there are many problems with the execution of instructions with dependencies. First, when there is a dependency between instructions, when the next instruction is in the reading stage, the execution result of the previous instruction is not written back to the memory, resulting in the next instruction being unable to read the data. At this time, the pipeline will stop waiting; secondly, the existence of L1Cache may cause the data required by the next instruction to overflow to the global memory, increasing the reading time of the global memory; and at this stage, the compiler usually inserts invalid instructions (NOP) between two instructions for pipeline execution of dependent instructions to wait for the memory reading and writing of data, which increases the compilation complexity and reduces the compilation efficiency.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical components or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.
[0006] The disclosed embodiments provide a method for processing an instruction-dependent GPGPU compiler and pipeline.
[0007] The method is applied to a system including a host and a GPGPU, and the method may include:
[0008] Compile the dependency operations to be processed to generate two instructions;
[0009] Decode the first instruction and determine whether the operand memory type is DReg. If not, read the operand from the corresponding memory according to the operand address. Determine whether the pipeline enters the dependent operation mode by judging dependflag[0]. In the dependent operation mode, after the instruction execution operation is completed, determine the processing of the calculation result by judging dependflag[1], store the calculation result in the dependent data register DReg[0], and then generate the execute_done signal output;
[0010] The pipeline completion stage is determined by judging dependflag[1]. If it is 0, it means that the pipeline has no write-back stage. Execute_done is selected as the Pipeline_done signal, and Pipeline_done is input to the Warp Schedule module. The Warp Schedule module starts the next instruction fetch operation of the pipeline.
[0011] Decode the second instruction and determine whether the operand memory type is DReg. If yes, it means that the operand is stored in DReg, generate the dependent register read enable rd_en, and skip reading. If the operand memory type is no, read the operand from the corresponding memory according to the operand address, determine dependflag[0] to determine whether the pipeline enters the dependent operation mode, and in the dependent operation mode, if the rd_en signal is detected, add the data of the dependent data register DReg[0] to the second operand according to dependflag[4:2]. After the calculation is completed, determine the processing of the calculation result by determining dependflag[1]. If dependflag[1] of this instruction is 1, the calculation result is sent to the write-back stage, the pipeline enters the write-back stage, writes the result back to the memory, and then generates the Write_done signal output;
[0012] If dependflag[1] is 1, it means that the pipeline has a write-back stage, Write_done is selected as the Pipeline_done signal, and Pipeline_done is input to the Warp Schedule module so that the Warp Schedule module can start the next instruction fetch operation of the pipeline.
[0013] In some embodiments, the dependency flag dependflag corresponding to the dependency operation to be processed indicates whether the current instruction has a dependency relationship with other instructions with dependflag[0], dependflag[1] indicates the current instruction operation type, 0 is the temporary result, 1 is the execution write back, dependflag[4:2] identifies the storage location of the current instruction result in the dependency data register, and the number of bits is determined by the maximum number of dependency data registers.
[0014] In some embodiments, the Host is composed of a CPU and a memory, and the CPU is used to complete the creation, allocation, scheduling and release of tasks;
[0015] Programs written on the CPU are compiled by the compiler and translated into hardware instructions that can be parsed by the GPGPU.
[0016] In some embodiments, the GPGPU is used as a coprocessor and is composed of AXI interface, Block Schedule, GPGPU configuration, GPGPU Memory, and SM, wherein the AXI interface is used as an internal interconnect bus to establish a connection between the GPGPU Memory and the Host Memory to achieve data communication;
[0017] Block Schedule is used to implement the execution scheduling of thread blocks;
[0018] GPGPU configuration is used to configure GPGPU control parameters.
[0019] In some embodiments, the GPGPU Memory is divided into Global Memory, System Memory and Constant Memory;
[0020] The Global Memory stores data corresponding to dependency operations to be processed, the System Memory stores control instructions, and the Constant Memory serves as a read-only memory during the operation of the GPGPU to store constant parameters during the operation.
[0021] In some embodiments, the streaming multiprocessor SM is a computing unit of the GPGPU, which is internally composed of a Wrap Schedule, a Register file, an L1 Cache, a Shared Memory, and a Pipeline;
[0022] The Wrap Schedule is used to implement the scheduling and maintenance of thread bundles, and the Register file, L1Cache and Shared Memory are used to cache data and intermediate calculation results during the operation process.
[0023] In some embodiments, the Pipeline is used to implement the computing function of the SM, and completes instruction fetching, decoding, data reading, execution, and result writing back through a five-stage pipeline, wherein the execution stage of the pipeline allocates several threads in a thread warp to each SP for execution.
[0024] In some embodiments, the SP is the smallest computing unit of GPGPU, completing ALU, Flow, and FPU operations;
[0025] Each SP is configured with a dependent data register DReg, which is used to store intermediate results generated during the calculation of dependent instructions.
[0026] The instruction-dependent GPGPU compiler and pipeline processing method provided in the embodiments of the present disclosure can achieve the following technical effects:
[0027] The optimized compilation process can complete dependent operations without invalid instruction waiting pipeline, which greatly improves compilation efficiency and reduces compilation complexity.
[0028] The execution of dependent instructions is reduced from a five-stage pipeline to a four-stage pipeline, which saves the memory read and write time of operands in the write-back stage and the read stage, improves computing efficiency, reduces the bandwidth occupancy of the global memory, and reduces the probability of memory competition with other thread bundles.
[0029] Instructions with dependencies are optimized and fixed registers are assigned to the intermediate calculation results of dependent instructions, avoiding external memory access caused by overflow of traditional L1 Cache and hiding some thread warp scheduling delays.
[0030] The above general description and the following description are exemplary and explanatory only and are not intended to limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] One or more embodiments are exemplarily described by corresponding drawings, which do not limit the embodiments. Elements with the same reference numerals in the drawings are shown as similar elements, and the drawings do not constitute a scale limitation, and wherein:
[0032] Figure 1 It is a flowchart of an instruction-dependent GPGPU compiler and pipeline processing method provided by an embodiment of the present disclosure;
[0033] Figure 2It is an overall architecture diagram of an instruction-dependent GPGPU compiler and pipeline processing system provided by an embodiment of the present disclosure;
[0034] Figure 3 It is a time-space diagram of an instruction execution pipeline provided by an embodiment of the present disclosure;
[0035] Figure 4 It is a pipeline optimization principle diagram for adding a corresponding dependent data register in SP provided by an embodiment of the present disclosure;
[0036] Figure 5 It is a schematic diagram of the structure of another instruction-dependent GPGPU compiler and pipeline processing system provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0037] In order to be able to understand the features and technical contents of the embodiments of the present disclosure in more detail, the implementation of the embodiments of the present disclosure is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present disclosure. In the following technical description, for the convenience of explanation, a full understanding of the disclosed embodiments is provided through multiple details. However, one or more embodiments can still be implemented without these details. In other cases, to simplify the drawings, well-known structures and devices can be simplified for display.
[0038] The terms "first", "second", etc. in the embodiments of the present disclosure are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so as to describe the embodiments of the present disclosure described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.
[0039] Unless otherwise stated, the term "plurality" means two or more.
[0040] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B indicates: A or B.
[0041] The term "and / or" is a description of the association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B.
[0042] The term "correspondence" may refer to an association relationship or a binding relationship. The correspondence between A and B means that there is an association relationship or a binding relationship between A and B.
[0043] The following describes the instruction-dependent GPGPU compiler and pipeline processing method provided by the embodiments of the present disclosure in conjunction with the accompanying drawings.
[0044] Figure 1 It is a flowchart of an instruction-dependent GPGPU compiler and pipeline processing method provided by an embodiment of the present disclosure.
[0045] like Figure 1 As shown, the instruction-dependent GPGPU compiler and pipeline processing method provided by the present disclosure may include:
[0046] S01, compile the dependency operation to be processed to generate two instructions;
[0047] S02, decode the first instruction, determine whether the operand memory type is DReg, if not, read the operand from the corresponding memory according to the operand address, and determine whether the pipeline enters the dependent operation mode by judging dependflag[0]. In the dependent operation mode, after the instruction execution operation is completed, determine the processing of the calculation result by judging dependflag[1], store the calculation result in the dependent data register DReg[0], and then generate execute_done signal output;
[0048] S03, determine the pipeline completion stage by judging dependflag[1]. If it is 0, it means that the pipeline has no write-back stage. Select Execute_done as the Pipeline_done signal, input Pipeline_done into the Warp Schedule module, and the Warp Schedule module starts the next instruction fetch operation of the pipeline;
[0049] S04, decode the second instruction, determine whether the operand memory type is DReg, if yes, it means the operand is stored in DReg, generate dependent register read enable rd_en, and skip reading; if the operand memory type is no, read the operand from the corresponding memory according to the operand address, determine dependflag[0] to determine whether the pipeline enters the dependent operation mode, in the dependent operation mode, if the rd_en signal is detected, then according to dependflag[4:2], add the data of the dependent data register DReg[0] to the second operand, after the calculation is completed, determine the processing of the calculation result by determining dependflag[1]. If dependflag[1] of this instruction is 1, the calculation result is sent to the write-back stage, the pipeline enters the write-back stage, writes the result back to the memory, and then generates Write_done signal output;
[0050] S05, if dependflag[1] is 1, it means that the pipeline has a write-back stage, Write_done is selected as the Pipeline_done signal, and Pipeline_done is input into the Warp Schedule module so that the Warp Schedule module can start the next instruction fetch operation of the pipeline.
[0051] In the present disclosure, by inserting dependent data registers to temporarily store the intermediate calculation results of dependent instructions, the five-stage pipeline is reduced to a four-stage pipeline, which saves the memory read and write time of the operands in the write-back stage and the read stage, improves the operation efficiency, reduces the bandwidth occupation of the global memory, and reduces the probability of memory competition with other thread bundles. The optimized pipeline allows the compilation process to complete the dependent operation without invalid instructions waiting for the pipeline, greatly improving the compilation efficiency and reducing the compilation complexity. In addition, the use of dependent data registers avoids external memory access caused by overflow of the traditional L1 Cache and hides some thread bundle scheduling delays.
[0052] In some embodiments, the dependency flag dependflag corresponding to the dependency operation to be processed indicates whether the current instruction has a dependency relationship with other instructions with dependflag[0], dependflag[1] indicates the current instruction operation type, 0 is the temporary result, 1 is the execution write back, dependflag[4:2] identifies the storage location of the current instruction result in the dependency data register, and the number of bits is determined by the maximum number of dependency data registers.
[0053] In some embodiments, the Host is composed of a CPU and a memory, and the CPU is used to complete the creation, allocation, scheduling and release of tasks;
[0054] Programs written on the CPU are compiled by the compiler and translated into hardware instructions that can be parsed by the GPGPU.
[0055] In some embodiments, the GPGPU is used as a coprocessor and is composed of AXI interface, Block Schedule, GPGPU configuration, GPGPU Memory, and SM, wherein the AXI interface is used as an internal interconnect bus to establish a connection between the GPGPU Memory and the Host Memory to achieve data communication;
[0056] Block Schedule is used to implement the execution scheduling of thread blocks;
[0057] GPGPU configuration is used to configure GPGPU control parameters.
[0058] In some embodiments, the GPGPU Memory is divided into Global Memory, System Memory and Constant Memory;
[0059] The Global Memory stores data corresponding to dependency operations to be processed, the System Memory stores control instructions, and the Constant Memory serves as a read-only memory during the operation of the GPGPU to store constant parameters during the operation.
[0060] In some embodiments, the streaming multiprocessor SM is a computing unit of the GPGPU, which is internally composed of a Wrap Schedule, a Register file, an L1 Cache, a Shared Memory, and a Pipeline;
[0061] The Wrap Schedule is used to implement the scheduling and maintenance of thread bundles, and the Register file, L1Cache and Shared Memory are used to cache data and intermediate calculation results during the operation process.
[0062] In some embodiments, the Pipeline is used to implement the computing function of the SM, and completes instruction fetching, decoding, data reading, execution, and result writing back through a five-stage pipeline, wherein the execution stage of the pipeline allocates several threads in a thread warp to each SP for execution.
[0063] In some embodiments, the SP is the smallest computing unit of GPGPU, completing ALU, Flow, and FPU operations;
[0064] Each SP is configured with a dependent data register DReg, which is used to store intermediate results generated during the calculation of dependent instructions.
[0065] Figure 2 It is an overall architecture diagram of an instruction-dependent GPGPU compiler and pipeline processing system provided by an embodiment of the present disclosure.
[0066] The instruction-dependent GPGPU compiler and pipeline processing method described in this article is applied to a system including a host and a GPGPU. The overall system architecture is as follows: Figure 2 As shown in the figure, it is divided into two parts: Host and GPGPU. Host consists of CPU and memory. CPU is the main processor to complete the establishment, allocation, scheduling and release of tasks. The program written by the developer on the CPU is compiled by the compiler and translated into hardware instructions that can be parsed by GPGPU.
[0067] GPGPU is used as a coprocessor to handle computationally intensive tasks that the CPU is not good at. A typical GPGPU consists of AXI interface, Block Schedule, GPGPU configuration, GPGPU Memory, and SM. AXIinterface is used as an internal interconnect bus to connect GPGPU Memory with Host Memory to achieve data communication; Block Schedule implements the execution scheduling of thread blocks; and GPGPU configuration configures the control parameters of GPGPU.
[0068] GPGPU Memory is divided into Global Memory, System Memory, and Constant Memory. Global Memory stores data corresponding to dependency operations to be processed, System Memory stores control instructions, and Constant Memory is used as read-only memory during GPGPU operation to store constant parameters during the operation.
[0069] SM (streaming multiprocessor) is a streaming multiprocessor and the computing unit of GPGPU. It is composed of Wrap Schedule, Register file, L1 Cache, Shared Memory and Pipeline. Wrap Schedule implements the scheduling and maintenance of thread bundles. Register file, L1 Cache and Shared Memory are used to cache data and intermediate calculation results during the operation process.
[0070] Pipeline is the key to SM's computing function. It completes instruction fetching, decoding, data reading, execution, and result writing through a five-stage pipeline. The efficiency of the pipeline directly determines the computing performance of GPGPU. Among them, the execution stage of the pipeline will assign several threads in a thread bundle to each SP (streaming processor) for execution.
[0071] SP is the smallest computing unit of GPGPU, which completes ALU, Flow, FPU and other operations. The method described in this article configures a dependent data register DReg for each SP to store the intermediate results generated during the calculation of dependent instructions.
[0072] Because GPGPU implements instruction execution through a five-stage pipeline, when there are interdependent instructions, the pipeline operation will cause interruption of the execution of dependent instructions due to its efficient continuous operation.
[0073] Figure 3 is a time-space diagram of an instruction execution pipeline provided by an embodiment of the present disclosure, combined with Figure 3 As shown in the figure, when executing the operation a*b+c, assuming that the GPGPU architecture can only perform a single operation, this operation needs to calculate a*b (ins1) first, and then add c (ins2). When the ins1 instruction is executed to the write-back stage (t5), the current result has not been written back to the memory, and the next instruction has entered the execution stage. Obviously, the calculation result of the previous instruction cannot be used. Therefore, the traditional compiler will insert two NOP instructions (the instruction does not perform any operation) between the two instructions (ins1 and ins2), as shown in the figure. Figure 3 As shown in the Tradition section, after the NOP instruction is inserted, ins1 writes the calculation result back to the memory after t5. At this time, ins2 has just completed the decoding stage. At t6, ins2 reads the execution result of ins1 from the memory and performs addition operation.
[0074] The pipeline architecture of GPGPU requires traditional compilers to insert invalid instructions into the compilation of dependent instructions, which reduces the execution efficiency of the pipeline and increases the complexity of compiler compilation.
[0075] Figure 4 It is a pipeline optimization principle diagram for adding dependent data registers corresponding to SP provided by an embodiment of the present disclosure.
[0076] In order to improve the execution efficiency of the pipeline and reduce the complexity of compiler compilation, combined with Figure 4 , Figure 1 The compiler optimization process corresponds to the processing method of the GPGPU compiler and pipeline for instruction dependencies. The compilation process is optimized for the situation where there are dependencies between instructions. A dependency identifier is added to the compilation instruction to indicate whether the current instruction has a dependency relationship with other instructions, and the storage location of the current instruction execution result in the dependent data register. A new operand storage type is added as the dependent data register, which is named DReg in this article.
[0077] The dependency flag of the compilation instruction takes 5 bits as an example. The actual application can be flexibly configured according to the system complexity and system architecture. The 5-bit dependency flag dependflag uses dependflag[0] to indicate whether the current instruction has a dependency relationship with other instructions, dependflag[1] indicates the current instruction operation type, 0 is the temporary result, 1 is the execution writeback, and dependflag[4:2] identifies the storage location of the current instruction result in the dependency data register. The number of bits is determined by the maximum number of dependency data registers. The actual application can be flexibly configured according to the system complexity and system architecture.
[0078] Taking the dependency operation a*b+c as an example, assuming that the GPGPU architecture can only perform a single operation, after the operation is compiled, it will be divided into two instructions (ins1 and ins2) to execute a*b first and then add it to c.
[0079] After the first instruction is compiled, the operand address and storage type are the same as normal hardware instructions, except for an additional dependency identifier 5'b00001, which indicates a dependent operation, the result of the operation is temporarily stored, and the result of the operation is stored in the 0th position of the dependent data register.
[0080] After the second instruction is compiled, the storage type of the first operand is DReg, and the address is the [4:2] bits of the dependency flag of the ins1 instruction, indicating that the first operand is stored in the 0th bit of the dependency data register. The address and storage type of the second operand are the same as those of a normal hardware instruction, and the dependency flag is 5'b00011, indicating a dependent operation, and the result of the operation is written back.
[0081] The optimized pipeline is as follows Figure 3 As shown in the Proposed section, after receiving the instruction, the execution pipeline of the GPGPU decodes it and determines whether the pipeline enters the dependent operation mode by judging dependflag[0]. In the dependent operation mode, after executing the instruction, the processing of the calculation result is determined by judging dependflag[1]. If dependflag[1] of the ins1 instruction is 0, the calculation result is stored in the dependent data register. After that, the pipeline skips the write-back stage and directly enters the next instruction fetch stage.
[0082] When the ins2 instruction is executed to the reading stage (t4), GPGPU reads c from the corresponding memory and enters the execution stage (t5). At this time, ins1 has completed the execution stage and written the calculation result to DReg. ins2 only needs to add the DReg value to c to complete the operation.
[0083] The optimized compilation process only needs two instructions to complete the dependent calculation, which greatly improves the compilation efficiency and reduces the compilation complexity.
[0084] exist Figure 1 In the pipeline optimization process corresponding to the GPGPU compiler and pipeline processing method that depends on instructions, the GPGPU execution pipeline has five stages: instruction fetch, decoding, reading, execution, and write back. The instruction fetch stage reads the operation instruction from SystemMemory; the decoding stage parses the instruction and extracts other information such as the operand storage address; the reading stage reads the operand from Global Memory or L1 Cache; the execution stage performs corresponding operations on the operand according to the instruction information; the write back stage writes the calculation result back to L1 Cache or other memory space.
[0085] In the whole process, L1 Cache acts as a pre-fetch cache for each SM, and pre-fetches data based on spatial locality or prediction algorithms. In the read phase, SM will first check whether the operand exists in L1 Cache. If not, it will read from Global Memory. In the write-back phase, SM will first write the result to L1 Cache. When the L1 Cache buffer is about to be full, it will ferry the data to Global Memory.
[0086] There are several problems with dependent instructions in this process: on the one hand, when the first dependent instruction is executed, the calculation result will be written back to the L1 Cache. If the Cache is full at this time, the data will be transferred back to the global memory. When the next instruction is executed to the read stage, the intermediate result needs to be read from the global memory, which takes a long time. On the other hand, multiple SMs in the GPGPU have the same priority for accessing the global memory. If two SMs access the global memory at the same time, the on-chip network will be blocked. At this time, the pipeline in one SM must stop, affecting the computing performance. The present disclosure solves the above problems by adding dependent data registers in the SP.
[0087] In a specific example, taking the dependency operation s=a*b+c as an example, the dependency identifiers of two dependent instructions are 5'b00001 and 5'b00011 respectively.
[0088] Execute the first instruction: After receiving the instruction, the execution pipeline of GPGPU decodes it and obtains the dependency identifier. The reading stage determines whether the operand memory type is DReg. If it is not for this instruction, the operand is read from the corresponding memory according to the operand address and sent to the execution stage. The execution stage determines whether the pipeline enters the dependent operation mode by judging dependflag[0]. In the dependent operation mode, after the instruction execution operation is completed, the processing of the calculation result is determined by judging dependflag[1]. If dependflag[1] of this instruction is 0 and dependflag[4:2] is 0, the calculation result is stored in the dependent data register DReg[0], and then the execute_done signal output is generated.
[0089] A multiplexer outside the pipeline is used to control the jump of the pipeline. The pipeline completion stage is determined by judging dependflag[1]. The current instruction is 0, indicating that the pipeline has no write-back stage. Execute_done is selected as the Pipeline_done signal, and Pipeline_done is input into the Warp Schedule module. The Warp Schedule module starts the next instruction fetch operation of the pipeline.
[0090] Execute the second instruction: After receiving the instruction, the execution pipeline of GPGPU decodes it and obtains the dependency identifier. The read stage determines whether the operand memory type is DReg. The first operand memory type of this instruction is yes, indicating that the operand is stored in DReg. Generate the dependency register read enable rd_en and skip the read. The second operand memory type is no. Read the operand from the corresponding memory according to the operand address and send it to the execution stage.
[0091] The execution stage performs operations according to the instructions, and determines whether the pipeline enters the dependent operation mode by judging dependflag[0]. In the dependent operation mode, if the rd_en signal is detected, the data of the dependent data register DReg[0] is added to the second operand according to dependflag[4:2]. After the calculation is completed, the processing of the calculation result is determined by judging dependflag[1]. If dependflag[1] of this instruction is 1, the calculation result is sent to the write-back stage, and the pipeline enters the write-back stage to write the result back to the memory, and then generate the Write_done signal output.
[0092] The multiplexer outside the pipeline determines that dependflag[1] is 1 at this time, indicating that the pipeline has a write-back stage, selects Write_done as the Pipeline_done signal, and inputs Pipeline_done into the Warp Schedule module. The WarpSchedule module starts the next instruction fetch operation of the pipeline.
[0093] The optimized pipeline reduces the execution of dependent instructions from five stages to four stages, saving the memory read and write time of operands in the write-back stage, and reducing or even eliminating the need for operand read operations in the read stage, saving bandwidth usage for memory reads and improving the data read rate of other thread bundles.
[0094] The advantages of the present invention are:
[0095] The optimized compilation process can complete dependent operations without invalid instruction waiting pipeline, which greatly improves compilation efficiency and reduces compilation complexity.
[0096] The execution of dependent instructions is reduced from a five-stage pipeline to a four-stage pipeline, which saves the memory read and write time of operands in the write-back stage and the read stage, improves computing efficiency, reduces the bandwidth occupancy of the global memory, and reduces the probability of memory competition with other thread bundles.
[0097] Instructions with dependencies are optimized and fixed registers are assigned to the intermediate calculation results of dependent instructions, avoiding external memory access caused by overflow of traditional L1 Cache and hiding some thread warp scheduling delays.
[0098] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present disclosure is not limited by the order of the actions described, because according to the present disclosure, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.
[0099] Combination Figure 5 As shown, the embodiment of the present disclosure provides another instruction-dependent GPGPU compiler and pipeline processing system 500, including a processor 504 and a memory 501. Optionally, the system may also include a communication interface 502 and a bus 503. Among them, the processor 504, the communication interface 502, and the memory 501 can communicate with each other through the bus 503. The communication interface 502 can be used for information transmission. The processor 504 can call the logic instructions in the memory 501 to execute the instruction-dependent GPGPU compiler and pipeline processing method of the above embodiment.
[0100] In addition, the logic instructions in the memory 501 described above can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0101] The memory 501 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the method in the embodiment of the present disclosure. The processor 504 executes the function application and data processing by running the program instructions / modules stored in the memory 501, that is, the processing method of the GPGPU compiler and pipeline dependent on the instructions in the above embodiment is implemented.
[0102] The memory 501 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 501 may include a high-speed random access memory and may also include a non-volatile memory.
[0103] An embodiment of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to execute a GPGPU compiler and a pipeline processing method on which the instructions are dependent.
[0104] The computer-readable storage medium mentioned above may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.
[0105] The technical solution of the embodiment of the present disclosure can be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method of the embodiment of the present disclosure. The aforementioned storage medium may be a non-transient storage medium, including: a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, and other media that can store program codes, or a transient storage medium.
[0106] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent possible changes only. Unless explicitly required, separate components and functions are optional, and the order of operations may vary. Parts and features of some embodiments may be included in or replace parts and features of other embodiments. As used in the description of the embodiments, unless the context clearly indicates otherwise, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of one or more associated listings. In addition, when used in this application, the term "comprise" and its variants "comprises" and / or including (comprising) refer to the existence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the existence or addition of one or more other features, wholes, steps, operations, elements, components and / or these groups. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the existence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same or similar parts between the embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.
[0107] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. Technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. Technicians can clearly understand that for the convenience and simplicity of description, the specific working process of the systems, devices and units described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0108] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units can be only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to implement this embodiment. In addition, each functional unit in the embodiment of the present disclosure may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit.
[0109] The flowchart and block diagram in the accompanying drawings show the possible architecture, functions and operations of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.
Claims
1. A method for processing an instruction-dependent GPGPU compiler and pipeline, characterized in that: The method is applied to a system including a host and a GPGPU; the method includes: Compile the dependency operations to be processed to generate two instructions; Decode the first instruction and determine whether the operand memory type is DReg. If not, read the operand from the corresponding memory according to the operand address. Determine whether the pipeline enters the dependent operation mode by judging dependflag[0]. In the dependent operation mode, after the instruction execution operation is completed, determine the processing of the calculation result by judging dependflag[1], store the calculation result in the dependent data register DReg[0], and then generate the execute_done signal output; The pipeline completion stage is determined by judging dependflag[1]. If it is 0, it means that the pipeline has no write-back stage. Execute_done is selected as the Pipeline_done signal, and Pipeline_done is input to the Warp Schedule module. The WarpSchedule module starts the next instruction fetch operation of the pipeline. Decode the second instruction and determine whether the operand memory type is DReg. If yes, it means that the operand is stored in DReg, generate the dependent register read enable rd_en, and skip reading. If the operand memory type is no, read the operand from the corresponding memory according to the operand address, determine dependflag[0] to determine whether the pipeline enters the dependent operation mode, and in the dependent operation mode, if the rd_en signal is detected, add the data of the dependent data register DReg[0] to the second operand according to dependflag[4:2]. After the calculation is completed, determine the processing of the calculation result by determining dependflag[1]. If dependflag[1] of this instruction is 1, the calculation result is sent to the write-back stage, the pipeline enters the write-back stage, writes the result back to the memory, and then generates the Write_done signal output; If dependflag[1] is 1, it means that the pipeline has a write-back stage, Write_done is selected as the Pipeline_done signal, and Pipeline_done is input to the Warp Schedule module so that the Warp Schedule module can start the next instruction fetch operation of the pipeline.
2. The method according to claim 1, characterized in that The dependency flag dependflag corresponding to the dependency operation to be processed indicates whether the current instruction has a dependency relationship with other instructions with dependflag[0], dependflag[1] indicates the current instruction operation type, 0 is the temporary result, 1 is the execution write back, dependflag[4:2] identifies the storage location of the current instruction result in the dependency data register, and the number of bits is determined by the maximum number of dependency data registers.
3. The method according to claim 1, characterized in that The Host is composed of a CPU and memory, and the CPU is used to complete the creation, allocation, scheduling and release of tasks; Programs written on the CPU are compiled by the compiler and translated into hardware instructions for GPGPU parsing.
4. The method according to claim 1, characterized in that: The GPGPU is used as a coprocessor and is composed of AXIinterface, Block Schedule, GPGPU configuration, GPGPU Memory, and SM, wherein the AXIinterface is used as an internal interconnection bus to establish a connection between the GPGPU Memory and the Host Memory to achieve data communication; Block Schedule is used to implement the execution scheduling of thread blocks; GPGPU configuration is used to configure GPGPU control parameters.
5. The method according to claim 4, characterized in that The GPGPU Memory is divided into Global Memory, System Memory and Constant Memory; The Global Memory stores data corresponding to dependency operations to be processed, the System Memory stores control instructions, and the Constant Memory serves as a read-only memory during the operation of the GPGPU to store constant parameters during the operation.
6. The method according to claim 5, characterized in that The streaming multiprocessor SM is the computing unit of GPGPU, which is composed of Wrap Schedule, Register file, L1 Cache, Shared Memory and Pipeline. The Wrap Schedule is used to implement the scheduling and maintenance of thread bundles, and the Register file, L1Cache and ShareMemory are used to cache data and intermediate calculation results during the operation process.
7. The method according to claim 6, characterized in that The Pipeline is used to implement the computing function of the SM, and completes instruction fetching, decoding, data reading, execution, and result writing back through a five-stage pipeline. The execution stage of the pipeline will allocate several threads in a thread warp to each SP for execution.
8. The method according to claim 7, characterized in that The SP is the smallest computing unit of GPGPU, completing ALU, Flow, and FPU operations; Each SP is configured with a dependent data register DReg, which is used to store intermediate results generated during the calculation of dependent instructions.
Citation Information
Cited By
GPGPU (General Purpose Graphics Processing Unit)-based instruction pipeline optimization and dynamic planning method and system
CN118796277A
Instruction pipeline optimization and dynamic programming method and system based on GPGPU
CN118796277B
GPGPU (General Purpose Graphics Processing Unit) thread block synchronization method and equipment based on thread lock and medium
CN119557115A
Tensor instruction optimization method and device and storage medium
CN121072629A
