[go: up one dir, main page]

CN116010109B - Cache resource allocation method, device, electronic device and storage medium - Google Patents

Cache resource allocation method, device, electronic device and storage medium Download PDF

Info

Publication number
CN116010109B
CN116010109B CN202310153348.3A CN202310153348A CN116010109B CN 116010109 B CN116010109 B CN 116010109B CN 202310153348 A CN202310153348 A CN 202310153348A CN 116010109 B CN116010109 B CN 116010109B
Authority
CN
China
Prior art keywords
shared cache
identification information
data request
cache
group
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310153348.3A
Other languages
Chinese (zh)
Other versions
CN116010109A (en
Inventor
请求不公布姓名
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mole Thread Intelligent Technology (Beijing) Co.,Ltd.
Original Assignee
Moore Threads Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Moore Threads Technology Co Ltd filed Critical Moore Threads Technology Co Ltd
Priority to CN202310153348.3A priority Critical patent/CN116010109B/en
Priority to CN202311076545.6A priority patent/CN117093371B/en
Publication of CN116010109A publication Critical patent/CN116010109A/en
Application granted granted Critical
Publication of CN116010109B publication Critical patent/CN116010109B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The disclosure relates to the technical field of electric digital data processing, and in particular relates to a cache resource allocation method, a cache resource allocation device, electronic equipment and a storage medium. A processor system comprising at least two levels of cache, the highest level of the at least two levels of cache being a shared cache, the shared cache comprising a plurality of shared cache sets, the method comprising: responding to a first data request from any application, and acquiring first identification information carried by the first data request; and responding to the first data request as the data request corresponding to the first identification information received for the first time, and distributing a preset number of shared cache groups to the first identification information. Because the number of the groups is more than the number of the ways, the shared cache resources are allocated based on the groups, so that the reasonable allocation of the shared cache resources can be realized more easily, and the utilization rate of the shared cache resources can be improved.

Description

缓存资源分配方法、装置、电子设备和存储介质Cache resource allocation method, device, electronic device and storage medium

技术领域technical field

本公开涉及电数字数据处理技术领域,尤其涉及一种缓存资源分配方法、缓存资源分配装置、电子设备和存储介质。The present disclosure relates to the technical field of electronic digital data processing, and in particular, to a cache resource allocation method, a cache resource allocation device, electronic equipment, and a storage medium.

背景技术Background technique

缓存是一种片上存储器,它位于CPU(Central Processing Unit,中央处理器)/GPU(Graphics Processing Unit,图形处理器)与内存之间,可以提供快速且小容量的数据读写。缓存内的数据是主内存的一部分,通过一定的映射关系存储在缓存中,并通过对比标签信息来获得数据。映射关系主要分为以下三种:第一种为直接映射。在直接映射中,内存中的某一块地址只能映射到缓存中的固定位置。第二种为全相连映射。在全相连映射中,内存中的某一块地址可以映射到缓存中的任意位置。第三种为组相连映射。组相连映射是直接映射和全相连映射的折中方案。在组相连映射中,将缓存分为若干组(set),每组有多个路(way)。内存中的某一块地址只能映射到固定的组,但是可以映射到每个组内不同的路。由于物理实现的复杂度,在组相连中,每组包含的路的数量通常不超过16个或32个。表1示出了组相连映射的一示例性的实现方式。在表1所示的实现方式中,将缓存分为M+1组,每个组包括N+1个路。Cache is a kind of on-chip memory, which is located between CPU (Central Processing Unit, central processing unit)/GPU (Graphics Processing Unit, graphics processing unit) and memory, and can provide fast and small-capacity data reading and writing. The data in the cache is a part of the main memory, which is stored in the cache through a certain mapping relationship, and the data is obtained by comparing the tag information. The mapping relationship is mainly divided into the following three types: The first is direct mapping. In direct mapping, a block of addresses in memory can only be mapped to a fixed location in the cache. The second type is fully connected mapping. In fully associative mapping, an address in memory can be mapped to any location in the cache. The third type is group associative mapping. Group associative mapping is a compromise between direct mapping and fully associative mapping. In set associative mapping, the cache is divided into several sets (sets), and each set has multiple ways (way). A block of addresses in memory can only be mapped to a fixed group, but it can be mapped to a different way in each group. Due to the complexity of physical implementation, in group connection, the number of ways included in each group usually does not exceed 16 or 32. Table 1 shows an exemplary implementation of group associative mapping. In the implementation shown in Table 1, the cache is divided into M+1 groups, and each group includes N+1 ways.

表1Table 1

路 #0road #0 路 #1road #1 路 #NRoad #N 组 #0Group #0 数据data 数据data 数据data 数据data 数据data 数据data 数据data 数据data 组 #MGroup #M 数据data 数据data 数据data 数据data

缓存利用了程序的局部性原理,分为时间局部性和空间局部性。时间局部性是指某一个地址可能会在一段时间内重复被访问。空间局部性是指一个地址被访问,则附近的地址也有很大可能会被访问。由于不同程序表现出的局部性也会不同,所以对于缓存的利用率也有差异。Cache utilizes the principle of program locality, which is divided into temporal locality and spatial locality. Time locality means that an address may be accessed repeatedly within a period of time. Spatial locality means that when an address is accessed, nearby addresses are also likely to be accessed. Since the locality exhibited by different programs will also be different, the utilization rate of the cache is also different.

如何提高缓存资源的利用率,是亟待解决的技术问题。How to improve the utilization rate of cache resources is an urgent technical problem to be solved.

发明内容Contents of the invention

本公开提供了一种缓存资源分配技术方案。The present disclosure provides a technical solution for cache resource allocation.

根据本公开的一方面,提供了一种缓存资源分配方法,处理器系统包括至少两级缓存,所述至少两级缓存中的最高级为共享缓存,所述共享缓存包括多个共享缓存组,所述方法包括:According to an aspect of the present disclosure, a cache resource allocation method is provided, the processor system includes at least two levels of cache, the highest level of the at least two levels of cache is a shared cache, and the shared cache includes multiple shared cache groups, The methods include:

响应于来自于任一应用的第一数据请求,获取所述第一数据请求携带的第一标识信息;In response to a first data request from any application, acquire first identification information carried in the first data request;

响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分配预设数量的共享缓存组。In response to the first data request being a data request corresponding to the first identification information received for the first time, assigning a preset number of shared cache groups to the first identification information.

在一种可能的实现方式中,所述共享缓存包括多个共享缓存通道;In a possible implementation manner, the shared cache includes multiple shared cache channels;

所述响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分配预设数量的共享缓存组,包括:The responding to the first data request being a data request corresponding to the first identification information received for the first time, allocating a preset number of shared cache groups to the first identification information includes:

响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分别分配所述多个共享缓存通道中的预设数量的共享缓存组。In response to the first data request being a data request corresponding to the first identification information received for the first time, assigning a preset number of shared cache groups among the plurality of shared cache channels to the first identification information.

在一种可能的实现方式中,所述预设数量包括第一预设数量和第二预设数量,且所述第一预设数量小于所述第二预设数量;In a possible implementation manner, the preset number includes a first preset number and a second preset number, and the first preset number is smaller than the second preset number;

所述响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分别分配所述多个共享缓存通道中的预设数量的共享缓存组,包括:The response to the first data request being a data request corresponding to the first identification information received for the first time, respectively assigning a preset number of shared caches in the plurality of shared cache channels to the first identification information group, including:

响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,其中,所述第一参照共享缓存通道表示所述第一标识信息对应的参照共享缓存通道;In response to the first data request being a data request corresponding to the first identification information received for the first time, determining a first reference shared cache channel corresponding to the first identification information from the plurality of shared cache channels, Wherein, the first reference shared cache channel indicates the reference shared cache channel corresponding to the first identification information;

向所述第一标识信息分配第一普通共享缓存通道中的所述第一预设数量的共享缓存组,并向所述第一标识信息分配所述第一参照共享缓存通道中的所述第二预设数量的共享缓存组,其中,所述第一普通共享缓存通道表示所述多个共享缓存通道中除所述第一参照共享缓存通道以外的共享缓存通道。Allocating the first preset number of shared cache groups in the first common shared cache channel to the first identification information, and allocating the first preset number of shared cache groups in the first reference shared cache channel to the first identification information Two preset numbers of shared cache groups, wherein the first common shared cache channel represents a shared cache channel other than the first reference shared cache channel among the plurality of shared cache channels.

在一种可能的实现方式中,所述响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,包括:In a possible implementation manner, the response to the first data request is a data request corresponding to the first identification information received for the first time, and the first data request is determined from the multiple shared cache channels. The first reference shared cache channel corresponding to the identification information includes:

响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,且所述多个共享缓存通道中存在未被确定为参照共享缓存通道的共享缓存通道,从所述未被确定为参照共享缓存通道的共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道。In response to the first data request being a data request corresponding to the first identification information received for the first time, and there is a shared cache channel that is not determined as a reference shared cache channel among the multiple shared cache channels, from the Among the shared cache channels that are not determined as reference shared cache channels, determine a first reference shared cache channel corresponding to the first identification information.

在一种可能的实现方式中,所述方法还包括:In a possible implementation, the method further includes:

获取所述第一参照共享缓存通道针对所述第一标识信息的第一命中率,以及所述第一普通共享缓存通道针对所述第一标识信息的第二命中率;Acquiring a first hit rate of the first reference shared cache channel for the first identification information, and a second hit rate of the first common shared cache channel for the first identification information;

根据所述第一命中率和所述第二命中率,调节分配给所述第一标识信息的共享缓存组的数量。According to the first hit ratio and the second hit ratio, the number of shared cache groups allocated to the first identification information is adjusted.

在一种可能的实现方式中,所述根据所述第一命中率和所述第二命中率,调节分配给所述第一标识信息的共享缓存组的数量,包括:In a possible implementation manner, the adjusting the number of shared cache groups allocated to the first identification information according to the first hit rate and the second hit rate includes:

确定所述第一命中率与所述第二命中率的比值;determining a ratio of the first hit rate to the second hit rate;

响应于所述比值大于或等于第一预设阈值,增大所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;或者,响应于所述比值小于或等于第二预设阈值,减少所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;其中,所述第一预设阈值大于所述第二预设阈值,且所述第一预设阈值和所述第二预设阈值均大于1。In response to the ratio being greater than or equal to a first preset threshold, increasing the number of shared cache groups allocated to the first identification information among the plurality of shared cache channels; or, in response to the ratio being less than or equal to a first threshold Two preset thresholds, reducing the number of shared cache groups allocated to the first identification information among the plurality of shared cache channels; wherein, the first preset threshold is greater than the second preset threshold, and the Both the first preset threshold and the second preset threshold are greater than 1.

在一种可能的实现方式中,所述方法还包括:In a possible implementation, the method further includes:

获取所述第一数据请求对应的第一请求地址;Obtain a first request address corresponding to the first data request;

响应于根据所述第一请求地址确定在本地缓存中发生缓存缺失,获取所述第一标识信息对应的组掩码、组偏移和标志位偏移量;In response to determining that a cache miss occurs in the local cache according to the first request address, acquire a group mask, a group offset, and a flag bit offset corresponding to the first identification information;

根据所述第一数据请求对应的第二请求地址、所述组掩码、所述组偏移和所述标志位偏移量,确定所述第一数据请求对应的新组位和新标签信息,其中,所述第二请求地址根据所述第一请求地址确定;According to the second request address corresponding to the first data request, the group mask, the group offset and the flag bit offset, determine the new group bit and new tag information corresponding to the first data request , wherein the second request address is determined according to the first request address;

根据所述第二请求地址中的通道信息和行内偏移地址,以及所述新组位和所述新标签信息,查找目标数据。Searching for target data according to the channel information and the in-row offset address in the second request address, as well as the new group bits and the new label information.

在一种可能的实现方式中,所述方法还包括:In a possible implementation, the method further includes:

对所述第一请求地址进行重映射,得到所述第二请求地址。Remapping the first request address to obtain the second request address.

在一种可能的实现方式中,所述根据所述第一数据请求对应的第二请求地址、所述组掩码、所述组偏移和所述标志位偏移量,确定所述第一数据请求对应的新组位和新标签信息,包括:In a possible implementation manner, the first data request is determined according to the second request address corresponding to the first data request, the group mask, the group offset, and the flag bit offset. New group bits and new label information corresponding to the data request, including:

从所述第二请求地址中,获取原始组位和原始标签信息;Obtain original group bits and original label information from the second request address;

将所述原始组位与所述组掩码进行与运算,得到所述第一数据请求所请求的目标数据在所述第一标识信息对应的多个共享缓存组中的相对位置;performing an AND operation on the original group bit and the group mask to obtain the relative position of the target data requested by the first data request in the plurality of shared cache groups corresponding to the first identification information;

根据所述组偏移和所述相对位置,确定所述第一数据请求对应的新组位;determining a new group bit corresponding to the first data request according to the group offset and the relative position;

根据所述原始标签信息、所述标志位偏移量和所述原始组位中的指定位,确定所述第一数据请求对应的新标签信息。Determine new tag information corresponding to the first data request according to the original tag information, the flag bit offset, and a specified bit in the original group bits.

在一种可能的实现方式中,所述根据所述第二请求地址中的通道信息和行内偏移地址,以及所述新组位和所述新标签信息,查找目标数据,包括:In a possible implementation manner, the searching for target data according to the channel information and in-row offset address in the second request address, as well as the new group bit and the new label information includes:

响应于根据所述通道信息、所述新组位、所述新标签信息和所述行内偏移地址,查找不到目标数据,从内存或外存中获取所述目标数据,将所述目标数据写入所述新组位对应的共享缓存组中,并向所述第一数据请求返回所述目标数据。Responding to the fact that the target data cannot be found according to the channel information, the new group bit, the new label information, and the in-line offset address, the target data is acquired from internal memory or external storage, and the target data is writing into the shared cache group corresponding to the new group bit, and returning the target data to the first data request.

在一种可能的实现方式中,所述第一标识信息包括以下任意一项:In a possible implementation manner, the first identification information includes any of the following:

根据所述应用调用的模块确定的标识信息、根据上下文的标识信息确定的标识信息、根据所述第一数据请求所请求的目标数据在内存中的地址区间确定的标识信息。The identification information determined according to the module called by the application, the identification information determined according to the context identification information, and the identification information determined according to the address range of the target data requested by the first data request in the memory.

根据本公开的一方面,提供了一种缓存资源分配装置,处理器系统包括至少两级缓存,所述至少两级缓存中的最高级为共享缓存,所述共享缓存包括多个共享缓存组,所述装置包括:第一获取模块,用于响应于来自于任一应用的第一数据请求,获取所述第一数据请求携带的第一标识信息;分配模块,用于响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分配预设数量的共享缓存组。According to an aspect of the present disclosure, a cache resource allocation device is provided, the processor system includes at least two levels of cache, the highest level of the at least two levels of cache is a shared cache, and the shared cache includes multiple shared cache groups, The device includes: a first acquiring module, configured to acquire first identification information carried in the first data request in response to a first data request from any application; an assigning module, configured to respond to the first data request The data request is a data request corresponding to the first identification information received for the first time, and a preset number of shared cache groups are allocated to the first identification information.

在一种可能的实现方式中,所述共享缓存包括多个共享缓存通道;所述分配模块用于:响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分别分配所述多个共享缓存通道中的预设数量的共享缓存组。In a possible implementation manner, the shared cache includes multiple shared cache channels; the allocating module is configured to: respond to the first data request corresponding to the first received first identification information , respectively assigning a preset number of shared cache groups in the plurality of shared cache channels to the first identification information.

在一种可能的实现方式中,所述预设数量包括第一预设数量和第二预设数量,且所述第一预设数量小于所述第二预设数量;所述分配模块用于:响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,其中,所述第一参照共享缓存通道表示所述第一标识信息对应的参照共享缓存通道;向所述第一标识信息分配第一普通共享缓存通道中的所述第一预设数量的共享缓存组,并向所述第一标识信息分配所述第一参照共享缓存通道中的所述第二预设数量的共享缓存组,其中,所述第一普通共享缓存通道表示所述多个共享缓存通道中除所述第一参照共享缓存通道以外的共享缓存通道。In a possible implementation manner, the preset quantity includes a first preset quantity and a second preset quantity, and the first preset quantity is smaller than the second preset quantity; the allocation module is used to : In response to the first data request being a data request corresponding to the first identification information received for the first time, from the plurality of shared cache channels, determine the first reference shared cache channel corresponding to the first identification information , wherein, the first reference shared cache channel represents the reference shared cache channel corresponding to the first identification information; the first preset number of shares in the first common shared cache channel are assigned to the first identification information Cache groups, and allocate the second preset number of shared cache groups in the first reference shared cache channel to the first identification information, wherein the first common shared cache channel represents the plurality of shared cache groups Shared cache channels in cache channels other than the first reference shared cache channel.

在一种可能的实现方式中,所述分配模块用于:响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,且所述多个共享缓存通道中存在未被确定为参照共享缓存通道的共享缓存通道,从所述未被确定为参照共享缓存通道的共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道。In a possible implementation manner, the allocating module is configured to: respond to the first data request being a data request corresponding to the first identification information received for the first time, and there are For the shared cache channels not determined as the reference shared cache channels, the first reference shared cache channel corresponding to the first identification information is determined from the shared cache channels not determined as the reference shared cache channels.

在一种可能的实现方式中,所述装置还包括:第二获取模块,用于获取所述第一参照共享缓存通道针对所述第一标识信息的第一命中率,以及所述第一普通共享缓存通道针对所述第一标识信息的第二命中率;调节模块,用于根据所述第一命中率和所述第二命中率,调节分配给所述第一标识信息的共享缓存组的数量。In a possible implementation manner, the device further includes: a second obtaining module, configured to obtain a first hit rate of the first reference shared cache channel for the first identification information, and the first common The second hit rate of the shared cache channel for the first identification information; an adjustment module, configured to adjust the shared cache group assigned to the first identification information according to the first hit rate and the second hit rate quantity.

在一种可能的实现方式中,所述调节模块用于:确定所述第一命中率与所述第二命中率的比值;响应于所述比值大于或等于第一预设阈值,增大所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;或者,响应于所述比值小于或等于第二预设阈值,减少所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;其中,所述第一预设阈值大于所述第二预设阈值,且所述第一预设阈值和所述第二预设阈值均大于1。In a possible implementation manner, the adjustment module is configured to: determine a ratio of the first hit rate to the second hit rate; increase the ratio in response to the ratio being greater than or equal to a first preset threshold The number of shared cache groups allocated to the first identification information among the multiple shared cache channels; or, in response to the ratio being less than or equal to a second preset threshold, reducing the number of shared cache groups allocated to the first identification information among the multiple shared cache channels The number of shared cache groups of the first identification information; wherein, the first preset threshold is greater than the second preset threshold, and both the first preset threshold and the second preset threshold are greater than 1.

在一种可能的实现方式中,所述装置还包括:第三获取模块,用于获取所述第一数据请求对应的第一请求地址;第四获取模块,用于响应于根据所述第一请求地址确定在本地缓存中发生缓存缺失,获取所述第一标识信息对应的组掩码、组偏移和标志位偏移量;确定模块,用于根据所述第一数据请求对应的第二请求地址、所述组掩码、所述组偏移和所述标志位偏移量,确定所述第一数据请求对应的新组位和新标签信息,其中,所述第二请求地址根据所述第一请求地址确定;查找模块,用于根据所述第二请求地址中的通道信息和行内偏移地址,以及所述新组位和所述新标签信息,查找目标数据。In a possible implementation manner, the device further includes: a third obtaining module, configured to obtain the first request address corresponding to the first data request; a fourth obtaining module, configured to respond to the The request address determines that a cache miss occurs in the local cache, and obtains the group mask, group offset, and flag bit offset corresponding to the first identification information; the determination module is configured to request the corresponding second The request address, the group mask, the group offset and the flag bit offset determine the new group bit and new tag information corresponding to the first data request, wherein the second request address is based on the The first request address is determined; a search module is configured to search for target data according to the channel information and the in-row offset address in the second request address, as well as the new group bit and the new tag information.

在一种可能的实现方式中,所述装置还包括:重映射模块,用于对所述第一请求地址进行重映射,得到所述第二请求地址。In a possible implementation manner, the device further includes: a remapping module, configured to remap the first request address to obtain the second request address.

在一种可能的实现方式中,所述确定模块用于:从所述第二请求地址中,获取原始组位和原始标签信息;将所述原始组位与所述组掩码进行与运算,得到所述第一数据请求所请求的目标数据在所述第一标识信息对应的多个共享缓存组中的相对位置;根据所述组偏移和所述相对位置,确定所述第一数据请求对应的新组位;根据所述原始标签信息、所述标志位偏移量和所述原始组位中的指定位,确定所述第一数据请求对应的新标签信息。In a possible implementation manner, the determining module is configured to: acquire original group bits and original label information from the second request address; perform an AND operation on the original group bits and the group mask, Obtain the relative position of the target data requested by the first data request in the plurality of shared cache groups corresponding to the first identification information; determine the first data request according to the group offset and the relative position The corresponding new group bit: determine the new tag information corresponding to the first data request according to the original tag information, the flag bit offset, and a specified bit in the original group bit.

在一种可能的实现方式中,所述查找模块用于:响应于根据所述通道信息、所述新组位、所述新标签信息和所述行内偏移地址,查找不到目标数据,从内存或外存中获取所述目标数据,将所述目标数据写入所述新组位对应的共享缓存组中,并向所述第一数据请求返回所述目标数据。In a possible implementation manner, the search module is configured to: in response to finding no target data according to the channel information, the new group bit, the new label information, and the in-line offset address, from The target data is acquired from the internal memory or the external storage, the target data is written into the shared cache group corresponding to the new group bit, and the target data is returned to the first data request.

在一种可能的实现方式中,所述第一标识信息包括以下任意一项:根据所述应用调用的模块确定的标识信息、根据上下文的标识信息确定的标识信息、根据所述第一数据请求所请求的目标数据在内存中的地址区间确定的标识信息。In a possible implementation manner, the first identification information includes any one of the following: identification information determined according to the module called by the application, identification information determined according to the identification information of the context, and information determined according to the first data request The identification information determined by the address range of the requested target data in the memory.

根据本公开的一方面,提供了一种电子设备,包括:一个或多个处理器;用于存储可执行指令的存储器;其中,所述一个或多个处理器被配置为调用所述存储器存储的可执行指令,以执行上述方法。According to an aspect of the present disclosure, there is provided an electronic device, comprising: one or more processors; a memory for storing executable instructions; wherein the one or more processors are configured to call the memory storage executable instructions to perform the above method.

根据本公开的一方面,提供了一种计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述方法。According to one aspect of the present disclosure, there is provided a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the above method is implemented.

根据本公开的一方面,提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器执行上述方法。According to an aspect of the present disclosure, there is provided a computer program product, including computer readable codes, or a non-volatile computer readable storage medium bearing computer readable codes, when the computer readable codes are stored in an electronic device During operation, the processor in the electronic device executes the above method.

在本公开实施例中,处理器系统包括至少两级缓存,所述至少两级缓存中的最高级为共享缓存,所述共享缓存包括多个共享缓存组,通过响应于来自于任一应用的第一数据请求,获取所述第一数据请求携带的第一标识信息,并响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分配预设数量的共享缓存组,由此基于组进行共享缓存资源的分配。由于组的数量比路的数量多(例如,共享缓存包括多个共享缓存通道,每个共享缓存通道包括256组,而组包含的路的数量通常不超过16个或32个),因此,基于组进行共享缓存资源的分配,能够更容易实现共享缓存资源的合理分配,并能够提高共享缓存资源的利用率。In an embodiment of the present disclosure, the processor system includes at least two levels of cache, the highest level of the at least two levels of cache is a shared cache, and the shared cache includes a plurality of shared cache groups. For the first data request, obtain the first identification information carried in the first data request, and respond to the first data request corresponding to the first identification information received for the first time, send the first identification information to the first data request The information allocates a preset number of shared cache groups, so that the shared cache resources are allocated based on the group. Since the number of groups is larger than the number of ways (for example, a shared cache includes multiple shared cache channels, each shared cache channel includes 256 groups, and the number of ways contained in a group usually does not exceed 16 or 32), therefore, based on The group allocates the shared cache resources, which can more easily realize the reasonable allocation of the shared cache resources, and can improve the utilization rate of the shared cache resources.

应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,而非限制本公开。It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.

根据下面参考附图对示例性实施例的详细说明,本公开的其它特征及方面将变得清楚。Other features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the accompanying drawings.

附图说明Description of drawings

此处的附图被并入说明书中并构成本说明书的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。The accompanying drawings here are incorporated into the description and constitute a part of the present description. These drawings show embodiments consistent with the present disclosure, and are used together with the description to explain the technical solution of the present disclosure.

图1示出GPU的缓存结构的一示意图。FIG. 1 shows a schematic diagram of a cache structure of a GPU.

图2示出本公开实施例提供的缓存资源分配方法的流程图。FIG. 2 shows a flow chart of a cache resource allocation method provided by an embodiment of the present disclosure.

图3示出本公开实施例提供的缓存资源分配方法中针对数据请求的标识信息按组分配的示意图。FIG. 3 shows a schematic diagram of group-by-group allocation of identification information for data requests in the method for allocating cache resources provided by an embodiment of the present disclosure.

图4示出本公开实施例提供的GPU的缓存结构的一示意图。FIG. 4 shows a schematic diagram of a cache structure of a GPU provided by an embodiment of the present disclosure.

图5示出本公开实施例提供的缓存查找方法的一示意图。FIG. 5 shows a schematic diagram of a cache lookup method provided by an embodiment of the present disclosure.

图6示出本公开实施例提供的缓存资源分配装置的框图。Fig. 6 shows a block diagram of an apparatus for allocating cache resources provided by an embodiment of the present disclosure.

图7示出本公开实施例提供的一电子设备1900的框图。FIG. 7 shows a block diagram of an electronic device 1900 provided by an embodiment of the present disclosure.

具体实施方式Detailed ways

以下将参考附图详细说明本公开的各种示例性实施例、特征和方面。附图中相同的附图标记表示功能相同或相似的元件。尽管在附图中示出了实施例的各种方面,但是除非特别指出,不必按比例绘制附图。Various exemplary embodiments, features, and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numbers in the figures indicate functionally identical or similar elements. While various aspects of the embodiments are shown in drawings, the drawings are not necessarily drawn to scale unless specifically indicated.

在这里专用的词“示例性”意为“用作例子、实施例或说明性”。这里作为“示例性”所说明的任何实施例不必解释为优于或好于其它实施例。The word "exemplary" is used exclusively herein to mean "serving as an example, embodiment, or illustration." Any embodiment described herein as "exemplary" is not necessarily to be construed as superior or better than other embodiments.

本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中术语“至少一种”表示多种中的任意一种或多种中的至少两种的任意组合,例如,包括A、B、C中的至少一种,可以表示包括从A、B和C构成的集合中选择的任意一个或多个元素。The term "and/or" in this article is just an association relationship describing associated objects, which means that there can be three relationships, for example, A and/or B can mean: A exists alone, A and B exist simultaneously, and there exists alone B these three situations. In addition, the term "at least one" herein means any one of a variety or any combination of at least two of the more, for example, including at least one of A, B, and C, which may mean including from A, Any one or more elements selected from the set formed by B and C.

另外,为了更好地说明本公开,在下文的具体实施方式中给出了众多的具体细节。本领域技术人员应当理解,没有某些具体细节,本公开同样可以实施。在一些实例中,对于本领域技术人员熟知的方法、手段、元件和电路未作详细描述,以便于凸显本公开的主旨。In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific implementation manners. It will be understood by those skilled in the art that the present disclosure may be practiced without some of the specific details. In some instances, methods, means, components and circuits that are well known to those skilled in the art have not been described in detail so as to obscure the gist of the present disclosure.

图1示出GPU(Graphics Processing Unit,图形处理器)的缓存结构的一示意图。GPU系统中通常存在至少两级缓存结构。在图1所示的示例中,GPU系统包括两级缓存。FIG. 1 shows a schematic diagram of a cache structure of a GPU (Graphics Processing Unit, graphics processor). There are usually at least two levels of cache structures in a GPU system. In the example shown in Figure 1, the GPU system includes two levels of cache.

GPU上存在多个运算单元集群(GPU cluster),且每个运算单元集群内部有多个运算单元。本地缓存(Local Cache)可以认为是第一级缓存,只被对应的运算单元集群访问。在图1中,包括K+1个运算单元集群(运算单元集群0至运算单元集群K),以及与K+1个运算单元集群一一对应的K+1个本地缓存(本地缓存0至本地缓存K)。其中,本地缓存也可以称为局部缓存、1级缓存、L1缓存等,在此不做限定。There are multiple computing unit clusters (GPU clusters) on the GPU, and each computing unit cluster has multiple computing units inside. The local cache (Local Cache) can be considered as the first-level cache, which is only accessed by the corresponding computing unit cluster. In Figure 1, it includes K+1 computing unit clusters (computing unit cluster 0 to computing unit cluster K), and K+1 local caches corresponding to the K+1 computing unit clusters (local cache 0 to local Cache K). Wherein, the local cache may also be called a local cache, a level 1 cache, an L1 cache, etc., which is not limited here.

联通模块(interconnect)可以用于将请求传递给对应的外部存储区块。The interconnect module (interconnect) can be used to pass the request to the corresponding external storage block.

共享缓存(Shared Cache)可以认为是第二级缓存。共享缓存可以被所有运算单元集群访问。其中,共享缓存也可以称为2级缓存、L2缓存、全局缓存等,在此不做限定。在图1中,包括L+1个共享缓存通道,分别为共享缓存通道0至共享缓存通道L。Shared cache (Shared Cache) can be considered as a second-level cache. The shared cache can be accessed by all computing unit clusters. Wherein, the shared cache may also be called level 2 cache, L2 cache, global cache, etc., which is not limited here. In FIG. 1 , there are L+1 shared cache channels, which are shared cache channel 0 to shared cache channel L respectively.

另外,在图1中,包括L+1个DRAM存储体(Dynamic Random Access Memory bank,动态随机存取内存存储体),分别为DRAM存储体0至DRAM存储体L。In addition, in FIG. 1 , it includes L+1 DRAM banks (Dynamic Random Access Memory banks, dynamic random access memory banks), which are DRAM banks 0 to DRAM banks L respectively.

其中,共享缓存通道与DRAM存储体之间可以是一对一或多对一的关系。Wherein, there may be a one-to-one or many-to-one relationship between the shared cache channel and the DRAM memory bank.

由于GPU可以并行处理很多运算或者应用,这些运算和应用的数据局部性并不一定相同,因此对缓存的要求也不同,甚至应用之间没有数据共享,那么都放在共享缓存里反而会影响运行效率。Since the GPU can process many operations or applications in parallel, the data locality of these operations and applications is not necessarily the same, so the requirements for the cache are also different. Even if there is no data sharing between applications, putting them in the shared cache will affect the operation. efficiency.

由于共享缓存可能被多线程、多核心或者多个不同的应用共同使用,而每个应用需要的缓存大小或者数据特性都有差别,因此最好可以区别对待,避免冲突,合理分配缓存资源。相关技术采用按路数划分(way partitioning)的方式,将不同的路分配给不同的应用。表2示出了组相连映射的另一示例性的实现方式。在表2所示的实现方式中,将缓存分为M+1组,每个组包括4个路。Since the shared cache may be used by multiple threads, multiple cores, or multiple different applications, and the cache size or data characteristics required by each application are different, it is best to treat them differently to avoid conflicts and allocate cache resources reasonably. The related technology adopts a method of way partitioning (way partitioning) to allocate different ways to different applications. Table 2 shows another exemplary implementation of group associative mapping. In the implementation manner shown in Table 2, the cache is divided into M+1 groups, and each group includes 4 ways.

表2Table 2

路 #0road #0 路 #1road #1 路 #2road #2 路 #3road #3 组 #0Group #0 数据data 数据data 数据data 数据data 数据data 数据data 数据data 数据data 组 #MGroup #M 数据data 数据data 数据data 数据data

在一个按路数划分的示例中,路0和路1只存应用A的数据,路2只存应用B的数据,路3只存应用C的数据。这样不同应用不会互相影响。In an example divided by the number of ways, way 0 and way 1 only store data of application A, way 2 only stores data of application B, way 3 only stores data of application C. This way different applications will not interfere with each other.

在这种按路数划分的方式的实际物理实现中,每组中路的数量是有限的(每组包含的路的数量通常不超过16个或32个),当请求者的数量过多,超过路的数量时(在GPU应用中很普遍),按路分配就产生了局限性,导致资源无法合理分配。In the actual physical implementation of this method divided by the number of ways, the number of ways in each group is limited (the number of ways in each group usually does not exceed 16 or 32), when the number of requesters exceeds When the number of ways is large (common in GPU applications), allocation by way has limitations, resulting in unreasonable allocation of resources.

本公开实施例提供了一种缓存资源分配方法,处理器系统包括至少两级缓存,所述至少两级缓存中的最高级为共享缓存,所述共享缓存包括多个共享缓存组,通过响应于来自于任一应用的第一数据请求,获取所述第一数据请求携带的第一标识信息,并响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分配预设数量的共享缓存组,由此基于组进行共享缓存资源的分配。由于组的数量比路的数量多(例如,共享缓存包括多个共享缓存通道,每个共享缓存通道包括256组,而组包含的路的数量通常不超过16个或32个),因此,基于组进行共享缓存资源的分配,能够更容易实现共享缓存资源的合理分配,并能够提高共享缓存资源的利用率。An embodiment of the present disclosure provides a cache resource allocation method. The processor system includes at least two levels of cache, the highest level of the at least two levels of cache is a shared cache, and the shared cache includes multiple shared cache groups. By responding to A first data request from any application, acquiring first identification information carried in the first data request, and responding to the fact that the first data request is a data request corresponding to the first identification information received for the first time, A preset number of shared cache groups are allocated to the first identification information, so that shared cache resources are allocated based on groups. Since the number of groups is larger than the number of ways (for example, a shared cache includes multiple shared cache channels, each shared cache channel includes 256 groups, and the number of ways contained in a group usually does not exceed 16 or 32), therefore, based on The group allocates the shared cache resource, which can more easily realize the reasonable allocation of the shared cache resource, and can improve the utilization rate of the shared cache resource.

下面结合附图对本公开实施例提供的缓存资源分配方法进行详细的说明。The method for allocating cache resources provided by the embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.

图2示出本公开实施例提供的缓存资源分配方法的流程图。所述缓存资源分配方法用于对缓存(Cache)的资源进行分配。在一种可能的实现方式中,所述缓存资源分配方法的执行主体可以是缓存资源分配装置,例如,所述缓存资源分配方法可以由终端设备或服务器或其它电子设备执行。其中,终端设备可以是用户设备(User Equipment,UE)、移动设备、用户终端、终端、蜂窝电话、无绳电话、个人数字助理(Personal Digital Assistant,PDA)、手持设备、计算设备、车载设备或者可穿戴设备等。在一些可能的实现方式中,所述缓存资源分配方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。如图2所示,所述缓存资源分配方法包括步骤S21至步骤S22。Fig. 2 shows a flow chart of a cache resource allocation method provided by an embodiment of the present disclosure. The cache resource allocation method is used to allocate cache (Cache) resources. In a possible implementation manner, the cache resource allocation method may be executed by a cache resource allocation apparatus, for example, the cache resource allocation method may be executed by a terminal device or a server or other electronic equipment. Wherein, the terminal device may be user equipment (User Equipment, UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (Personal Digital Assistant, PDA), handheld device, computing device, vehicle-mounted device, or Wearable equipment etc. In some possible implementation manners, the method for allocating cache resources may be implemented in a manner in which a processor invokes computer-readable instructions stored in a memory. As shown in FIG. 2 , the cache resource allocation method includes steps S21 to S22.

在步骤S21中,响应于来自于任一应用的第一数据请求,获取所述第一数据请求携带的第一标识信息。In step S21, in response to a first data request from any application, first identification information carried in the first data request is acquired.

在步骤S22中,响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分配预设数量的共享缓存组。In step S22, in response to the first data request being a data request corresponding to the first identification information received for the first time, assigning a preset number of shared cache groups to the first identification information.

在本公开实施例中,处理器系统包括至少两级缓存,所述至少两级缓存中的最高级为共享缓存,所述共享缓存包括多个共享缓存组。In an embodiment of the present disclosure, the processor system includes at least two levels of cache, the highest level of the at least two levels of cache is a shared cache, and the shared cache includes multiple shared cache groups.

其中,所述处理器系统可以为GPU(Graphics Processing Unit,图形处理器)系统或者CPU(Central Processing Unit,中央处理器)系统,在此不做限定。在下文中,以所述处理器系统为GPU系统为例进行说明。Wherein, the processor system may be a GPU (Graphics Processing Unit, graphics processing unit) system or a CPU (Central Processing Unit, central processing unit) system, which is not limited herein. In the following, description will be made by taking the processor system as an example of a GPU system.

在一种可能的实现方式中,所述处理器系统可以包括两级缓存。其中,第一级缓存可以为本地缓存,第二级缓存可以为共享缓存。In a possible implementation manner, the processor system may include a two-level cache. Wherein, the first-level cache may be a local cache, and the second-level cache may be a shared cache.

在另一种可能的实现方式中,所述处理器系统可以包括三级缓存。其中,第一级缓存和第二级缓存可以为本地缓存,第三级缓存可以为共享缓存。In another possible implementation manner, the processor system may include a L3 cache. Wherein, the first-level cache and the second-level cache may be local caches, and the third-level cache may be a shared cache.

在本公开实施例中,共享缓存可以包括至少一个通道,即,共享缓存可以包括至少一个共享缓存通道。其中,共享缓存通道表示共享缓存的通道。任一共享缓存通道能够被不同的运算单元集群访问。In the embodiment of the present disclosure, the shared cache may include at least one channel, that is, the shared cache may include at least one shared cache channel. Wherein, the shared cache channel indicates a shared cache channel. Any shared cache channel can be accessed by different computing unit clusters.

在一种可能的实现方式中,共享缓存可以包括多个共享缓存通道。例如,共享缓存通道的数量可以为16、24、32、48等等,在此不做限定。在该实现方式中,每个共享缓存通道可以分别包括多个组(set),即,每个共享缓存通道可以分别包括多个共享缓存组。例如,每个共享缓存通道可以分别包括256个共享缓存组。In a possible implementation manner, the shared cache may include multiple shared cache channels. For example, the number of shared cache channels may be 16, 24, 32, 48, etc., which is not limited here. In this implementation, each shared cache channel may include multiple sets (sets), that is, each shared cache channel may include multiple shared cache sets. For example, each shared cache channel may respectively include 256 shared cache groups.

在本公开实施例中,每个共享缓存组可以分别包括多个路(way)。例如,每个共享缓存组中的路的数量可以为4、8、16、32等等。In the embodiment of the present disclosure, each shared cache group may include multiple ways (way). For example, the number of ways in each shared cache group can be 4, 8, 16, 32, and so on.

在本公开实施例中,第一数据请求可以为任一应用发出的任一数据请求。第一标识信息可以标识第一数据请求携带的标识信息。In this embodiment of the present disclosure, the first data request may be any data request sent by any application. The first identification information may identify the identification information carried in the first data request.

任一应用可以发出大量的数据请求。同一应用发出的不同数据请求携带的标识信息可以不同,也可以相同。不同应用发出的不同数据请求携带的标识信息可以不同,也可以相同。Any application can make a large number of data requests. The identification information carried in different data requests sent by the same application may be different or the same. The identification information carried in different data requests sent by different applications may be different or the same.

在一种可能的实现方式中,所述第一标识信息包括以下任意一项:根据所述应用调用的模块确定的标识信息、根据上下文的标识信息确定的标识信息、根据所述第一数据请求所请求的目标数据在内存中的地址区间确定的标识信息。In a possible implementation manner, the first identification information includes any one of the following: identification information determined according to the module called by the application, identification information determined according to the identification information of the context, and information determined according to the first data request The identification information determined by the address range of the requested target data in the memory.

作为该实现方式的一个示例,可以根据应用调用的模块确定数据请求的标识信息。以GPU为例,应用调用的GPU模块可以包括GPU中处理坐标变换的专用单元、GPU中负责纹理压缩的专用单元等等,在此不做限定。在该示例中,在同一应用调用同一模块发出两个数据请求时,该两个数据请求的标识信息相同;在同一应用调用两个不同的模块发出两个数据请求时,该两个数据请求的标识信息不同;在两个应用调用同一模块分别发出数据请求时,该两个数据请求的标识信息相同;在两个应用调用两个不同的模块分别发出数据请求时,该两个数据请求的标识信息不同。例如,应用A1调用模块M1发出的第一数据请求与应用A1调用模块M1发出的第二数据请求的标识信息相同,应用A1调用模块M1发出的第一数据请求与应用A1调用模块M2发出的第三数据请求的标识信息不同,应用A1调用模块M1发出的第一数据请求与应用A2调用模块M1发出的第四数据请求的标识信息相同,应用A1调用模块M1发出的第一数据请求与应用A2调用模块M2发出的第五数据请求的标识信息不同。As an example of this implementation manner, the identification information of the data request may be determined according to the module called by the application. Taking the GPU as an example, the GPU module invoked by the application may include a dedicated unit in the GPU for processing coordinate transformation, a dedicated unit in the GPU for texture compression, etc., which are not limited here. In this example, when the same application calls the same module to send two data requests, the identification information of the two data requests is the same; when the same application calls two different modules to send two data requests, the identification information of the two data requests The identification information is different; when two applications call the same module to issue data requests respectively, the identification information of the two data requests is the same; when two applications call two different modules to issue data requests respectively, the identification information of the two data requests The information is different. For example, the identification information of the first data request sent by the application A1 calling the module M1 is the same as the identification information of the second data request sent by the application A1 calling the module M1, and the first data request sent by the application A1 calling the module M1 is the same as the first data request sent by the application A1 calling the module M2. The identification information of the three data requests is different. The identification information of the first data request issued by application A1 calling module M1 is the same as the identification information of the fourth data request issued by application A2 calling module M1. The first data request issued by application A1 calling module M1 is the same as that of application A2. The identification information of the fifth data request sent by the calling module M2 is different.

作为该实现方式的另一个示例,可以根据上下文的标识信息,确定数据请求的标识信息。在该示例中,上下文的标识信息可以指应用的标识信息。在该示例中,同一应用发出的不同数据请求的标识信息相同,不同应用发出的数据请求的标识信息不同。As another example of this implementation manner, the identification information of the data request may be determined according to the identification information of the context. In this example, the identification information of the context may refer to the identification information of the application. In this example, different data requests sent by the same application have the same identification information, and data requests sent by different applications have different identification information.

作为该实现方式的另一个示例,可以根据数据请求所请求的目标数据在内存中的地址区间,确定数据请求的标识信息。不同应用可以访问内存中的同一段地址,因此,不同应用发出的数据请求的标识信息可能相同。同一应用可以访问内存中的不同地址,因此,同一应用发出的不同数据请求的标识信息可能不同。As another example of this implementation manner, the identification information of the data request may be determined according to the address range of the target data requested by the data request in the memory. Different applications can access the same address in the memory, therefore, the identification information of data requests sent by different applications may be the same. The same application can access different addresses in the memory, therefore, the identification information of different data requests issued by the same application may be different.

在该实现方式中,通过根据所述应用调用的模块确定第一标识信息,或者根据上下文的标识信息确定第一标识信息,或者根据所述第一数据请求所请求的目标数据在内存中的地址区间确定第一标识信息,由此能够合理地确定数据请求的标识信息,从而有助于实现更合理的共享缓存资源的分配。In this implementation, the first identification information is determined according to the module called by the application, or the first identification information is determined according to the identification information of the context, or the address in the memory of the target data requested by the first data request The interval determines the first identification information, so that the identification information of the data request can be reasonably determined, thereby helping to achieve a more reasonable allocation of shared cache resources.

尽管以上实现方式介绍了数据请求的标识信息的确定方式如上,但本领域技术人员能够理解,本公开应不限于此。本领域技术人员可以根据实际应用场景需求和/或个人喜好灵活确定数据请求的标识信息的确定方式。Although the above implementation manners describe the determination manner of the identification information of the data request as above, those skilled in the art can understand that the present disclosure should not be limited thereto. Those skilled in the art may flexibly determine the manner of determining the identification information of the data request according to actual application scenario requirements and/or personal preferences.

在一种可能的实现方式中,所述共享缓存包括多个共享缓存通道;所述响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分配预设数量的共享缓存组,包括:响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分别分配所述多个共享缓存通道中的预设数量的共享缓存组。In a possible implementation manner, the shared cache includes multiple shared cache channels; the first data request corresponding to the first identification information received in response to the first data request sends the Allocating a preset number of shared cache groups with one piece of identification information includes: in response to the first data request being a data request corresponding to the first identification information received for the first time, allocating the multiple cache groups to the first identification information respectively A preset number of shared cache groups in each shared cache channel.

例如,所述共享缓存包括16个共享缓存通道,分别为共享缓存通道0至共享缓存通道15,那么,可以响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分别分配所述16个共享缓存通道中的预设数量的共享缓存组。For example, the shared cache includes 16 shared cache channels, namely shared cache channel 0 to shared cache channel 15, then, in response to the first data request, the data corresponding to the first identification information received for the first time may be The request is to allocate a preset number of shared cache groups among the 16 shared cache channels to the first identification information.

在该实现方式中,通过响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分别分配所述多个共享缓存通道中的预设数量的共享缓存组,由此有利于平衡每个共享缓存通道得到的请求。In this implementation manner, by responding to the first data request being a data request corresponding to the first identification information received for the first time, the first identification information is respectively allocated to the first identification information in the plurality of shared cache channels. Set the number of shared cache groups, which is beneficial to balance the requests obtained by each shared cache channel.

作为该实现方式的一个示例,所述预设数量包括第一预设数量和第二预设数量,且所述第一预设数量小于所述第二预设数量;所述响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分别分配所述多个共享缓存通道中的预设数量的共享缓存组,包括:响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,其中,所述第一参照共享缓存通道表示所述第一标识信息对应的参照共享缓存通道(reference cache);向所述第一标识信息分配第一普通共享缓存通道中的所述第一预设数量的共享缓存组,并向所述第一标识信息分配所述第一参照共享缓存通道中的所述第二预设数量的共享缓存组,其中,所述第一普通共享缓存通道表示所述多个共享缓存通道中除所述第一参照共享缓存通道以外的共享缓存通道。As an example of this implementation, the preset number includes a first preset number and a second preset number, and the first preset number is smaller than the second preset number; the response to the first A data request is a data request corresponding to the first identification information received for the first time, assigning a preset number of shared cache groups in the plurality of shared cache channels to the first identification information, including: responding to the The first data request is a data request corresponding to the first identification information received for the first time, and the first reference shared cache channel corresponding to the first identification information is determined from the plurality of shared cache channels, wherein the The first reference shared cache channel indicates a reference shared cache channel (reference cache) corresponding to the first identification information; assigning the first preset number of shares in the first common shared cache channel to the first identification information Cache groups, and allocate the second preset number of shared cache groups in the first reference shared cache channel to the first identification information, wherein the first common shared cache channel represents the plurality of shared cache groups Shared cache channels in cache channels other than the first reference shared cache channel.

在该示例中,第二预设数量可以为第一预设数量的2倍、1.5倍、3倍等,在此不做限定。第一预设数量可以表示普通共享缓存通道对应的预设数量,第二预设数量可以表示参照共享缓存通道对应的预设数量。第一参照共享缓存通道可以表示第一标识信息对应的参照共享缓存通道。不同标识信息对应的参照共享缓存通道可以不同。任一标识信息对应的参照共享缓存通道的数量可以为一个或两个以上。例如,任一标识信息对应的参照共享缓存通道的数量可以为一个。对于任一标识信息,普通共享缓存通道可以表示除该标识信息对应的参照共享缓存通道以外的共享缓存通道。例如,共享缓存通道的数量为16个,参照共享缓存通道的数量为1个,则普通共享缓存通道的数量为15个。In this example, the second preset amount may be 2 times, 1.5 times, 3 times, etc. of the first preset amount, which is not limited here. The first preset number may indicate a preset number corresponding to a common shared cache channel, and the second preset number may indicate a preset number corresponding to a reference shared cache channel. The first reference shared cache channel may indicate a reference shared cache channel corresponding to the first identification information. The reference shared cache channels corresponding to different identification information may be different. The number of reference shared cache channels corresponding to any identification information may be one or more than two. For example, the number of reference shared cache channels corresponding to any piece of identification information may be one. For any identification information, a common shared cache channel may represent a shared cache channel other than the reference shared cache channel corresponding to the identification information. For example, if the number of shared cache channels is 16, and the number of reference shared cache channels is 1, then the number of common shared cache channels is 15.

在一个例子中,第一预设数量为16,第二预设数量为32。在这个例子中,各个第一普通共享缓存通道可以分别为第一标识信息分配16个共享缓存组,第一参照共享缓存通道可以分别为第一标识信息分配32个共享缓存组。In one example, the first preset number is 16, and the second preset number is 32. In this example, each first common shared cache channel may allocate 16 shared cache groups for the first identification information, and the first reference shared cache channel may allocate 32 shared cache groups for the first identification information.

在该示例中,通过响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,向所述第一标识信息分配第一普通共享缓存通道中的所述第一预设数量的共享缓存组,并向所述第一标识信息分配所述第一参照共享缓存通道中的所述第二预设数量的共享缓存组,由此能够基于参照共享缓存通道确定第一标识信息对应的数据请求所需的共享缓存资源的大小情况,从而有利于提高共享缓存的利用率。In this example, by responding to the first data request being a data request corresponding to the first identification information received for the first time, from the multiple shared cache channels, determine the first data request corresponding to the first identification information A reference shared cache channel, assigning the first preset number of shared cache groups in the first common shared cache channel to the first identification information, and assigning the first reference shared cache to the first identification information The second preset number of shared cache groups in the channel can thereby determine the size of the shared cache resource required by the data request corresponding to the first identification information based on the reference to the shared cache channel, thereby helping to improve the utilization of the shared cache Rate.

在一个示例中,所述响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,包括:响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,且所述多个共享缓存通道中存在未被确定为参照共享缓存通道的共享缓存通道,从所述未被确定为参照共享缓存通道的共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道。In an example, the response to the first data request is a data request corresponding to the first identification information received for the first time, and from the plurality of shared cache channels, determine the The first reference shared cache channel, including: responding to the first data request being a data request corresponding to the first identification information received for the first time, and there is one of the multiple shared cache channels that is not determined to be a reference shared cache The shared cache channel of the channel determines the first reference shared cache channel corresponding to the first identification information from the shared cache channels not determined as the reference shared cache channel.

在该示例中,对于不同的标识信息,参照共享缓存通道的选取应尽量均衡。例如,共4个共享缓存通道和3个数据请求的标识信息。其中,4个共享缓存通道分别为共享缓存通道0、共享缓存通道1、共享缓存通道2和共享缓存通道3,3个数据请求的标识信息分别为第一标识信息(ID0)、第二标识信息(ID1)和第三标识信息(ID2)。例如,在针对第一标识信息选取共享缓存通道2作为参照共享缓存通道之后,在针对第二标识信息选取参照共享缓存通道时,可以避开共享缓存通道2,例如选取共享缓存通道3作为参照共享缓存通道。在针对第三标识信息选取参照共享缓存通道时,可以避开共享缓存通道2和共享缓存通道3,例如选择共享缓存通道0或共享缓存通道1作为参照共享缓存通道。In this example, for different identification information, selection of reference shared cache channels should be as balanced as possible. For example, identification information of 4 shared cache channels and 3 data requests. Among them, the four shared cache channels are shared cache channel 0, shared cache channel 1, shared cache channel 2, and shared cache channel 3, and the identification information of the three data requests is the first identification information (ID0) and the second identification information (ID1) and third identification information (ID2). For example, after the shared cache channel 2 is selected as the reference shared cache channel for the first identification information, when the reference shared cache channel is selected for the second identification information, the shared cache channel 2 can be avoided, for example, the shared cache channel 3 can be selected as the reference shared cache channel. cache channel. When selecting the reference shared cache channel for the third identification information, shared cache channel 2 and shared cache channel 3 may be avoided, for example, shared cache channel 0 or shared cache channel 1 is selected as the reference shared cache channel.

在该示例中,通过响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,且所述多个共享缓存通道中存在未被确定为参照共享缓存通道的共享缓存通道,从所述未被确定为参照共享缓存通道的共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,由此能够提高共享缓存资源的利用率。In this example, by responding to the first data request is the data request corresponding to the first identification information received for the first time, and among the multiple shared cache channels there is a shared The cache channel determines the first reference shared cache channel corresponding to the first identification information from the shared cache channels not determined as the reference shared cache channel, thereby improving the utilization rate of shared cache resources.

在另一个示例中,所述响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,包括:响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,将所述多个共享缓存通道中剩余容量最大的共享缓存通道,确定为所述第一标识信息对应的第一参照共享缓存通道。In another example, the response to the first data request is a data request corresponding to the first identification information received for the first time, and determining from the multiple shared cache channels that the first identification information corresponds to The first reference shared cache channel includes: in response to the first data request being the data request corresponding to the first identification information received for the first time, assigning the shared cache channel with the largest remaining capacity among the multiple shared cache channels , determine as the first reference shared cache channel corresponding to the first identification information.

在另一个示例中,所述响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,包括:响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,随机选取所述第一标识信息对应的第一参照共享缓存通道。In another example, the response to the first data request is a data request corresponding to the first identification information received for the first time, and determining from the multiple shared cache channels that the first identification information corresponds to The first reference shared cache channel includes: in response to the first data request being a data request corresponding to the first identification information received for the first time, randomly selecting the first shared cache channel from the plurality of shared cache channels The first reference shared cache channel corresponding to the identification information.

在另一个示例中,对于不同的标识信息,可以按顺序选取参照共享缓存通道。例如,第一次选取共享缓存通道0作为参照共享缓存通道,第二次选取共享缓存通道1作为参照共享缓存通道,第三次选取共享缓存通道2作为参照共享缓存通道,以此类推。In another example, for different identification information, reference shared cache channels may be selected sequentially. For example, for the first time, shared buffer channel 0 is selected as the reference shared buffer channel, for the second time, shared buffer channel 1 is selected as the reference shared buffer channel, for the third time, shared buffer channel 2 is selected as the reference shared buffer channel, and so on.

在一个示例中,所述方法还包括:获取所述第一参照共享缓存通道针对所述第一标识信息的第一命中率,以及所述第一普通共享缓存通道针对所述第一标识信息的第二命中率;根据所述第一命中率和所述第二命中率,调节分配给所述第一标识信息的共享缓存组的数量。In an example, the method further includes: obtaining a first hit rate of the first reference shared cache channel for the first identification information, and a hit ratio of the first common shared cache channel for the first identification information A second hit rate: adjusting the number of shared cache groups allocated to the first identification information according to the first hit rate and the second hit rate.

在该示例中,可以以预设频率统计第一命中率和第二命中率,从而可以以预设频率调节分配给各个标识信息的共享缓存资源。In this example, the first hit rate and the second hit rate may be counted at a preset frequency, so that shared cache resources allocated to each piece of identification information may be adjusted at a preset frequency.

在该示例中,在普通共享缓存通道的数量为多个的情况下,可以将各个普通共享缓存通道针对第一标识信息的命中率的平均值或者中位数,确定为第二命中率。In this example, when there are multiple common shared cache channels, the average or median of the hit rates of each common shared cache channel with respect to the first identification information may be determined as the second hit rate.

在该示例中,通过获取所述第一参照共享缓存通道针对所述第一标识信息的第一命中率,以及所述第一普通共享缓存通道针对所述第一标识信息的第二命中率,并根据所述第一命中率和所述第二命中率,调节分配给所述第一标识信息的共享缓存组的数量,由此基于第一参照共享缓存通道和第一普通共享缓存通道的性能差异,动态调节分配给第一标识信息的共享缓存资源,从而能够进一步提高共享缓存资源的利用率,提高不同应用的运行效率。In this example, by obtaining the first hit rate of the first reference shared cache channel for the first identification information and the second hit rate of the first common shared cache channel for the first identification information, And according to the first hit rate and the second hit rate, adjust the number of shared cache groups allocated to the first identification information, thereby based on the performance of the first reference shared cache channel and the first common shared cache channel difference, and dynamically adjust the shared cache resource allocated to the first identification information, thereby further improving the utilization rate of the shared cache resource and improving the operating efficiency of different applications.

在一个例子中,所述根据所述第一命中率和所述第二命中率,调节分配给所述第一标识信息的共享缓存组的数量,包括:确定所述第一命中率与所述第二命中率的比值;响应于所述比值大于或等于第一预设阈值,增大所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;或者,响应于所述比值小于或等于第二预设阈值,减少所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;其中,所述第一预设阈值大于所述第二预设阈值,且所述第一预设阈值和所述第二预设阈值均大于1。In an example, the adjusting the number of shared cache groups allocated to the first identification information according to the first hit rate and the second hit rate includes: determining the first hit rate and the second hit rate The ratio of the second hit rate; in response to the ratio being greater than or equal to a first preset threshold, increasing the number of shared cache groups allocated to the first identification information in the plurality of shared cache channels; or, in response to The ratio is less than or equal to a second preset threshold, and the number of shared cache groups allocated to the first identification information in the plurality of shared cache channels is reduced; wherein, the first preset threshold is greater than the second A preset threshold, and both the first preset threshold and the second preset threshold are greater than 1.

其中,第一预设阈值和第二预设阈值可以通过寄存器配置。第二预设阈值可以略大于1。Wherein, the first preset threshold and the second preset threshold can be configured through registers. The second preset threshold may be slightly greater than 1.

由于第一标识信息在第一参照共享缓存通道中分配得到的共享缓存组的数量大于第一标识信息在第一普通共享缓存通道中分配得到的共享缓存组的数量,因此,若更多的共享缓存资源带来了显著更高的命中率(例如所述比值大于或等于第一预设阈值),则可以认为缓存资源的增加对提高命中率有明显收益,进而可以考虑增加针对第一标识信息的缓存空间。若更多的共享缓存资源并未带来明显的命中率的增加(例如所述比值小于或等于第二预设阈值),则可以认为缓存资源的增加对提高命中率无益,进而可以减少分配给第一标识信息的共享缓存资源。Since the number of shared cache groups allocated by the first identification information in the first reference shared cache channel is greater than the number of shared cache groups allocated by the first identification information in the first common shared cache channel, if more shared If the cache resource brings a significantly higher hit rate (for example, the ratio is greater than or equal to the first preset threshold), it can be considered that the increase in the cache resource has obvious benefits for improving the hit rate, and then it can be considered to increase the first identification information. cache space. If more shared cache resources do not bring about a significant increase in the hit rate (for example, the ratio is less than or equal to the second preset threshold), it can be considered that the increase in cache resources is not beneficial to the increase in the hit rate, and then the allocation to A shared cache resource of the first identification information.

在上述例子中,在所述比值小于第一预设阈值且大于第二预设阈值的情况下,可以不改变第一标识信息对应的共享缓存组的数量。In the above example, when the ratio is smaller than the first preset threshold and larger than the second preset threshold, the number of shared cache groups corresponding to the first identification information may not be changed.

另外,在缓存资源的分配变更时,为了维护数据一致性,可以采用额外的缓存维护操作,例如清空缓存操作(flush操作)、清除操作(invalidate)等。In addition, when the allocation of cache resources is changed, in order to maintain data consistency, additional cache maintenance operations, such as clearing the cache (flush operation) and clearing (invalidate), can be used.

在上述例子中,通过确定所述第一命中率与所述第二命中率的比值,响应于所述比值大于或等于第一预设阈值,增大所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量,或者,响应于所述比值小于或等于第二预设阈值,减少所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量,其中,所述第一预设阈值大于所述第二预设阈值,且所述第一预设阈值和所述第二预设阈值均大于1,由此能够进一步提高共享缓存资源的利用率。In the above example, by determining the ratio of the first hit rate to the second hit rate, in response to the ratio being greater than or equal to a first preset threshold, increasing the The number of shared cache groups of the first identification information, or, in response to the ratio being less than or equal to a second preset threshold, reducing the number of shared cache groups allocated to the first identification information among the plurality of shared cache channels quantity, wherein, the first preset threshold is greater than the second preset threshold, and both the first preset threshold and the second preset threshold are greater than 1, thereby further improving the utilization of shared cache resources Rate.

在一种可能的实现方式中,所述方法还包括:获取所述第一数据请求对应的第一请求地址;响应于根据所述第一请求地址确定在本地缓存中发生缓存缺失,获取所述第一标识信息对应的组掩码、组偏移和标志位偏移量;根据所述第一数据请求对应的第二请求地址、所述组掩码、所述组偏移和所述标志位偏移量,确定所述第一数据请求对应的新组位和新标签信息,其中,所述第二请求地址根据所述第一请求地址确定;根据所述第二请求地址中的通道信息和行内偏移地址,以及所述新组位和所述新标签信息,查找目标数据。In a possible implementation, the method further includes: obtaining a first request address corresponding to the first data request; in response to determining that a cache miss occurs in the local cache according to the first request address, obtaining the The group mask, group offset and flag bit offset corresponding to the first identification information; according to the second request address corresponding to the first data request, the group mask, the group offset and the flag bit The offset is to determine the new set of bits and new tag information corresponding to the first data request, wherein the second request address is determined according to the first request address; according to the channel information and The offset address within the row, as well as the new group bits and the new tag information, are used to find the target data.

在该实现方式中,第一请求地址可以表示第一数据请求携带的请求地址。第一请求地址可以为虚拟地址或物理地址。In this implementation manner, the first request address may indicate the request address carried in the first data request. The first request address may be a virtual address or a physical address.

作为该实现方式的一个示例,可以从ID-缓存组映射表中,获取第一标识信息对应的组掩码(set mask)、组偏移(set offset)和标志位偏移量(tag shift)。其中,组掩码可以用于确定分配给第一标识信息的共享缓存组的数量。例如,组掩码set mask=0x0f,可以表示分配给第一标识信息的共享缓存组的数量为16。组偏移可以表示分配给第一标识信息的共享缓存组的起始位置。例如,组偏移set offset=0x10,可以表示第一标识信息的共享缓存组的起始位置为共享缓存通道中的第17组。标志位偏移量可以用于确定标签的移位量。As an example of this implementation, the set mask (set mask), set offset (set offset) and tag shift (tag shift) corresponding to the first identification information may be obtained from the ID-cache group mapping table . Wherein, the group mask may be used to determine the number of shared cache groups allocated to the first identification information. For example, the group mask set mask=0x0f may indicate that the number of shared cache groups allocated to the first identification information is 16. The group offset may indicate the starting position of the shared cache group allocated to the first identification information. For example, the group offset set offset=0x10 may indicate that the starting position of the shared cache group of the first identification information is the 17th group in the shared cache channel. The flag bit offset can be used to determine the shift amount of the label.

在该实现方式中,新组位表示用于存储第一数据请求所请求的目标数据的组位。新标签信息可以表示目标数据对应的新的标签信息。新标签信息可以存储在目标数据对应的共享缓存组中,以用于后续缓存查找及命中与否的判断。In this implementation, the new group bit indicates the group bit used to store the target data requested by the first data request. The new tag information may represent new tag information corresponding to the target data. The new tag information can be stored in the shared cache group corresponding to the target data for subsequent cache lookup and hit-or-miss judgment.

在该实现方式中,不同标识信息对应的组掩码的大小可以相同,也可以不同。例如,各个标识信息对应的组掩码均为0x0f。又如,数据请求可以携带共享缓存组的请求大小,并可以根据该请求大小确定分配给该数据请求的标识信息的共享缓存组的数量。In this implementation manner, the sizes of group masks corresponding to different identification information may be the same or different. For example, the group mask corresponding to each identification information is 0x0f. For another example, the data request may carry the request size of the shared cache group, and the number of shared cache groups assigned to the identification information of the data request may be determined according to the request size.

在该实现方式中,通过获取所述第一数据请求对应的第一请求地址,响应于根据所述第一请求地址确定在本地缓存中发生缓存缺失,获取所述第一标识信息对应的组掩码、组偏移和标志位偏移量,根据所述第一数据请求对应的第二请求地址、所述组掩码、所述组偏移和所述标志位偏移量,确定所述第一数据请求对应的新组位和新标签信息,其中,所述第二请求地址根据所述第一请求地址确定,根据所述第二请求地址中的通道信息和行内偏移地址,以及所述新组位和所述新标签信息,查找目标数据,由此能够实现基于数据请求的标识信息进行共享缓存组的分配。In this implementation, by acquiring the first request address corresponding to the first data request, in response to determining that a cache miss occurs in the local cache according to the first request address, the group mask corresponding to the first identification information is acquired code, group offset, and flag bit offset, and determine the first data request according to the second request address corresponding to the first data request, the group mask, the group offset, and the flag bit offset A new set of bits and new label information corresponding to a data request, wherein the second request address is determined according to the first request address, according to the channel information and the in-row offset address in the second request address, and the The new group bit and the new tag information are used to search for the target data, thereby realizing the allocation of the shared cache group based on the identification information of the data request.

作为该实现方式的一个示例,所述方法还包括:对所述第一请求地址进行重映射,得到所述第二请求地址。As an example of this implementation manner, the method further includes: remapping the first request address to obtain the second request address.

在一个例子中,可以通过地址交织和哈希运算,将GPU发出的地址(即数据请求携带的请求地址)打乱,以平均分配给不同的共享缓存通道。In an example, the addresses sent by the GPU (that is, the request addresses carried in the data requests) can be scrambled through address interleaving and hash operations, so as to be evenly allocated to different shared cache channels.

在该示例中,通过对所述第一请求地址进行重映射,得到所述第二请求地址,由此能够平衡每个共享缓存通道得到的请求,提高共享缓存资源的利用率。In this example, the second request address is obtained by remapping the first request address, so that the requests obtained by each shared cache channel can be balanced, and the utilization rate of shared cache resources can be improved.

作为该实现方式的另一个示例,第一请求地址为虚拟地址;所述方法还包括:通过内存管理单元对第一请求地址进行虚拟地址至物理地址的转换,得到第二请求地址。在该示例中,第二请求地址为物理地址。As another example of this implementation, the first request address is a virtual address; the method further includes: converting the first request address from a virtual address to a physical address by a memory management unit to obtain the second request address. In this example, the second request address is a physical address.

作为该实现方式的另一个示例,第一请求地址为物理地址,可以直接将第一请求地址作为第二请求地址。As another example of this implementation manner, the first request address is a physical address, and the first request address may be directly used as the second request address.

作为该实现方式的一个示例,所述根据所述第一数据请求对应的第二请求地址、所述组掩码、所述组偏移和所述标志位偏移量,确定所述第一数据请求对应的新组位和新标签信息,包括:从所述第二请求地址中,获取原始组位和原始标签信息;将所述原始组位与所述组掩码进行与运算,得到所述第一数据请求所请求的目标数据在所述第一标识信息对应的多个共享缓存组中的相对位置;根据所述组偏移和所述相对位置,确定所述第一数据请求对应的新组位;根据所述原始标签信息、所述标志位偏移量和所述原始组位中的指定位,确定所述第一数据请求对应的新标签信息。As an example of this implementation, the first data is determined according to the second request address corresponding to the first data request, the group mask, the group offset and the flag bit offset Requesting corresponding new group bits and new label information includes: obtaining original group bits and original label information from the second request address; and performing an AND operation on the original group bits and the group mask to obtain the The relative position of the target data requested by the first data request in the plurality of shared cache groups corresponding to the first identification information; according to the group offset and the relative position, determine the new corresponding to the first data request Group bit: determine new tag information corresponding to the first data request according to the original tag information, the flag bit offset, and a specified bit in the original group bit.

例如,第二请求地址包括32比特,以16进制表示为0x12345678。其中,高4比特(0x1)为通道信息;第16~27比特(0x234)为原始标签信息;第8~15比特(0x56)为原始组位;低8比特(0x78)为行内偏移地址,用于确定其访问的是缓存行中的第0x78字节的数据。For example, the second request address includes 32 bits, expressed as 0x12345678 in hexadecimal. Among them, the upper 4 bits (0x1) are channel information; the 16th to 27th bits (0x234) are the original label information; the 8th to 15th bits (0x56) are the original group bits; the lower 8 bits (0x78) are the offset addresses in the row, It is used to determine its access to the 0x78th byte of data in the cache line.

例如,组掩码set mask=0x0f,组偏移set offset=0x10,标志位偏移量tag shift=0x4。For example, group mask set mask=0x0f, group offset set offset=0x10, and tag shift=0x4.

将原始组位0x56与组掩码0x0f进行与运算,可以得到第一数据请求所请求的目标数据在第一标识信息对应的多个共享缓存组中的相对位置0x06。其中,将原始组位和组掩码分别转换为二进制,得到0000010100000110和0000000011111111。0000010100000110&0000000011111111=0000000000000110,从而确定第一数据请求所请求的目标数据在第一标识信息对应的多个共享缓存组中的相对位置为0x06。By ANDing the original group bit 0x56 and the group mask 0x0f, the relative position 0x06 of the target data requested by the first data request in the plurality of shared cache groups corresponding to the first identification information can be obtained. Wherein, the original group bit and the group mask are respectively converted into binary to obtain 0000010100000110 and 0000000011111111. 0000010100000110&0000000011111111=0000000000000110, thereby determining that the target data requested by the first data request is in the multiple shared cache groups corresponding to the first identification information Relative to The location is 0x06.

将组偏移和所述相对位置相加,可以得到第一数据请求对应的新组位0x16。即,根据组掩码,选择第二请求地址中的第8~11比特作为新组位的一部分,并增加0x10的偏移。The new group bit 0x16 corresponding to the first data request can be obtained by adding the group offset and the relative position. That is, according to the group mask, the 8th to 11th bits in the second request address are selected as part of the new group bits, and an offset of 0x10 is added.

根据原始标签信息0x234、标志位偏移量0x4以及原始组位中的0x5,可以得到新标签信息0x2345。According to the original tag information 0x234, the flag bit offset 0x4 and the original group bit 0x5, the new tag information 0x2345 can be obtained.

从而,可以得到新的请求地址0x123451678。在这个例子中,新的请求地址中的第8~11比特根据第二请求地址确定,且共有16个共享缓存组分配给第一标识信息。Thus, the new request address 0x123451678 can be obtained. In this example, the 8th to 11th bits in the new request address are determined according to the second request address, and a total of 16 shared cache groups are allocated to the first identification information.

在该示例中,通过从所述第二请求地址中,获取原始组位和原始标签信息,将所述原始组位与所述组掩码进行与运算,得到所述第一数据请求所请求的目标数据在所述第一标识信息对应的多个共享缓存组中的相对位置,根据所述组偏移和所述相对位置,确定所述第一数据请求对应的新组位,并根据所述原始标签信息、所述标志位偏移量和所述原始组位中的指定位,确定所述第一数据请求对应的新标签信息,由此能够实现基于数据请求的标识信息进行共享缓存组的分配,且在确定新标签信息时,保留了原始组位中的指定位,从而能够保持原始地址的完整。In this example, the original group bits and original label information are obtained from the second request address, and the original group bits are ANDed with the group mask to obtain the requested data in the first data request. The relative position of the target data in the multiple shared cache groups corresponding to the first identification information, according to the group offset and the relative position, determine the new group bit corresponding to the first data request, and according to the The original tag information, the offset of the flag bit, and the specified bit in the original group bit determine the new tag information corresponding to the first data request, so that the shared cache group can be realized based on the identification information of the data request Assignment, and when determining the new label information, the designated bit in the original group bit is retained, so that the integrity of the original address can be maintained.

图3示出本公开实施例提供的缓存资源分配方法中针对数据请求的标识信息按组分配的示意图。在图3中,请求ID表示数据请求携带的标识信息,例如第一数据请求携带的第一标识信息。可以从ID-缓存组映射表中,获取第一标识信息对应的组掩码、组偏移和标志位偏移量。在图3所示的ID-缓存组映射表中,包括ID0~IDN与组掩码、组偏移、标志位偏移量之间的映射关系。可以从请求地址(例如第二请求地址)中获取原始标签信息、原始组位和行内偏移地址。可以将原始组位与组掩码进行按位与运算,得到第一数据请求所请求的目标数据在第一标识信息对应的多个共享缓存组中的相对位置。可以将组偏移与所述相对位置相加,得到新组位。可以通过移位器对原始标签信息、标志位偏移量、原始组位中的指定位进行处理,得到新标签信息。可以根据通道信息、行内偏移地址、新组位和新标签信息,进行缓存查找。FIG. 3 shows a schematic diagram of group-by-group allocation of identification information for data requests in the method for allocating cache resources provided by an embodiment of the present disclosure. In FIG. 3 , the request ID represents the identification information carried in the data request, for example, the first identification information carried in the first data request. The group mask, group offset and flag bit offset corresponding to the first identification information may be obtained from the ID-cache group mapping table. The ID-cache group mapping table shown in FIG. 3 includes the mapping relationship between ID0~IDN and group mask, group offset, and flag bit offset. The original label information, original group bit and in-line offset address can be obtained from the request address (eg, the second request address). A bitwise AND operation may be performed on the original group bits and the group mask to obtain the relative position of the target data requested by the first data request in the plurality of shared cache groups corresponding to the first identification information. The group offset can be added to the relative position to obtain a new group bit. The original label information, the flag bit offset, and the specified bit in the original group bits can be processed by a shifter to obtain new label information. Cache lookup can be performed based on channel information, in-line offset address, new group bit, and new tag information.

需要注意的是,以上的组掩码与组偏移的定义仅为一个例子,而非唯一的定义方式。例如,还可以通过新组位=原始组位+组偏移&组掩码等方式,实现同样的按组分配的功能。It should be noted that the above definition of group mask and group offset is just an example, not the only way of definition. For example, the same group-by-group allocation function can also be realized by means of new group bit=original group bit+group offset&group mask.

作为该实现方式的一个示例,所述根据所述第二请求地址中的通道信息和行内偏移地址,以及所述新组位和所述新标签信息,查找目标数据,包括:响应于根据所述通道信息、所述新组位、所述新标签信息和所述行内偏移地址,查找不到目标数据,从内存或外存中获取所述目标数据,将所述目标数据写入所述新组位对应的共享缓存组中,并向所述第一数据请求返回所述目标数据。As an example of this implementation, the searching for the target data according to the channel information and the in-line offset address in the second request address, as well as the new group bit and the new tag information includes: responding to The channel information, the new group bit, the new label information and the offset address in the row, if the target data cannot be found, the target data is obtained from the internal memory or external storage, and the target data is written into the The new group is placed in the corresponding shared cache group, and the target data is returned to the first data request.

在该示例中,在所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求的情况下,在共享缓存通道中查找不到目标数据。此时,可以从内存或外存中获取所述目标数据,将所述目标数据写入所述新组位对应的共享缓存组中,并向所述第一数据请求返回所述目标数据。In this example, if the first data request is a data request corresponding to the first identification information received for the first time, no target data can be found in the shared cache channel. At this time, the target data may be obtained from the internal memory or external storage, written into the shared cache group corresponding to the new group bit, and returned to the first data request.

在该示例中,通过响应于根据所述通道信息、所述新组位、所述新标签信息和所述行内偏移地址,查找不到目标数据,从内存或外存中获取所述目标数据,将所述目标数据写入所述新组位对应的共享缓存组中,并向所述第一数据请求返回所述目标数据,由此能够实现将目标数据写入第一标识信息对应的共享缓存组中。In this example, the target data is obtained from internal memory or external storage in response to the fact that the target data cannot be found according to the channel information, the new group bit, the new label information and the in-row offset address , write the target data into the shared cache group corresponding to the new group bit, and return the target data to the first data request, so that the target data can be written into the shared cache group corresponding to the first identification information in the cache group.

图4示出本公开实施例提供的GPU的缓存结构的一示意图。其中,与图1重复的部分不再赘述。在图4中,可以通过地址交织和哈希运算,将GPU发出的地址(即数据请求携带的请求地址)打乱,以平均分配给不同的共享缓存通道。另外,针对数据请求携带的标识信息,可以从各个共享缓存通道中,选取所述标识信息对应的参照共享缓存通道。FIG. 4 shows a schematic diagram of a cache structure of a GPU provided by an embodiment of the present disclosure. Wherein, the part that overlaps with FIG. 1 will not be repeated here. In Figure 4, through address interleaving and hashing operations, the addresses issued by the GPU (that is, the request addresses carried by the data request) can be scrambled to be evenly allocated to different shared cache channels. In addition, for the identification information carried in the data request, a reference shared cache channel corresponding to the identification information may be selected from each shared cache channel.

图5示出本公开实施例提供的缓存查找方法的一示意图。如图5所示,可以响应于数据请求,进行本地缓存查找。若在本地缓存中命中(即,在本地缓存中查找到数据请求所请求的目标数据),则从本地缓存中取出目标数据并返回目标数据给数据请求。若在本地缓存中未命中(即,在本地缓存中发生缓存缺失),则可以通过地址交织和哈希运算,将数据请求携带的第一请求地址转换为第二请求地址。可以根据第二请求地址中的通道信息,确定目标数据对应的共享缓存通道,并可以将数据请求发送至对应的共享缓存通道。可以根据数据请求携带的标识信息,从ID-缓存组映射表中,获取对应的组掩码、组偏移和标志位偏移量。可以从第二请求地址中获取原始标签信息、原始组位和行内偏移地址。可以将原始组位与组掩码进行按位与运算,得到数据请求所请求的目标数据在所述标识信息对应的多个共享缓存组中的相对位置。可以将组偏移与所述相对位置相加,得到新组位。可以通过对原始标签信息、标志位偏移量、原始组位中的指定位进行处理,得到新标签信息。可以根据通道信息、行内偏移地址、新组位和新标签信息,在目标数据对应的共享缓存通道进行共享缓存查找。若在共享缓存中命中,则从共享缓存中取出目标数据并返回目标数据给数据请求。若在共享缓存中未命中(即缺失),则可以将数据请求发送至对应的DRAM存储体,从该DRAM存储体中取出目标数据并返回目标数据给数据请求,并可以根据缓存请求控制信号判断是否将目标数据填入缓存。FIG. 5 shows a schematic diagram of a cache lookup method provided by an embodiment of the present disclosure. As shown in Figure 5, a local cache lookup may be performed in response to a data request. If it hits in the local cache (that is, the target data requested by the data request is found in the local cache), the target data is fetched from the local cache and returned to the data request. If there is a miss in the local cache (that is, a cache miss occurs in the local cache), the first request address carried in the data request can be converted into the second request address through address interleaving and hash operation. The shared cache channel corresponding to the target data may be determined according to the channel information in the second request address, and the data request may be sent to the corresponding shared cache channel. The corresponding group mask, group offset and flag bit offset may be obtained from the ID-cache group mapping table according to the identification information carried in the data request. The original label information, the original group bit and the offset address in the row can be obtained from the second request address. A bitwise AND operation may be performed on the original group bits and the group mask to obtain the relative position of the target data requested by the data request in the plurality of shared cache groups corresponding to the identification information. The group offset can be added to the relative position to obtain a new group bit. The new tag information can be obtained by processing the original tag information, the offset of the flag bit, and the designated bit in the original group bit. A shared cache lookup can be performed on the shared cache channel corresponding to the target data according to the channel information, the in-line offset address, the new group bit and the new tag information. If it hits in the shared cache, the target data is fetched from the shared cache and returned to the data request. If there is a miss (that is, missing) in the shared cache, the data request can be sent to the corresponding DRAM storage bank, the target data is taken out from the DRAM storage bank and the target data is returned to the data request, and can be judged according to the cache request control signal Whether to fill the target data into the cache.

下面通过一个具体的应用场景说明本公开实施例提供的缓存资源分配方法。在该应用场景中,可以响应于来自于任一应用的第一数据请求,获取所述第一数据请求携带的第一标识信息。其中,所述第一标识信息包括以下任意一项:根据所述应用调用的模块确定的标识信息、根据上下文的标识信息确定的标识信息、根据所述第一数据请求所请求的目标数据在内存中的地址区间确定的标识信息。可以响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,且所述多个共享缓存通道中存在未被确定为参照共享缓存通道的共享缓存通道,从所述未被确定为参照共享缓存通道的共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,其中,所述第一参照共享缓存通道表示所述第一标识信息对应的参照共享缓存通道,向所述第一标识信息分配第一普通共享缓存通道中的所述第一预设数量的共享缓存组,并向所述第一标识信息分配所述第一参照共享缓存通道中的所述第二预设数量的共享缓存组,其中,所述第一普通共享缓存通道表示所述多个共享缓存通道中除所述第一参照共享缓存通道以外的共享缓存通道。The cache resource allocation method provided by the embodiment of the present disclosure is described below through a specific application scenario. In this application scenario, the first identification information carried in the first data request may be acquired in response to the first data request from any application. Wherein, the first identification information includes any of the following items: identification information determined according to the module called by the application, identification information determined according to the identification information of the context, and target data requested according to the first data request in the internal memory. The identification information determined by the address range in . In response to the first data request being a data request corresponding to the first identification information received for the first time, and there is a shared cache channel among the multiple shared cache channels that is not determined to refer to the shared cache channel, from the Among the shared cache channels that are not determined as reference shared cache channels, determine the first reference shared cache channel corresponding to the first identification information, where the first reference shared cache channel indicates the first reference shared cache channel corresponding to the first identification information Referring to the shared cache channel, assigning the first preset number of shared cache groups in the first common shared cache channel to the first identification information, and assigning the first reference shared cache channel to the first identification information The second preset number of shared cache groups, wherein the first common shared cache channel represents a shared cache channel other than the first reference shared cache channel among the plurality of shared cache channels.

可以响应于根据所述第一请求地址确定在本地缓存中发生缓存缺失,获取所述第一标识信息对应的组掩码、组偏移和标志位偏移量。可以通过地址交织和哈希运算,对所述第一请求地址进行重映射,得到第二请求地址。可以从所述第二请求地址中,获取原始组位和原始标签信息;将所述原始组位与所述组掩码进行与运算,得到所述第一数据请求所请求的目标数据在所述第一标识信息对应的多个共享缓存组中的相对位置;根据所述组偏移和所述相对位置,确定所述第一数据请求对应的新组位;根据所述原始标签信息、所述标志位偏移量和所述原始组位中的指定位,确定所述第一数据请求对应的新标签信息。可以根据所述第二请求地址中的通道信息和行内偏移地址,以及所述新组位和所述新标签信息,进行缓存查找。In response to determining that a cache miss occurs in the local cache according to the first request address, the group mask, group offset, and flag bit offset corresponding to the first identification information may be acquired. The second request address may be obtained by remapping the first request address through address interleaving and hash operation. The original group bit and original tag information may be obtained from the second request address; and the original group bit and the group mask are performed to obtain the target data requested by the first data request in the The relative position in the multiple shared cache groups corresponding to the first identification information; according to the group offset and the relative position, determine the new group bit corresponding to the first data request; according to the original tag information, the The offset of the flag bit and the specified bit in the original set of bits determine the new tag information corresponding to the first data request. A cache lookup may be performed according to the channel information and the in-line offset address in the second request address, as well as the new group bit and the new tag information.

可以以预设频率调节调节分配给第一标识信息的共享缓存资源。例如,可以获取所述第一参照共享缓存通道针对所述第一标识信息的第一命中率,以及所述第一普通共享缓存通道针对所述第一标识信息的第二命中率;确定所述第一命中率与所述第二命中率的比值;响应于所述比值大于或等于第一预设阈值,增大所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;或者,响应于所述比值小于或等于第二预设阈值,减少所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;其中,所述第一预设阈值大于所述第二预设阈值,且所述第一预设阈值和所述第二预设阈值均大于1。The shared cache resource allocated to the first identification information may be adjusted at a preset frequency. For example, a first hit rate of the first reference shared cache channel for the first identification information and a second hit rate of the first common shared cache channel for the first identification information may be obtained; determine the The ratio of the first hit rate to the second hit rate; in response to the ratio being greater than or equal to a first preset threshold, increasing the shared cache group allocated to the first identification information among the multiple shared cache channels or, in response to the ratio being less than or equal to a second preset threshold, reducing the number of shared cache groups allocated to the first identification information among the multiple shared cache channels; wherein, the first preset The threshold is set to be greater than the second preset threshold, and both the first preset threshold and the second preset threshold are greater than 1.

可以理解,本公开提及的上述各个方法实施例,在不违背原理逻辑的情况下,均可以彼此相互结合形成结合后的实施例,限于篇幅,本公开不再赘述。本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。It can be understood that the above-mentioned method embodiments mentioned in this disclosure can all be combined with each other to form a combined embodiment without violating the principle and logic. Due to space limitations, this disclosure will not repeat them. Those skilled in the art can understand that, in the above method in the specific implementation manner, the specific execution order of each step should be determined according to its function and possible internal logic.

此外,本公开还提供了缓存资源分配装置、电子设备、计算机可读存储介质、计算机程序产品,上述均可用来实现本公开提供的任一种缓存资源分配方法,相应技术方案和技术效果可参见方法部分的相应记载,不再赘述。In addition, the present disclosure also provides cache resource allocation devices, electronic equipment, computer-readable storage media, and computer program products, all of which can be used to implement any cache resource allocation method provided in the present disclosure. The corresponding technical solutions and technical effects can be found in The corresponding records in the method part will not be repeated here.

图6示出本公开实施例提供的缓存资源分配装置的框图。在本公开实施例中,处理器系统包括至少两级缓存,所述至少两级缓存中的最高级为共享缓存,所述共享缓存包括多个共享缓存组。如图6所示,所述缓存资源分配装置包括:Fig. 6 shows a block diagram of an apparatus for allocating cache resources provided by an embodiment of the present disclosure. In an embodiment of the present disclosure, the processor system includes at least two levels of cache, the highest level of the at least two levels of cache is a shared cache, and the shared cache includes multiple shared cache groups. As shown in Figure 6, the cache resource allocation device includes:

第一获取模块61,用于响应于来自于任一应用的第一数据请求,获取所述第一数据请求携带的第一标识信息;The first acquiring module 61 is configured to acquire first identification information carried in the first data request in response to a first data request from any application;

分配模块62,用于响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分配预设数量的共享缓存组。The allocation module 62 is configured to allocate a preset number of shared cache groups to the first identification information in response to the first data request being a data request corresponding to the first identification information received for the first time.

在一种可能的实现方式中,所述共享缓存包括多个共享缓存通道;In a possible implementation manner, the shared cache includes multiple shared cache channels;

所述分配模块62用于:The distribution module 62 is used for:

响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分别分配所述多个共享缓存通道中的预设数量的共享缓存组。In response to the first data request being a data request corresponding to the first identification information received for the first time, assigning a preset number of shared cache groups among the plurality of shared cache channels to the first identification information.

在一种可能的实现方式中,所述预设数量包括第一预设数量和第二预设数量,且所述第一预设数量小于所述第二预设数量;In a possible implementation manner, the preset number includes a first preset number and a second preset number, and the first preset number is smaller than the second preset number;

所述分配模块62用于:The distribution module 62 is used for:

响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,其中,所述第一参照共享缓存通道表示所述第一标识信息对应的参照共享缓存通道;In response to the first data request being a data request corresponding to the first identification information received for the first time, determining a first reference shared cache channel corresponding to the first identification information from the plurality of shared cache channels, Wherein, the first reference shared cache channel indicates the reference shared cache channel corresponding to the first identification information;

向所述第一标识信息分配第一普通共享缓存通道中的所述第一预设数量的共享缓存组,并向所述第一标识信息分配所述第一参照共享缓存通道中的所述第二预设数量的共享缓存组,其中,所述第一普通共享缓存通道表示所述多个共享缓存通道中除所述第一参照共享缓存通道以外的共享缓存通道。Allocating the first preset number of shared cache groups in the first common shared cache channel to the first identification information, and allocating the first preset number of shared cache groups in the first reference shared cache channel to the first identification information Two preset numbers of shared cache groups, wherein the first common shared cache channel represents a shared cache channel other than the first reference shared cache channel among the plurality of shared cache channels.

在一种可能的实现方式中,所述分配模块62用于:In a possible implementation manner, the allocation module 62 is used to:

响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,且所述多个共享缓存通道中存在未被确定为参照共享缓存通道的共享缓存通道,从所述未被确定为参照共享缓存通道的共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道。In response to the first data request being a data request corresponding to the first identification information received for the first time, and there is a shared cache channel that is not determined as a reference shared cache channel among the multiple shared cache channels, from the Among the shared cache channels that are not determined as reference shared cache channels, determine a first reference shared cache channel corresponding to the first identification information.

在一种可能的实现方式中,所述装置还包括:In a possible implementation manner, the device further includes:

第二获取模块,用于获取所述第一参照共享缓存通道针对所述第一标识信息的第一命中率,以及所述第一普通共享缓存通道针对所述第一标识信息的第二命中率;A second acquiring module, configured to acquire a first hit rate of the first reference shared cache channel for the first identification information, and a second hit rate of the first common shared cache channel for the first identification information ;

调节模块,用于根据所述第一命中率和所述第二命中率,调节分配给所述第一标识信息的共享缓存组的数量。An adjustment module, configured to adjust the number of shared cache groups allocated to the first identification information according to the first hit rate and the second hit rate.

在一种可能的实现方式中,所述调节模块用于:In a possible implementation manner, the adjustment module is used for:

确定所述第一命中率与所述第二命中率的比值;determining a ratio of the first hit rate to the second hit rate;

响应于所述比值大于或等于第一预设阈值,增大所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;或者,响应于所述比值小于或等于第二预设阈值,减少所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;其中,所述第一预设阈值大于所述第二预设阈值,且所述第一预设阈值和所述第二预设阈值均大于1。In response to the ratio being greater than or equal to a first preset threshold, increasing the number of shared cache groups allocated to the first identification information among the plurality of shared cache channels; or, in response to the ratio being less than or equal to a first threshold Two preset thresholds, reducing the number of shared cache groups allocated to the first identification information among the plurality of shared cache channels; wherein, the first preset threshold is greater than the second preset threshold, and the Both the first preset threshold and the second preset threshold are greater than 1.

在一种可能的实现方式中,所述装置还包括:In a possible implementation manner, the device further includes:

第三获取模块,用于获取所述第一数据请求对应的第一请求地址;A third obtaining module, configured to obtain a first request address corresponding to the first data request;

第四获取模块,用于响应于根据所述第一请求地址确定在本地缓存中发生缓存缺失,获取所述第一标识信息对应的组掩码、组偏移和标志位偏移量;A fourth acquiring module, configured to acquire a group mask, a group offset, and a flag bit offset corresponding to the first identification information in response to determining that a cache miss occurs in the local cache according to the first request address;

确定模块,用于根据所述第一数据请求对应的第二请求地址、所述组掩码、所述组偏移和所述标志位偏移量,确定所述第一数据请求对应的新组位和新标签信息,其中,所述第二请求地址根据所述第一请求地址确定;A determining module, configured to determine a new group corresponding to the first data request according to the second request address corresponding to the first data request, the group mask, the group offset, and the flag bit offset bit and new tag information, wherein the second request address is determined according to the first request address;

查找模块,用于根据所述第二请求地址中的通道信息和行内偏移地址,以及所述新组位和所述新标签信息,查找目标数据。A search module, configured to search for target data according to the channel information and the in-row offset address in the second request address, as well as the new group bits and the new tag information.

在一种可能的实现方式中,所述装置还包括:In a possible implementation manner, the device further includes:

重映射模块,用于对所述第一请求地址进行重映射,得到所述第二请求地址。A remapping module, configured to remap the first request address to obtain the second request address.

在一种可能的实现方式中,所述确定模块用于:In a possible implementation manner, the determination module is used for:

从所述第二请求地址中,获取原始组位和原始标签信息;Obtain original group bits and original label information from the second request address;

将所述原始组位与所述组掩码进行与运算,得到所述第一数据请求所请求的目标数据在所述第一标识信息对应的多个共享缓存组中的相对位置;performing an AND operation on the original group bit and the group mask to obtain the relative position of the target data requested by the first data request in the plurality of shared cache groups corresponding to the first identification information;

根据所述组偏移和所述相对位置,确定所述第一数据请求对应的新组位;determining a new group bit corresponding to the first data request according to the group offset and the relative position;

根据所述原始标签信息、所述标志位偏移量和所述原始组位中的指定位,确定所述第一数据请求对应的新标签信息。Determine new tag information corresponding to the first data request according to the original tag information, the flag bit offset, and a specified bit in the original group bits.

在一种可能的实现方式中,所述查找模块用于:In a possible implementation manner, the search module is used to:

响应于根据所述通道信息、所述新组位、所述新标签信息和所述行内偏移地址,查找不到目标数据,从内存或外存中获取所述目标数据,将所述目标数据写入所述新组位对应的共享缓存组中,并向所述第一数据请求返回所述目标数据。Responding to the fact that the target data cannot be found according to the channel information, the new group bit, the new label information, and the in-line offset address, the target data is acquired from internal memory or external storage, and the target data is writing into the shared cache group corresponding to the new group bit, and returning the target data to the first data request.

在一种可能的实现方式中,所述第一标识信息包括以下任意一项:In a possible implementation manner, the first identification information includes any of the following:

根据所述应用调用的模块确定的标识信息、根据上下文的标识信息确定的标识信息、根据所述第一数据请求所请求的目标数据在内存中的地址区间确定的标识信息。The identification information determined according to the module called by the application, the identification information determined according to the context identification information, and the identification information determined according to the address range of the target data requested by the first data request in the memory.

在一些实施例中,本公开实施例提供的装置具有的功能或包含的模块可以用于执行上文方法实施例描述的方法,其具体实现和技术效果可以参照上文方法实施例的描述,为了简洁,这里不再赘述。In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the methods described in the above method embodiments, and its specific implementation and technical effects can refer to the descriptions of the above method embodiments, for It is concise and will not be repeated here.

本公开实施例还提供一种计算机可读存储介质,其上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现上述方法。其中,所述计算机可读存储介质可以是非易失性计算机可读存储介质,或者可以是易失性计算机可读存储介质。An embodiment of the present disclosure also provides a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the foregoing method is implemented. Wherein, the computer-readable storage medium may be a non-volatile computer-readable storage medium, or may be a volatile computer-readable storage medium.

本公开实施例还提出一种计算机程序,包括计算机可读代码,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器执行上述方法。An embodiment of the present disclosure also proposes a computer program, including computer readable codes. When the computer readable codes are run in an electronic device, a processor in the electronic device executes the above method.

本公开实施例还提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器执行上述方法。An embodiment of the present disclosure also provides a computer program product, including computer-readable codes, or a non-volatile computer-readable storage medium carrying computer-readable codes, when the computer-readable codes are run in an electronic device , the processor in the electronic device executes the above method.

本公开实施例还提供一种电子设备,包括:一个或多个处理器;用于存储可执行指令的存储器;其中,所述一个或多个处理器被配置为调用所述存储器存储的可执行指令,以执行上述方法。An embodiment of the present disclosure also provides an electronic device, including: one or more processors; a memory for storing executable instructions; wherein the one or more processors are configured to call the executable instructions stored in the memory instruction to perform the above method.

电子设备可以被提供为终端、服务器或其它形态的设备。Electronic devices may be provided as terminals, servers, or other forms of devices.

图7示出本公开实施例提供的一电子设备1900的框图。例如,电子设备1900可以被提供为一终端或服务器。参照图7,电子设备1900包括处理组件1922,其进一步包括一个或多个处理器,以及由存储器1932所代表的存储器资源,用于存储可由处理组件1922的执行的指令,例如应用程序。存储器1932中存储的应用程序可以包括一个或一个以上的每一个对应于一组指令的模块。此外,处理组件1922被配置为执行指令,以执行上述方法。FIG. 7 shows a block diagram of an electronic device 1900 provided by an embodiment of the present disclosure. For example, the electronic device 1900 may be provided as a terminal or a server. Referring to FIG. 7 , electronic device 1900 includes processing component 1922 , which further includes one or more processors, and a memory resource represented by memory 1932 for storing instructions executable by processing component 1922 , such as application programs. The application programs stored in memory 1932 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.

电子设备1900还可以包括一个电源组件1926被配置为执行电子设备1900的电源管理,一个有线或无线网络接口1950被配置为将电子设备1900连接到网络,和一个输入/输出接口1958(I/O接口)。电子设备1900可以操作基于存储在存储器1932的操作系统,例如微软服务器操作系统(Windows ServerTM),苹果公司推出的基于图形用户界面操作系统(MacOS XTM),多用户多进程的计算机操作系统(UnixTM), 自由和开放原代码的类Unix操作系统(LinuxTM),开放原代码的类Unix操作系统(FreeBSDTM)或类似。Electronic device 1900 may also include a power supply component 1926 configured to perform power management of electronic device 1900, a wired or wireless network interface 1950 configured to connect electronic device 1900 to a network, and an input/output interface 1958 (I/O interface). The electronic device 1900 can operate based on the operating system stored in the memory 1932, such as the Microsoft server operating system (Windows Server TM ), the graphical user interface-based operating system (MacOS X TM ) introduced by Apple Inc., and the multi-user and multi-process computer operating system ( Unix TM ), a free and open-source Unix-like operating system (Linux TM ), an open-source Unix-like operating system (FreeBSD TM ), or similar.

在示例性实施例中,还提供了一种非易失性计算机可读存储介质,例如包括计算机程序指令的存储器1932,上述计算机程序指令可由电子设备1900的处理组件1922执行以完成上述方法。In an exemplary embodiment, there is also provided a non-transitory computer-readable storage medium, such as the memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the electronic device 1900 to implement the above method.

本公开可以是系统、方法和/或计算机程序产品。计算机程序产品可以包括计算机可读存储介质,其上载有用于使处理器实现本公开的各个方面的计算机可读程序指令。The present disclosure can be a system, method and/or computer program product. A computer program product may include a computer readable storage medium having computer readable program instructions thereon for causing a processor to implement various aspects of the present disclosure.

计算机可读存储介质可以是可以保持和存储由指令执行设备使用的指令的有形设备。计算机可读存储介质例如可以是――但不限于――电存储设备、磁存储设备、光存储设备、电磁存储设备、半导体存储设备或者上述的任意合适的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、静态随机存取存储器(SRAM)、便携式压缩盘只读存储器(CD-ROM)、数字多功能盘(DVD)、记忆棒、软盘、机械编码设备、例如其上存储有指令的打孔卡或凹槽内凸起结构、以及上述的任意合适的组合。这里所使用的计算机可读存储介质不被解释为瞬时信号本身,诸如无线电波或者其他自由传播的电磁波、通过波导或其他传输媒介传播的电磁波(例如,通过光纤电缆的光脉冲)、或者通过电线传输的电信号。A computer readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device. A computer readable storage medium may be, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (non-exhaustive list) of computer-readable storage media include: portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or flash memory), static random access memory (SRAM), compact disc read only memory (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanically encoded device, such as a printer with instructions stored thereon A hole card or a raised structure in a groove, and any suitable combination of the above. As used herein, computer-readable storage media are not to be construed as transient signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., pulses of light through fiber optic cables), or transmitted electrical signals.

这里所描述的计算机可读程序指令可以从计算机可读存储介质下载到各个计算/处理设备,或者通过网络、例如因特网、局域网、广域网和/或无线网下载到外部计算机或外部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和/或边缘服务器。每个计算/处理设备中的网络适配卡或者网络接口从网络接收计算机可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算/处理设备中的计算机可读存储介质中。Computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a respective computing/processing device, or downloaded to an external computer or external storage device over a network, such as the Internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and/or edge servers. A network adapter card or a network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing/processing device .

用于执行本公开操作的计算机程序指令可以是汇编指令、指令集架构(ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及常规的过程式编程语言—诸如“C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(FPGA)或可编程逻辑阵列(PLA),该电子电路可以执行计算机可读程序指令,从而实现本公开的各个方面。Computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or Source or object code written in any combination, including object-oriented programming languages—such as Smalltalk, C++, etc., and conventional procedural programming languages—such as the “C” language or similar programming languages. Computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server implement. In cases involving a remote computer, the remote computer can be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as through the Internet using an Internet service provider). connect). In some embodiments, electronic circuits, such as programmable logic circuits, field programmable gate arrays (FPGAs) or programmable logic arrays (PLAs), can be customized by utilizing state information of computer-readable program instructions, which can Various aspects of the present disclosure are implemented by executing computer readable program instructions.

这里参照根据本公开实施例的方法、装置(系统)和计算机程序产品的流程图和/或框图描述了本公开的各个方面。应当理解,流程图和/或框图的每个方框以及流程图和/或框图中各方框的组合,都可以由计算机可读程序指令实现。Aspects of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It should be understood that each block of the flowcharts and/or block diagrams, and combinations of blocks in the flowcharts and/or block diagrams, can be implemented by computer-readable program instructions.

这些计算机可读程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理器,从而生产出一种机器,使得这些指令在通过计算机或其它可编程数据处理装置的处理器执行时,产生了实现流程图和/或框图中的一个或多个方框中规定的功能/动作的装置。也可以把这些计算机可读程序指令存储在计算机可读存储介质中,这些指令使得计算机、可编程数据处理装置和/或其他设备以特定方式工作,从而,存储有指令的计算机可读介质则包括一个制造品,其包括实现流程图和/或框图中的一个或多个方框中规定的功能/动作的各个方面的指令。These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine such that when executed by the processor of the computer or other programmable data processing apparatus , producing an apparatus for realizing the functions/actions specified in one or more blocks in the flowchart and/or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause computers, programmable data processing devices and/or other devices to work in a specific way, so that the computer-readable medium storing instructions includes An article of manufacture comprising instructions for implementing various aspects of the functions/acts specified in one or more blocks in flowcharts and/or block diagrams.

也可以把计算机可读程序指令加载到计算机、其它可编程数据处理装置、或其它设备上,使得在计算机、其它可编程数据处理装置或其它设备上执行一系列操作步骤,以产生计算机实现的过程,从而使得在计算机、其它可编程数据处理装置、或其它设备上执行的指令实现流程图和/或框图中的一个或多个方框中规定的功能/动作。It is also possible to load computer-readable program instructions into a computer, other programmable data processing device, or other equipment, so that a series of operational steps are performed on the computer, other programmable data processing device, or other equipment to produce a computer-implemented process , so that instructions executed on computers, other programmable data processing devices, or other devices implement the functions/actions specified in one or more blocks in the flowcharts and/or block diagrams.

附图中的流程图和框图显示了根据本公开的多个实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的一部分,所述模块、程序段或指令的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, a portion of a program segment, or an instruction that includes one or more Executable instructions. In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified function or action , or may be implemented by a combination of dedicated hardware and computer instructions.

该计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software Development Kit,SDK)等等。The computer program product can be specifically realized by means of hardware, software or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium. In another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), etc. wait.

上文对各个实施例的描述倾向于强调各个实施例之间的不同之处,其相同或相似之处可以互相参考,为了简洁,本文不再赘述。The above descriptions of the various embodiments tend to emphasize the differences between the various embodiments, the same or similar points can be referred to each other, and for the sake of brevity, details are not repeated herein.

若本公开实施例的技术方案涉及个人信息,应用本公开实施例的技术方案的产品在处理个人信息前,已明确告知个人信息处理规则,并取得个人自主同意。若本公开实施例的技术方案涉及敏感个人信息,应用本公开实施例的技术方案的产品在处理敏感个人信息前,已取得个人单独同意,并且同时满足“明示同意”的要求。例如,在摄像头等个人信息采集装置处,设置明确显著的标识告知已进入个人信息采集范围,将会对个人信息进行采集,若个人自愿进入采集范围即视为同意对其个人信息进行采集;或者在个人信息处理的装置上,利用明显的标识/信息告知个人信息处理规则的情况下,通过弹窗信息或请个人自行上传其个人信息等方式获得个人授权;其中,个人信息处理规则可包括个人信息处理者、个人信息处理目的、处理方式以及处理的个人信息种类等信息。If the technical solutions of the embodiments of the present disclosure involve personal information, the products applying the technical solutions of the embodiments of the present disclosure have clearly notified the personal information processing rules and obtained the individual's independent consent before processing personal information. If the technical solutions of the embodiments of the present disclosure involve sensitive personal information, the products applying the technical solutions of the embodiments of the present disclosure have obtained individual consent before processing sensitive personal information, and at the same time meet the requirement of "express consent". For example, at a personal information collection device such as a camera, a clear and prominent sign is set up to inform that it has entered the scope of personal information collection, and personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed to agree to the collection of his personal information; or On the personal information processing device, when the personal information processing rules are informed with obvious signs/information, personal authorization is obtained through pop-up information or by asking individuals to upload their personal information; among them, the personal information processing rules may include Information such as the information processor, the purpose of personal information processing, the method of processing, and the type of personal information processed.

以上已经描述了本公开的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实施例的原理、实际应用或对市场中的技术的改进,或者使本技术领域的其它普通技术人员能理解本文披露的各实施例。Having described various embodiments of the present disclosure above, the foregoing description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and alterations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principle of each embodiment, practical application or improvement of technology in the market, or to enable other ordinary skilled in the art to understand each embodiment disclosed herein.

Claims (13)

1.一种缓存资源分配方法,其特征在于,处理器系统包括至少两级缓存,所述至少两级缓存中的最高级为共享缓存,所述共享缓存包括多个共享缓存通道,每个共享缓存通道分别包括多个共享缓存组,每个共享缓存组分别包括多个路,所述方法包括:1. A cache resource allocation method, characterized in that the processor system includes at least two levels of cache, the highest level in the at least two levels of cache is a shared cache, and the shared cache includes a plurality of shared cache channels, each shared The cache channels respectively include a plurality of shared cache groups, and each shared cache group includes a plurality of ways, and the method includes: 响应于来自于任一应用的第一数据请求,获取所述第一数据请求携带的第一标识信息,其中,所述第一数据请求为任一应用发出的任一数据请求,所述第一标识信息表示所述第一数据请求携带的标识信息;In response to a first data request from any application, obtain first identification information carried by the first data request, where the first data request is any data request sent by any application, and the first The identification information indicates the identification information carried in the first data request; 响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分别分配所述多个共享缓存通道中的预设数量的共享缓存组,其中,至少两个共享缓存通道分配给所述第一标识信息的共享缓存组的数量不同。In response to the first data request being a data request corresponding to the first identification information received for the first time, assigning a preset number of shared cache groups among the plurality of shared cache channels to the first identification information, Wherein, at least two shared cache channels allocate different numbers of shared cache groups to the first identification information. 2.根据权利要求1所述的方法,其特征在于,所述预设数量包括第一预设数量和第二预设数量,且所述第一预设数量小于所述第二预设数量;2. The method according to claim 1, wherein the preset number includes a first preset number and a second preset number, and the first preset number is smaller than the second preset number; 所述响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分别分配所述多个共享缓存通道中的预设数量的共享缓存组,包括:The response to the first data request being a data request corresponding to the first identification information received for the first time, respectively assigning a preset number of shared caches in the plurality of shared cache channels to the first identification information group, including: 响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,其中,所述第一参照共享缓存通道表示所述第一标识信息对应的参照共享缓存通道;In response to the first data request being a data request corresponding to the first identification information received for the first time, determining a first reference shared cache channel corresponding to the first identification information from the plurality of shared cache channels, Wherein, the first reference shared cache channel indicates the reference shared cache channel corresponding to the first identification information; 向所述第一标识信息分配第一普通共享缓存通道中的所述第一预设数量的共享缓存组,并向所述第一标识信息分配所述第一参照共享缓存通道中的所述第二预设数量的共享缓存组,其中,所述第一普通共享缓存通道表示所述多个共享缓存通道中除所述第一参照共享缓存通道以外的共享缓存通道。Allocating the first preset number of shared cache groups in the first common shared cache channel to the first identification information, and allocating the first preset number of shared cache groups in the first reference shared cache channel to the first identification information Two preset numbers of shared cache groups, wherein the first common shared cache channel represents a shared cache channel other than the first reference shared cache channel among the plurality of shared cache channels. 3.根据权利要求2所述的方法,其特征在于,所述响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,从所述多个共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道,包括:3. The method according to claim 2, wherein the response to the first data request is a data request corresponding to the first identification information received for the first time, from the plurality of shared cache channels , determining the first reference shared cache channel corresponding to the first identification information, including: 响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,且所述多个共享缓存通道中存在未被确定为参照共享缓存通道的共享缓存通道,从所述未被确定为参照共享缓存通道的共享缓存通道中,确定所述第一标识信息对应的第一参照共享缓存通道。In response to the first data request being a data request corresponding to the first identification information received for the first time, and there is a shared cache channel that is not determined as a reference shared cache channel among the multiple shared cache channels, from the Among the shared cache channels that are not determined as reference shared cache channels, determine a first reference shared cache channel corresponding to the first identification information. 4.根据权利要求2所述的方法,其特征在于,所述方法还包括:4. The method according to claim 2, characterized in that the method further comprises: 获取所述第一参照共享缓存通道针对所述第一标识信息的第一命中率,以及所述第一普通共享缓存通道针对所述第一标识信息的第二命中率;Acquiring a first hit rate of the first reference shared cache channel for the first identification information, and a second hit rate of the first common shared cache channel for the first identification information; 根据所述第一命中率和所述第二命中率,调节分配给所述第一标识信息的共享缓存组的数量。According to the first hit ratio and the second hit ratio, the number of shared cache groups allocated to the first identification information is adjusted. 5.根据权利要求4所述的方法,其特征在于,所述根据所述第一命中率和所述第二命中率,调节分配给所述第一标识信息的共享缓存组的数量,包括:5. The method according to claim 4, wherein the adjusting the number of shared cache groups assigned to the first identification information according to the first hit rate and the second hit rate comprises: 确定所述第一命中率与所述第二命中率的比值;determining a ratio of the first hit rate to the second hit rate; 响应于所述比值大于或等于第一预设阈值,增大所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;或者,响应于所述比值小于或等于第二预设阈值,减少所述多个共享缓存通道中分配给所述第一标识信息的共享缓存组的数量;其中,所述第一预设阈值大于所述第二预设阈值,且所述第一预设阈值和所述第二预设阈值均大于1。In response to the ratio being greater than or equal to a first preset threshold, increasing the number of shared cache groups allocated to the first identification information among the plurality of shared cache channels; or, in response to the ratio being less than or equal to a first threshold Two preset thresholds, reducing the number of shared cache groups allocated to the first identification information among the plurality of shared cache channels; wherein, the first preset threshold is greater than the second preset threshold, and the Both the first preset threshold and the second preset threshold are greater than 1. 6.根据权利要求1所述的方法,其特征在于,所述方法还包括:6. The method according to claim 1, further comprising: 获取所述第一数据请求对应的第一请求地址;Obtain a first request address corresponding to the first data request; 响应于根据所述第一请求地址确定在本地缓存中发生缓存缺失,获取所述第一标识信息对应的组掩码、组偏移和标志位偏移量;In response to determining that a cache miss occurs in the local cache according to the first request address, acquire a group mask, a group offset, and a flag bit offset corresponding to the first identification information; 根据所述第一数据请求对应的第二请求地址、所述组掩码、所述组偏移和所述标志位偏移量,确定所述第一数据请求对应的新组位和新标签信息,其中,所述第二请求地址根据所述第一请求地址确定;According to the second request address corresponding to the first data request, the group mask, the group offset and the flag bit offset, determine the new group bit and new tag information corresponding to the first data request , wherein the second request address is determined according to the first request address; 根据所述第二请求地址中的通道信息和行内偏移地址,以及所述新组位和所述新标签信息,查找目标数据。Searching for target data according to the channel information and the in-row offset address in the second request address, as well as the new group bits and the new label information. 7.根据权利要求6所述的方法,其特征在于,所述方法还包括:7. The method according to claim 6, further comprising: 对所述第一请求地址进行重映射,得到所述第二请求地址。Remapping the first request address to obtain the second request address. 8.根据权利要求6所述的方法,其特征在于,所述根据所述第一数据请求对应的第二请求地址、所述组掩码、所述组偏移和所述标志位偏移量,确定所述第一数据请求对应的新组位和新标签信息,包括:8. The method according to claim 6, wherein the second request address corresponding to the first data request, the group mask, the group offset and the flag bit offset , determining the new group bit and new tag information corresponding to the first data request, including: 从所述第二请求地址中,获取原始组位和原始标签信息;Obtain original group bits and original label information from the second request address; 将所述原始组位与所述组掩码进行与运算,得到所述第一数据请求所请求的目标数据在所述第一标识信息对应的多个共享缓存组中的相对位置;performing an AND operation on the original group bit and the group mask to obtain the relative position of the target data requested by the first data request in the plurality of shared cache groups corresponding to the first identification information; 根据所述组偏移和所述相对位置,确定所述第一数据请求对应的新组位;determining a new group bit corresponding to the first data request according to the group offset and the relative position; 根据所述原始标签信息、所述标志位偏移量和所述原始组位中的指定位,确定所述第一数据请求对应的新标签信息。Determine new tag information corresponding to the first data request according to the original tag information, the flag bit offset, and a specified bit in the original group bits. 9.根据权利要求6所述的方法,其特征在于,所述根据所述第二请求地址中的通道信息和行内偏移地址,以及所述新组位和所述新标签信息,查找目标数据,包括:9. The method according to claim 6, characterized in that, according to the channel information in the second request address and the in-line offset address, as well as the new group bit and the new label information, the target data is searched ,include: 响应于根据所述通道信息、所述新组位、所述新标签信息和所述行内偏移地址,查找不到目标数据,从内存或外存中获取所述目标数据,将所述目标数据写入所述新组位对应的共享缓存组中,并向所述第一数据请求返回所述目标数据。Responding to the fact that the target data cannot be found according to the channel information, the new group bit, the new label information, and the in-line offset address, the target data is acquired from internal memory or external storage, and the target data is writing into the shared cache group corresponding to the new group bit, and returning the target data to the first data request. 10.根据权利要求1至9中任意一项所述的方法,其特征在于,所述第一标识信息包括以下任意一项:10. The method according to any one of claims 1 to 9, wherein the first identification information includes any of the following: 根据所述应用调用的模块确定的标识信息、根据上下文的标识信息确定的标识信息、根据所述第一数据请求所请求的目标数据在内存中的地址区间确定的标识信息。The identification information determined according to the module called by the application, the identification information determined according to the context identification information, and the identification information determined according to the address range of the target data requested by the first data request in the memory. 11.一种缓存资源分配装置,其特征在于,处理器系统包括至少两级缓存,所述至少两级缓存中的最高级为共享缓存,所述共享缓存包括多个共享缓存通道,每个共享缓存通道分别包括多个共享缓存组,每个共享缓存组分别包括多个路,所述装置包括:11. A cache resource allocation device, characterized in that the processor system includes at least two levels of cache, the highest level of the at least two levels of cache is a shared cache, and the shared cache includes a plurality of shared cache channels, each shared The cache channels respectively include a plurality of shared cache groups, and each shared cache group includes a plurality of ways, and the device includes: 第一获取模块,用于响应于来自于任一应用的第一数据请求,获取所述第一数据请求携带的第一标识信息,其中,所述第一数据请求为任一应用发出的任一数据请求,所述第一标识信息表示所述第一数据请求携带的标识信息;The first acquiring module is configured to acquire the first identification information carried by the first data request in response to the first data request from any application, where the first data request is any For a data request, the first identification information represents the identification information carried in the first data request; 分配模块,用于响应于所述第一数据请求为首次接收到的所述第一标识信息对应的数据请求,向所述第一标识信息分配预设数量的共享缓存组,其中,至少两个共享缓存通道分配给所述第一标识信息的共享缓存组的数量不同。An allocation module, configured to allocate a preset number of shared cache groups to the first identification information in response to the first data request being a data request corresponding to the first identification information received for the first time, wherein at least two The shared cache channels allocate different numbers of shared cache groups to the first identification information. 12.一种电子设备,其特征在于,包括:12. An electronic device, characterized in that it comprises: 一个或多个处理器;one or more processors; 用于存储可执行指令的存储器;memory for storing executable instructions; 其中,所述一个或多个处理器被配置为调用所述存储器存储的可执行指令,以执行权利要求1至10中任意一项所述的方法。Wherein, the one or more processors are configured to invoke executable instructions stored in the memory to perform the method according to any one of claims 1-10. 13.一种计算机可读存储介质,其上存储有计算机程序指令,其特征在于,所述计算机程序指令被处理器执行时实现权利要求1至10中任意一项所述的方法。13. A computer-readable storage medium, on which computer program instructions are stored, wherein the method according to any one of claims 1 to 10 is implemented when the computer program instructions are executed by a processor.
CN202310153348.3A 2023-02-23 2023-02-23 Cache resource allocation method, device, electronic device and storage medium Active CN116010109B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202310153348.3A CN116010109B (en) 2023-02-23 2023-02-23 Cache resource allocation method, device, electronic device and storage medium
CN202311076545.6A CN117093371B (en) 2023-02-23 2023-02-23 Cache resource allocation method, device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310153348.3A CN116010109B (en) 2023-02-23 2023-02-23 Cache resource allocation method, device, electronic device and storage medium

Related Child Applications (1)

Application Number Title Priority Date Filing Date
CN202311076545.6A Division CN117093371B (en) 2023-02-23 2023-02-23 Cache resource allocation method, device, electronic device and storage medium

Publications (2)

Publication Number Publication Date
CN116010109A CN116010109A (en) 2023-04-25
CN116010109B true CN116010109B (en) 2023-07-04

Family

ID=86037526

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202310153348.3A Active CN116010109B (en) 2023-02-23 2023-02-23 Cache resource allocation method, device, electronic device and storage medium
CN202311076545.6A Active CN117093371B (en) 2023-02-23 2023-02-23 Cache resource allocation method, device, electronic device and storage medium

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN202311076545.6A Active CN117093371B (en) 2023-02-23 2023-02-23 Cache resource allocation method, device, electronic device and storage medium

Country Status (1)

Country Link
CN (2) CN116010109B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116010109B (en) * 2023-02-23 2023-07-04 摩尔线程智能科技(北京)有限责任公司 Cache resource allocation method, device, electronic device and storage medium
CN116521095B (en) * 2023-07-03 2023-09-08 摩尔线程智能科技(北京)有限责任公司 Response output system, method, electronic device, storage medium, and program product
CN119473664A (en) * 2025-01-15 2025-02-18 山东云海国创云计算装备产业创新中心有限公司 Data processing system, method, product, equipment and storage medium

Family Cites Families (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8401994B2 (en) * 2009-09-18 2013-03-19 Oracle International Corporation Distributed consistent grid of in-memory database caches
US8935483B2 (en) * 2009-04-27 2015-01-13 Lsi Corporation Concurrent, coherent cache access for multiple threads in a multi-core, multi-thread network processor
US9021179B2 (en) * 2011-06-10 2015-04-28 International Business Machines Corporation Store storage class memory information command
CN102270180B (en) * 2011-08-09 2014-04-02 清华大学 Multicore processor cache and management method thereof
US10002076B2 (en) * 2015-09-29 2018-06-19 Nxp Usa, Inc. Shared cache protocol for parallel search and replacement
CN106909515B (en) * 2017-02-11 2020-09-18 苏州浪潮智能科技有限公司 Multi-core shared last-level cache management method and device for mixed main memory
US10789175B2 (en) * 2017-06-01 2020-09-29 Mellanox Technologies Ltd. Caching policy in a multicore system on a chip (SOC)
CN109857681B (en) * 2017-11-30 2023-07-18 华为技术有限公司 Cache address mapping method and related equipment
US11086777B2 (en) * 2019-04-01 2021-08-10 Arm Limited Replacement of cache entries in a set-associative cache
CN112148665B (en) * 2019-06-28 2024-01-09 深圳市中兴微电子技术有限公司 Cache allocation method and device
US10949352B1 (en) * 2020-03-05 2021-03-16 Nxp Usa, Inc. Data processing system having a shared cache
US11481332B1 (en) * 2021-05-07 2022-10-25 Ventana Micro Systems Inc. Write combining using physical address proxies stored in a write combine buffer
US11593109B2 (en) * 2021-06-07 2023-02-28 International Business Machines Corporation Sharing instruction cache lines between multiple threads
CN114217861A (en) * 2021-12-06 2022-03-22 海光信息技术股份有限公司 Data processing method and device, electronic device and storage medium
CN114928652B (en) * 2022-04-29 2023-06-20 高德软件有限公司 Map data transmission method, map data transmission device, electronic device, storage medium, and program
CN115052042B (en) * 2022-06-07 2023-05-26 成都北中网芯科技有限公司 Method for realizing high-performance multi-channel shared cache
CN115098169B (en) * 2022-06-24 2024-03-05 海光信息技术股份有限公司 Method and device for retrieving instructions based on capacity sharing
CN115061972B (en) * 2022-07-05 2023-10-13 摩尔线程智能科技(北京)有限责任公司 Processor, data read-write method, device and storage medium
CN115357196A (en) * 2022-08-31 2022-11-18 鹏城实验室 Dynamically scalable set associative cache method, device, equipment and medium
CN115168247B (en) * 2022-09-02 2022-12-02 北京登临科技有限公司 Method for dynamically sharing memory space in parallel processor and corresponding processor
CN116010109B (en) * 2023-02-23 2023-07-04 摩尔线程智能科技(北京)有限责任公司 Cache resource allocation method, device, electronic device and storage medium

Also Published As

Publication number Publication date
CN116010109A (en) 2023-04-25
CN117093371B (en) 2024-05-17
CN117093371A (en) 2023-11-21

Similar Documents

Publication Publication Date Title
CN116010109B (en) Cache resource allocation method, device, electronic device and storage medium
US10572378B2 (en) Dynamic memory expansion by data compression
US11954528B2 (en) Technologies for dynamically sharing remote resources across remote computing nodes
CN104809076B (en) Cache management method and device
TW201717040A (en) System and method for a shared cache with adaptive partitioning
JP6262407B1 (en) Providing shared cache memory allocation control in shared cache memory systems
JP7506096B2 (en) Dynamic allocation of computing resources
CN112148665B (en) Cache allocation method and device
US11068418B2 (en) Determining memory access categories for tasks coded in a computer program
US10204060B2 (en) Determining memory access categories to use to assign tasks to processor cores to execute
US9575881B2 (en) Systems and methods for providing improved latency in a non-uniform memory architecture
US8543770B2 (en) Assigning memory to on-chip coherence domains
CN115640098A (en) Virtual machine heterogeneous memory pooling method and system
JP2018508894A (en) Method and device for accessing a data visitor directory in a multi-core system
TW201941087A (en) Data structure with rotating bloom filters
US10339052B2 (en) Massive access request for out-of-core textures by a parallel processor with limited memory
CN116563089B (en) Memory management method, device and equipment of graphic processor and storage medium
US9542333B2 (en) Systems and methods for providing improved latency in a non-uniform memory architecture
CN107526691B (en) Cache management method and device
US20200167286A1 (en) Increasing the lookahead amount for prefetching
CN116107926B (en) Management methods, devices, equipment, media and program products for cache replacement strategies
CN116166575B (en) Method, device, equipment, medium and program product for configuring access segment length
CN117539636A (en) Memory management method and device for bus module, electronic equipment and storage medium
CN119013661A (en) Method and system for determining and using profile features in a heterogeneous environment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address

Address after: B655, 4th Floor, Building 14, Cuiwei Zhongli, Haidian District, Beijing, 100036

Patentee after: Mole Thread Intelligent Technology (Beijing) Co.,Ltd.

Country or region after: China

Address before: 209, 2nd Floor, No. 31 Haidian Street, Haidian District, Beijing

Patentee before: Moore Threads Technology Co., Ltd.

Country or region before: China

CP03 Change of name, title or address