WO2014206218A1 - 一种访问数据缓存的方法和处理器 - Google Patents

一种访问数据缓存的方法和处理器 Download PDF

Info

Publication number
WO2014206218A1
WO2014206218A1 PCT/CN2014/080063 CN2014080063W WO2014206218A1 WO 2014206218 A1 WO2014206218 A1 WO 2014206218A1 CN 2014080063 W CN2014080063 W CN 2014080063W WO 2014206218 A1 WO2014206218 A1 WO 2014206218A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
cache
private
shared
thread
Prior art date
Application number
PCT/CN2014/080063
Other languages
English (en)
French (fr)
Inventor
徐远超
范东睿
张�浩
叶笑春
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2014206218A1 publication Critical patent/WO2014206218A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0806Multiuser, multiprocessor or multiprocessing cache systems
    • G06F12/0842Multiuser, multiprocessor or multiprocessing cache systems for multiprocessing or multitasking

Definitions

  • the present invention relates to the field of computers, and in particular, to a method and a process for accessing a data cache.
  • the current multi-core cache usually involves a LI cache as a private cache and other levels as a multi-level hierarchy of shared caches.
  • Multi-core processors provide greater parallel computing power and can run multiple program loads simultaneously, but there are performance interference issues between programs running simultaneously on a multi-core shared cache, mainly due to the core of the program data occurring on the shared cache. Inter-replacement, the performance of the program is affected, because the replaced data needs to be fetched again when used again, increasing the memory access delay and memory bandwidth, making the resource utilization low and the program performance difficult to determine, for the dense access but the reuse rate The problem is even more pronounced when low-streaming applications and programs that are not densely populated but have high reusability are mixed.
  • one implementation is to divide the shared cache into multiple shares, each corresponding to an associated entity, which is usually the smallest scheduling unit of the operating system, such as a thread.
  • this method of partitioning does not take into account the possibility of sharing data between threads. If there is shared data but no shared cache, the shared data between threads will have multiple copies in the private cache, thus requiring more cache space. , also need to maintain the cache of multiple copies of the consistency; another way to achieve Page shading technology implements cache partitioning, but this method limits the physical memory space that each thread can use. It can do good cache isolation for multiple independent processes, but in a multi-threaded program for streaming data applications. There is a lot of shared data between threads, and it is not appropriate to perform complete isolation. That is to say, page coloring technology is suitable for cache isolation between processes, and is not suitable for cache isolation between multiple threads in the same process.
  • Embodiments of the present invention provide a method and processor for accessing a data cache, which can reduce the scope of data lookup, reduce access latency, and improve system performance.
  • a processor including a program counter, a register file, an instruction prefetching component, an instruction decoding component, an instruction transmitting component, an address generating unit, an arithmetic logic unit, a shared floating point unit, a shared instruction cache, and an internal bus. , Also includes:
  • the data buffer is a level 1 cache
  • the level 1 cache includes a private data cache and a shared data cache
  • the private data cache includes a plurality of private caches, where the private cache is used to store thread private data.
  • the shared data cache is used to store shared data between the threads.
  • the processor is a simultaneous multi-threaded structure, and the private cache corresponds to a hardware thread--all hardware threads share the shared data cache.
  • a method for accessing a data cache including:
  • the method further includes: If the data does not exist in the private data cache, accessing the main memory, and backfilling the cache line from which the data is obtained from the main memory to the private data cache corresponding to the thread;
  • the determining, according to the additional flag bit in the physical address corresponding to the data, the data type of the data includes:
  • U 'J determines that the data type of the data is private data
  • U 'J determines that the data type of the data is shared data.
  • the accessing the data cache corresponding to the thread according to the thread and the data type includes:
  • the private data cache includes multiple private caches, where the private data cache is used to store private data of the thread, and the sharing A data cache is used to store shared data between the threads;
  • the private cache corresponds to a hardware thread--all hardware threads share the shared data cache.
  • Embodiments of the present invention provide a method and a processor for accessing a data cache
  • the processor including a program counter, a register file, an instruction prefetching component, an instruction decoding component, an instruction transmitting component, an address generating unit, an arithmetic logic unit, and a shared floating Point unit, shared instruction cache and internal bus, also includes data buffer, data buffer is level 1 cache, level 1 cache includes private data cache and shared data cache, private data cache includes multiple private caches, private The cache is used to store the private data of the thread, and the shared data cache is used to store the shared data between the threads.
  • the data of the data is determined according to the additional flag bits in the physical address corresponding to the data.
  • the data type includes private data and shared data
  • the thread corresponding to the data is determined according to the accessed data, and then the data cache corresponding to the thread is accessed according to the thread and the data type to obtain data in the data cache, and the data cache is private data cache or shared.
  • Data caching can reduce the scope of data lookup, reduce access latency, and improve system performance.
  • FIG. 1 is a schematic structural diagram of a processor according to an embodiment of the present invention.
  • FIG. 2 is a schematic diagram of buffer partitioning according to an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of a method for accessing a data cache according to an embodiment of the present invention. .
  • the embodiment of the present invention provides a processor 01, as shown in FIG. 1, including a program counter 011, a register file 012, an instruction prefetching component 013, an instruction decoding component 014, an instruction transmitting component 015, an address generating unit 016, and an arithmetic logic.
  • the unit 017, the shared floating point unit 018, the shared instruction cache 019, and the internal bus also include:
  • Data buffer 021, data buffer 021 is a level 1 cache, level 1 cache includes a private The data cache 0211 and the shared data cache 0212, the private data cache 021 1 includes a plurality of private caches 021 1a, the private data cache 021 1 is used to store private data of threads, and the shared cache 0212 is used to store shared data of threads.
  • the processor 01 is a simultaneous multi-threaded structure, and the private data cache 021 1 corresponds to a hardware thread, and all hardware threads share a shared data cache 0212.
  • the simultaneous multi-threaded architecture is implemented on a feature that allows multiple threads to be transmitted in one clock cycle to improve utilization of features.
  • the private cache is used by a single user, and the shared cache is shared for multiple users.
  • PC Program Counter
  • GRF General Register File
  • a logical processor core in a processor core corresponds to a GRF, and the number is the same as the number of PCs.
  • Fetch instruction prefetching component
  • Decoder instruction decoding component
  • Issue is the instruction transmitting component, used to transmit the instruction
  • AGU Address Generator Unit
  • the module for address calculation generates an address for controlling access to the memory.
  • the ALU Arimetic Logic Unit
  • CPU Central Processing Unit
  • shared Float Point Unit is a circuit unit dedicated to floating-point arithmetic operations in a processor.
  • the shared instruction cache is used to store instructions, and the internal bus is used to connect various components within the processor.
  • the data buffer (Cache) 021 is a first level cache LI Cache (Level 1 Cache ) of the processor 01, and the LI Cache includes a private data cache 021 1 and a shared data cache 0212.
  • the private data cache 021 1 includes a plurality of independent private caches (D-Cache) 0211a for storing private data of respective hardware threads, and a shared data cache 0212 for storing shared data between threads.
  • D-Cache independent private caches
  • the private cache and the shared cache are at the same level L1.
  • the private data of the thread is stored in the private cache, and the shared data between the threads is stored in the shared cache.
  • the existing multi-core cache is usually a private cache of LI cache, and other hierarchical layers of L2, L3 and the like are shared caches.
  • the invention does not use a multi-level hierarchy, retaining the Ll cache.
  • each hardware thread has its own private cache, and all hardware threads share a shared cache.
  • the processor 01 can be a many-core processor, each processor core is a simultaneous multi-threaded structure, and the buffer 021 is a component of each processor core.
  • the hardware implementation of the cache can be as shown in Figure 2. Inside a processor core with simultaneous multi-threaded architecture, there are multiple hardware threads, each hardware thread corresponding to a private cache 021 1 , and all hardware threads share a shared cache 0212. Private cache 021 1 and shared cache 0212 belong to the same level.
  • an embodiment of the present invention provides a processor, including a program counter, a register file, an instruction prefetching component, an instruction decoding component, an instruction transmitting component, an address generating unit, an arithmetic logic unit, a shared floating point unit, and a shared
  • the instruction cache and the internal bus further include a data buffer, the data buffer is a level 1 cache, the level 1 cache includes a private data cache and a shared data cache, the private data cache and the shared data cache belong to the same level, and the private data cache includes multiple Private cache, private data cache is used to store private data of threads, and shared data cache is used to store shared data between threads. This can reduce the scope of data search, reduce access delay and improve system performance.
  • An embodiment of the present invention provides a method for accessing cache data, as shown in FIG. 3, including:
  • the processor accesses data in the data buffer of the processor, the processor determines a data type of the data according to an additional flag bit in the physical address corresponding to the data, where the data type includes private data and shared data.
  • the data type of the data can be determined by modifying the Page Table Entry (PTE) identifier in the operating system.
  • the thread private data can be stored in the page frame of each thread by compiling the supported paging mechanism, and the inter-thread shared data belonging to one process is stored in the thread sharing page frame.
  • the operating system allocates memory space in units of pages, and the base address of the page frame is written in the page table entry.
  • identify whether the page frame points to a private area or a shared area define one in the reserved bits of the page table entry.
  • the flag bit of the bit is used to distinguish whether the physical page frame corresponding to the page table item is a private area. For example, if it is a private area, the flag position is 1, and if it is a shared area, the flag position is 0.
  • the location of the logo of the private area and the shared area is not limited.
  • Table 1 for example, in a 4KB size page table entry structure, a bit flag can be defined in bits 9-14 to distinguish the physical page corresponding to the page table entry.
  • the box is a private area or a shared area.
  • the virtual address is used.
  • TLB Translation Lookaside Buffer
  • Table 2 shows the composition of the physical address, including the flag bits share_flag, tag set index, block offset, and byte offset.
  • the CPU can determine the type of data to access the data based on the additional flag bits in the physical address. If the flag bit in the physical address is the first flag, it is determined that the data type of the data is private data; if the flag bit in the physical address is the second flag The flag determines the data type of the data as shared data. For example, the first flag is 1 and the second flag is 0.
  • the processor determines, according to the accessed data, a thread corresponding to the data, and then accesses a cache corresponding to the thread according to the thread and the data type, to obtain data in the cache, and the cache is a private cache or a shared cache.
  • the CPU may determine, according to the accessed data, which hardware thread is initiated by the data thread, and then determine a cache area to be accessed according to the hardware thread and the data type, if share — flag is 1, and the data type is private data, then access the private data cache corresponding to the hardware thread. If the share_flag is 0 and the data type is shared data, access the shared data cache in the buffer to obtain the data in the cache. . Private data caching and shared data caching are done synchronously by hardware.
  • Each hardware thread corresponds to a private data cache, and all hardware threads share a shared data cache.
  • the private data cache and the shared data cache belong to the same level LI cache.
  • the CPU accesses the main memory in the memory, and obtains the cache line of the data to be accessed from the main memory.
  • Backfilling the cache line into the private data cache corresponding to the hardware thread if the CPU accesses the shared thread cache of the hardware thread, that is, there is no data to be accessed in the shared data cache, the CPU accesses the main memory in the memory, The cache line of the data to be accessed is obtained from the main memory, and the cache line is backfilled into the shared data cache shared by all hardware threads.
  • the cache line to be backfilled may be replaced with the least recently used cache line by LRU (Least Recently Used), or When the cache line does not exist in the cache, the cache line is directly backfilled into the data cache.
  • LRU Least Recently Used
  • the replacement strategy used in backfilling is the same as the prior art, and will not be described here.
  • an embodiment of the present invention provides a method for accessing a data cache.
  • the data type includes private data and Sharing data, determining the thread corresponding to the data according to the accessed data, and then accessing the data cache corresponding to the thread according to the thread and the data type, to obtain the data in the data cache, and the data cache is a private data cache or a shared data cache, which can reduce the data search.
  • the range reducing access latency and improving system performance.
  • the disclosed processor and method may be implemented in other manners.
  • the device embodiments described above are only schematic.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be electrical, mechanical or otherwise.
  • each functional unit may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit.
  • the above units may be implemented in the form of hardware or in the form of hardware plus software functional units.
  • All or part of the steps of implementing the foregoing method embodiments may be performed by hardware related to the program instructions.
  • the foregoing program may be stored in a computer readable storage medium, and when executed, the program includes the steps of the foregoing method embodiments;
  • the foregoing storage medium includes:
  • U disk, removable hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk, etc. can store various program code media.

Landscapes

  • Engineering & Computer Science (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

提供一种访问数据缓存的方法和处理器,涉及计算机领域,能够减小数据査找的范围,降低访问延迟,提高系统性能。该处理器的数据缓存器为一级缓存,一级缓存包括私有数据缓存和共享数据缓存,私有数据缓存包括多个私有缓存,私有数据缓存用于存储线程的私有数据,共享数据缓存用于存储线程之间的共享数据,当访问处理器的数据缓存器中的数据时,根据数据对应的物理地址附加的标志位确定数据的数据类型,数据类型包括私有数据和共享数据,根据访问的数据确定数据对应的线程,进而根据线程和数据类型访问线程对应的数据缓存,以获取数据缓存中的数据。用于划分数据缓存和访问数据缓存。

Description

一种访问数据緩存的方法和处理器 本申请要求于 2013 年 6 月 28 日提交中国专利局、 申请号为 201310269618.3、发明名称为 "一种访问数据緩存的方法和处理器" 的中国专 利申请的优先权, 上述专利申请的全部内容通过引用结合在本申请中。
技术领域
本发明涉及计算机领域, 尤其涉及一种访问数据緩存的方法和处理 哭口 o
背景技术
处理器进入多核时代后, 访存一直是系统性能的瓶颈, 内存系统 性能的增长速度严重滞后处理器性能的增长速度,访存的速度严重限制 计算速度的发挥。 目前的多核 cache (緩冲存储器)通常涉及为 LI cache 为私有 cache , 其它层次为共享 cache的多级层次结构。
多核处理器提供了更大的并行计算能力, 能够同时运行多种程序 负载, 但是在共享 cache 的多核上同时运行的程序间会有性能干扰问 题, 主要是由于程序数据在共享 cache上发生的核间替换, 使得程序性 能受到影响, 因为被替换的数据再次使用时需要再次访存, 增加了访存 延迟和访存带宽,使得资源利用率低和程序性能难以确定,对于访存密 集但重用率低的流式应用程序和访存不密集但重用率高的程序混合运 行时, 问题会更加突出。
因此, 要对 cache 进行合理管理, 现有技术中, 一种实现方式为将 共享 cache 划分成多份, 每一份对应一个关联的实体, 该实体通常是操 作系统最小的调度单位, 如线程。 但是这种划分方法没有考虑到线程之 间存在共享数据的可能性, 如果存在共享数据但没有共享 cache , 线程之 间的共享数据会在私有 cache 中存在多个副本, 从而需要更多的 cache 空间, 还需要维护多个副本的 cache —致性; 还有一种实现方式为通过 页着色技术实现 cache 划分, 但是这种方法限制了每个线程所能使用的 物理内存空间, 对于独立的多个进程能够做到很好的 cache 隔离, 但是 在流式数据应用的多线程程序中, 线程之间有很多共享数据, 进行完全 隔离是不适宜的。 也就是说页着色技术适用于进程之间的 cache 隔离, 不太适合同一进程内多个线程之间的 cache隔离。
发明内容
本发明的实施例提供一种访问数据緩存的方法和处理器, 能够减 小数据查找的范围, 降低访问延迟, 提高系统性能。
为达到上述目的, 本发明的实施例釆用如下技术方案:
第一方面, 提供一种处理器, 包括程序计数器、 寄存器堆、 指令 预取部件、 指令译码部件、 指令发射部件、 地址生成单元、 算术逻辑单 元、 共享浮点单元、 共享指令緩存以及内部总线, 还包括:
数据緩存器, 所述数据緩存器为一级緩存, 所述一级緩存包括私 有数据緩存和共享数据緩存, 所述私有数据緩存包括多个私有緩存, 所 述私有緩存用于存储线程的私有数据,所述共享数据緩存用于存储所述 线程之间的共享数据。
结合第一方面, 在第一方面的第一种可能实现的方式中, 所述处 理器为同时多线程结构, 所述私有緩存与硬件线程——对应, 所有硬件 线程共用所述共享数据緩存。
第二方面, 提供一种访问数据緩存的方法, 包括:
当访问处理器的数据緩存器中的数据时, 根据所述数据对应的物 理地址中附加的标志位确定所述数据的数据类型,所述数据类型包括私 有数据和共享数据;
根据访问的数据确定所述数据对应的线程, 进而根据所述线程和 所述数据类型访问所述线程对应的数据緩存,以获取所述数据緩存中的 数据, 所述数据緩存为私有数据緩存或共享数据緩存。
结合第二方面, 在第二方面的第一种可能实现的方式中, 所述方 法还包括: 若所述私有数据緩存中不存在所述数据, 则访问主存储器, 并将 从所述主存储器中获取所述数据所在的緩存行回填至所述线程对应的 私有数据緩存中;
若所述共享数据緩存中不存在所述数据, 则访问所述主存储器, 并将从所述主存储器中获取所述数据所在的緩存行回填至所述共享数 据緩存中。
结合第二方面的第一种可能实现的方式, 在第二种可能实现的方 式中,所述根据所述数据对应的物理地址中附加的标志位确定所述数据 的数据类型包括:
若所述物理地址中的标志位为第一标志, U 'J确定所述数据的数据 类型为私有数据;
若所述物理地址中的标志位为第二标志, U 'J确定所述数据的数据 类型为共享数据。
结合第二方面的第二种可能实现的方式, 在第三种可能实现的方 式中,所述根据所述线程和所述数据类型访问所述线程对应的数据緩存 包括:
若所述数据类型为所述私有数据, 则访问所述线程对应的私有数 据緩存;
若所述数据类型为所述共享数据, 则访问所述共享数据緩存。 结合第二方面的第三种可能实现的方式, 在第四种可能实现的方 式中, 所述私有数据緩存包括多个私有緩存, 所述私有数据緩存用于存 储线程的私有数据,所述共享数据緩存用于存储所述线程之间的共享数 据;
其中, 所述私有緩存与硬件线程——对应, 所有硬件线程共用所 述共享数据緩存。
本发明实施例提供一种访问数据緩存的方法和处理器, 该处理器包 括程序计数器、 寄存器堆、 指令预取部件、 指令译码部件、 指令发射部 件、 地址生成单元、 算术逻辑单元、 共享浮点单元、 共享指令緩存以及 内部总线, 还包括数据緩存器, 数据緩存器为一级緩存, 一级緩存包括 私有数据緩存和共享数据緩存, 私有数据緩存包括多个私有緩存, 私有 緩存用于存储线程的私有数据, 共享数据緩存用于存储线程之间的共享 数据, 当访问处理器的数据緩存器中的数据时, 根据数据对应的物理地 址中附加的标志位确定数据的数据类型, 数据类型包括私有数据和共享 数据, 根据访问的数据确定数据对应的线程, 进而根据线程和数据类型 访问线程对应的数据緩存, 以获取数据緩存中的数据, 数据緩存为私有 数据緩存或共享数据緩存, 能够减小数据查找的范围, 降低访问延迟, 提高系统性能。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将 对实施例或现有技术描述中所需要使用的附图作简单地介绍, 显而易见 地, 下面描述中的附图是本发明的一些实施例, 对于本领域普通技术人 员来讲, 在不付出创造性劳动的前提下, 还可以根据这些附图获得其他 的附图。
图 1为本发明实施例提供的一种处理器结构示意图;
图 2为本发明实施例提供的一种緩存划分示意图;
图 3为本发明实施例提供的一种访问数据緩存的方法流程示意图。。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行 清楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明一部分实施例, 而 不是全部的实施例。基于本发明中的实施例, 本领域普通技术人员在没有做 出创造性劳动前提下所获得的所有其他实施例 , 都属于本发明保护的范围。
本发明实施例提供一种处理器 01 , 如图 1 所示, 包括程序计数器 011、 寄存器堆 012、 指令预取部件 013、 指令译码部件 014、 指令发射 部件 015、 地址生成单元 016、 算术逻辑单元 017、 共享浮点单元 018、 共享指令緩存 019、 以及内部总线, 还包括:
数据緩存器 021 , 数据緩存器 021为一级緩存, 一级緩存包括私有 数据緩存 021 1和共享数据緩存 0212 , 私有数据緩存 021 1 包括多个私 有緩存 021 1a, 私有数据緩存 021 1 用于存储线程的私有数据, 共享緩 存 0212用于存储线程的共享数据。
其中, 处理器 01 为同时多线程结构, 私有数据緩存 021 1 与硬件 线程——对应, 所有硬件线程公用一个共享数据緩存 0212。 该同时多 线程结构为允许在一个时钟周期内发射多个线程的指令到功能部件上 执行, 以提高功能部件的利用率。 私有緩存为单个用户所用, 共享緩存 为多个用户共享使用。
PC ( Program Counter, 程序计数器) 有 16个, 为 PC0~PC15 , — 个处理器核内逻辑处理器核(硬件线程)的个数与 PC的个数是一致的。
GRF ( General Register File, 寄存器堆) , 一个处理器核内的逻辑 处理器核对应一个 GRF , 数量上与 PC的数量一致。
Fetch (指令预取部件) 用于获取指令, Decoder (指令译码部件) 用于对指令进行解码, Issue 为指令发射部件, 用于发射指令, AGU ( Address Generator Unit,地址生成单元)为进行所有地址计算的模块, 生成一个用于对访问存储器进行控制的地址。 ALU ( Arithmetic Logic Unit, 算术逻辑单元) 是 CPU ( Central Processing Unit, 中央处理器) 的执行单元, 可以由 "And Gate" (与门) 和' Or Gate" (或门) 构成的 算术逻辑单元。 共享浮点单元 ( Shared Float Point Unit ) 为处理器中专 门进行浮点算术运算的电路单元,共享指令緩存用于存储指令, 内部总 线用于连接处理器内各部件。
数据緩存器( Cache )021为处理器 01的第一级緩存 LI Cache( Level 1 Cache ) , 该 LI Cache包括私有数据緩存 021 1和共享数据緩存 0212。
私有数据緩存 021 1包括多个独立的私有緩存 (D-Cache ) 0211a, 用于存储各个硬件线程的私有数据, 共享数据緩存 0212用于存储线程 之间的共享数据。
私有 cache和共享 cache在同一层次 L1 ,在 CPU将数据填入 cache 时, 将线程的私有数据存储于私有 cache中, 线程之间的共享数据存储 于共享 cache中。
本领域技术人员可以理解, 目前现有的多核 cache通常为 LI cache 为私有 cache , 其他 L2、 L3等层次为共享 cache的多级层次结构, 本 发明不釆用多级层次结构, 保留 Ll cache。 这样, 每个硬件线程都有自 己的私有 cache , 所有硬件线程公用一个共享 cache。
举例来说, 该处理器 01可以为众核处理器, 每一个处理器核为同 时多线程结构, 緩存器 021为每一个处理器核的组成部分。 该 cache的 硬件实施可以如图 2所示。在一个同时多线程结构的处理器核内部,有 多个硬件线程, 每一个硬件线程对应一个私有緩存 021 1 , 所有的硬件 线程共用一个共享緩存 0212。 私有緩存 021 1和共享緩存 0212属于同 一个层次。
因此, 本发明实施例提供一种处理器, 该处理器包括程序计数器, 寄存器堆、 指令预取部件、 指令译码部件、 指令发射部件、 地址生成单 元、 算术逻辑单元、 共享浮点单元、 共享指令緩存以及内部总线, 还包 括数据緩存器, 该数据緩存器为一级緩存, 一级緩存包括私有数据緩存 和共享数据緩存, 私有数据緩存和共享数据緩存属于同一层次, 私有数 据緩存包括多个私有緩存, 私有数据緩存用于存储线程的私有数据,共 享数据緩存用于存储线程之间的共享数据,这样, 能够减小数据查找的 范围, 降低访问延迟, 提高系统性能。
本发明实施例提供一种访问緩存数据的方法, 如图 3所示, 包括:
101、 当处理器访问处理器的数据緩存器中的数据时, 处理器根据 数据对应的物理地址中附加的标志位确定数据的数据类型,数据类型包 括私有数据和共享数据。
示例性的, 可以通过修改操作系统中的页表项 ( Page Table Entry , PTE )标识来确定数据的数据类型。 可以通过编译支持的分页机制, 将 线程私有数据存储在每一个线程独占的页框(Page Frame ) 中, 将属于 一个进程的线程间共享数据存储在线程共享的页框中。
具体的, 操作系统分配内存空间是以页为单位的, 页框的基地址 写在页表项中, 为了识别页框指向的是私有区域还是共享区域, 在页表 项的保留位中定义一个比特的标志位,该标志位用于区分该页表项对应 的物理页框是否为私有区域, 示例性的, 若为私有区域, 标志位置 1 , 若为共享区域, 标志位置 0。 这里对私有区域和共享区域的标志位置不 做限定。 如表 1所示, 举例来说, 以 4KB大小的页表项结构来说明, 可以在第 9-14位中定义一个比特的标志位来区分页表项对应的物理页 框为私有区域或共享区域。
4KB大小的页表项结构
Figure imgf000009_0001
当 CPU 访问緩存数据时使用的是虚拟地址, 先查找 TLB ( Translation Lookaside Buffer, 旁路转换緩冲区)表, 该表为虚拟 地址和物理地址的高速緩存表, 用于根据虚拟地址得到物理地址。 若 TLB 中没有对应的虚拟地址, 则进入分页处理以得到物理地址, 以及 存储在页表项中的标志位 share— flag , 并将该标志位存放在 TLB 表的 物理地址中; 若 TLB表中有对应的虚拟地址项, 则直接获取 TLB表中 的物理地址以及标志位 share— flag, 并将该标志位添加到物理地址中。 如表 2所示为物理地址的组成, 包括标志位 share— flag , tag (标签) set index (组索引号) , block offset (块偏移 )和 byte offset (字节偏移 ) 。
表 2 物理地址组成
Figure imgf000009_0002
这样, 通过对页表项中某一位保留位进行定义, 并将定义的标志 位作为物理地址的附加位传给 CPU, CPU可以根据物理地址中附加的 标志位确定要访问数据的数据类型。 若物理地址中的标志位为第一标 志, 则确定数据的数据类型为私有数据; 若物理地址中的标志位为第二 标志, 则确定数据的数据类型为共享数据。 例如, 该第一标志位 1 , 第 二标志为 0。
102、 处理器根据访问的数据确定数据对应的线程, 进而根据线程 和数据类型访问线程对应的緩存, 以获取緩存中的数据,緩存为私有緩 存或共享緩存。
具体的, 在确定的要访问的数据的数据类型后, CPU 可以根据访 问的数据确定该数据访问是由哪个硬件线程发起的,进而根据该硬件线 程和数据类型确定要访问的緩存区域, 若 share— flag为 1 , 数据类型为 私有数据, 则访问硬件线程对应的私有数据緩存; 若 share— flag为 0 , 数据类型为共享数据, 则访问緩存器中的共享数据緩存, 以获取緩存中 的数据。 私有数据緩存和共享数据緩存是由硬件同步完成的。
其中, 每一个硬件线程对应一个私有数据緩存, 所有的硬件线程 共用一个共享数据緩存,私有数据緩存和共享数据緩存属于同一个层次 LI cache。
此外, 若 CPU访问硬件线程对应的私有数据緩存不命中, 即私有 数据緩存中不存在要访问的数据, 则 CPU访问内存中的主存储器, 并 从主存储器中获取要访问的数据所在的緩存行,将该緩存行回填至该硬 件线程对应的私有数据緩存中; 若 CPU访问硬件线程的共享数据緩存 不命中, 即共享数据緩存中不存在要访问的数据, 则 CPU访问内存中 的主存储器, 并从主存储器中获取要访问的数据所在的緩存行, 将该緩 存行回填至所有硬件线程共享的共享数据缓存中。 其中,在将緩存行回 填至数据緩存中时, 若数据緩存填满时, 可以通过 LRU ( Least Recently Used, 最近最少使用到的) 将要回填的緩存行替换最近最少使用到的 緩存行, 或者在緩存中不存在该緩存行时, 直接将该緩存行回填至数据 緩存中。 回填时所釆用的替换策略与现有技术相同, 这里不再赘述。
这样一来, 由于高通量应用程序线程相似度高, 数据共享度低, 通过对数据緩存进行重新划分,线程各自的私有数据分布在各自的私有 緩存中, 没有任何干扰, 共享数据存储在共享数据緩存中, 在 CPU查 找緩存中的数据时,可以根据物理地址的标志位直接确定要查找的对象 是私有数据緩存还是共享数据緩存,减小了查找范围,降低了访问延迟, 提高了系统性能。 因此, 本发明实施例提供一种访问数据緩存的方法, 当访问处理 器的数据緩存器中的数据时,根据数据对应的物理地址中的标志位确定 数据的数据类型,数据类型包括私有数据和共享数据,根据访问的数据 确定数据对应的线程,进而根据线程和数据类型访问线程对应的数据緩 存, 以获取数据緩存中的数据,数据緩存为私有数据緩存或共享数据緩 存, 能够减小数据查找的范围, 降低访问延迟, 提高系统性能。
在本申请所提供的几个实施例中, 应该理解到, 所揭露的处理器 和方法, 可以通过其它的方式实现。 例如, 以上所描述的设备实施例仅 仅是示意性的, 例如, 所述单元的划分, 仅仅为一种逻辑功能划分, 实 际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可 以集成到另一个系统, 或一些特征可以忽略, 或不执行。 另一点, 所显 示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接 口, 装置或单元的间接耦合或通信连接, 可以是电性, 机械或其它的形 式。
另外, 在本发明各个实施例中的处理器中, 各功能单元可以集成 在一个处理单元中,也可以是各个单元单独物理包括, 也可以两个或两 个以上单元集成在一个单元中。且上述的各单元既可以釆用硬件的形式 实现, 也可以釆用硬件加软件功能单元的形式实现。
实现上述方法实施例的全部或部分步骤可以通过程序指令相关的 硬件来完成, 前述的程序可以存储于一计算机可读取存储介质中, 该程 序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:
U盘、 移动硬盘、 只读存储器 (Read Only Memory , 简称 ROM ) 、 随 机存取存储器 (Random Access Memory, 简称 RAM ) 、 磁碟或者光盘 等各种可以存储程序代码的介质。
以上所述, 仅为本发明的具体实施方式, 但本发明的保护范围并不 局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内, 可轻易想到变化或替换, 都应涵盖在本发明的保护范围之内。 因此, 本 发明的保护范围应以所述权利要求的保护范围为准。

Claims

权利 要求 书
1、 一种处理器, 包括程序计数器、 寄存器堆、 指令预取部件、 指令 译码部件、 指令发射部件、 地址生成单元、 算术逻辑单元、 共享浮点单 元、 共享指令緩存以及内部总线, 其特征在于, 还包括:
数据緩存器, 所述数据緩存器为一级緩存, 所述一级緩存包括私有 数据緩存和共享数据緩存, 所述私有数据緩存包括多个私有緩存, 所述 私有数据緩存用于存储线程的私有数据, 所述共享数据緩存用于存储所 述线程之间的共享数据。
2、 根据权利要求 1所述的处理器核, 其特征在于, 所述处理器为同 时多线程结构, 所述私有緩存与硬件线程——对应, 所有硬件线程共用 所述共享数据緩存。
3、 一种访问数据緩存的方法, 其特征在于, 包括:
当访问处理器的数据緩存器中的数据时, 根据所述数据对应的物理 地址中附加的标志位确定所述数据的数据类型, 所述数据类型包括私有 数据和共享数据;
根据访问的数据确定所述数据对应的线程, 进而根据所述线程和所 述数据类型访问所述线程对应的数据緩存, 以获取所述数据緩存中的数 据, 所述数据緩存为私有数据緩存或共享数据緩存。
4、 根据权利要求 3所述的方法, 其特征在于, 所述方法还包括: 若所述私有数据緩存中不存在所述数据, 则访问主存储器, 并将从 所述主存储器中获取所述数据所在的緩存行回填至所述线程对应的私有 数据緩存中;
若所述共享数据緩存中不存在所述数据, 则访问所述主存储器, 并 将从所述主存储器中获取所述数据所在的緩存行回填至所述共享数据緩 存中。
5、 根据权利要求 4所述的方法, 其特征在于, 所述根据所述数据对 应的物理地址中附加的标志位确定所述数据的数据类型包括:
若所述物理地址中的标志位为第一标志, U 'J确定所述数据的数据类 型为私有数据;
若所述物理地址中的标志位为第二标志, U 'J确定所述数据的数据类 型为共享数据。
6、 根据权利要求 5所述的方法, 其特征在于, 所述根据所述线程和 所述数据类型访问所述线程对应的数据緩存包括:
若所述数据类型为所述私有数据, 则访问所述线程对应的私有数据 緩存;
若所述数据类型为所述共享数据, 则访问所述共享数据緩存。
7、 根据权利要求 6所述的方法, 其特征在于, 所述私有数据緩存包 括多个私有緩存, 所述私有緩存用于存储线程的私有数据, 所述共享数 据緩存用于存储所述线程之间的共享数据;
其中, 所述私有緩存与硬件线程——对应, 所有硬件线程共用所述 共享数据緩存。
PCT/CN2014/080063 2013-06-28 2014-06-17 一种访问数据缓存的方法和处理器 WO2014206218A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310269618.3A CN104252392B (zh) 2013-06-28 2013-06-28 一种访问数据缓存的方法和处理器
CN201310269618.3 2013-06-28

Publications (1)

Publication Number Publication Date
WO2014206218A1 true WO2014206218A1 (zh) 2014-12-31

Family

ID=52141029

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/080063 WO2014206218A1 (zh) 2013-06-28 2014-06-17 一种访问数据缓存的方法和处理器

Country Status (2)

Country Link
CN (1) CN104252392B (zh)
WO (1) WO2014206218A1 (zh)

Families Citing this family (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106815174B (zh) * 2015-11-30 2019-07-30 大唐移动通信设备有限公司 数据访问控制方法及节点控制器
CN105677581A (zh) * 2016-01-05 2016-06-15 上海斐讯数据通信技术有限公司 一种内存访问装置和方法
CN105743803B (zh) * 2016-01-21 2019-01-25 华为技术有限公司 一种共享缓存的数据处理装置
CN107037260A (zh) * 2016-11-24 2017-08-11 国网河南省电力公司周口供电公司 一种远程通信式微电网电能表
CN107943743A (zh) * 2017-11-17 2018-04-20 江苏微锐超算科技有限公司 计算设备的信息存储、读取方法及共享虚拟介质承载芯片
CN109840410B (zh) * 2017-12-28 2021-09-21 中国科学院计算技术研究所 一种进程内数据隔离与保护的方法和系统
US10860487B2 (en) * 2019-04-17 2020-12-08 Chengdu Haiguang Integrated Circuit Design Co. Ltd. Multi-core processing device and method of transferring data between cores thereof
CN110058931B (zh) 2019-04-19 2022-03-22 上海兆芯集成电路有限公司 用以任务调度的处理系统及其加速方法
CN110083387B (zh) 2019-04-19 2021-11-12 上海兆芯集成电路有限公司 使用轮询机制的处理系统及其访存方法
CN110032452B (zh) 2019-04-19 2021-08-24 上海兆芯集成电路有限公司 处理系统与异构处理器加速方法
CN110083388B (zh) * 2019-04-19 2021-11-12 上海兆芯集成电路有限公司 用于调度的处理系统及其访存方法
CN110032453B (zh) 2019-04-19 2022-05-03 上海兆芯集成电路有限公司 用以任务调度与分配的处理系统及其加速方法
CN110046053B (zh) * 2019-04-19 2021-11-12 上海兆芯集成电路有限公司 用以分配任务的处理系统及其访存方法
CN112199217B (zh) * 2020-10-23 2022-07-12 无锡江南计算技术研究所 一种软硬协同的线程私有数据访问优化方法
WO2022199357A1 (zh) * 2021-03-23 2022-09-29 北京灵汐科技有限公司 数据处理方法及装置、电子设备、计算机可读存储介质
CN114035847B (zh) * 2021-11-08 2023-08-29 海飞科(南京)信息技术有限公司 用于并行执行核心程序的方法和装置
CN114036084B (zh) * 2021-11-17 2022-12-06 海光信息技术股份有限公司 一种数据访问方法、共享缓存、芯片系统和电子设备
CN114265812B (zh) * 2021-11-29 2024-02-02 山东云海国创云计算装备产业创新中心有限公司 降低risc-v向量处理器访存延迟的方法、装置、设备及介质
CN114217861A (zh) * 2021-12-06 2022-03-22 海光信息技术股份有限公司 数据处理方法及装置、电子装置和存储介质
CN114327777B (zh) * 2021-12-30 2022-07-29 元心信息科技集团有限公司 确定全局页目录的方法、装置、电子设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090037658A1 (en) * 2007-07-31 2009-02-05 Krishnakanth Sistla Providing an inclusive shared cache among multiple core-cache clusters
CN101571843A (zh) * 2008-04-29 2009-11-04 国际商业机器公司 在多核处理器中动态共享高速缓存的方法、设备和系统
CN102270180A (zh) * 2011-08-09 2011-12-07 清华大学 一种多核处理器高速缓存及其管理方法
CN103092788A (zh) * 2012-12-24 2013-05-08 华为技术有限公司 多核处理器及数据访问方法

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5895487A (en) * 1996-11-13 1999-04-20 International Business Machines Corporation Integrated processing and L2 DRAM cache
CN101510191B (zh) * 2009-03-26 2010-10-06 浙江大学 具备缓存窗口的多核体系架构的实现方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090037658A1 (en) * 2007-07-31 2009-02-05 Krishnakanth Sistla Providing an inclusive shared cache among multiple core-cache clusters
CN101571843A (zh) * 2008-04-29 2009-11-04 国际商业机器公司 在多核处理器中动态共享高速缓存的方法、设备和系统
CN102270180A (zh) * 2011-08-09 2011-12-07 清华大学 一种多核处理器高速缓存及其管理方法
CN103092788A (zh) * 2012-12-24 2013-05-08 华为技术有限公司 多核处理器及数据访问方法

Also Published As

Publication number Publication date
CN104252392A (zh) 2014-12-31
CN104252392B (zh) 2019-06-18

Similar Documents

Publication Publication Date Title
WO2014206218A1 (zh) 一种访问数据缓存的方法和处理器
US8285969B2 (en) Reducing broadcasts in multiprocessors
US8521944B2 (en) Performing memory accesses using memory context information
US8645666B2 (en) Means to share translation lookaside buffer (TLB) entries between different contexts
US10339060B2 (en) Optimized caching agent with integrated directory cache
US9727475B2 (en) Method and apparatus for distributed snoop filtering
US20180150406A1 (en) Processor using a level 3 translation lookaside buffer implemented in off-chip or die-stacked dynamic random-access memory
WO2014206217A1 (zh) 一种指令缓存的管理方法和处理器
US8037281B2 (en) Miss-under-miss processing and cache flushing
US9727482B2 (en) Address range priority mechanism
US9311239B2 (en) Power efficient level one data cache access with pre-validated tags
US9361233B2 (en) Method and apparatus for shared line unified cache
US20170185515A1 (en) Cpu remote snoop filtering mechanism for field programmable gate array
WO2014090087A1 (en) Translation management instructions for updating address translation data structures in remote processing nodes
US8335908B2 (en) Data processing apparatus for storing address translations
US20200104259A1 (en) System, method, and apparatus for snapshot prefetching to improve performance of snapshot operations
GB2507759A (en) Hierarchical cache with a first level data cache which can access a second level instruction cache or a third level unified cache
US20140189247A1 (en) Apparatus and method for implementing a scratchpad memory
US20210073129A1 (en) Cache line demote infrastructure for multi-processor pipelines
US9183161B2 (en) Apparatus and method for page walk extension for enhanced security checks
GB2532545A (en) Processors and methods for cache sparing stores
EP3732576A1 (en) Systems, methods, and apparatuses for patching pages
Vasilakis et al. Decoupled fused cache: Fusing a decoupled LLC with a DRAM cache
Pham et al. TLB shootdown mitigation for low-power many-core servers with L1 virtual caches
US10013352B2 (en) Partner-aware virtual microsectoring for sectored cache architectures

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14818315

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14818315

Country of ref document: EP

Kind code of ref document: A1