Cache consistency optimization method, device and equipment for multi-level bus
By dividing core groups in a multi-core processor system and dynamically adjusting the cache consistency protocol, the problem of low maintenance efficiency of cache consistency protocol is solved, more efficient cache consistency management is achieved, and the performance of parallel programs is improved.
Patent Information
- Application Number
- CN202411131862.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-08-19
AI Technical Summary
The maintenance efficiency of cache coherence protocols in the prior art, especially in multi-core processor systems, results in complex and inefficient cache coherence management.
By dividing the processor cores connected by multi-level buses into multiple core groups, the processor cores in each core group are interconnected through the first-level bus, and the core groups are interconnected through the second-level bus, according to the cache consistency dependence between threads The relationship dynamically adjusts the working mode of the cache consistency protocol, and adopts in-group or inter-group cache consistency protocols to improve maintenance efficiency.
Improve the maintenance efficiency of the cache coherence protocol, reduce unnecessary cache coherence operations, and improve the running performance of parallel programs.
Smart Images

Figure CN118656236B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a cache consistency optimization method, device and equipment for a multi-level bus. Background Art
[0002] Each processor core on a modern multi-core processor has a cache to improve data access speed and ensure the convenience of program writing. When running parallel programs, multiple threads or processes running on multiple processor cores may read and write data in the same shared memory area. In order to ensure the correctness of parallel program operation, cache coherence is required between different processors in the same computing node and between different processor cores of the same processor, so that the same data is consistent between the caches of multiple processor cores.
[0003] With the continuous development of computer technology, most applications running on supercomputers are parallel programs. Threads are the basic units for operating system scheduling processor cores. Since all threads belonging to the same process need to share the storage space of the process, it is necessary to maintain the cache consistency protocol between these threads. Despite this, the number of threads in most applications when they are actually running in parallel is usually set to a small number (for example, for programs that implement MPI+OpenMP hybrid parallelism, the number of OpenMP threads generally does not exceed 8). There is usually no shared memory area between two different processes. Even if there is, it is often necessary to establish shared memory through explicit calls to corresponding operating system commands. It can be seen that in most cases, it is only necessary to maintain cache consistency between multiple threads in the same process. However, most of the cache consistency operations in existing methods are redundant, and the maintenance efficiency of cache consistency protocols is low. Summary of the invention
[0004] The present disclosure provides a cache consistency optimization method, device and equipment for a multi-level bus to solve the problem of low maintenance efficiency of a cache consistency protocol.
[0005] In a first aspect, the present disclosure provides a cache consistency optimization method for a multi-level bus, comprising:
[0006] Divide all processor cores interconnected by multi-level buses into multiple core groups, all processor cores in each core group are interconnected by a primary bus, and core groups are interconnected by a secondary bus;
[0007] If the threads running in the current core group do not have a cache consistency dependency relationship with any threads running in any other core group, the cache consistency protocol working mode of the current core group is set to the intra-group cache consistency protocol; if any thread running in the current core group has a cache consistency dependency relationship with any thread running in any other core group, the cache consistency protocol working mode of the current core group is set to the inter-group cache consistency protocol;
[0008] The core group whose cache consistency protocol works in the intra-group cache consistency protocol independently maintains the intra-group cache consistency protocol based on the primary bus. The core group whose cache consistency protocol works in the inter-group cache consistency protocol jointly maintains the inter-group cache consistency protocol with other core groups that have cache consistency dependencies based on the primary bus and the secondary bus.
[0009] In some embodiments, the primary bus and the secondary bus are disconnected or connected to each other through a switch. The cache consistency protocol works in a mode where the primary bus and the secondary bus corresponding to the core group of the intra-group cache consistency protocol remain disconnected, and the cache consistency protocol works in a mode where the primary bus and the secondary bus corresponding to the core group of the inter-group cache consistency protocol remain connected.
[0010] In some embodiments, independently maintaining an intra-group cache consistency protocol based on a primary bus includes: a primary bus controller causing each processor core to perform cache consistency operations only with other processor cores in the same core group;
[0011] Based on the primary bus and the secondary bus, the inter-group cache consistency protocol is jointly maintained with other core groups that have cache consistency dependencies, including: the primary bus controller enables each processor core to perform cache consistency operations with other processor cores in the same core group and processor cores of other core groups that adopt the inter-group cache consistency protocol; the secondary bus controller obtains and records the cache consistency protocol working mode of all core groups, and sends it to all core groups that adopt the inter-group cache consistency protocol.
[0012] In some embodiments, the operating system records each thread group having a cache coherence dependency, and updates the cache coherence dependency between threads when creating or ending a thread or process, establishing a shared storage space between processes, or calling a cache coherence declaration command;
[0013] When the operating system performs thread scheduling, it determines the working mode of the cache consistency protocol of each core group based on the cache consistency dependencies between threads at that time.
[0014] In some embodiments, threads with cache coherence dependencies are scheduled onto the same core group.
[0015] In some embodiments, the method further comprises:
[0016] When the application thread calls the operating system command, the application thread and the operating system thread read and write parameters through the memory instead of the cache, so as to realize the parameter transfer between the application thread and the operating system thread.
[0017] In some embodiments, the method further comprises:
[0018] When an application thread calls an operating system command, if the application thread and the operating system thread are not in the same core group, the core group where the application thread is located and the core group where the operating system thread is located both use an inter-group cache consistency protocol.
[0019] In some embodiments, the method further comprises:
[0020] Before a thread is swapped out, all valid cache blocks that have been modified by the thread and not yet written back are written to the shared cache or memory.
[0021] In a second aspect, the present disclosure provides a cache consistency optimization device for a multi-level bus, comprising:
[0022] A partitioning module is used to partition all processor cores interconnected by multi-level buses into multiple core groups, all processor cores in each core group are interconnected by a primary bus, and the core groups are interconnected by a secondary bus;
[0023] A setting module is used to set the cache consistency protocol working mode of the current core group to the intra-group cache consistency protocol if there is no cache consistency dependency between the threads running in the current core group and any threads running in any other core group; if there is a cache consistency dependency between any thread running in the current core group and any thread running in any other core group, then the cache consistency protocol working mode of the current core group is set to the inter-group cache consistency protocol;
[0024] A processing module is used for a core group whose cache consistency protocol works in an intra-group cache consistency protocol to independently maintain an intra-group cache consistency protocol based on a primary bus, and a core group whose cache consistency protocol works in an inter-group cache consistency protocol to jointly maintain an inter-group cache consistency protocol with other core groups that have cache consistency dependencies based on a primary bus and a secondary bus.
[0025] In a third aspect, the present disclosure provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the above aspects.
[0026] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the method described in the above aspects when executed by a processor.
[0027] In a fifth aspect, the present disclosure provides a computer program product, including a computer program / instructions, which implements the steps of the method described in the above aspects when the computer program is executed by a processor.
[0028] The present disclosure provides a cache consistency optimization method, device and equipment for multi-level buses, which divide all processor cores interconnected by multi-level buses into multiple core groups, all processor cores in each core group are interconnected by a primary bus, and each core group is interconnected by a secondary bus; if each thread running in the current core group does not have a cache consistency dependency relationship with any thread running in any other core group, the cache consistency protocol working mode of the current core group is set to the intra-group cache consistency protocol; if any thread running in the current core group has a cache consistency dependency relationship with any thread running in any other core group, the cache consistency protocol working mode of the current core group is set to the inter-group cache consistency protocol; the core group whose cache consistency protocol working mode is the intra-group cache consistency protocol independently maintains the intra-group cache consistency protocol based on the primary bus, and the core group whose cache consistency protocol working mode is the inter-group cache consistency protocol jointly maintains the inter-group cache consistency protocol based on the primary bus and the secondary bus with other core groups with cache consistency dependencies. The maintenance efficiency of the cache consistency protocol is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The present disclosure will be described in more detail below based on embodiments and with reference to the accompanying drawings:
[0030] Figure 1 A schematic diagram of a flow chart of a cache consistency optimization method for a multi-level bus provided in an embodiment of the present disclosure;
[0031] Figure 2 A schematic diagram of the structure of a cache consistency optimization device for a multi-level bus provided in an embodiment of the present disclosure.
[0032] In the drawings, the same reference numerals are used for the same components, and the drawings are not drawn to scale. DETAILED DESCRIPTION
[0033] In order to enable those skilled in the art to better understand the technical solution of the present disclosure, and to fully understand and implement how the present disclosure applies technical means to solve technical problems and achieve the corresponding technical effects, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only embodiments of a part of the present disclosure, not all of the embodiments. The embodiments of the present disclosure and the various features in the embodiments can be combined with each other without conflict, and the technical solutions formed are all within the scope of protection of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of the present disclosure.
[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0035] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0036] There are two main cache consistency protocols: the snooping-based consistency protocol (hereinafter referred to as the snooping protocol) and the directory-based consistency protocol (hereinafter referred to as the directory protocol). Among them, the implementation of the snooping protocol relies on a bus or bus-like network connection. Using this network connection, all requests issued by the private cache of a single processor core will be broadcast to the private caches of all other processor cores in the system, and the access requests of all processors can also be sequenced on this bus to achieve the requirements for access order in the cache consistency model and the storage identity model. The snooping protocol can also handle multiple conflicting requests for the same data block well through the bus structure, and the private caches of multiple processors can also communicate directly through this bus structure, reducing communication delays. However, since all requests are transmitted through the bus, and the bus bandwidth resources are limited, it will affect the scalability of the entire system. The directory protocol uses a directory structure to manage cache lines. In the directory protocol, the memory access request issued by the private cache of the processor core will first be sent to the directory structure that owns the corresponding cache block. This directory structure records the sharing status of the current cache block. The directory structure controller will choose to respond to this request or forward this request to the private cache of other corresponding processor cores according to the status of the current cache block. This method does not need to rely on a network with a specific topology, and reduces bandwidth consumption in the network through point-to-point direct communication, which is easy to expand. However, in the implementation of the directory protocol, all requests must be processed through the directory structure, which will introduce additional delays.
[0037] At present, the number of cores in a CPU has reached nearly 100, and a computing node of a supercomputer usually has two CPUs, which requires supporting cache consistency of nearly 200 processor cores. In this case, the directory protocol will encounter bottleneck problems, such as the increasing size of the directory and the increase in access latency. For the snooping protocol, the design and layout of the bus will also encounter difficulties, and the restriction of bus bandwidth resources on the performance of parallel programs will become more obvious. For example, in commercial CPUs of companies such as AMD that use the snooping protocol, in order to reduce the difficulty of bus design, a multi-level bus structure that is easy to expand is adopted. Taking a CPU with 48 processor cores as an example, all processor cores will be divided into 6 groups, and the 8 processor cores in each group will be interconnected based on the primary bus, and the 6 groups will be interconnected through the secondary bus. The primary bus and the secondary bus are combined to realize the interconnection and snooping protocol of all 48 processor cores.
[0038] It is understandable that for a listening protocol based on a multi-level bus structure, if it can be ensured that multiple threads within the same process are running on multiple processor cores interconnected by the same primary bus, then the cache consistency protocol can be maintained only within the same primary bus range, so that multiple primary buses on the same CPU can work independently, thereby improving the maintenance efficiency of the cache consistency protocol several times. Similarly, for two processes with shared memory, they can also be scheduled to processor cores interconnected by the same primary bus. Based on this, the present application proposes a cache consistency optimization method for a multi-level bus to improve the maintenance efficiency of the cache consistency protocol. The present application will be described in detail below through specific embodiments.
[0039] Embodiment 1
[0040] Figure 1 The present invention provides a schematic flow chart of a cache consistency optimization method for a multi-level bus. Figure 1 As shown, the cache consistency optimization method for a multi-level bus provided in this embodiment may include:
[0041] S101, dividing all processor cores interconnected by a multi-level bus into a plurality of core groups, wherein all processor cores in each core group are interconnected by a primary bus, and the core groups are interconnected by a secondary bus.
[0042] The multi-level bus interconnection in this embodiment can be, for example, two-level interconnection, three-level interconnection, etc., and this embodiment does not limit the number of levels. Taking a CPU with 64 processor cores as an example, when interconnected through two-level buses, every 8 processor cores form a first-level core group based on the first-level bus interconnection, and all 8 first-level core groups are interconnected through the second-level bus; when interconnected through a three-level bus, every 4 processor cores form a first-level core group based on the first-level bus, every 4 first-level core groups form a second-level core group based on the second-level bus, and all 4 second-level core groups are interconnected through the third-level bus.
[0043] S102. If there is no cache consistency dependency between the threads running in the current core group and any threads running in any other core group, the cache consistency protocol working mode of the current core group is set to the intra-group cache consistency protocol; if there is a cache consistency dependency between any thread running in the current core group and any thread running in any other core group, the cache consistency protocol working mode of the current core group is set to the inter-group cache consistency protocol.
[0044] The reason why modern CPUs need to maintain cache consistency between any two processor cores is because the hardware cannot assume that there is no need to maintain cache consistency between two threads, that is, the hardware cannot assume that there is no cache consistency dependency between the two threads. In this embodiment, how to determine whether there is a cache consistency dependency between two threads can be explained from the following aspects. The specific implementation is as follows: 1) It is assumed by default that there is no cache consistency dependency between different processes, which also means that it is safe to turn off cache consistency between two threads belonging to different processes. 2) It is assumed by default that there is a cache consistency dependency between different threads of the same process, that is, the cache consistency between different threads belonging to the same process needs to be maintained. 3) After establishing a shared storage space between two processes, there is a cache consistency dependency between the two processes and their threads. 4) A cache consistency declaration command is provided so that a group of processes or a group of threads can declare whether there is or is not a cache consistency dependency between them.
[0045] It is understandable that as time goes by, the threads running on a processor core will continue to change, and this change is completed by the scheduling of threads by the operating system. Therefore, in this embodiment, it can be determined during thread scheduling whether each core group should use the intra-group or inter-group cache consistency protocol. This determination process can be completed by the operating system, or it can be accelerated with the assistance of corresponding hardware. The following is an example of the operating system completing the determination process: First, the operating system records each thread group with cache consistency dependencies. When creating or ending a thread (or process), establishing a shared storage space between processes, or a group of processes (or a group of threads) calling a cache consistency declaration command, the cache consistency dependency between threads is updated. When the operating system performs thread scheduling, it can determine whether each core group has a cache consistency dependency with other core groups after the scheduling is completed based on the cache consistency dependency between threads at that time. If two threads with cache consistency dependencies run on two different core groups at the same time, there is a cache consistency dependency between the two core groups. Establishing shared storage space between processes and calling cache consistency declaration commands will change the cache consistency dependencies between some threads, which may involve running threads, thereby changing the cache consistency dependencies between core groups. Therefore, when the cache consistency dependencies between threads change, it is necessary to determine whether the cache consistency dependencies between core groups will change. Generally speaking, creating or ending a thread (or process) and establishing shared storage space between processes are system calls that need to be processed by the operating system. If the cache consistency declaration command is also made a system call, it can ensure that the operating system can perceive any changes in cache consistency dependencies.
[0046] That is to say, in some embodiments, the operating system records each thread group with cache consistency dependencies, and updates the cache consistency dependencies between threads when creating or ending a thread or process, establishing shared storage space between processes, or calling a cache consistency declaration command; when the operating system performs thread scheduling, it determines the cache consistency protocol working mode of each core group based on the cache consistency dependencies between threads at that time.
[0047] Based on the above description of how the cache consistency protocol of each core group is determined during thread scheduling, the thread scheduling of the operating system is further optimized. Specifically, threads with cache consistency dependencies are scheduled to the same core group. For example, when thread A is scheduled for execution, there are idle processor core resources in the two core groups C1 and C2, where A has a cache consistency dependency with the threads on C1 but has no dependency with any threads on C2, then A should be scheduled to run on C1, and should not be scheduled to run on C2.
[0048] S103, the core group whose cache consistency protocol works in the intra-group cache consistency protocol independently maintains the intra-group cache consistency protocol based on the primary bus, and the core group whose cache consistency protocol works in the inter-group cache consistency protocol jointly maintains the inter-group cache consistency protocol with other core groups that have cache consistency dependencies based on the primary bus and the secondary bus.
[0049] The cache consistency optimization method for multi-level buses provided in this embodiment divides all processor cores interconnected by multi-level buses into multiple core groups, all processor cores in each core group are interconnected by a primary bus, and core groups are interconnected by a secondary bus; if each thread running in the current core group does not have a cache consistency dependency relationship with any thread running in any other core group, the cache consistency protocol working mode of the current core group is set to the intra-group cache consistency protocol; if any thread running in the current core group has a cache consistency dependency relationship with any thread running in any other core group, the cache consistency protocol working mode of the current core group is set to the inter-group cache consistency protocol; the core group whose cache consistency protocol working mode is the intra-group cache consistency protocol independently maintains the intra-group cache consistency protocol based on the primary bus, and the core group whose cache consistency protocol working mode is the inter-group cache consistency protocol jointly maintains the inter-group cache consistency protocol based on the primary bus and the secondary bus with other core groups with cache consistency dependencies. The maintenance efficiency of the cache consistency protocol is improved.
[0050] Embodiment 2
[0051] On the basis of the above embodiments, the following will further explain in detail how to complete the intra-group cache consistency protocol and the inter-group cache consistency protocol. It should be noted that the following functions can be achieved by upgrading the bus hardware: each core group can independently complete the intra-group cache consistency protocol based on its primary bus, or it can jointly complete the inter-group cache consistency protocol with several other core groups. Specifically, the primary bus and the secondary bus can be disconnected or connected to each other through a switch. When the secondary bus and a primary bus remain disconnected, the core group corresponding to the primary bus performs the intra-group cache consistency protocol; when the secondary bus and a primary bus remain connected, the core group corresponding to the primary bus performs the inter-group cache consistency protocol. That is, in some embodiments, the primary bus and the secondary bus are disconnected or connected to each other through a switch, and the cache consistency protocol works in a manner that the primary bus corresponding to the core group of the intra-group cache consistency protocol remains disconnected from the secondary bus, and the cache consistency protocol works in a manner that the primary bus corresponding to the core group of the inter-group cache consistency protocol remains connected to the secondary bus.
[0052] The controller of a primary bus will implement various cache consistency protocol working modes. When it is an intra-group cache consistency protocol, the primary bus controller allows each processor core to perform cache consistency operations only with other processor cores in the same core group. Based on the primary bus, the independent maintenance of the intra-group cache consistency protocol can specifically include: the primary bus controller allows each processor core to perform cache consistency operations only with other processor cores in the same core group.
[0053] When it is an inter-group cache consistency protocol, the primary bus controller enables each processor core to perform cache consistency operations with other processor cores in the same core group, as well as with processor cores of other core groups that are in the inter-group cache consistency protocol mode. The secondary bus controller obtains and records the cache consistency protocol working mode of all core groups, and sends the information to all core groups in the inter-group cache consistency protocol mode. Based on the primary bus and the secondary bus, the inter-group cache consistency protocol is jointly maintained with other core groups that have cache consistency dependencies, which may specifically include: the primary bus controller enables each processor core to perform cache consistency operations with other processor cores in the same core group and other processor cores of each core group that adopt the inter-group cache consistency protocol mode; the secondary bus controller obtains and records the cache consistency protocol working mode of all core groups, and sends it to all core groups that adopt the inter-group cache consistency protocol mode.
[0054] It is important to emphasize that the working mode of the cache coherence protocol of a core group may change over time, for example, from inter-group to intra-group, or vice versa. When a change is about to occur, the primary bus controller should first initiate a request to the secondary bus controller, and only after receiving a response from the secondary bus controller can the working mode change be completed. After receiving a request from a primary bus controller, the secondary bus controller needs to record the upcoming change, and then notify the primary bus controllers of each core group that is in the inter-group cache coherence protocol mode of the change.
[0055] Embodiment 3
[0056] The application thread may call operating system commands, that is, make a system call. This means that the application thread will pass parameters to the operating system thread, so that there is shared storage space between the application thread and the operating system thread. When an application thread is making a system call, it may happen that the core group where the thread is located is using the intra-group cache consistency protocol while the operating system thread is running on another core group. This application provides two ways to implement parameter passing between application threads and operating system threads.
[0057] The first method is to implement parameter passing through forced memory read and write, that is, the application thread and the operating system thread read and write parameters through the memory without passing through the cache, that is, the reading and writing of parameters bypass the cache. This function needs to be implemented based on a combination of software and hardware, for example, there needs to be read and write instructions that bypass the cache (which may lead to a large number of modifications to the operating system call program), or there needs to be a processor state setting that bypasses the cache (let the operating system thread always be in a state of bypassing the cache, and let the application thread be in a state of bypassing the cache during the system call). That is to say, in some embodiments, when the application thread calls the operating system command, the application thread and the operating system thread read and write parameters through the memory without passing through the cache to implement parameter passing between the application thread and the operating system thread.
[0058] The second is when the application thread and the operating system thread are not on the same core group, ensuring that the core group where the application thread is located and the core group where the operating system is located use the inter-group cache consistency protocol when the system call is made. This can be achieved through hardware, that is, the application thread queries the core group where the operating system thread is located at the beginning of the system call, and when it is found that the core group where it is located is different from the core group where the operating system thread is located, it initiates a request to the secondary bus to let the two core groups use the inter-group cache consistency protocol; when the system call is completed, the cache consistency protocol of each core group is restored to the corresponding state. That is to say, in some embodiments, when the application thread calls the operating system command, if the application thread and the operating system thread are not in the same core group, the core group where the application thread is located and the core group where the operating system thread is located both use the inter-group cache consistency protocol.
[0059] Normally, there are two ways to write the data in the modified valid cache block back to the memory, namely write-through and write-back. Wherein write-through means that the data of the store instruction is written to the memory immediately after the corresponding cache block is modified, while write-back means that the data of the store instruction is not written to the memory immediately after the corresponding cache block is modified, but is written to the memory only when the cache block is to be replaced. The operating system will use methods such as time slice rotation to switch threads running on each processor core, which may cause a thread running on one core group to be scheduled to run on another core group. When the private cache of each core adopts a write-back strategy, there will be a situation where a thread needs to migrate the cache block that was not written to the shared cache or memory before swapping out from one core to the private cache of another core. When there is only a global cache consistency protocol, this cache block migration process can be automatically completed through the cache consistency protocol. However, in the technical solution provided in the present application, it may occur that two cores are in two core groups that use the cache consistency protocol within the group, making it impossible to complete the migration of cache blocks through the cache consistency protocol. In order to ensure correctness, the present application proposes that: when a thread is swapped out, all valid cache blocks that have been modified by the thread and have not been written back need to be written to the shared cache or memory first. This usually needs to be done through the hardware function support of the cache. That is, before the thread is swapped out, all valid cache blocks that have been modified by the thread and have not been written back are written to the shared cache or memory.
[0060] The above content is discussed using cache consistency under a multi-level bus as an example, but it is also applicable to the case of a multi-level directory protocol (where each core group has an intra-group consistency directory and all core groups have an inter-group consistency directory). For the intra-group cache consistency protocol, only the intra-group consistency directory is used; for the inter-group cache consistency protocol, the inter-group consistency directory is used in combination.
[0061] The above content also applies to the situation where the directory protocol and the bus protocol are mixed at multiple levels, in which it is not limited which level uses the directory protocol and which level uses the bus protocol. For example, for two-level mixing, there can be two scenarios. Among them, the first is to use the directory protocol within each core group and the bus protocol between core groups. For the case of the cache consistency protocol within the group, only the intra-group consistency directory is used; for the case of the cache consistency protocol between groups, the intra-group consistency directory and the inter-group consistency bus are used together. The second is to use the bus protocol within each core group and the directory protocol between core groups. For the case of the cache consistency protocol within the group, only the intra-group consistency bus is used; for the cache consistency protocol between groups, the intra-group consistency bus and the inter-group consistency directory are used together.
[0062] Embodiment 4
[0063] Figure 2 The schematic diagram of the structure of a cache consistency optimization device for a multi-level bus provided by an embodiment of the present disclosure. Figure 2 As shown, the cache consistency optimization device 20 for a multi-level bus provided in this embodiment may include:
[0064] A division module 201 is used to divide all processor cores interconnected by multi-level buses into multiple core groups, all processor cores in each core group are interconnected by a primary bus, and the core groups are interconnected by a secondary bus;
[0065] The setting module 202 is used to set the cache consistency protocol working mode of the current core group to the intra-group cache consistency protocol if there is no cache consistency dependency between each thread running in the current core group and any thread running in any other core group; if any thread running in the current core group has a cache consistency dependency with any thread running in any other core group, then set the cache consistency protocol working mode of the current core group to the inter-group cache consistency protocol;
[0066] Processing module 203 is used for the core group whose cache consistency protocol working mode is the intra-group cache consistency protocol to independently maintain the intra-group cache consistency protocol based on the primary bus, and the core group whose cache consistency protocol working mode is the inter-group cache consistency protocol to jointly maintain the inter-group cache consistency protocol with other core groups that have cache consistency dependencies based on the primary bus and the secondary bus.
[0067] The device of this embodiment can be used to perform Figure 1 The technical solution of the method embodiment shown has similar implementation principles and technical effects, which will not be repeated here.
[0068] In some embodiments, the primary bus and the secondary bus are disconnected or connected to each other through a switch. The cache consistency protocol works in a mode where the primary bus and the secondary bus corresponding to the core group of the intra-group cache consistency protocol remain disconnected, and the cache consistency protocol works in a mode where the primary bus and the secondary bus corresponding to the core group of the inter-group cache consistency protocol remain connected.
[0069] In some embodiments, the processing module 203 is used to independently maintain the cache consistency protocol within the group based on the primary bus, which may specifically include: the primary bus controller enables each processor core to perform cache consistency operations only with other processor cores in the same core group;
[0070] The processing module 203 is used to jointly maintain the inter-group cache consistency protocol with other core groups that have cache consistency dependencies based on the primary bus and the secondary bus. Specifically, it may include: the primary bus controller enables each processor core to perform cache consistency operations with other processor cores in the same core group and processor cores of other core groups that adopt the inter-group cache consistency protocol; the secondary bus controller obtains and records the cache consistency protocol working mode of all core groups, and sends it to all core groups that adopt the inter-group cache consistency protocol.
[0071] In some embodiments, the operating system records each thread group having a cache coherence dependency, and updates the cache coherence dependency between threads when creating or ending a thread or process, establishing a shared storage space between processes, or calling a cache coherence declaration command;
[0072] When the operating system performs thread scheduling, it determines the working mode of the cache consistency protocol of each core group based on the cache consistency dependencies between threads at that time.
[0073] In some embodiments, the processing module 203 is further configured to schedule threads having cache coherence dependencies to the same core group.
[0074] In some embodiments, the processing module 203 is also used for, when the application thread calls the operating system command, the application thread and the operating system thread read and write parameters through the memory instead of the cache, so as to realize parameter transfer between the application thread and the operating system thread.
[0075] In some embodiments, the processing module 203 is also used for, when an application thread calls an operating system command, if the application thread and the operating system thread are not in the same core group, then both the core group where the application thread is located and the core group where the operating system thread is located adopt an inter-group cache consistency protocol.
[0076] In some embodiments, the processing module 203 is further configured to write all valid cache blocks that have been modified by the thread and have not yet been written back into the shared cache or memory before the thread is swapped out.
[0077] Embodiment 5
[0078] On the basis of the above embodiments, this embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the above embodiments.
[0079] In some implementations of this embodiment, a computer-readable storage medium is provided, on which a computer program is stored, characterized in that when the computer program is executed by a processor, the steps of the method described in the above embodiment are implemented.
[0080] In some implementations of this embodiment, a computer program product is provided, including a computer program / instructions, characterized in that when the computer program is executed by a processor, the steps of the method described in the above embodiment are implemented.
[0081] The processor may include, but is not limited to, one or more processors or microprocessors. Each processor may be an application specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a controller, a microcontroller, a microprocessor or other electronic components to execute the method in the above embodiments.
[0082] The computer-readable storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof, and the computer-readable storage medium may include but is not limited to, for example, random access memory (RAM), read-only memory (ROM), flash memory, EPROM memory, EEPROM memory, registers, computer storage media (e.g., hard disk, floppy disk, solid-state drive, removable disk, CD-ROM, DVD-ROM, Blu-ray disc, etc.).
[0083] The computer-readable storage medium may also store at least one computer executable program / instruction, which may be, for example, a computer-readable instruction. The computer-readable storage medium includes, but is not limited to, for example, a volatile memory and / or a non-volatile memory. The volatile memory may include, for example, a random access memory (RAM) and / or a cache memory (cache), etc. The computer-readable storage medium may include, for example, a read-only memory (ROM), a hard disk, a flash memory, etc. For example, a non-transitory computer-readable storage medium may be connected to a computing device such as a computer, and then, when the computing device runs the computer-readable instructions stored on the computer-readable storage medium, the various methods described above may be performed.
[0084] In addition, the computer device may also include (but not limited to) a data bus, an input / output (I / O) bus, a display, and input / output devices (eg, keyboard, mouse, speaker, etc.), etc.
[0085] The processor may communicate with external devices via an I / O bus via a wired or wireless network.
[0086] In one embodiment, the at least one computer executable instruction may also be compiled into or constitute a software product / computer program product, wherein one or more computer executable instructions are executed by a processor to perform the various functions and / or method steps in the embodiments described in the present technology.
[0087] In the embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0088] It should be noted that in the present disclosure, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element limited by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0089] Although the embodiments disclosed in the present disclosure are as above, the above contents are only embodiments adopted for facilitating the understanding of the present disclosure and are not intended to limit the present disclosure. Any technician in the technical field to which the present disclosure belongs can make any modifications and changes in the form and details of the implementation without departing from the spirit and scope disclosed in the present disclosure, but the scope of patent protection of the present disclosure shall still be subject to the scope defined in the attached claims.
Claims
1. A cache consistency optimization method for a multi-level bus, characterized in that: include: Divide all processor cores interconnected by multi-level buses into multiple core groups, all processor cores in each core group are interconnected by a primary bus, and core groups are interconnected by a secondary bus; If the threads running in the current core group do not have a cache consistency dependency with any threads running in any other core group, the cache consistency protocol working mode of the current core group is set to the intra-group cache consistency protocol; If any thread running in the current core group has a cache consistency dependency with any thread running in any other core group, the cache consistency protocol working mode of the current core group is set to the inter-group cache consistency protocol; The core group whose cache consistency protocol works in the intra-group cache consistency protocol independently maintains the intra-group cache consistency protocol based on the primary bus. The core group whose cache consistency protocol works in the inter-group cache consistency protocol jointly maintains the inter-group cache consistency protocol with other core groups with cache consistency dependency based on the primary bus and the secondary bus. The method of independently maintaining the intra-group cache consistency protocol based on the primary bus includes: the primary bus controller enables each processor core to perform cache consistency operations only with other processor cores in the same core group; the method of jointly maintaining the inter-group cache consistency protocol with other core groups that have cache consistency dependencies based on the primary bus and the secondary bus includes: the primary bus controller enables each processor core to perform cache consistency operations with other processor cores in the same core group and processor cores of other core groups that adopt the inter-group cache consistency protocol; the secondary bus controller obtains and records the cache consistency protocol working mode of all core groups, and sends it to all core groups that adopt the inter-group cache consistency protocol.
2. The method according to claim 1, characterized in that The primary bus and the secondary bus are disconnected or connected to each other through a switch. The cache consistency protocol works in a manner that the primary bus corresponding to the core group of the intra-group cache consistency protocol remains disconnected from the secondary bus, and the cache consistency protocol works in a manner that the primary bus corresponding to the core group of the inter-group cache consistency protocol remains connected.
3. The method according to claim 1, characterized in that The operating system records each thread group with cache consistency dependencies, and updates the cache consistency dependencies between threads when creating or ending a thread or process, establishing a shared storage space between processes, or calling a cache consistency declaration command; When the operating system performs thread scheduling, it determines the working mode of the cache consistency protocol of each core group based on the cache consistency dependencies between threads at that time.
4. The method according to claim 3, characterized in that Schedule threads with cache coherence dependencies onto the same core group.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: When the application thread calls the operating system command, the application thread and the operating system thread read and write parameters through the memory instead of the cache, so as to realize the parameter transfer between the application thread and the operating system thread.
6. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: When an application thread calls an operating system command, if the application thread and the operating system thread are not in the same core group, the core group where the application thread is located and the core group where the operating system thread is located both use an inter-group cache consistency protocol.
7. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Before a thread is swapped out, all valid cache blocks that have been modified by the thread and not yet written back are written to the shared cache or memory.
8. A cache consistency optimization device for a multi-level bus, characterized in that: include: A partitioning module is used to partition all processor cores interconnected by multi-level buses into multiple core groups, all processor cores in each core group are interconnected by a primary bus, and the core groups are interconnected by a secondary bus; A setting module, used for setting the cache consistency protocol working mode of the current core group to the intra-group cache consistency protocol if there is no cache consistency dependency between the threads running in the current core group and any threads running in any other core group; If any thread running in the current core group has a cache consistency dependency with any thread running in any other core group, the cache consistency protocol working mode of the current core group is set to the inter-group cache consistency protocol; A processing module, used for a core group whose cache consistency protocol works in an intra-group cache consistency protocol to independently maintain an intra-group cache consistency protocol based on a primary bus, and a core group whose cache consistency protocol works in an inter-group cache consistency protocol to jointly maintain an inter-group cache consistency protocol with other core groups having a cache consistency dependency relationship based on a primary bus and a secondary bus; The method of independently maintaining the intra-group cache consistency protocol based on the primary bus includes: the primary bus controller enables each processor core to perform cache consistency operations only with other processor cores in the same core group; the method of jointly maintaining the inter-group cache consistency protocol with other core groups that have cache consistency dependencies based on the primary bus and the secondary bus includes: the primary bus controller enables each processor core to perform cache consistency operations with other processor cores in the same core group and processor cores of other core groups that adopt the inter-group cache consistency protocol; the secondary bus controller obtains and records the cache consistency protocol working mode of all core groups, and sends it to all core groups that adopt the inter-group cache consistency protocol.
9. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
11. A computer program product comprising a computer program / instructions, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
