Data access method and related equipment
By configuring cache space for peripheral devices, first checking in the cache whether there is data to be accessed in the cache, the problem of access delay of peripheral devices is solved and data access efficiency is improved.
Patent Information
- Application Number
- CN202510522136.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-08-08
AI Technical Summary
The data access delay of peripheral devices is large, especially when high loads or multiple devices are accessed simultaneously, which affects system performance. How to improve data access efficiency becomes the key.
Configure peripheral cache for peripheral devices. First, check whether there is data to be accessed in the cache space. If it exists, the access will be performed in the cache. Otherwise, send a request to the peripheral device and obtain the access result to avoid direct access to the peripheral device.
Through the use of peripheral cache, direct access to peripheral devices is reduced, access delay is reduced, and data access efficiency is improved.
Smart Images

Figure CN120448300A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a data access method and related devices. Background Art
[0002] Peripheral devices refer to various external hardware devices connected to the computer host, such as printers, monitors, storage devices, coprocessors (such as field programmable gate arrays FPGA, graphics processing units GPU, general-purpose graphics processors GPGPU), etc. They exchange data with the computer through interfaces, expand the computer's functions, and provide users with rich input, output and storage capabilities.
[0003] However, because peripheral devices typically communicate with the host computer via buses and external interfaces, their data transmission speeds are limited by interface bandwidth, protocol overhead, and the device's own processing power. This results in significant latency in accessing peripheral devices. This latency is particularly pronounced under high loads or when multiple devices are accessing the device simultaneously, potentially impacting overall system performance.
[0004] Therefore, how to improve the efficiency of data access to data in peripheral devices has become an important factor restricting computer response speed and work efficiency. Summary of the Invention
[0005] In view of this, embodiments of the present application provide a data access method and related devices, which can improve data access efficiency.
[0006] To achieve the above objectives, the embodiments of the present application provide the following technical solutions.
[0007] In a first aspect, an embodiment of the present application provides a data access method applied to a peripheral cache, comprising:
[0008] Obtaining a pending access request, wherein the pending access request is used to request access to a pending address of a peripheral device;
[0009] Based on the access request to be processed, determining whether there is data to be accessed corresponding to the address to be accessed in the cache space corresponding to the peripheral device;
[0010] If yes, accessing the data to be accessed is performed in the cache space based on the pending access request, and feeding back an access result corresponding to the pending access request to the peripheral controller;
[0011] If not, the pending access request is sent to the peripheral device, and an access result corresponding to the pending access request fed back by the peripheral device is obtained, and the access result is forwarded to the peripheral controller.
[0012] Optionally, the determining, based on the pending access request, whether there is data to be accessed corresponding to the to-be-accessed address in a cache space corresponding to the peripheral device includes:
[0013] Determining, based on the request information of the pending access request, a peripheral device corresponding to the pending access request;
[0014] Determining a preset cache partition corresponding to the peripheral device;
[0015] Determine whether there is to-be-accessed data corresponding to the to-be-accessed address in the preset cache partition.
[0016] Optionally, if the access operation corresponding to the pending access request is a read operation, the access to the data to be accessed is performed in the cache space based on the pending access request, and the access result corresponding to the pending access request is fed back to the peripheral controller, specifically: the data to be accessed is read from the cache space, and the read data to be accessed is fed back to the peripheral controller as the access result.
[0017] Optionally, if the access operation corresponding to the pending access request is a write operation, the access to the data to be accessed is performed in the cache space based on the pending access request, and the access result corresponding to the pending access request is fed back to the peripheral controller, specifically: the data to be written is written in the location corresponding to the data to be accessed in the cache space, and the feedback message of successful writing is fed back to the peripheral controller as the access result.
[0018] Optionally, after the feedback message of successful writing is fed back to the request issuer as the access result, when the data to be written is replaced by data at other addresses of the peripheral device in the peripheral cache, it also includes: updating the data to be written to the address corresponding to the peripheral device.
[0019] Optionally, after the step of obtaining the access result corresponding to the pending access request fed back by the peripheral device and forwarding the access result to the peripheral controller, the method further includes:
[0020] The read data to be accessed is determined from the obtained access result, and the data to be accessed is cached in a cache space corresponding to the peripheral device.
[0021] Optionally, in the step of caching the data to be accessed in the cache space corresponding to the peripheral device, the data to be accessed is cached in the cache space of the peripheral device based on a cache replacement mechanism;
[0022] The cache replacement mechanism includes storing the data to be accessed in the free space when there is free space in the cache space corresponding to the peripheral device; selecting the cache space to be replaced where the peripheral cache data that meets the preset conditions is located based on a preset algorithm when there is no free space in the cache space corresponding to the peripheral device, storing the data to be accessed in the cache space to be replaced, and updating the peripheral cache data in the cache space to be replaced to the peripheral device.
[0023] Optionally, before the step of obtaining the pending access request, the process further includes:
[0024] Obtain a prefetch request, wherein the prefetch request is used to request data reading from a to-be-prefetched address of a peripheral device;
[0025] Based on the prefetch request, reading the to-be-fetched data at the to-be-fetched address from the peripheral device, and updating the to-be-fetched data to the peripheral cache;
[0026] Feedback prefetch task completion message to the peripheral controller.
[0027] Optionally, reading the to-be-fetched data at the to-be-fetched address from the peripheral device based on the prefetch request, and updating the to-be-fetched data to the peripheral cache includes:
[0028] Based on the prefetch request, a corresponding data read command is generated; wherein the generated data read command is one or more, one data read command corresponds to an address to be read, and the address to be read is at least a portion of the address to be prefetched;
[0029] Selecting and sending a data read command to the peripheral device, so that the peripheral device reads and feeds back corresponding data to be prefetched based on the data read command;
[0030] After obtaining the data to be prefetched, updating the obtained data to be prefetched into a cache space corresponding to the peripheral device;
[0031] confirming whether the prefetch task corresponding to the prefetch request is completed;
[0032] If not, executing the step of selecting and sending a data read command to the peripheral device, and, after obtaining the data to be prefetched, updating the obtained data to be prefetched into the cache space corresponding to the peripheral device, and confirming whether the prefetch task corresponding to the prefetch request is completed, until it is confirmed that the prefetch task corresponding to the prefetch request is completed;
[0033] If so, the step of feeding back the pre-fetch task completion message to the peripheral controller is performed.
[0034] Optionally, the step of generating a corresponding data read command based on the prefetch request further includes configuring an identification bit for the data read command to indicate a processing status of the data read command;
[0035] In the step of selecting and sending the data read command to the peripheral device, the flag bit of the data read command is further configured to be in a sent state;
[0036] In the step of updating the acquired data to be prefetched into the cache space corresponding to the peripheral device after acquiring the data to be prefetched, the flag bit of the data read command is further configured to be in a completed state;
[0037] In the step of confirming whether the prefetch task corresponding to the prefetch request is completed, it is determined whether there is an unexecuted data read command based on the identification bit of the data read command to determine whether the prefetch task corresponding to the prefetch request is completed.
[0038] In a second aspect, an embodiment of the present application provides a data access method, applied to a peripheral controller, comprising:
[0039] Obtaining a pending access request, wherein the pending access request is used to request access to a pending address of a peripheral device;
[0040] Allocating the pending access request to a peripheral cache corresponding to the peripheral device, so that the peripheral cache executes the data access method;
[0041] Obtain an access result of the peripheral device cache, and feed the access result back to the request issuer.
[0042] Optionally, before obtaining the pending access request, the process further includes:
[0043] Obtain a prefetch request, wherein the prefetch request is used to request data reading from a to-be-prefetched address of a peripheral device;
[0044] configuring the prefetch request to a peripheral cache corresponding to the peripheral device, so that the peripheral cache executes the data access method;
[0045] After obtaining the pre-fetch task completion message, forward the pre-fetch task completion message to the request issuer.
[0046] In a third aspect, an embodiment of the present application provides a data access method, applied to a peripheral device, comprising:
[0047] Obtaining a pending access request from a peripheral cache, the pending access request being used to request access to a pending address of a peripheral device; the peripheral cache being used to execute the data access method;
[0048] Based on the access request to be processed, access to the data to be accessed is performed, and an access result is fed back to the peripheral cache.
[0049] Optionally, if the access operation corresponding to the pending access request is a read operation, the access to the data to be accessed is performed based on the pending access request, and the access result is fed back to the peripheral cache, specifically: based on the pending access request, the access data corresponding to the address to be accessed is read, and the read data to be accessed is fed back to the peripheral cache as the access result.
[0050] Optionally, if the access operation corresponding to the pending access request is a write operation, the access to the data to be accessed is performed based on the pending access request, and the access result is fed back to the peripheral cache, specifically: based on the pending access request, the data to be written is written in the space corresponding to the access address of the peripheral device, and the feedback message of successful writing is fed back to the peripheral cache as the access result.
[0051] In a fourth aspect, an embodiment of the present application provides a peripheral cache, including access control logic and cache space;
[0052] The access control logic is used to obtain a pending access request, which is used to request access to a pending address of a peripheral device; based on the pending access request, determine whether there is pending data corresponding to the pending address in the cache space corresponding to the peripheral device; if so, based on the pending access request, perform access to the pending data in the cache space, and feed back an access result corresponding to the pending access request to the peripheral controller; if not, send the pending access request to the peripheral device, obtain the access result corresponding to the pending access request fed back by the peripheral device, and forward the access result to the peripheral controller.
[0053] Optionally, prefetch control logic is also included;
[0054] The prefetch control logic is used to obtain a prefetch request, which is used to request data reading from the to-be-prefetched address of the peripheral device; based on the prefetch request, control the access control logic to read the to-be-prefetched data of the to-be-prefetched address from the peripheral device, and update the to-be-prefetched data to the peripheral cache; and feed back a prefetch task completion message to the peripheral controller.
[0055] In a fifth aspect, an embodiment of the present application provides a computing device comprising: at least one peripheral controller, at least one peripheral cache, and at least one peripheral device; the peripheral controller is used to execute a data access method applied to the peripheral controller, the peripheral cache is used to execute a data access method applied to the peripheral cache, and the peripheral device executes a data access method applied to the peripheral device.
[0056] In a sixth aspect, an embodiment of the present application provides a storage medium, which stores one or more computer-executable instructions, and the one or more computer-executable instructions execute a data access method applied to a peripheral cache, and / or execute a data access method applied to a peripheral controller, and / or execute a data access method applied to a peripheral device.
[0057] In a seventh aspect, an embodiment of the present application provides a computer program comprising one or more computer-executable instructions, which, when executed, implement a data access method applied to a peripheral cache, and / or implement a data access method applied to a peripheral controller, and / or implement a data access method applied to a peripheral device.
[0058] An embodiment of the present application provides a data access method and related devices, wherein the data access method applied to the peripheral cache includes: obtaining a pending access request, the pending access request being used to request access to a pending address of the peripheral device; based on the pending access request, determining whether there is pending data corresponding to the pending address in the cache space corresponding to the peripheral device; if so, based on the pending access request, performing access to the pending data in the cache space, and feeding back the access result corresponding to the pending access request to the request issuer; if not, sending the pending access request to the peripheral device, and when obtaining the access result corresponding to the pending access request fed back by the peripheral device, forwarding the access result to the peripheral controller.
[0059] It can be seen that the embodiment of the present application configures a peripheral cache for the peripheral device, so that when executing a pending access request for the peripheral device, it first determines whether there is accessed data corresponding to the accessed address in the cache space corresponding to the peripheral device, and when there is accessed data corresponding to the accessed address, based on the pending access request, access to the accessed data is executed in the cache space without having to access the peripheral device, thereby avoiding access to the peripheral device with a certain probability, and further avoiding the delay caused by accessing the peripheral device, thereby improving data access efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.
[0061] Figure 1 An optional framework diagram for a computing device;
[0062] Figure 2 A schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0063] Figure 3 An optional flow chart of a data access method provided in an embodiment of the present application;
[0064] Figure 4 Another optional flow chart of a data access method provided in an embodiment of the present application;
[0065] Figure 5 An optional example diagram of a data prefetching process provided in an embodiment of the present application;
[0066] Figure 6 Another optional example diagram of a data prefetching process provided in an embodiment of the present application;
[0067] Figure 7 An optional structural diagram of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0069] refer to Figure 1 An optional framework diagram of a computing device is shown, which may include a host and peripheral devices coupled to the host, wherein the host may include a processor, a DMA (direct memory access) device, etc., and the host and the peripheral devices may communicate based on a bus and an external interface.
[0070] It is understandable that the peripheral device connected to the host can be one or more. Moreover, when there are many peripheral devices, the host can also cascade the peripheral devices to the host based on a switch cascade technology.
[0071] However, with the development of peripheral devices, the bandwidth of peripheral devices has gradually increased, and the corresponding access delay has also increased significantly. In particular, in the cascade scenario of peripheral devices, the access delay will be further increased.
[0072] In an embodiment provided in the present application, a data access method and related devices are provided, and the data access method applied to the peripheral cache includes: obtaining a pending access request, the pending access request being used to request access to a pending address of the peripheral device; based on the pending access request, determining whether there is pending data corresponding to the pending address in the cache space corresponding to the peripheral device; if so, based on the pending access request, performing access to the pending data in the cache space, and feeding back the access result corresponding to the pending access request to the request issuer; if not, sending the pending access request to the peripheral device, and when obtaining the access result corresponding to the pending access request fed back by the peripheral device, forwarding the access result to the peripheral controller.
[0073] It can be seen that the embodiment of the present application configures a peripheral cache for the peripheral device, so that when executing a pending access request for the peripheral device, it first determines whether there is accessed data corresponding to the accessed address in the cache space corresponding to the peripheral device, and when the accessed data exists, based on the pending access request, access to the accessed data is executed in the cache space without having to access the peripheral device, thereby avoiding access to the peripheral device with a certain probability, and further avoiding the delay caused by accessing the peripheral device, thereby improving data access efficiency.
[0074] The solution proposed in this application is described in detail below.
[0075] Figure 2 The schematic diagram of the structure of the computing device is shown as an example. Figure 2 As shown, the computing device may include a host and peripheral devices coupled to the host. The host includes a processor core, a DMA device, a peripheral controller, a peripheral cache, and other host devices. The processor core, DMA device, peripheral controller, and other host devices implement data exchange based on an on-chip network, while the peripheral controller is connected to the peripheral devices based on the peripheral cache. The other host devices may be, for example, other processor cores.
[0076] The peripheral controller is used to manage the peripheral resources and access processes of peripheral devices. There can be multiple or one peripheral controller. If there are multiple peripheral controllers, they can correspond one-to-one with peripheral devices, or one-to-many with peripheral devices, meaning one peripheral controller controls multiple peripheral devices. During the peripheral device access process, the peripheral controller is used to assign access tasks to the corresponding peripheral devices and, after receiving result data from the peripheral devices, feed the result data back to the requester.
[0077] The peripheral cache is used to provide data cache space for peripheral devices, by caching at least part of the data of the peripheral device to the peripheral cache, so as to implement access to part of the data of the peripheral device based on the peripheral cache, thereby reducing the probability of the host accessing the peripheral device when performing the corresponding access task. The peripheral cache can be configured on the host chip (such as the system-on-chip SOC), so as to implement access to the cached data based on intra-chip communication. There can be multiple or one peripheral cache. The peripheral cache matches the peripheral device, that is, the peripheral cache can correspond to the peripheral device one-to-one, or one-to-many with the peripheral device, that is, one peripheral cache corresponds to multiple peripheral devices; in an optional example, the peripheral cache can also match the peripheral controller, that is, the peripheral cache can correspond to the peripheral controller one-to-one, or one-to-many with the peripheral controller.
[0078] Among them, regardless of the corresponding method, if a peripheral cache corresponds to multiple peripheral devices, the correspondence with the peripheral device can be achieved in the peripheral cache by configuring cache partitions. Specifically, a preset cache partition area can be divided in the peripheral cache as a cache partition to be matched, and the cache partition to be matched can be further configured to the peripheral device to be configured, so that the peripheral device to be configured corresponds to the cache partition to be matched.
[0079] After the peripheral cache is configured to the preset cache partition of the peripheral device, the preset cache partition can store the peripheral data stored in the corresponding peripheral device (i.e., the data stored in the peripheral device), wherein, in the preset cache partition, the peripheral data can be marked based on its corresponding storage address in the peripheral device, so that it can be determined whether the corresponding peripheral data exists in the preset cache partition based on the address information in the access request of the corresponding peripheral device.
[0080] In a specific implementation, the peripheral cache is configured between the peripheral controller and the peripheral device, so as to cache and access data in the peripheral device based on access information in the peripheral controller, thereby improving data access efficiency.
[0081] In a further implementation, the present application also provides a corresponding data access method, which can be applied to the above computing device to implement data access control of peripheral devices based on peripheral cache. Figure 3 An optional flow chart of a data access method is shown, the method comprising:
[0082] Step S100: The peripheral controller obtains a pending access request, where the pending access request is used to request access to a pending address of a peripheral device.
[0083] The pending access request may be issued from any data processing device (eg, a processor core, a DMA device) in the host and transmitted to the peripheral controller based on a bus.
[0084] It is understandable that the peripheral device may be any peripheral device coupled to the host, and accordingly, the pending access request is used to access the pending address of the peripheral device, wherein the pending address is the address requested to be accessed by the pending access request.
[0085] Step S110: the peripheral controller allocates the pending access request to the peripheral cache corresponding to the peripheral device;
[0086] It is understandable that, for the peripheral device requested to be accessed by the pending access request, the peripheral controller may configure the pending access request to the peripheral cache corresponding to the peripheral device to execute the corresponding data access task.
[0087] In a specific implementation, the pending access request may include corresponding access information, such as identification information of the peripheral device requesting access, address information of the corresponding address to be accessed, and corresponding operation information. Accordingly, the peripheral controller may allocate the pending access request to the peripheral cache corresponding to the peripheral device based on the access information in the pending access request.
[0088] Correspondingly, the peripheral device cache can obtain the pending access request.
[0089] Step S120: The peripheral cache determines, based on the access request to be processed, whether there is data to be accessed corresponding to the address to be accessed in the cache space corresponding to the peripheral device;
[0090] In a specific implementation, after obtaining the pending access request, the corresponding peripheral device is confirmed based on the request information of the pending access request, and then the cache space corresponding to the peripheral device is determined.
[0091] Taking the cache space corresponding to the peripheral device in the peripheral cache as a preset cache partition as an example, the peripheral device corresponding to the pending access request can be determined based on the request information of the pending access request, so as to determine the preset cache partition corresponding to the peripheral device, and then determine whether there is the to-be-accessed data corresponding to the to-be-accessed address in the preset cache partition.
[0092] In an optional implementation, the address to be accessed may be confirmed based on the address information in the request information.
[0093] If the data to be accessed exists in the cache space corresponding to the peripheral device, step S130 is executed; otherwise, step S140 is executed.
[0094] Step S130 , the peripheral cache executes access to the to-be-accessed data in the cache space based on the to-be-processed access request, and feeds back an access result corresponding to the to-be-processed access request to the peripheral controller;
[0095] Based on the request information in the to-be-processed access request, a corresponding access operation may be performed on the to-be-accessed data in the cache space.
[0096] In an optional example, if the access operation corresponding to the pending access request is a read operation, the existence of the data to be accessed in the cache space corresponding to the peripheral device can be understood as a read hit in the cache. Then, this step can specifically be reading the data to be accessed from the cache space. Accordingly, the read data to be accessed can be fed back to the peripheral controller as an access result.
[0097] In an optional example, if the access operation corresponding to the pending access request is a write operation, the corresponding pending access request may include the corresponding data to be written, and the existence of the data to be accessed in the cache space corresponding to the peripheral device can be understood as a write hit in the cache. This step can specifically be writing the data to be written to the location corresponding to the data to be accessed in the cache space (that is, updating the data to be written to the cache space where the data to be accessed is located). Accordingly, a feedback message of successful writing can be fed back to the peripheral controller as an access result.
[0098] It should be noted that after the data to be written is written into the corresponding cache space, the data to be written can be updated to the address corresponding to the peripheral device at a preset time. In an optional example, the preset time can be after the feedback message of successful writing is fed back to the peripheral controller as an access result, and the data to be written is replaced by data at other addresses of the peripheral device in the peripheral cache.
[0099] After feeding back the access result to the peripheral controller, the peripheral controller may execute step S170 to obtain the access result and feed back the access result to the request issuer.
[0100] Step S140: the peripheral cache sends the pending access request to the peripheral device;
[0101] When the to-be-accessed data corresponding to the to-be-accessed address does not exist in the cache space of the peripheral device in the peripheral cache, the to-be-processed access request can be sent to the peripheral device so that the peripheral device executes the access task corresponding to the to-be-processed access request.
[0102] Correspondingly, the peripheral device can obtain the pending access request.
[0103] Step S150: the peripheral device accesses the data to be accessed based on the access request to be processed, and feeds back the access result to the peripheral device cache;
[0104] After obtaining the pending access request, the peripheral device may perform a corresponding access based on the corresponding request information.
[0105] In an optional example, if the access operation corresponding to the pending access request is a read operation, this step can specifically be to read the accessed data corresponding to the accessed address based on the pending access request, and accordingly, the read accessed data can be fed back to the peripheral cache as an access result.
[0106] In an optional example, if the access operation corresponding to the pending access request is a write operation, the corresponding pending access request may include the corresponding data to be written. Then, this step may specifically be based on the pending access request, and write the data to be written into the space corresponding to the access address of the peripheral device (that is, update the data to be written to the location where the data to be accessed is located). Accordingly, the feedback message of successful writing may be fed back to the peripheral cache as an access result.
[0107] It is understandable that the peripheral device feeds back the corresponding access result to the peripheral cache, and accordingly, the peripheral cache can obtain the access result fed back by the peripheral device corresponding to the to-be-processed access request.
[0108] Step S160: the peripheral cache obtains the access result corresponding to the pending access request fed back by the peripheral device, and forwards the access result to the peripheral controller;
[0109] After obtaining the corresponding access result, the peripheral cache can forward the access result to the peripheral controller, so that the peripheral controller forwards the access result to the request issuer. Accordingly, the peripheral controller can execute step S170 to obtain the access result and feed the access result back to the request issuer.
[0110] Step S170: The peripheral controller obtains the access result and feeds the access result back to the request issuer;
[0111] By feeding back the access result to the request issuer, it indicates that the corresponding access task has been completed.
[0112] In a further optional example, after obtaining the access result in step S160 , the peripheral cache may further update the data in the peripheral cache based on the access result.
[0113] Specifically, refer to Figure 4 Another optional flowchart of a data access method is shown. After the peripheral cache obtains the access result, if the access operation corresponding to the access request to be processed is a read operation, the access result includes the read data to be accessed. In this example, step S180 can be further executed.
[0114] In step S180 , the peripheral cache determines the read data to be accessed from the obtained access result, and caches the data to be accessed into the cache space corresponding to the peripheral device.
[0115] It is understood that the access result is obtained when the pending access request does not hit the peripheral cache, indicating that the accessed data is not cached in the peripheral cache. By caching the accessed data in the corresponding cache space, when a subsequent pending access request needs to access the accessed data, it can be directly obtained from the corresponding cache space without having to access it again from the peripheral device.
[0116] In an optional example, the data to be accessed can be cached in the cache space of the peripheral device based on a cache replacement mechanism. The cache replacement mechanism can be understood as a cache data replacement rule, which can be implemented based on a preset algorithm. Specifically, the cache replacement mechanism may include, for example, storing the data to be accessed in the free space when there is free space in the cache space corresponding to the peripheral device; when there is no free space in the cache space corresponding to the peripheral device, selecting the cache space to be replaced where the peripheral cache data that meets the preset conditions is located based on a preset algorithm, storing the data to be accessed in the cache space to be replaced, and updating the peripheral cache data of the cache space to be replaced to the peripheral device.
[0117] The preset algorithm may be, for example, a cache data replacement algorithm such as a least recently used (LRU) algorithm, a first in first out (FIFO) algorithm, a least frequently used (LFU) algorithm, or a random replacement algorithm.
[0118] It should be noted that when the access request corresponds to a write operation, the data to be written is written into the corresponding cache space, so that the peripheral cache data stored in the peripheral cache may be data that has not yet been updated in the peripheral device. Therefore, the data in the peripheral device can be updated by updating the peripheral cache data in the cache space to be replaced to the peripheral device.
[0119] It can be understood that the step of updating the peripheral cache data to the peripheral device is essentially a process after the access request is executed, which does not affect the processing time of the access request. As a result, the embodiment of the present application can improve the data access efficiency while realizing the data update of the peripheral device and avoiding data errors of the peripheral device.
[0120] In a further optional example, the embodiment of the present application also provides a data pre-fetch process for pre-fetching preset data to a peripheral cache before executing data access, thereby reducing the probability of accessing the peripheral device in the data access process and improving data access efficiency. In a specific implementation, the data pre-fetch process can be executed before step S100 of the data access method, or after step S170, that is, before or after an access request is executed, to provide a basis for the execution of subsequent access requests. Specifically, refer to Figure 5 An optional example diagram of a data prefetching process is shown, including:
[0121] Step S200: The peripheral controller obtains a prefetch request, where the prefetch request is used to request data reading from a to-be-prefetched address of the peripheral device.
[0122] The prefetch request may be a data prefetch processing task issued by the request issuer, used to provide a cached data basis for subsequent data access. The prefetch request may be issued by any data processing device in the host (e.g., a processor core, a DMA device) and transmitted to the peripheral controller based on a bus. The prefetch request may be generated based on software requirements or hardware requirements, such as software programs, operating systems, etc., or hardware such as instruction processing logic in the host.
[0123] The peripheral device may determine the peripheral device indicated in the expected request based on the request information of the prefetch request. It is understandable that the request information may include identification information of the peripheral device, request type, request operation information, address to be prefetched, etc.
[0124] When accessing peripheral data of a peripheral device may be performed later, a prefetch request is first issued to prefetch the data that may be accessed, thereby reducing data access latency and improving data access efficiency. Therefore, issuing a prefetch request indicates that the data of the peripheral device may be accessed later.
[0125] It should be noted that, since the peripheral cache configured for the peripheral device is usually smaller than the storage space of the peripheral device, the prefetch request can select part of the data of the peripheral device for prefetching. Accordingly, the selected prefetched data can be the to-be-prefetched data of the to-be-prefetched address.
[0126] Step S210 , the peripheral controller configures the pre-fetch request to the peripheral cache of the corresponding peripheral device;
[0127] The corresponding data prefetch task is executed by configuring the prefetch request to the peripheral cache corresponding to the peripheral device.
[0128] In a specific implementation, the prefetch request may include corresponding prefetch information, such as identification information of the peripheral device requesting prefetch, address information of the corresponding address to be prefetched, and corresponding operation information. Accordingly, the peripheral controller may configure the prefetch request to the peripheral cache corresponding to the peripheral device based on the prefetch information in the prefetch request.
[0129] Correspondingly, the peripheral cache can obtain the prefetch request.
[0130] Step S220: the peripheral cache reads the to-be-prefetched data at the to-be-prefetched address from the peripheral device based on the prefetch request, and updates the to-be-prefetched data to the peripheral cache;
[0131] After obtaining the prefetch request, the peripheral cache can determine the peripheral device corresponding to the prefetch request based on the corresponding request information, thereby reading the to-be-prefetched data at the to-be-prefetched address from the peripheral device.
[0132] It should be noted that the data reading process corresponding to the prefetch request can be executed once or multiple times, and the number of executions can be determined based on the amount of data to be prefetched and the distribution of storage locations (i.e., the data to be prefetched is distributed in continuous or discontinuous storage space).
[0133] In a specific example, refer to Figure 6 Another optional example diagram of a data pre-fetching process is shown, and the corresponding data reading process may include:
[0134] Step S221: The peripheral cache generates a corresponding data read command based on the prefetch request;
[0135] Wherein, the data read command is used to read the peripheral data in the address to be read. The generated data read command can be one or more (i.e., at least 2). Wherein, one data read command corresponds to one address to be read, and accordingly, the address to be read is at least a part of the address to be prefetched. When there is one data read command, the address to be read is consistent with the address to be prefetched; when there are multiple data read commands, the address to be read can be an address segment in the address to be prefetched, and the addresses to be read in multiple data read commands can be merged into the address to be prefetched.
[0136] In a specific example, an identification bit may be further configured for the data read command to indicate the processing status of the data read command, for example, whether it has been sent or completed.
[0137] In step S222 , the peripheral cache selects and sends the data read command to the peripheral device, so that the peripheral device reads and feeds back the corresponding data to be pre-fetched based on the data read command.
[0138] When there are multiple data read commands, the peripheral cache can sort the data read commands and issue a data read command in sequence. In a specific example, after selecting and sending the data read command, the flag bit of the data read command can be further configured to be in a sent state.
[0139] It is understandable that when there are multiple data read commands, the data to be pre-fetched that is read is only the peripheral data corresponding to the data read command, that is, the peripheral data corresponding to the address to be read.
[0140] In step S223 , after obtaining the data to be pre-fetched, the peripheral cache updates the obtained data to be pre-fetched into the cache space corresponding to the peripheral device.
[0141] The cache space may or may not have free space. When there is no free space in the cache space, during the update process of the acquired data to be prefetched, the data to be prefetched may be replaced into the corresponding cache space based on a preset algorithm. It should be noted that during this data update process, data to be prefetched belonging to the same prefetch task do not replace each other.
[0142] In a specific example, this step may further configure the flag of the data read command to be in a completed state after the acquired data to be pre-fetched is updated into the cache space corresponding to the peripheral device.
[0143] Step S224, the peripheral cache confirms whether the prefetch task corresponding to the prefetch request is completed;
[0144] Among them, reading the complete data to be prefetched can be understood as completing the corresponding prefetch task. Among them, it can be determined whether the prefetch task corresponding to the prefetch request is completed based on the address to be prefetched. If the peripheral data corresponding to the address to be prefetched has been read in full, it indicates that the prefetch task corresponding to the prefetch request has been completed. Otherwise, the prefetch task corresponding to the prefetch request is not completed. Alternatively, based on the identification bit of the data read command generated in step S221, it is determined whether there is a data read command that has not been executed, and whether the prefetch task corresponding to the prefetch request is completed. It can be understood that if there is a data read command that has not been executed, the prefetch task corresponding to the prefetch request is not completed; if there is no data read command that has not been executed, the prefetch task corresponding to the prefetch request is completed.
[0145] If not, it indicates that there are still unexecuted commands to be read, and the process continues with step S222 to step S224 until the prefetch task corresponding to the prefetch request is completed.
[0146] If so, execute step S230.
[0147] Step S230 : The peripheral cache feeds back a pre-fetch task completion message to the peripheral controller.
[0148] By feeding back the prefetch task completion message, it is indicated that the data to be prefetched has been prefetched, so that the peripheral controller can forward the prefetch task completion message to the request issuer after obtaining the prefetch task completion message.
[0149] Step S240: The peripheral controller forwards the pre-fetch task completion message to the request issuer.
[0150] The peripheral controller forwards the pre-fetch task completion message to the request issuer, so that the request issuer can know that the pre-fetch task has been completed.
[0151] In a further example of the present application, an optional structure of a peripheral cache is also provided, referring to Figure 7 An optional structural diagram of a computing device is shown, wherein the peripheral cache includes access control logic and cache space.
[0152] Among them, the access control logic is used to implement the access-related control in the embodiment of the present application. Specifically, the access control logic can be used to obtain a pending access request, the pending access request is used to request access to the access address of the peripheral device; based on the pending access request, determine whether there is accessed data corresponding to the access address in the cache space corresponding to the peripheral device; if so, based on the pending access request, perform access to the accessed data in the cache space, and feedback the access result corresponding to the pending access request to the peripheral controller; if not, send the pending access request to the peripheral device, obtain the access result corresponding to the pending access request fed back by the peripheral device, and forward the access result to the peripheral controller.
[0153] In a further example, the peripheral cache may further include prefetch control logic, which can execute prefetch process control. Specifically, the prefetch control logic can be used to obtain a prefetch request, which is used to request data to be read from the address to be prefetched of the peripheral device; based on the prefetch request, control the access control logic to read the data to be prefetched at the address to be prefetched from the peripheral device, and update the data to be prefetched to the peripheral cache; and feedback a prefetch task completion message to the peripheral controller.
[0154] In a specific implementation, the prefetch control logic can control the access control logic to generate a corresponding data read command based on the prefetch request; wherein the generated data read command is one or more, and one data read command corresponds to an address to be read, and the address to be read is at least a portion of the address to be prefetched; the access control logic further selects and sends a data read command to the peripheral device, so that the peripheral device reads and feeds back the corresponding data to be prefetched based on the data read command; then, after obtaining the data to be prefetched, the access control logic updates the obtained data to be prefetched into the cache space corresponding to the peripheral device; further, the access control logic confirms whether the prefetch task corresponding to the prefetch request is completed; if not, the access control logic executes the steps of selecting and sending a data read command to the peripheral device, and, after obtaining the data to be prefetched, updating the obtained data to be prefetched into the cache space corresponding to the peripheral device, and confirming whether the prefetch task corresponding to the prefetch request is completed, until it is confirmed that the prefetch task corresponding to the prefetch request is completed; if so, the prefetch control logic feeds back a prefetch task completion message to the peripheral controller.
[0155] In a specific implementation, the peripheral controller can parse the prefetch request and configure the prefetch control logic of the peripheral cache. For example, the prefetch control logic is configured to control the peripheral cache based on which addresses or address segments to prefetch data, the priority of the corresponding tasks, timeout / busy abandonment, etc. Correspondingly, the prefetch control logic sends a prefetch operation corresponding to the prefetch request to the access control logic. Based on the prefetch operation, the access control logic generates a read command to the peripheral device and writes the data returned by the peripheral device into the cache space. If the prefetch task is only one, the task is terminated. If the prefetch task is multiple, the read command is sent repeatedly and the feedback data is written into the cache space.
[0156] An embodiment of the present application also provides a computer device, which may include: at least one peripheral controller, at least one peripheral cache and at least one peripheral device; the peripheral controller is used to execute the data access method applied to the peripheral controller provided in the embodiment of the present application, the peripheral cache is used to execute the data access method applied to the peripheral cache provided in the embodiment of the present application, and the peripheral device executes the data access method applied to the peripheral device provided in the embodiment of the present application.
[0157] An embodiment of the present application also provides a storage medium, which stores one or more computer-executable instructions, and the one or more computer-executable instructions are used to execute the data access method applied to the peripheral controller provided in the embodiment of the present application, and / or execute the data access method applied to the peripheral cache provided in the embodiment of the present application, and / or execute the data access method applied to the peripheral device provided in the embodiment of the present application.
[0158] An embodiment of the present application also provides a computer program, comprising one or more computer-executable instructions, which, when executed, may implement the data access method applied to a peripheral cache as provided in an embodiment of the present application, and / or, implement the data access method applied to a peripheral controller as provided in an embodiment of the present application, and / or, implement the data access method applied to a peripheral device as provided in an embodiment of the present application.
[0159] The above describes multiple embodiment schemes provided by the embodiments of the present application. The various optional methods introduced in each embodiment scheme can be combined and cross-referenced with each other without conflict, thereby extending a variety of possible embodiment schemes, which can all be considered as embodiment schemes disclosed and open in the embodiments of the present application.
[0160] Although the embodiments of the present application are disclosed above, the present application is not limited thereto. Any person skilled in the art may make various changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims.
Claims
1. A data access method, characterized in that: Applicable to peripheral cache, including: Obtaining a pending access request, wherein the pending access request is used to request access to a pending address of a peripheral device; Based on the access request to be processed, determining whether there is data to be accessed corresponding to the address to be accessed in the cache space corresponding to the peripheral device; If yes, accessing the data to be accessed is performed in the cache space based on the pending access request, and feeding back an access result corresponding to the pending access request to the peripheral controller; If not, the pending access request is sent to the peripheral device, and an access result corresponding to the pending access request fed back by the peripheral device is obtained, and the access result is forwarded to the peripheral controller.
2. The method according to claim 1, characterized in that The determining, based on the pending access request, whether there is data to be accessed corresponding to the to-be-accessed address in a cache space corresponding to the peripheral device, includes: Determining, based on the request information of the pending access request, a peripheral device corresponding to the pending access request; Determining a preset cache partition corresponding to the peripheral device; Determine whether there is to-be-accessed data corresponding to the to-be-accessed address in the preset cache partition.
3. The method according to claim 1, characterized in that If the access operation corresponding to the pending access request is a read operation, the access to the data to be accessed is performed in the cache space based on the pending access request, and the access result corresponding to the pending access request is fed back to the peripheral controller, specifically: the data to be accessed is read from the cache space, and the read data to be accessed is fed back to the peripheral controller as the access result.
4. The method according to claim 1, wherein If the access operation corresponding to the pending access request is a write operation, the access to the data to be accessed is performed in the cache space based on the pending access request, and the access result corresponding to the pending access request is fed back to the peripheral controller, specifically: the data to be written is written in the location corresponding to the data to be accessed in the cache space, and the feedback message of successful writing is fed back to the peripheral controller as the access result.
5. The method according to claim 4, characterized in that After the feedback message of successful writing is fed back to the request issuer as the access result, when the data to be written is replaced by data of other addresses of the peripheral device in the peripheral cache, it also includes: updating the data to be written to the address corresponding to the peripheral device.
6. The method according to claim 1, characterized in that After the step of obtaining the access result corresponding to the pending access request fed back by the peripheral device and forwarding the access result to the peripheral controller, the method further includes: The read data to be accessed is determined from the obtained access result, and the data to be accessed is cached in a cache space corresponding to the peripheral device.
7. The method according to claim 6, characterized in that In the step of caching the data to be accessed into the cache space corresponding to the peripheral device, the data to be accessed is cached into the cache space of the peripheral device based on a cache replacement mechanism; The cache replacement mechanism includes storing the to-be-accessed data in the free space when there is free space in the cache space corresponding to the peripheral device; When there is no free space in the cache space corresponding to the peripheral device, a cache space to be replaced where the peripheral cache data that meets the preset conditions is located is selected based on a preset algorithm, the data to be accessed is stored in the cache space to be replaced, and the peripheral cache data in the cache space to be replaced is updated to the peripheral device.
8. The method according to claim 1, characterized in that Before the step of obtaining the pending access request, the method further includes: Obtain a prefetch request, wherein the prefetch request is used to request data reading from a to-be-prefetched address of a peripheral device; Based on the prefetch request, reading the to-be-fetched data at the to-be-fetched address from the peripheral device, and updating the to-be-fetched data to the peripheral cache; Feedback prefetch task completion message to the peripheral controller.
9. The method according to claim 8, characterized in that The method of reading the to-be-prefetched data at the to-be-prefetched address from the peripheral device based on the prefetch request and updating the to-be-prefetched data to the peripheral cache includes: Based on the prefetch request, a corresponding data read command is generated; wherein the generated data read command is one or more, one data read command corresponds to an address to be read, and the address to be read is at least a portion of the address to be prefetched; Selecting and sending a data read command to the peripheral device, so that the peripheral device reads and feeds back corresponding data to be prefetched based on the data read command; After obtaining the data to be prefetched, updating the obtained data to be prefetched into a cache space corresponding to the peripheral device; confirming whether the prefetch task corresponding to the prefetch request is completed; If not, executing the step of selecting and sending a data read command to the peripheral device, and, after obtaining the data to be prefetched, updating the obtained data to be prefetched into the cache space corresponding to the peripheral device, and confirming whether the prefetch task corresponding to the prefetch request is completed, until it is confirmed that the prefetch task corresponding to the prefetch request is completed; If so, the step of feeding back the pre-fetch task completion message to the peripheral controller is performed.
10. The method according to claim 9, characterized in that The step of generating a corresponding data read command based on the prefetch request further includes configuring an identification bit for the data read command to indicate a processing status of the data read command; In the step of selecting and sending the data read command to the peripheral device, the flag bit of the data read command is further configured to be in a sent state; In the step of updating the acquired data to be prefetched into the cache space corresponding to the peripheral device after acquiring the data to be prefetched, the flag bit of the data read command is further configured to be in a completed state; In the step of confirming whether the prefetch task corresponding to the prefetch request is completed, it is determined whether there is an unexecuted data read command based on the identification bit of the data read command to determine whether the prefetch task corresponding to the prefetch request is completed.
11. A data access method, characterized in that: Applicable to peripheral controllers, including: Obtaining a pending access request, wherein the pending access request is used to request access to a pending address of a peripheral device; configuring the pending access request to a peripheral cache corresponding to the peripheral device, so that the peripheral cache executes the data access method according to any one of claims 1 to 10; Obtain an access result of the peripheral device cache, and feed the access result back to the request issuer.
12. The method according to claim 11, characterized in that Before obtaining the pending access request, the method further includes: Obtain a prefetch request, wherein the prefetch request is used to request data reading from a to-be-prefetched address of a peripheral device; configuring the prefetch request to a peripheral cache corresponding to the peripheral device, so that the peripheral cache executes the data access method according to any one of claims 1 to 10; After obtaining the pre-fetch task completion message, forward the pre-fetch task completion message to the request issuer.
13. A data access method, characterized in that: Applicable to peripheral devices, including: Obtaining a pending access request from a peripheral cache, the pending access request being used to request access to a pending address of a peripheral device; the peripheral cache being used to execute the data access method according to any one of claims 1 to 10; Based on the access request to be processed, access to the data to be accessed is performed, and an access result is fed back to the peripheral cache.
14. The method according to claim 13, characterized in that If the access operation corresponding to the pending access request is a read operation, the access to the data to be accessed is performed based on the pending access request, and the access result is fed back to the peripheral cache, specifically: based on the pending access request, the access data corresponding to the address to be accessed is read, and the read data to be accessed is fed back to the peripheral cache as the access result.
15. The method according to claim 13, characterized in that If the access operation corresponding to the pending access request is a write operation, the access to the data to be accessed is performed based on the pending access request, and the access result is fed back to the peripheral cache. Specifically, based on the pending access request, the data to be written is written in the space corresponding to the access address to be accessed of the peripheral device, and a feedback message of successful writing is fed back to the peripheral cache as the access result.
16. A peripheral cache, characterized in that: Includes access control logic and cache space; The access control logic is used to obtain a pending access request, where the pending access request is used to request access to a pending address of a peripheral device; Based on the pending access request, determine whether there is accessed data corresponding to the accessed address in the cache space corresponding to the peripheral device; if so, based on the pending access request, perform access to the accessed data in the cache space, and feedback the access result corresponding to the pending access request to the peripheral controller; if not, send the pending access request to the peripheral device, obtain the access result corresponding to the pending access request fed back by the peripheral device, and forward the access result to the peripheral controller.
17. The external device cache according to claim 16, characterized in that: Also includes prefetch control logic; The prefetch control logic is used to obtain a prefetch request, wherein the prefetch request is used to request data to be read from a to-be-prefetched address of a peripheral device; based on the prefetch request, control the access control logic to read the to-be-prefetched data of the to-be-prefetched address from the peripheral device, and update the to-be-prefetched data to the peripheral cache; Feedback prefetch task completion message to the peripheral controller.
18. A computing device, characterized in that include: At least one peripheral controller, at least one peripheral cache and at least one peripheral device; the peripheral controller is used to execute the data access method of claim 11 or 12, the peripheral cache is used to execute the data access method described in any one of claims 1-10, and the peripheral device executes the data access method described in any one of claims 13-15.
19. A storage medium, characterized in that: The storage medium stores one or more computer-executable instructions, and the one or more computer-executable instructions can execute the data access method described in any one of claims 1 to 10, and / or execute the data access method described in any one of claims 11 to 12, and / or execute the data access method described in any one of claims 13 to 15.
20. A computer program, characterized in that The method comprises one or more computer-executable instructions, which, when executed, implement the data access method according to any one of claims 1 to 10, and / or implement the data access method according to any one of claims 11 to 12, and / or implement the data access method according to any one of claims 13 to 15.
Citation Information
Patent Citations
Data access method and device, electronic equipment and storage medium
CN115408431A
Efficient computing device
CN115525599A
Solid state disk peripheral management system and method, solid state disk controller and solid state disk
CN116540935A
Transparent host-side caching of virtual disks located on shared storage
US20140059292A1
A new USB protocol based computer acceleration device using multi I / O channel SLC NAND and DRAM cache
US20160253093A1