Data processing method, device and system based on GPU on-chip memory

By enabling two threads on the GPU device, one thread obtains writable data, and the other thread pre-reads read-only data to the GPU on-chip memory, solving the problem of long data loading time in GPU computing tasks, improving data processing efficiency and performance.

CN118409874BActive Publication Date: 2024-10-18ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410881312.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-02
Publication Date
2024-10-18
Estimated Expiration
2044-07-02

AI Technical Summary

Technical Problem

Traditional CPU hardware is difficult to meet the computing needs of machine learning or deep learning tasks. Especially in the large model inference stage, the time for loading model parameter data from the GPU global memory to the computing unit becomes a performance bottleneck.

Method used

By enabling two GPU threads on the GPU device, one thread is responsible for obtaining writable data, and the other thread pre-reads the read-only data in the GPU global memory to the GPU on-chip memory, thereby reducing data loading time.

Benefits of technology

It improves the data processing efficiency of GPU computing tasks, shortens the data loading time during model calculation, and improves overall performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118409874B_ABST
    Figure CN118409874B_ABST
Patent Text Reader

Abstract

The embodiments of this specification provide a data processing method, device and system based on GPU on-chip memory. A data acquisition operation for first data is initiated on a first GPU thread, and the first data includes writable data required for a GPU computing task; during the execution of the data acquisition operation by the first GPU thread, a data pre-reading process of pre-reading second data from the GPU global memory to the GPU on-chip memory is initiated on a second GPU thread, and the second data includes read-only data required for the GPU computing task stored in the GPU global memory; and in response to the completion of the data acquisition process for the first data and the data pre-reading process for the second data, a GPU computing task is executed on the second GPU thread based on the first data and the second data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification generally relate to the field of data processing technology, and more particularly to a method, device and system for data processing based on GPU on-chip memory. Background Art

[0002] Traditional CPU hardware devices have been unable to meet the task computing requirements of machine learning tasks or deep learning tasks, especially the model computing requirements of large generative models represented by ChatGPT. GPU hardware devices have become the mainstream acceleration hardware for model reasoning due to their advantages such as high-speed parallel processing capabilities and stronger memory access bandwidth. However, in the large model reasoning stage, especially when the batch data of model feature data used for model reasoning is small, the performance bottleneck of model reasoning is not the model calculation itself, but the data loading time of the model parameter data (model weight matrix) used for model calculation from the GPU global memory to the GPU computing unit. Summary of the invention

[0003] The embodiments of this specification provide a data processing solution based on GPU on-chip memory. With this data processing solution, by enabling the first and second GPU threads on the GPU device, and during the reading of the writable data required for the GPU computing task via the first GPU thread, the read-only data for the GPU computing task stored in the GPU global memory is pre-read to the GPU on-chip memory via the second GPU thread before the GPU computing task is executed, thereby reducing the data loading time when the GPU computing unit executes the GPU computing task, thereby improving the data processing efficiency.

[0004] According to one aspect of an embodiment of the present specification, a data processing method based on GPU on-chip memory is provided, comprising: initiating a data acquisition operation for first data on a first GPU thread, the first data including writable data required for a GPU computing task; during execution of the data acquisition operation by the first GPU thread, initiating a data pre-reading process for pre-reading second data from the GPU global memory to the GPU on-chip memory on a second GPU thread, the second data including read-only data required for the GPU computing task stored in the GPU global memory; and in response to completion of the data acquisition process for the first data and the data pre-reading process for the second data, executing the GPU computing task based on the first data and the second data on the second GPU thread.

[0005] Optionally, in an example of the above aspect, the data processing method further includes: determining whether to initiate a data pre-reading process of pre-reading the second data from the GPU global memory to the GPU on-chip memory according to a pre-reading configuration file.

[0006] Optionally, in an example of the above aspect, the GPU on-chip memory includes L2 Cache, and the data pre-reading process of initiating on the second GPU thread to pre-read the second data from the GPU global memory to the GPU on-chip memory includes: initiating on the second GPU thread a first data pre-reading process of pre-reading the second data from the GPU global memory to the L2 Cache.

[0007] Optionally, in an example of the above aspect, the GPU on-chip memory also includes GPU shared memory and GPU registers, and the data pre-reading process initiated on the second GPU thread to pre-read the second data from the GPU global memory to the GPU on-chip memory also includes: when the data pre-read by the first data pre-reading process is partial data of the second data, initiating a second data pre-reading process on the second GPU thread to pre-read the remaining data from the GPU global memory to the GPU shared memory and / or the GPU registers.

[0008] Optionally, in an example of the above aspect, the GPU on-chip memory also includes GPU shared memory and GPU registers, and the data pre-reading process initiated on the second GPU thread to pre-read the second data from the GPU global memory to the GPU on-chip memory also includes: when there is no need to execute the first data pre-reading process, initiating a third data pre-reading process on the second GPU thread to pre-read the second data from the GPU global memory to the GPU shared memory and / or the GPU registers.

[0009] Optionally, in an example of the above aspect, the data stored in the L2 Cache is cached in the form of byte blocks, and each byte block has an eviction priority.

[0010] Optionally, in an example of the above aspect, the eviction priority includes latest eviction, normal eviction and last eviction, and the GPU computing optimization method also includes: after pre-reading the second data into the L2 Cache, setting the eviction priority of the byte block caching the second data to last eviction.

[0011] Optionally, in an example of the above aspect, the data processing method further includes: when pre-reading the second data into the L2 Cache, if the free cache space of the L2 Cache is insufficient to cache the second data, evicting the byte blocks cached in the L2 Cache according to the eviction priority of latest eviction, normal eviction and last eviction until the free cache space of the L2 Cache is sufficient to cache the pre-read second data.

[0012] Optionally, in an example of the above aspect, the GPU computing task includes a model computing task of a model reasoning process, the first data includes model feature data, and the second data includes model parameter data.

[0013] Optionally, in an example of the above aspect, the GPU computing is assigned a GPU computing lock, and the data processing method further includes: during the data acquisition of the first data, occupying the GPU computing lock on the first GPU thread, and after completing the data acquisition of the first data, releasing the GPU computing lock on the first GPU thread. In response to the completion of the data acquisition process of the first data and the data pre-reading process of the second data, performing the GPU computing based on the first data and the second data on the second GPU thread includes: in response to the completion of the data acquisition process of the first data and the data pre-reading process of the second data, occupying the GPU computing lock on the second GPU thread, and performing the GPU computing based on the first data and the second data.

[0014] Optionally, in an example of the above aspect, the GPU computing lock is implemented by allocating volatile integer space to the GPU global memory.

[0015] According to another aspect of an embodiment of the present specification, a data processing method based on GPU on-chip memory is provided, comprising: issuing a GPU computing task to a GPU device via a CPU device, and creating a first GPU thread for acquiring first data and a second GPU thread for pre-reading second data and performing GPU computing, wherein the first data includes writable data required for the GPU computing task, and the second data includes read-only data required for the GPU computing task stored in a GPU global memory; after the GPU computing task is started, initiating a data acquisition operation for the first data on the first GPU thread via the GPU device; during the execution of the data acquisition operation by the first GPU thread, initiating a data pre-reading process of pre-reading the second data from the GPU global memory to the GPU on-chip memory on the second GPU thread via the GPU device; and in response to completion of the data acquisition process for the first data and the data pre-reading process for the second data, executing the GPU computing task based on the first data and the second data on the second GPU thread via the GPU device.

[0016] According to another aspect of an embodiment of the present specification, there is provided a data processing device based on GPU on-chip memory, comprising: a data acquisition unit, initiating a data acquisition operation for first data on a first GPU thread, the first data including writable data required for a GPU computing task; a data pre-reading unit, initiating a data pre-reading process for pre-reading second data from the GPU global memory to the GPU on-chip memory on a second GPU thread during execution of the data acquisition operation by the first GPU thread, the second data including read-only data required for the GPU computing task stored in the GPU global memory; and a computing task execution unit, executing the GPU computing task based on the first data and the second data on the second GPU thread in response to completion of the data acquisition process for the first data and the data pre-reading process for the second data.

[0017] According to another aspect of an embodiment of the present specification, a data processing system based on GPU on-chip memory is provided, comprising: a CPU device, which issues a GPU computing task to a GPU device, and creates a first GPU thread for acquiring first data and a second GPU thread for pre-reading second data and performing GPU computing, wherein the first data includes writable data required for the GPU computing task, and the second data includes read-only data required for the GPU computing task stored in a GPU global memory; and a GPU device, comprising a GPU computing device based on GPU on-chip memory as described above.

[0018] According to another aspect of an embodiment of the present specification, a data processing device based on GPU on-chip memory is provided, comprising: at least one processor; a memory coupled to the at least one processor; and a computer program stored in the memory, wherein the at least one processor executes the computer program to implement the data processing method based on GPU on-chip memory as described above.

[0019] According to another aspect of an embodiment of the present specification, a data processing system based on GPU on-chip memory is provided, comprising: at least one processor; a memory coupled to the at least one processor; and a computer program stored in the memory, wherein the at least one processor executes the computer program to implement the data processing method based on GPU on-chip memory as described above.

[0020] According to another aspect of an embodiment of the present specification, a computer-readable storage medium is provided, which stores executable instructions, and when the instructions are executed, a processor executes the data processing method based on the GPU on-chip memory as described above.

[0021] According to another aspect of an embodiment of the present specification, a computer program product is provided, including a computer program, wherein the computer program is executed by a processor to implement the data processing method based on GPU on-chip memory as described above. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] A further understanding of the nature and advantages of the content of this specification may be achieved by referring to the following drawings. In the drawings, similar components or features may have the same reference numerals.

[0023] Figure 1 A performance comparison chart of GPU video memory is shown.

[0024] Figure 2 A schematic diagram showing the model structure of the GLM model is shown.

[0025] Figure 3 A schematic diagram of data transmission in matrix multiplication operation is shown.

[0026] Figure 4 A schematic diagram showing the principle of GPU on-chip memory pre-reading according to an embodiment of this specification is shown.

[0027] Figure 5 An exemplary block diagram of a data processing system according to an embodiment of the present description is shown.

[0028] Figure 6 An exemplary flow chart of a data processing method according to an embodiment of the present specification is shown.

[0029] Figure 7 An example schematic diagram of a pre-read configuration file according to an embodiment of the present specification is shown.

[0030] Figure 8 An example schematic diagram of an L2 Cache data pre-reading process according to an embodiment of this specification is shown.

[0031] Fig. 9 An exemplary block diagram of a data processing device based on an on-chip memory according to an embodiment of the present specification is shown.

[0032] Fig.10 An exemplary schematic diagram of an on-chip memory-based data processing device implemented based on a computer system according to an embodiment of the present specification is shown.

[0033] Fig.11 An exemplary schematic diagram of an on-chip memory-based data processing system implemented based on a computer system according to an embodiment of the present specification is shown. DETAILED DESCRIPTION

[0034] The subject matter described herein will now be discussed with reference to example embodiments. It should be understood that the discussion of these embodiments is only to enable those skilled in the art to better understand and implement the subject matter described herein, and is not a limitation of the scope of protection, applicability or examples set forth in the claims. The functions and arrangements of the elements discussed can be changed without departing from the scope of protection of the contents of this specification. Various examples can omit, replace or add various processes or components as needed. For example, the described method can be performed in an order different from the described order, and various steps can be added, omitted or combined. In addition, the features described relative to some examples can also be combined in other examples.

[0035] As used herein, the term "including" and its variations represent open terms, meaning "including but not limited to". The term "based on" means "based at least in part on". The terms "one embodiment" and "an embodiment" mean "at least one embodiment". The term "another embodiment" means "at least one other embodiment". The terms "first", "second", etc. may refer to different or the same objects. Other definitions may be included below, whether explicit or implicit. Unless the context clearly indicates otherwise, the definition of a term is consistent throughout the specification.

[0036] The flowcharts used in this specification illustrate the operations implemented by the system according to some embodiments in this specification. It should be clearly understood that the operations of the flowcharts may not be implemented in sequence. On the contrary, the operations may be implemented in reverse order or simultaneously. In addition, one or more other operations may be added to the flowchart. One or more operations may be removed from the flowchart.

[0037] Before proceeding with the description, several concepts involved in the embodiments of this specification are first introduced.

[0038] Graphics Processing Unit (GPU) is a microprocessor that performs image and graphics related operations on personal computers, workstations, game consoles and some mobile devices (such as tablets, smart phones, etc.). It can be used for graphics display and computing acceleration, and has high-speed parallel computing capabilities. GPU can also be called display core, visual processor, display chip, etc.

[0039] The internal storage of the GPU can be called GPU video memory. In order to meet the application scenarios of the GPU, the GPU video memory can be divided into GPU on-chip storage and GPU off-chip storage according to the location of the storage hardware. Common GPU on-chip storage includes GPU shared memory (Shared Memory), GPU registers (Register) and GPU L1 / L2 cache (Cache). GPU off-chip storage includes GPU local memory (Local memory) and GPU global memory (Global memory).

[0040] GPU memory bandwidth refers to the data transfer rate between the GPU computing unit and the GPU memory. Due to the different hardware materials of GPU on-chip storage and GPU off-chip storage, the transmission speed from GPU on-chip storage to GPU computing unit is usually 5 to 10 times that of GPU off-chip storage to GPU computing unit. Figure 1 A performance comparison chart of GPU video memory is shown.

[0041] Streaming Multiprocessors (SM) are computing logic units within the GPU, which are similar to a core in a multi-core CPU chip. A CPU core usually runs one thread, while SM can run multiple threads (for example, lightweight threads).

[0042] GPU global memory can be accessed and globally shared by all threads in the GPU device, and has a large storage space. Like the CPU architecture, GPU computing units cannot directly use data in GPU global memory and need to go through the cache. L2 Cache can be globally accessed by all SMs, and its bandwidth is several times that of GPU global memory. L1 Cache is used to store data within SMs and can be shared by computing units within SMs, but L1 Cache cannot be accessed across SMs.

[0043] GPU shared memory is memory that can be accessed within a computing block. Its access speed is significantly faster than L2Cache. GPU shared memory is mainly used to cache data that needs to be read and written repeatedly.

[0044] In the inference phase of large models (e.g., large language models) based on GPU computing units, especially when the batch data of model feature data used for model inference is small, the performance bottleneck of model inference is not the model calculation itself, but the data loading time of the model parameter data (model weight matrix) used for model calculation from the GPU global memory to the GPU computing unit. The following is an example of the GLM model.

[0045] Figure 2 A schematic diagram showing the model structure of the GLM model.

[0046] like Figure 2 As shown in the figure, the large model structure of the GLM model includes a normalization layer (LayerNorm), an attention layer (Attention), and a multi-layer perceptron layer (MatMul), where the attention layer is used to perform matrix multiplication operations. Through the analysis of the model calculation time consumption, it can be seen that in a model inference process, the time consumption of matrix multiplication accounts for more than 50%.

[0047] Different from the training process, after the model service is launched, when performing matrix multiplication in the inference phase, the input size depends on the size of the instantaneous traffic. For the matrix multiplication operation of the GLM model, the matrices used for matrix multiplication include the model feature matrix X and the model weight matrix Y. When the batch data of the model feature data is small, the model feature matrix X is usually small, while the model weight matrix Y is large. The size of the model weight matrix Y is usually [hidden_states, 4 hidden_states], taking the common 10B model in the industry as an example, hidden_states is 4096, and float16 is used for storage, and the size of the model weight matrix Y is 128MB. The model feature matrix X is a variable matrix input in real time, while the model weight matrix Y will not change once the model training is completed, that is, the model weight matrix is ​​an immutable matrix, and the model weight matrix Y will be stored in the GPU global memory of the GPU device.

[0048] Figure 3 A schematic diagram of data transmission in matrix multiplication operation is shown.

[0049] When performing matrix multiplication, the model feature matrix X is input in real time, and the model weight matrix Y is loaded from the GPU global memory to the GPU shared memory, then read from the GPU shared memory to the GPU register, and loaded from the GPU register to the GPU computing unit for matrix multiplication. From the above, it can be seen that the time consumption of matrix multiplication includes the data loading time required for matrix multiplication and the matrix multiplication calculation time. As the computing power of the GPU continues to improve, the matrix multiplication calculation time will be much less than the data loading time required for matrix multiplication. The data loading time required for matrix multiplication includes the data loading time of the model feature matrix X and the data loading time of the model weight matrix Y. Since the data volume of the model feature matrix X is much smaller than the data volume of the model weight matrix Y, especially when the batch data of the model feature data is small, the data loading time of the model weight matrix Y from the GPU global memory to the GPU computing unit is much longer than the data input time of the model feature matrix X, which results in the time consumption of the matrix multiplication operation depending on the data loading time of the model weight matrix Y from the GPU global memory to the GPU computing unit.

[0050] Considering that the data used by the GPU computing task includes variable data and read-only data, the variable data needs to be input in real time, while the read-only data does not change and is stored in the GPU global memory, and needs to be loaded from the GPU global memory to the GPU computing unit when performing GPU computing, the embodiment of this specification proposes a data processing method based on the GPU on-chip memory. In this data processing method, when performing the data loading operation of the GPU computing task, two threads are started, and during the period of using one thread to perform the data acquisition operation of the writable data, another thread is used to pre-read the read-only data from the GPU global memory to the GPU on-chip memory, thereby using the strong data access capability of the GPU on-chip memory to shorten the data loading time of the read-only data during the model calculation, thereby improving the computing speed of the GPU calculation.

[0051] Figure 4 A schematic diagram showing the principle of GPU on-chip memory pre-reading according to an embodiment of the present specification is shown.

[0052] like Figure 4 As shown, after receiving the GPU computing task, the scheduling module in the CPU device creates a first GPU thread (GPU thread 1) and a second GPU thread (GPU thread 2) on the GPU device. The data used by the GPU computing task includes writable data and read-only data. The writable data may be, for example, model feature data or other real-time data input in real time, and the read-only data may include, for example, model weight data, and the read-only data is stored in the GPU global memory, and is pre-read from the GPU global memory to the GPU on-chip memory when performing GPU computing. The first GPU thread is used to obtain the writable data required for the GPU computing task (PreOP operation), and the second GPU is used to implement the pre-read operation of the read-only data from the GPU global memory to the GPU on-chip memory (for example, pre-read to L2 Cache (PreloadTOCache), pre-read to GPU shared memory / GPU register) and GPU computing operation, and during the execution of the first GPU thread, the pre-read operation of the read-only data is performed on the second GPU thread.

[0053] The data processing system and data processing method based on GPU on-chip memory according to the embodiments of this specification will be described in detail below with reference to the accompanying drawings.

[0054] Figure 5 1 shows an example block diagram of a data processing system 500 according to an embodiment of the present specification. Figure 5 As shown, the data processing system 500 includes a CPU device 510 and a GPU device 520 .

[0055] The CPU device 510 is used to allocate and schedule GPU computing tasks. The data used by the scheduled GPU computing tasks when performing GPU computing includes writable data and read-only data stored in the GPU global memory. For example, when performing model reasoning based on a large model, the CPU device 510 can divide the model calculation in the model reasoning task to be executed into one or more GPU computing tasks, and schedule the GPU computing tasks to the GPU computing unit to perform GPU computing. In some embodiments, the model calculation may, for example, include a matrix multiplication calculation between a model feature matrix and a model weight matrix.

[0056] In response to the GPU computing task being scheduled to the GPU device 520, the scheduling unit in the CPU device 510 creates a first GPU thread and a second GPU thread on the GPU device 520. The GPU device 520 uses the created first GPU thread to obtain writable data under the scheduling of the scheduling unit, and uses the second GPU thread to pre-read read-only data from the GPU global memory to the GPU on-chip memory during the period when the first GPU thread obtains the writable data. After the second GPU thread completes the data acquisition operation of the writable data and the data pre-reading operation of the read-only data, the GPU device 520 uses the second GPU thread to perform GPU computing based on the writable data and the read-only data, thereby completing the GPU computing task.

[0057] Figure 6 An exemplary flow chart of a data processing method 600 according to an embodiment of the present specification is shown.

[0058] like Figure 6 As shown, at 601, the CPU device completes the GPU computing task allocation, and at 602, the GPU computing task is scheduled to the corresponding GPU computing unit to perform GPU computing, and a first GPU thread and a second GPU thread are created on the GPU device, the first GPU thread is used to obtain the writable data (hereinafter referred to as the first data) required for the GPU computing task, and the second GPU is used to implement the pre-reading operation and GPU computing operation of pre-reading the read-only data (hereinafter referred to as the second data) required for the GPU computing task from the GPU global memory to the GPU on-chip memory. For example, in the model reasoning process, the GPU computing task can be a model computing task such as a matrix multiplication operation task, the writable data is the input model feature matrix data, and the read-only data is the model weight matrix data.

[0059] At 603, after receiving the GPU computing task and starting the GPU computing of the GPU computing task, the GPU device performs a first data acquisition operation on the first GPU thread to acquire first data required for the GPU computing. In some embodiments, the first data acquisition operation may also be referred to as a pre-operation (PreOP) of the GPU computing.

[0060] During the time when the first GPU thread performs a data acquisition operation for the first data, a data pre-reading operation is initiated on the second GPU thread to pre-read the second data from the GPU global memory to the GPU on-chip memory. In some embodiments, the GPU on-chip memory may include at least one of an L2 Cache, a GPU shared memory, and a GPU register.

[0061] In some embodiments, it can be determined whether it is necessary to pre-read the second data required for the GPU computing task from the GPU global memory to the GPU on-chip memory based on a pre-read configuration file. The pre-read configuration file is used to configure which GPU on-chip memories can perform data pre-read operations on. In some embodiments, it can also be determined in other ways whether it is necessary to pre-read the second data required for the GPU computing task from the GPU global memory to the GPU on-chip memory. For example, it is determined whether it is necessary to pre-read the second data required for the GPU computing task from the GPU global memory to the GPU on-chip memory based on the remaining capacity space size of the GPU on-chip memory.

[0062] Figure 7 FIG. 2 shows an example schematic diagram of a pre-read configuration file according to an embodiment of the present specification. Figure 7 In the example of the pre-reading configuration file shown, the pre-reading configuration file has an L2 Cache pre-reading identification field "use_L2_preload" and a shared memory / register pre-reading identification field "use_smem_reg_preload", wherein a field value of 0 indicates that no pre-reading operation is performed, and a field value of 1 indicates that a pre-reading operation is performed. Figure 7 In the performance, the values ​​of "use_L2_preload" and "use_smem_reg_preload" are 1, which stipulates that pre-read operations from GPU global memory to L2Cache and pre-read operations from GPU global memory to GPU shared memory and GPU registers are required.

[0063] Specifically, Figure 6 As shown, during the period when the GPU device executes the first data acquisition on the first GPU thread, the CPU device reads the pre-read configuration file at 604. Subsequently, it is determined whether it is necessary to pre-read the second data from the GPU global memory to the GPU on-chip memory according to the pre-read configuration file. Figure 6 In the example shown, the GPU on-chip memory includes L2 Cache, GPU shared memory, and GPU registers.

[0064] At 605, the CPU device determines whether it is necessary to pre-read the second data from the GPU global memory to the L2 Cache according to the pre-read configuration file. After determining that it is necessary to pre-read the second data from the GPU global memory to the L2 Cache, at 606, the CPU device initiates a second data pre-read request to the GPU device, where the second data pre-read request is used to request to pre-read the second data from the GPU global memory to the L2 Cache.

[0065] At 607, after receiving the second data pre-reading request, the GPU device initiates a first data pre-reading process on the second GPU thread to pre-read the second data from the GPU global memory to the L2 Cache. Depending on the data size of the second data and the size of the available memory space of the L2 Cache, the data pre-read by the first data pre-reading process may be part of the data or all of the data of the second data. When executing the first data pre-reading process, if the data size of the second data exceeds the size of the available memory space of the L2 Cache, part of the second data is pre-read from the GPU global memory to the L2 Cache. For example, assuming that the memory capacity of the L2 Cache is k MB and the size of the second data is (k+n) MB, part of the data of the size of k MB starting from the first data of the second data is pre-read to the L2 Cache, and the remaining n MB of data is not pre-read to the L2 Cache. If the data size of the second data does not exceed the size of the available memory space of the L2 Cache, all of the second data is pre-read from the GPU global memory to the L2 Cache.

[0066] like Figure 3 As shown in the figure, before GPU computing, the data required for GPU computing needs to be transferred from the GPU global memory to the GPU computing unit through the L2 cache and L1 cache in sequence. Affected by the GPU memory bandwidth, loading data from the GPU global memory is slow, so GPU computing is limited by the memory access speed and has poor performance. With the continuous development of GPU technology, the L2 Cache of GPU has gradually increased. For example, the storage capacity of Nvidia's latest L40s inference card has increased by 16 times compared to the L2 Cache of the previous generation A10 card, so L2 cache can be used for data preloading.

[0067] Figure 8 An example schematic diagram of an L2 Cache data pre-reading process according to an embodiment of this specification is shown.

[0068] like Figure 8As shown, the data in the GPU global memory is cached in the L2 Cache in the form of byte blocks, and each byte block has an eviction priority. For example, the GPU pre-reads data from the GPU global memory through the second GPU thread, and caches it in the L2 Cache in units of 32-byte blocks (sectors). The cache line size of each L2 Cache is 4 sectors, that is, 128 bytes. Each sector is set with a tag to identify whether it is in the cache. When the cache space is insufficient to store a new sector, the cached sector in the L2 Cache will be evicted. Each sector can be set with an eviction priority, and the eviction priority includes the latest eviction (evict_first), the last eviction (evict_last), and (evict_normal). The eviction order of the byte block is the latest eviction -> normal eviction -> last eviction. In some embodiments, for each byte block (sector), the initial eviction priority is set to normal eviction, and when the cached data is the second data required for GPU calculation, the eviction priority is changed to the last eviction, and when the cached data can be updated at any time or is not related to GPU calculation, the eviction priority is set to the latest eviction.

[0069] When pre-reading the second data into the L2 Cache, if the free cache space of the L2 Cache is insufficient to cache the second data, the byte blocks cached in the L2 Cache are evicted according to the eviction priorities of latest eviction, normal eviction, and last eviction until the free cache space of the L2 Cache is sufficient to cache the second data.

[0070] When it is determined that there is no need to perform a pre-read operation from the GPU global memory to the L2 Cache, at 608, the CPU device initiates a GPU computing request to the GPU device, where the GPU computing request is used to initiate a GPU computing operation on the second GPU thread.

[0071] At 609, when it is determined that it is not necessary to perform a pre-read operation from the GPU global memory to the L2 Cache or the data pre-read by the first data pre-reading process is part of the second data, the GPU device determines on the second GPU thread according to the pre-reading configuration file whether it is necessary to pre-read the second data or the remaining data of the second data from the GPU global memory to the GPU shared memory and / or the GPU register. In some embodiments, after the GPU device completes the first data pre-reading process to the L2 Cache, if the data pre-read by the first data pre-reading process is part of the second data, the GPU device determines on the second GPU thread according to the pre-reading configuration file whether it is necessary to pre-read the remaining data of the second data from the GPU global memory to the GPU shared memory and / or the GPU register. Alternatively, after receiving a GPU computing request initiated by the CPU device, the GPU device determines on the second GPU thread according to the pre-reading configuration file whether it is necessary to pre-read the second data from the GPU global memory to the GPU shared memory and / or the GPU register.

[0072] When it is determined that the remaining data or all the data of the second data needs to be pre-read from the GPU global memory to the GPU shared memory and / or the GPU register, at 610, a second data pre-reading process for pre-reading the remaining data of the second data from the GPU global memory to the GPU shared memory and / or the GPU register is initiated on the second GPU thread, or a third data pre-reading process for pre-reading the second data (all the data) from the GPU global memory to the GPU shared memory and / or the GPU register is initiated on the second GPU thread. Here, whether the data pre-read by the second data pre-reading process is part of the remaining data of the second data or all the data can be determined based on the data size of the remaining data and the size of the available memory space of the GPU shared memory and / or the GPU register. Similarly, whether the data pre-read by the third data pre-reading process is part of the second data or all the data can be determined based on the data size of the second data and the size of the available memory space of the GPU shared memory and / or the GPU register.

[0073] from Figure 3It can be seen that in addition to transmitting the data of the matrix multiplication operation to the GPU computing unit through the L1 / L2 Cache, it can also be transmitted to the GPU computing unit through the GPU shared memory and GPU registers and other GPU on-chip memories. Since L2 Cache preloading is transparent to subsequent operations, there is no need to modify the subsequent execution logic, but the disadvantage is that it can only modify the eviction priority of the L2 Cache and cannot achieve precise data preloading control. GPU shared memory and GPU registers are programmable GPU on-chip memories. By programming the address of GPU shared memory or GPU registers during the data preloading process (for example, programming the memory address of the preloaded data or the memory address to be stored), precise data preloading control can be achieved.

[0074] Each SM of a GPU device has a fixed amount of GPU shared memory and GPU registers. Taking L40 as an example, there are 144 SMs, 64KB of GPU shared memory and 64KB of GPU registers on each SM. If 128 SMs are used, and 64KB of GPU shared memory and 64KB of GPU registers are used on each SM, 16MB of data can be preloaded.

[0075] After completing the pre-reading of data from the GPU global memory to the GPU on-chip memory, for example, after completing the pre-reading of data from the GPU global memory to the GPU shared memory and / or the GPU register or determining that it is not necessary to perform the pre-reading of data from the GPU global memory to the GPU shared memory and / or the GPU register, at 611, the GPU computing task is performed on the second GPU thread based on the first data and the second data. It should be noted that if the data pre-read from the GPU global memory to the GPU on-chip memory is all the data of the second data, then when performing GPU computing, the second data is loaded from the GPU on-chip memory to the GPU computing unit. Subsequently, the GPU computing unit uses the first data and the second data to perform the GPU computing task. If the data pre-read from the GPU global memory to the GPU on-chip memory is not all the data of the second data, then when performing GPU computing, part of the pre-read second data is loaded from the GPU on-chip memory to the GPU computing unit, and part of the second data that is not pre-read is loaded from the GPU global memory to the GPU computing unit. Subsequently, the GPU computing unit uses the first data and the second data to perform the GPU computing task.

[0076] After the GPU calculation is completed, the GPU device returns a GPU calculation completion message to the CPU device, for example, returns the GPU calculation result, at 612. Subsequently, at 613, the CPU device performs thread synchronization on the first GPU thread and the second GPU thread, thereby implementing GPU calculation task processing.

[0077] In some embodiments, in order to ensure that the first data has been obtained before the GPU computing of the GPU computing task is executed, a GPU computing lock can be allocated for the GPU computing. The GPU computing lock is used to control the enabling operation of the GPU computing on the GPU device. In some embodiments, the GPU computing lock is implemented by allocating volatile integer space to the GPU global memory. For example, when the value of the CPU computing lock is 0, it indicates that the GPU computing lock is idle, thereby the GPU computing operation can be performed, and when the value of the CPU computing lock is 1, it indicates that the GPU computing lock is occupied, in which case the GPU computing operation cannot be performed.

[0078] During the first data acquisition period, the GPU device may acquire and occupy the GPU computing lock on the first GPU thread. For example, the initial value of the GPU computing lock may be set to 0. After the first GPU thread acquires the GPU computing lock, the value of the GPU computing lock becomes 1. After completing the first data acquisition operation, the GPU device may release the GPU computing lock on the first GPU thread. For example, the value of the GPU computing lock is set from 1 to 0, thereby making the GPU computing lock become idle.

[0079] In addition, in response to the data acquisition process of the first data and the data pre-reading process of the second data being completed, a GPU computing lock is acquired and occupied on the second GPU thread.

[0080] For example, after completing data loading, the SM keeps querying the value of the GPU computing lock. If the value of the GPU computing lock becomes 0, the GPU computing lock is acquired and the value of the GPU computing lock is set to 1, thereby occupying the GPU computing lock.

[0081] It should be noted that in Figure 6 In the example, although it is disclosed that whether it is necessary to pre-read the second data from the GPU global memory to the GPU on-chip memory is determined according to the pre-read configuration file, in other embodiments, the above-mentioned pre-read determination process based on the pre-read configuration file may not be required, that is, as long as the second data required for GPU calculation exists in the GPU global memory, the data pre-read process of pre-reading the second data from the GPU global memory to the GPU on-chip memory is executed.

[0082] Fig. 9 FIG. 1 shows an example block diagram of a data processing device 900 based on an on-chip memory according to an embodiment of the present specification. Fig. 9 As shown, the data processing device 900 includes a data acquisition unit 910 , a data pre-reading unit 920 and a computing task execution unit 930 .

[0083] The data acquisition unit 910 is configured to initiate a data acquisition operation for first data on a first GPU thread, where the first data includes writable data required for a GPU computing task.

[0084] The data pre-reading unit 920 is configured to initiate a data pre-reading process of pre-reading second data from the GPU global memory to the GPU on-chip memory on the second GPU thread during the first GPU thread executing the data acquisition operation, wherein the second data includes read-only data required for the GPU computing task stored in the GPU global memory. In some embodiments, it can be determined whether the second data needs to be pre-read from the GPU global memory to the GPU on-chip memory according to the pre-reading configuration file.

[0085] In some embodiments, in response to the need to pre-read the second data from the GPU global memory to the L2 Cache, the data pre-read unit 920 initiates a first data pre-reading process on the second GPU thread to pre-read the second data (e.g., part or all of the data) from the GPU global memory to the L2 Cache.

[0086] When the data pre-read in the first data pre-reading process is part of the second data, it can be determined whether it is necessary to pre-read the remaining data of the second data from the GPU global memory to the GPU shared memory and / or the GPU register. For example, it can be determined whether it is necessary to pre-read the remaining data of the second data from the GPU global memory to the GPU shared memory and / or the GPU register according to the pre-reading configuration file. In response to the need to pre-read the remaining data of the second data from the GPU global memory to the GPU shared memory and / or the GPU register, the data pre-reading unit 920 initiates a second data pre-reading process on the second GPU thread to pre-read the remaining data of the second data (e.g., part or all of the data) from the GPU global memory to the GPU shared memory and / or the GPU register.

[0087] When it is not necessary to pre-read the second data from the GPU global memory to the L2 Cache, it can be determined whether it is necessary to pre-read the second data from the GPU global memory to the GPU shared memory and / or the GPU register. For example, it can be determined whether it is necessary to pre-read the second data from the GPU global memory to the GPU shared memory and / or the GPU register according to the pre-reading configuration file. In response to the need to pre-read the second data from the GPU global memory to the GPU shared memory and / or the GPU register, the data pre-reading unit 920 initiates a third data pre-reading process on the second GPU thread to pre-read the second data (e.g., part or all of the data) from the GPU global memory to the GPU shared memory and / or the GPU register.

[0088] In response to the data pre-reading for the second data being completed and the GPU computing lock being successfully acquired on the second GPU thread, the computing task execution unit 930 executes the GPU computing task based on the first data and the second data on the second GPU thread.

[0089] As above Figures 1 to 9 , describes a data processing method, a data processing device and a data processing system based on GPU on-chip memory according to an embodiment of this specification. The above-mentioned data processing device and data processing system can be implemented by hardware, or by software or a combination of hardware and software.

[0090] Fig.10 FIG. 1 shows an example schematic diagram of a data processing device 1000 based on GPU on-chip memory implemented based on a computer system according to an embodiment of the present specification. Fig.10 As shown, the data processing device 1000 may include at least one processor 1010, a memory (e.g., a non-volatile memory) 1020, a memory 1030, and a communication interface 1040, and the at least one processor 1010, the memory 1020, the memory 1030, and the communication interface 1040 are connected together via a bus 1060. At least one processor 1010 executes at least one computer-readable instruction stored or encoded in the memory (i.e., the above-mentioned element implemented in the form of software).

[0091] In one embodiment, computer executable instructions are stored in a memory, which when executed cause at least one processor 1010 to: initiate a data acquisition operation for first data on a first GPU thread, the first data including writable data required for a GPU computing task; initiate a data pre-reading process on a second GPU thread to pre-read second data from a GPU global memory to a GPU on-chip memory during the execution of the data acquisition operation by the first GPU thread, the second data including read-only data required for the GPU computing task stored in the GPU global memory; and in response to completion of the data acquisition process for the first data and the data pre-reading process for the second data, execute a GPU computing task on the second GPU thread based on the first data and the second data.

[0092] It should be understood that the computer executable instructions stored in the memory, when executed, cause at least one processor 1010 to perform the above combined operations in various embodiments of this specification. Figure 1-Figure 9 Describes the various operations and functions.

[0093] Fig.11 FIG. 1 shows an example schematic diagram of a data processing system 1100 based on GPU on-chip memory implemented based on a computer system according to an embodiment of the present specification. Fig.11As shown, the data processing system 1100 may include at least one processor 1110, a memory (e.g., a non-volatile memory) 1120, a memory 1130, and a communication interface 1140, and the at least one processor 1110, the memory 1120, the memory 1130, and the communication interface 1140 are connected together via a bus 1160. At least one processor 1110 executes at least one computer-readable instruction stored or encoded in the memory (i.e., the above-mentioned element implemented in the form of software).

[0094] In one embodiment, computer executable instructions are stored in a memory, which, when executed, cause at least one processor 1110 to: issue a GPU computing task to a GPU device via a CPU device, and create a first GPU thread for acquiring first data and a second GPU thread for pre-reading second data and performing GPU computing, wherein the first data includes writable data required for the GPU computing task, and the second data includes read-only data required for the GPU computing task stored in a GPU global memory; after the GPU computing task is started, initiate a data acquisition operation for the first data on the first GPU thread via the GPU device; during execution of the data acquisition operation by the first GPU thread, initiate a data pre-reading process for pre-reading the second data from the GPU global memory to the GPU on-chip memory on the second GPU thread via the GPU device; and in response to completion of the data acquisition process for the first data and the data pre-reading process for the second data, execute the GPU computing task based on the first data and the second data on the second GPU thread via the GPU device.

[0095] It should be understood that the computer executable instructions stored in the memory, when executed, cause at least one processor 1110 to perform the above combined operations in various embodiments of the present specification. Figure 1-Figure 9 Describes the various operations and functions.

[0096] According to one embodiment, a program product such as a machine-readable medium (e.g., a non-transitory machine-readable medium) is provided. The machine-readable medium may have instructions (i.e., the above-mentioned elements implemented in the form of software), which, when executed by a machine, causes the machine to perform the above-mentioned combination of various embodiments of this specification. Figure 1-Figure 9 Specifically, a system or device equipped with a readable storage medium may be provided, on which a software program code implementing the functions of any of the above-mentioned embodiments is stored, and a computer or processor of the system or device reads and executes the instructions stored in the readable storage medium.

[0097] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above-mentioned embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute a part of the present invention.

[0098] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, the program code may be downloaded from a server computer or a cloud via a communication network.

[0099] According to one embodiment, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the processor performs the above combination of the various embodiments of this specification. Figure 1-Figure 9 Describes the various operations and functions.

[0100] Those skilled in the art should understand that the various embodiments disclosed above can be modified and altered in various ways without departing from the essence of the invention. Therefore, the protection scope of the present invention should be defined by the appended claims.

[0101] It should be noted that not all steps and units in the above-mentioned processes and system structure diagrams are necessary, and some steps or units can be ignored according to actual needs. The execution order of each step is not fixed and can be determined as needed. The device structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.

[0102] In the above embodiments, the hardware unit or module can be implemented mechanically or electrically. For example, a hardware unit, module or processor can include permanent dedicated circuits or logic (such as special processors, FPGA or ASIC) to complete the corresponding operation. The hardware unit or processor can also include programmable logic or circuits (such as general-purpose processors or other programmable processors), which can be temporarily set by software to complete the corresponding operation. The specific implementation method (mechanical method, or dedicated permanent circuit, or temporarily set circuit) can be determined based on cost and time considerations.

[0103] The specific embodiments described above in conjunction with the accompanying drawings describe exemplary embodiments, but do not represent all embodiments that can be implemented or fall within the scope of protection of the claims. The term "exemplary" used throughout this specification means "used as an example, instance or illustration" and does not mean "preferred" or "having advantages" over other embodiments. For the purpose of providing an understanding of the described technology, the specific embodiments include specific details. However, these technologies can be implemented without these specific details. In some instances, in order to avoid making the concepts of the described embodiments difficult to understand, well-known structures and devices are shown in block diagram form.

[0104] The above description of the present disclosure is provided to enable any person of ordinary skill in the art to implement or use the present disclosure. Various modifications to the present disclosure will be apparent to those of ordinary skill in the art, and the general principles defined herein may be applied to other variations without departing from the scope of protection of the present disclosure. Therefore, the present disclosure is not limited to the examples and designs described herein, but is consistent with the widest range of principles and novel features disclosed herein.

Claims

1. A data processing method based on GPU on-chip memory, comprising: Initiate a data acquisition operation for first data on a first GPU thread, where the first data includes writable data required for a GPU computing task; During the execution of the data acquisition operation by the first GPU thread, initiating a data pre-reading process of pre-reading second data from the GPU global memory to the GPU on-chip memory on the second GPU thread, wherein the second data includes read-only data required by the GPU computing task stored in the GPU global memory; as well as In response to completion of a data acquisition process for the first data and a data pre-reading process for the second data, the GPU computing task is executed on the second GPU thread based on the first data and the second data.

2. The data processing method according to claim 1, further comprising: Determine whether to initiate a data pre-reading process of pre-reading the second data from the GPU global memory to the GPU on-chip memory according to the pre-reading configuration file.

3. The data processing method according to claim 1, wherein: The GPU on-chip memory includes L2 Cache, Initiating a data pre-reading process on a second GPU thread to pre-read second data from the GPU global memory to the GPU on-chip memory includes: A first data pre-reading process is initiated on the second GPU thread to pre-read the second data from the GPU global memory to the L2Cache.

4. The data processing method according to claim 3, wherein: The GPU on-chip memory also includes a GPU shared memory and a GPU register, and initiating a data pre-reading process of pre-reading second data from the GPU global memory to the GPU on-chip memory on the second GPU thread further includes: When the data pre-read by the first data pre-reading process is part of the second data, a second data pre-reading process is initiated on the second GPU thread to pre-read the remaining data from the GPU global memory to the GPU shared memory and / or the GPU register.

5. The data processing method according to claim 3, wherein: The GPU on-chip memory also includes a GPU shared memory and a GPU register, and initiating a data pre-reading process of pre-reading second data from the GPU global memory to the GPU on-chip memory on the second GPU thread further includes: When there is no need to execute the first data pre-reading process, a third data pre-reading process is initiated on the second GPU thread to pre-read the second data from the GPU global memory to the GPU shared memory and / or the GPU register.

6. The data processing method according to claim 3, wherein: The data stored in the L2 Cache is cached in the form of byte blocks, and each byte block has an eviction priority.

7. The data processing method according to claim 6, wherein: The eviction priorities include latest eviction, normal eviction and last eviction, and the GPU computing optimization method further includes: After pre-reading the second data into the L2 Cache, the eviction priority of the byte block caching the second data is set to last eviction.

8. The data processing method according to claim 7, further comprising: When pre-reading the second data into the L2 Cache, if the free cache space of the L2 Cache is insufficient to cache the second data, the byte blocks cached in the L2 Cache are evicted according to the eviction priorities of latest eviction, normal eviction and last eviction until the free cache space of the L2 Cache is sufficient to cache the pre-read second data.

9. The data processing method according to claim 1, wherein: The GPU computing task includes a model computing task of a model reasoning process, the first data includes model feature data, and the second data includes model parameter data.

10. The data processing method according to claim 1, wherein: The GPU computing is assigned a GPU computing lock, and the data processing method further includes: During the data acquisition of the first data, occupying the GPU computing lock on the first GPU thread, and after completing the data acquisition of the first data, releasing the GPU computing lock on the first GPU thread, In response to the data acquisition process of the first data and the data pre-reading process of the second data being completed, performing the GPU calculation based on the first data and the second data on the second GPU thread includes: In response to completion of the data acquisition process of the first data and the data pre-reading process of the second data, the GPU computing lock is occupied on the second GPU thread, and the GPU computing is performed based on the first data and the second data.

11. The data processing method according to claim 10, wherein: The GPU computing lock is implemented by allocating volatile integer space to the GPU global memory.

12. A data processing method based on GPU on-chip memory, comprising: Sending a GPU computing task to a GPU device via a CPU device, and creating a first GPU thread for acquiring first data and a second GPU thread for pre-reading second data and performing GPU computing, wherein the first data includes writable data required for the GPU computing task, and the second data includes read-only data required for the GPU computing task stored in a GPU global memory; After the GPU computing task is started, initiating a data acquisition operation for the first data on the first GPU thread via the GPU device; During the execution of the data acquisition operation by the first GPU thread, initiating, on the second GPU thread, via the GPU device, a data pre-reading process of pre-reading the second data from the GPU global memory to the GPU on-chip memory; as well as In response to completion of a data acquisition process for the first data and a data pre-reading process for the second data, the GPU computing task is executed based on the first data and the second data on the second GPU thread via the GPU device.

13. A data processing device based on GPU on-chip memory, comprising: A data acquisition unit, initiating a data acquisition operation for first data on a first GPU thread, where the first data includes writable data required for a GPU computing task; a data pre-reading unit, which initiates, on a second GPU thread, a data pre-reading process of pre-reading second data from the GPU global memory to the GPU on-chip memory during the period when the first GPU thread performs a data acquisition operation, wherein the second data includes read-only data required for the GPU computing task stored in the GPU global memory; as well as A computing task execution unit, in response to completion of a data acquisition process of the first data and a data pre-reading process of the second data, executes the GPU computing task based on the first data and the second data on the second GPU thread.

14. A data processing system based on GPU on-chip memory, comprising: The CPU device issues a GPU computing task to the GPU device, and creates a first GPU thread for acquiring first data and a second GPU thread for pre-reading second data and performing GPU computing, wherein the first data includes writable data required for the GPU computing task, and the second data includes read-only data required for the GPU computing task stored in a GPU global memory; and A GPU device, comprising a GPU computing device based on GPU on-chip memory as described in claim 13.

15. A data processing device based on GPU on-chip memory, comprising: at least one processor; a memory coupled to the at least one processor; as well as A computer program stored in the memory, wherein the at least one processor executes the computer program to implement the data processing method based on GPU on-chip memory as claimed in any one of claims 1 to 11.

16. A data processing system based on GPU on-chip memory, comprising: at least one processor; a memory coupled to the at least one processor; as well as The computer program stored in the memory, the at least one processor executes the computer program to implement the data processing method based on GPU on-chip memory as claimed in claim 12.

17. A computer-readable storage medium storing executable instructions, which, when executed, cause a processor to execute the data processing method based on GPU on-chip memory as described in any one of claims 1 to 11 or the data processing method based on GPU on-chip memory as described in claim 12.

18. A computer program product, comprising a computer program, wherein the computer program is executed by a processor to implement the data processing method based on GPU on-chip memory as claimed in any one of claims 1 to 11 or the data processing method based on GPU on-chip memory as claimed in claim 12.

Citation Information

Patent Citations

  • Method for accelerating GPU directed at deep learning super-resolution technology

    CN105869117A

  • Computing architecture

    CN111522776A