A storage method for GPU firmware logs

By storing the logs into the sram after the GPU is powered on and migrating the logs to the HBM after the HBM page table is established, the problems of log loss and sram log overwrite after the GPU is started are solved, and efficient log storage is achieved.

CN119046184BActive Publication Date: 2025-03-21沐曦科技(成都)有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411184697.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-27
Publication Date
2025-03-21
Estimated Expiration
2044-08-27

AI Technical Summary

Technical Problem

In the prior art, the GPU firmware logs generated between GPU startup and HBM initialization are lost, or the logs are quickly overwritten when sram is used as log storage space.

Method used

After the GPU is powered on, the GPU firmware log is stored in the sram, and after the kernel driver kmd is loaded, if the page table of the HBM is established, the log storage pointer is pointed to the position in the HBM with paaddr2 as the starting address and len' as the offset, and the GPU firmware stores the GPU firmware logs stored in the sram in the HBM with this physical address as the starting address.

Benefits of technology

It realizes secure storage of GPU firmware logs, avoids log loss and overwrite problems, and improves the efficiency of log storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046184B_ABST
    Figure CN119046184B_ABST
Patent Text Reader

Abstract

The present application relates to the field of electronic digital data processing technology, and in particular to a method for storing GPU firmware logs. It includes: after the GPU is powered on, the GPU firmware log is stored in sram; after kmd is loaded, if the page table of HBM is established, kmd sends information that the page table is established to the GPU firmware; after the GPU firmware receives the information, it sends information to kmd to apply for HBM space; if the firmware cannot access HBM through the virtual address, kmd obtains the physical address paaddr2 corresponding to vaaddr2 and sends it to the firmware; the GPU firmware points the log storage pointer to the position in HBM with paaddr2 as the starting address and len' as the offset; with paaddr2 as the starting address, the GPU firmware log stored in sram is moved to HBM. The present invention solves the problem of GPU firmware log loss and log being quickly overwritten.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronic digital data processing, and in particular to a storage method for a GPU firmware log. Background Art

[0002] During the GPU startup phase, GPU firmware logs will be generated. However, HBM (High Bandwidth Memory) has not been initialized at this time. If HBM is used as the storage space for logs, the GPU firmware logs generated between GPU startup and HBM initialization will not be stored, resulting in the loss of GPU firmware logs generated between GPU startup and HBM initialization. In order to avoid this situation, the prior art practice is to use the memory space sram (Static Random-Access Memory) used for GPU firmware operation as the log storage space. However, sram has a small storage space, and more logs are generated after the kernel driver is loaded. If all logs after GPU startup are stored in sram, there will be a problem of logs in sram being quickly overwritten. Summary of the invention

[0003] The present invention aims to provide a method for storing GPU firmware logs, so as to solve the problem of GPU firmware log loss between GPU startup and HBM initialization caused by using HBM as the storage space for logs in the prior art, or the problem of logs in SRAM being quickly overwritten when using SRAM as the storage space for logs.

[0004] According to the present invention, a method for storing a GPU firmware log is provided, the method comprising the following steps:

[0005] S100, after the GPU is powered on, the GPU firmware log is stored in a first storage space sram, where sram is a memory space where the GPU firmware runs.

[0006] S200, after the kernel driver kmd is loaded, if the page table of the second storage space HBM is established, kmd sends information that the page table of HBM is established to the GPU firmware.

[0007] S300, after receiving the information that the HBM page table is established from kmd, the GPU firmware sends information for applying for HBM space to kmd, where the information for applying for HBM space includes a virtual address vaaddr2 and a storage space size len2.

[0008] S400, if the GPU firmware cannot access the HBM through the virtual address, kmd obtains the physical address paaddr2 corresponding to vaaddr2 according to the received information of applying for the HBM space and the HBM page table, and sends paaddr2 to the GPU firmware.

[0009] S500, after receiving paaddr2 sent by kmd, the GPU firmware points the log storage pointer to the location in HBM with paaddr2 as the starting address and len' as the offset; len' is the storage space occupied by the GPU firmware log stored in sram. S600, the GPU firmware moves the GPU firmware log stored in sram to HBM with paaddr2 as the starting address.

[0010] Compared with the prior art, the present invention has at least the following beneficial effects:

[0011] The present invention provides a processing method for accelerated training. After the GPU is powered on, the memory space SRAM in which the GPU firmware runs is used as the storage space for the log, so that the storage of the GPU firmware log in the SRAM is realized, and the problem of GPU firmware log loss caused by using HBM as the storage space for the log in the prior art is solved. Moreover, after the kernel driver kmd is loaded, if the page table of the second storage space HBM is established, the GPU firmware is informed of the information that the page table of the HBM is established. After the GPU firmware receives the information that the page table of the HBM is established, the HBM space application information including the virtual address and the storage space size is sent to the kernel driver kmd. If the GPU firmware cannot access the HBM through the virtual address, the kernel driver kmd receives the information that the HBM space is applied for and sends the virtual address corresponding to the virtual address according to the virtual address and the HBM page table included in the information. The physical address is returned to the GPU firmware, so that the log storage pointer is pointed to the position in the HBM with paaddr2 as the starting address and len' as the offset, and the GPU firmware stores the GPU firmware log stored in the sram in the HBM with the physical address as the starting address. Therefore, not only the subsequently generated log can be stored in the HBM from the position with paaddr2 as the starting address and len' as the offset, but also the migration of the GPU firmware log stored in the sram from the sram to the HBM is realized, and the migration process does not affect the storage of the subsequently generated log in the HBM; after the HBM page table is established, the present invention uses the HBM as the log storage space, the storage space of the HBM is larger than the storage space of the sram, and the storage space that can be applied for log storage in the HBM is larger, which can solve the problem of the log in the sram being quickly overwritten when the sram is used as the storage space of the log in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0013] Figure 1 This is a flowchart of a method for storing GPU firmware logs provided in Embodiment 1 of the present invention. DETAILED DESCRIPTION

[0014] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0015] Embodiment 1:

[0016] According to this embodiment, a method for storing a GPU firmware log is provided, the method comprising the following steps: Figure 1 As shown:

[0017] S100, after the GPU is powered on, the GPU firmware log is stored in a first storage space sram, where sram is a memory space where the GPU firmware runs.

[0018] In this embodiment, after the GPU is powered on, the GPU firmware starts to run, and the SRAM also has a storage function, and the storage location of the GPU firmware log is set to the SRAM; specifically, storing the GPU firmware log to the first storage space SRAM includes:

[0019] S110, determining the starting address paaddr1 where the GPU firmware log is stored in sram.

[0020] In this embodiment, sram determines a physical address included therein as paaddr1.

[0021] S120, determine the storage space size len1 for the GPU firmware log in sram.

[0022] Optionally, len1 is a value set in advance according to actual needs, which is the storage space size that can meet the storage requirements of the GPU firmware log generated after the GPU is started and the HBM is initialized.

[0023] S130, point the log storage pointer to the location of paaddr1 in sram.

[0024] In this embodiment, the log storage pointer is pointed to the position of paaddr1 in SRAM. Then, when a log needs to be stored, the log is stored in SRAM starting from the position of paaddr1; the position of the log storage pointer will change as the log is stored, and the position pointed to by the log storage pointer is the starting address of the storage of the newly generated log.

[0025] S200, after the kernel driver kmd is loaded, if the page table of the second storage space HBM is established, kmd sends information that the page table of HBM is established to the GPU firmware.

[0026] In this embodiment, the page table of the HBM includes the mapping relationship between the physical address and the virtual address included in the HBM.

[0027] In this embodiment, after the kernel driver kmd is loaded, if the page table of the second storage space HBM is not established, it waits until the page table of the HBM is established, and kmd sends information indicating that the page table of the HBM is established to the GPU firmware.

[0028] S300, after the GPU firmware receives the information indicating that the page table of the HBM is established sent by kmd, it sends information requesting HBM space to kmd, and the information requesting HBM space includes the virtual address vaaddr2 and the storage space size len2.

[0029] S400, if the GPU firmware cannot access the HBM through the virtual address, then kmd obtains the physical address paaddr2 corresponding to vaaddr2 according to the received information requesting HBM space and the page table of the HBM, and sends paaddr2 to the GPU firmware.

[0030] In this embodiment, len1 < len2, that is, the storage space applied for by kmd in the HBM is larger than the storage space size for the GPU firmware log in the above-mentioned sram; if the storage space size occupied by the log stored in the HBM is equal to len2, the log is circularly stored starting from the position of paaddr2 in the HBM to achieve the reuse of the storage space in the HBM, and since the log corresponding to the position closer to the position of paaddr2 in the HBM has an earlier generation time and has been read, therefore, even if the newly generated log overwrites the log stored in the position closer to the position of paaddr2 in the HBM, it does not affect debugging.

[0031] Those skilled in the art know that any method for obtaining a physical address according to a virtual address and a page table in the prior art falls within the protection scope of the present invention.

[0032] In this embodiment, S400 further includes: if the GPU firmware can access the HBM through the virtual address, then there is no need for the process of kmd obtaining the physical address corresponding to vaaddr2, but the log storage pointer is pointed to the position in the HBM with the address corresponding to vaaddr2 as the starting address and an offset of len', and the GPU firmware log stored in the sram is transported to the HBM starting from the address corresponding to vaaddr2 in the HBM.

[0033] S500, after receiving paaddr2 sent by kmd, the GPU firmware points the log storage pointer to a position in HBM with paaddr2 as the starting address and len' as the offset; len' is the storage space occupied by the GPU firmware log stored in sram.

[0034] In this embodiment, the log storage pointer is pointed to a position in the HBM with paaddr2 as the starting address and len' as the offset, so that the purpose of storing the subsequently generated logs in the storage space after the position in the HBM can be achieved.

[0035] S600, the GPU firmware moves the GPU firmware log stored in sram to HBM using paaddr2 as the starting address.

[0036] In the present embodiment, when the GPU firmware cannot access the HBM through the virtual address, the log storage pointer is first pointed to the position in the HBM with paaddr2 as the starting address and len' as the offset, and then the operation of moving the GPU firmware log stored in the sram to the HBM is performed, which can avoid the impact of the process of migrating the GPU firmware log stored in the sram from the sram to the HBM on the storage of subsequently generated logs in the HBM. Compared with the method of moving the GPU firmware log stored in the sram to the HBM and then pointing the log storage pointer to the HBM (in the process of executing the log migration, new logs may be generated, and this method enables the new logs to be stored in the sram), the present embodiment can reduce the amount of migrated logs and improve the efficiency of log storage.

[0037] The present embodiment provides a processing method for accelerated training, which uses the memory space sram where the GPU firmware runs as the storage space for the log after the GPU is powered on, thereby realizing the storage of the GPU firmware log in sram, and solving the problem of GPU firmware log loss caused by using HBM as the storage space for the log in the prior art; moreover, in the present embodiment, after the kernel driver kmd is loaded, if the page table of the second storage space HBM is established, the information that the page table of the HBM is established is notified to the GPU firmware, and after the GPU firmware receives the information that the page table of the HBM is established, the information on applying for the HBM space including the virtual address and the size of the storage space is sent to the kernel driver kmd; if the GPU firmware cannot access the HBM through the virtual address, then after the kernel driver kmd receives the information on applying for the HBM space sent by the GPU firmware, it determines the physical address corresponding to the virtual address according to the virtual address included in the information and the page table of the HBM. The physical address is returned to the GPU firmware, so that the log storage pointer is pointed to the position in the HBM with paaddr2 as the starting address and len' as the offset, and the GPU firmware stores the GPU firmware log stored in the sram in the HBM with the physical address as the starting address. Therefore, not only the subsequently generated log can be stored in the HBM from the position with paaddr2 as the starting address and len' as the offset, but also the migration of the GPU firmware log stored in the sram from the sram to the HBM is realized, and the migration process does not affect the storage of the subsequently generated log in the HBM; in this embodiment, after the HBM page table is established, the HBM is used as the log storage space. Compared with the storage space of sram, the storage space of HBM is larger, and the storage space that can be applied for log storage in the HBM is larger, which can solve the problem of the log in the sram being quickly overwritten when the sram is used as the storage space of the log in the prior art.

[0038] As an optional specific implementation, the method further includes: S700, if a storage space for storing logs in the HBM fails, entering S800.

[0039] S800, reload the kernel driver kmd. If the page table of the second storage space HBM is rebuilt, kmd sends the information that the page table of HBM is rebuilt to the GPU firmware.

[0040] S900, after receiving the information from kmd that the HBM page table is rebuilt, the GPU firmware resends the information requesting the HBM space to kmd.

[0041] S1000, if the GPU firmware cannot access the HBM through the virtual address, kmd obtains the new physical address paaddr'2 corresponding to vaaddr2 according to the received information of applying for HBM space and the re-established HBM page table, and sends paaddr'2 to the GPU firmware.

[0042] In this embodiment, S1000 also includes: if the GPU firmware can access the HBM through the virtual address, the process of kmd obtaining the new physical address corresponding to vaaddr2 is no longer required, but the log storage pointer is pointed to the position in the HBM with the address corresponding to vaaddr2 as the starting address and len' as the offset, and the GPU firmware uses the address corresponding to vaaddr2 in the HBM as the starting address to move the GPU firmware log stored in sram to the HBM.

[0043] S1100, after receiving paaddr'2 sent by kmd, the GPU firmware points the log storage pointer to the position in HBM with paaddr'2 as the starting address and len' as the offset, and moves the GPU firmware log stored in sram to HBM with paaddr'2 as the starting address.

[0044] Based on S700-S1100, if the storage space for storing logs in the HBM fails, the newly created HBM page table after kmd is reloaded will no longer contain the storage space for storing logs that failed, that is, the newly created HBM page table has changed. Even if the information for applying for HBM space sent by the GPU firmware of this embodiment to kmd includes the same virtual address vaaddr2, when the GPU firmware cannot access the HBM through the virtual address, the physical address (i.e. paaddr'2) obtained by kmd based on vaaddr2 and the newly created HBM page table is no longer the previous physical address (i.e. paaddr2), thereby avoiding the problem of storing logs in the failed storage space.

[0045] As an optional specific implementation, the method further includes: E700, if a storage space for storing logs in the HBM fails, entering E800;

[0046] E800, power on the GPU again, and store the GPU firmware log in the first storage space sram.

[0047] E900, reload the kernel driver kmd. If the page table of the second storage space HBM is rebuilt, kmd sends the information that the page table of HBM is rebuilt to the GPU firmware.

[0048] E1000, after receiving the information sent by kmd that the HBM page table has been rebuilt, the GPU firmware resends the information requesting HBM space to kmd.

[0049] E1100, if the GPU firmware cannot access the HBM through the virtual address, kmd obtains the new physical address paaddr'2 corresponding to vaaddr2 according to the received information of applying for the HBM space and the re-established HBM page table, and sends paaddr'2 to the GPU firmware.

[0050] In this embodiment, E1100 also includes: if the GPU firmware can access the HBM through the virtual address, the process of kmd obtaining the new physical address corresponding to vaaddr2 is no longer required, but the log storage pointer is pointed to the position in the HBM with the address corresponding to vaaddr2 as the starting address and len' as the offset, and the GPU firmware uses the address corresponding to vaaddr2 in the HBM as the starting address to move the GPU firmware log stored in sram to the HBM.

[0051] E1200, after receiving paaddr'2 sent by kmd, the GPU firmware points the log storage pointer to the location in HBM with paaddr'2 as the starting address and len' as the offset, and moves the GPU firmware log stored in sram to HBM with paaddr'2 as the starting address.

[0052] Based on E700-E1200, if the storage space for storing logs in HBM fails, the newly created HBM page table will no longer contain the failed storage space for storing logs after the GPU is powered on again, that is, the newly created HBM page table has changed. Even if the information for applying for HBM space sent by the GPU firmware of this embodiment to kmd includes the same virtual address vaaddr2, when the GPU firmware cannot access HBM through the virtual address, the physical address (i.e. paaddr'2) obtained by kmd based on vaaddr2 and the newly created HBM page table is no longer the previous physical address (i.e. paaddr2), thereby avoiding the problem of storing logs in the failed storage space.

[0053] Embodiment 2:

[0054] In order to solve the problem that a log of one thread may be inserted into a log of another thread when storing logs in HBM in a GPU multi-threaded scenario in the first embodiment, this embodiment is based on the first embodiment, and after S600, the method further includes the following steps:

[0055] P100, in response to a demand of a first thread of a GPU to store a first log, assign a first line number to the first log; when the first line number is assigned to the first log, a storage space size corresponding to the first line number is d1.

[0056] In this embodiment, the line number is a preset global variable. After each line number is assigned to a log, the value of the line number is increased by 1. When a new log is to be stored, the current line number is assigned to the new log; for example, the initial value of the line number is 1. When any log of any thread of the GPU needs to be stored, the current line number (i.e., 1) is assigned to the first log to be stored; when the second log needs to be stored, regardless of whether the second log is generated by the same thread of the GPU as the first log, the current line number (i.e., 2) is assigned to the second log to be stored; when the third log needs to be stored, regardless of whether the third log is generated by the same thread of the GPU as the first and second logs, the current line number (i.e., 3) is assigned to the third log to be stored; and so on. In this embodiment, if the space size corresponding to the current line number plus the size of the log to be printed is greater than the total size of the log space, the line number is rolled back to the initial value of the line number (if the initial value of the line number is 0, the line number is rolled back to 0).

[0057] As a first specific implementation, the storage space corresponding to each row number has the same size, which is a preset maximum storage space for a single log.

[0058] As a second specific implementation, the storage space corresponding to each line number is the storage space occupied by the log corresponding to the line number, and the storage space occupied by the log is a known value. For example, the log corresponding to the first line number is the first log, and the storage space occupied by the first log is 256 bytes, so the storage space corresponding to the first line number is also 256 bytes. For another example, the log corresponding to the first line number is the first log, and the storage space occupied by the first log is 32 bytes, so the storage space corresponding to the first line number is also 32 bytes.

[0059] In this embodiment, the starting address corresponding to the next row number is the next address of the last address corresponding to the previous row number. For example, if the second row number is the next row number of the first row number, then the starting address corresponding to the second row number is the next address of the last address corresponding to the first row number.

[0060] P200, storing the first log in a storage space corresponding to the first row number starting from a starting address corresponding to the first row number.

[0061] As a specific implementation, the starting address corresponding to the first line number is 0, so the first log is stored starting from 0.

[0062] P300, if the first log has not been stored yet, the first thread of the GPU is cut off by the second thread of the GPU, and the second thread of the GPU has a need to store the second log, then enter P400.

[0063] For example, the starting address corresponding to the first line number is 0, the storage space occupied by the first log is 256 bytes, and the offset corresponding to the interrupt address corresponding to the first log when the first thread of the GPU is cut off by the second thread of the GPU is 128 bytes, which means that half of the storage of the first log in the storage space corresponding to the first line number is completed.

[0064] In this embodiment, a thread being cut off means that the operating system or the operating environment switches from the currently executing thread to another thread for execution, and the thread includes an interrupt processing task; a person skilled in the art knows that any thread scheduling strategy in the prior art falls within the protection scope of the present invention, for example, a thread scheduling strategy based on priority or a thread scheduling strategy based on time slice rotation.

[0065] As an optional specific implementation, if the first log has not been stored yet, the first thread of the GPU is cut off by the second thread of the GPU, but the second thread of the GPU does not have the need to store the second log, it is determined that there will be no problem of log printing confusion, and the log printing method in the prior art can be executed; optionally, if the second thread of the GPU does not have the need to print the log, the log is not stored during the execution of the second thread of the GPU until the second thread of the GPU is cut off by the first thread of the GPU, and the unstored logs of the first thread of the GPU continue to be stored.

[0066] In this embodiment, if the first thread of the GPU is not cut off by other threads of the GPU during the process of storing the first log, the first log is stored until the first log is completely stored.

[0067] In this embodiment, if the first thread of the GPU still needs to store a fourth log after the first log is stored, and the first thread of the GPU has not been cut off, then enter P310; the fourth log is the next log generated by the first thread and located after the first log.

[0068] P310, assign the second line number to the fourth log.

[0069] P320, storing the fourth log in the storage space corresponding to the second row number starting from the start address corresponding to the second row number.

[0070] P400, record the first line number and the first interrupt address addr1 corresponding to the first log when the first thread of the GPU is cut off by the second thread of the GPU, and assign the second line number to the second log; the second line number is the next line number of the first line number; the storage space size corresponding to the second line number is d2.

[0071] In this embodiment, the interval between adjacent row numbers is 1. If the first row number is 1, then the second row number is 2.

[0072] P500, store the second log in the storage space corresponding to the second row number starting from the starting address corresponding to the second row number.

[0073] P600, if the second log is not stored completely and the second thread of the GPU is cut off by the first thread of the GPU, then record the second line number and the interrupt address addr3 corresponding to the second log when the second thread of the GPU is cut off by the first thread of the GPU, and continue to store the unstored part of the first log in the storage space corresponding to the first line number starting from addr1.

[0074] In this embodiment, when the second log is not completely stored and the second thread of the GPU is cut off by the first thread of the GPU, the second line number and the interrupt address addr3 corresponding to the second log when the second thread of the GPU is cut off by the first thread of the GPU are recorded. Therefore, when the second thread of the GPU is subsequently switched back, the unstored part of the second log continues to be stored in the storage space corresponding to the second line number starting from addr3.

[0075] In this embodiment, when the first thread is cut off, the line number corresponding to the first log (i.e., the first line number) and the interrupt address corresponding to the first log when the first thread is cut off by the second thread (i.e., the first interrupt address) are recorded; if the second thread of the GPU is switched back to the first thread of the GPU, then the unstored part of the first log continues to be stored starting from the first interrupt address.

[0076] In this embodiment, if the second log has been stored before the second thread of the GPU is cut off by the first thread of the GPU (that is, the storage process of the second log is not interrupted), then when the second thread of the GPU is cut off by the first thread of the GPU, there is no need to record information related to the second log.

[0077] In this embodiment, if the second log has been stored before the second thread of the GPU is cut off by the first thread of the GPU (that is, the storage process of the second log has not been interrupted), but the second thread of the GPU generates a new log before being cut off by the first thread, then it is necessary to determine whether the storage process of the newly generated log of the second thread is interrupted when the second thread is cut off by the first thread. As a specific implementation, P600 also includes: if the second log is stored, and the second thread of the GPU has a need to store the fifth log, and the second thread of the GPU has not been cut off, then the third line number is assigned to the fifth log, and the fifth log is stored in the storage space corresponding to the third line number starting from the starting address corresponding to the third line number; the fifth log is the next log generated by the second thread of the GPU after the second log. Further, if the fifth log has not been stored, and the second thread of the GPU is cut off by the first thread of the GPU, then the third line number and the interrupt address addr4 corresponding to the fifth log when the second thread of the GPU is cut off by the first thread of the GPU are recorded, and the unstored part of the first log is continued to be stored in the storage space corresponding to the first line number starting from addr1. Therefore, when the second thread of the subsequent GPU is switched back, the unstored portion of the fifth log is stored in the storage space corresponding to the third row number starting from addr4.

[0078] In this embodiment, when the second log is not completely stored and the second thread of the GPU is cut off by the first thread of the GPU, the portion of the first log that is not stored is continuously stored in the storage space corresponding to the first line number starting from addr1; however, if the first log is not completely stored and the first thread of the GPU is cut off by other threads of the GPU for the second time, the first line number and the first interrupt address addr6 corresponding to the first log when the first thread of the GPU is cut off for the second time are recorded, so as to continue to store the portion of the first log that is not stored in the storage space corresponding to the first line number starting from addr6 when the first thread is switched back to the first thread later.

[0079] In addition to the advantages of the first embodiment, the present embodiment can also solve the log confusion problem in a multi-threaded scenario. Specifically, when the first thread of the GPU has a need to store the first log, a line number (i.e., the first line number) is assigned to the first log, and the storage space size corresponding to the first line number is d1; the first log is stored starting from the starting address corresponding to the first line number. If the first thread is cut off by the second thread during the process of storing the first log, the first line number and the interrupt address corresponding to the first log are recorded, and the next line number of the first line number (i.e., the second line number) is assigned to the second log with storage requirements of the second thread, and the storage space size of the second line number is d2, and the second log is stored starting from the starting address corresponding to the second line number; if the second log storage is completed and the second thread is cut off by the first thread, the first log is stored in the storage space corresponding to the first line number starting from the interrupt address corresponding to the first log. Therefore, even if the first thread is cut off by the second thread during the log printing process, the printed log of the second thread will not be inserted into a log of the first thread, that is, the problem of log printing confusion is solved.

[0080] As a specific implementation, P600 also includes: if the second log has not been stored yet, the second thread of the GPU is cut off by the third thread of the GPU, and the third thread of the GPU has a need to store the third log, then entering P700.

[0081] P700, record the second line number and the interrupt address addr2 corresponding to the second log when the second thread of the GPU is cut off by the third thread of the GPU, and assign the third line number to the third log; the third line number is the next line number of the second line number.

[0082] P800, store the third log in the storage space corresponding to the third row number starting from the starting address corresponding to the third row number.

[0083] P900: If the third thread of the GPU is cut off by the second thread of the GPU, then continue to store the unstored part of the second log in the storage space corresponding to the second row number starting from addr2.

[0084] In this embodiment, if the third log has been stored when the third thread of the GPU is cut off by the second thread of the GPU, then the information related to the third log does not need to be recorded; if the third log has not been stored when the third thread of the GPU is cut off by the second thread of the GPU, then the information related to the third log is also recorded, including the line number corresponding to the third log (i.e., the third line number) and the interrupt address addr5 corresponding to the third log when the third thread of the GPU is cut off by the second thread of the GPU; if the third log has been stored when the third thread of the GPU is cut off by the second thread of the GPU, but the third thread of the GPU has generated a new log before it is cut off, and the process of storing the newly generated log in the storage space corresponding to the corresponding line number is interrupted, then the information related to the newly generated log is also recorded, including the line number corresponding to the newly generated log and the interrupt address corresponding to the newly generated log when the third thread of the GPU is cut off by the second thread of the GPU.

[0085] As a specific implementation, after P900, the method further includes:

[0086] P1000, if the second thread of the GPU is cut off by the first thread of the GPU, then continue to store the unstored part of the first log in the storage space corresponding to the first line number starting from addr1.

[0087] In this embodiment, P900 further includes: if the third thread of the GPU is cut off by the first thread of the GPU, then continuing to store the unstored part of the first log in the storage space corresponding to the first line number starting from addr1.

[0088] In this embodiment, P900 also includes, if the third thread of the GPU is cut off by the fourth thread of the GPU, and the fourth thread has a need to store the sixth log, then the current line number is assigned to the sixth log, and the sixth log is stored in the storage space corresponding to the corresponding line number starting from the starting address of the corresponding line number.

[0089] Although some specific embodiments of the present invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It will also be appreciated by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.

Claims

1. A method for storing GPU firmware logs, characterized in that: The method comprises the following steps: S100, after the GPU is powered on, the GPU firmware log is stored in a first storage space sram, where sram is the memory space where the GPU firmware runs; S200, after the kernel driver kmd is loaded, if the page table of the second storage space HBM is established, kmd sends the information that the page table of HBM is established to the GPU firmware; S300, after receiving the information that the HBM page table is established from kmd, the GPU firmware sends information for applying for HBM space to kmd, where the information for applying for HBM space includes a virtual address vaaddr2 and a storage space size len2; S400, if the GPU firmware cannot access the HBM through the virtual address, kmd obtains the physical address paaddr2 corresponding to vaaddr2 according to the received information of applying for the HBM space and the page table of the HBM, and sends paaddr2 to the GPU firmware; S500, after receiving paaddr2 sent by kmd, the GPU firmware points the log storage pointer to the position in HBM with paaddr2 as the starting address and len' as the offset; len' is the storage space occupied by the GPU firmware log stored in sram; S600, the GPU firmware moves the GPU firmware log stored in sram to HBM using paaddr2 as the starting address.

2. The method for storing GPU firmware logs according to claim 1, characterized in that: In S100, storing the GPU firmware log in the first storage space sram includes: S110, determining the starting address paaddr1 where the GPU firmware log is stored in sram; S120, determining the storage space size len1 for GPU firmware log in sram; S130, point the log storage pointer to the location of paaddr1 in sram.

3. The method for storing GPU firmware logs according to claim 1, characterized in that: If the storage space occupied by the logs stored in the HBM is equal to len2, the logs are stored in a circular manner starting from the location of paaddr2 in the HBM.

4. The method for storing GPU firmware logs according to claim 1, wherein: The method further comprises: S700: If the storage space for storing logs in the HBM fails, enter S800; S800, causing the kernel driver kmd to reload, and if the page table of the second storage space HBM is rebuilt, kmd sends information that the page table of HBM is rebuilt to the GPU firmware; S900, after receiving the information from kmd that the HBM page table is rebuilt, the GPU firmware resends the information requesting HBM space to kmd; S1000, if the GPU firmware cannot access the HBM through the virtual address, kmd obtains the new physical address paaddr'2 corresponding to vaaddr2 according to the received information of applying for the HBM space and the re-established HBM page table, and sends paaddr'2 to the GPU firmware; S1100, after receiving paaddr'2 sent by kmd, the GPU firmware points the log storage pointer to the location in HBM with paaddr'2 as the starting address and len' as the offset; S1200, the GPU firmware moves the GPU firmware log stored in sram to HBM with paaddr'2 as the starting address.

5. The method for storing GPU firmware logs according to claim 1, characterized in that: In S200, after the kernel driver kmd is loaded, if the page table of the second storage space HBM is not established, it waits until the page table of HBM is established, and kmd sends information that the page table of HBM is established to the GPU firmware.

6. The method for storing GPU firmware logs according to claim 1, characterized in that: The page table of the HBM includes a mapping relationship between the physical addresses and virtual addresses included in the HBM.

7. The method for storing GPU firmware logs according to claim 2, characterized in that: len1 <len2。

Citation Information

Patent Citations

  • Memory management method and hybrid memory management unit

    CN114490441A

  • Intelligent high bandwidth memory appliance

    US20190050325A1