Shared Data Structures
By sharing read-only elements across processing units in a multi-tile processor, the memory demands of parallel processing are reduced, enabling larger models to be executed efficiently without excessive memory usage.
Patent Information
- Application Number
- JP2023502613
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-07-14
- Filing Date
- 2021-07-13
- Publication Date
- 2024-11-11
- Estimated Expiration
- 2041-07-13
AI Technical Summary
The permanent storage of local programs and data in the memory of each tile within a multi-tile processor chip leads to memory space exhaustion and inefficient use, particularly in parallel processing scenarios where the same operations need to be performed simultaneously across multiple tiles.
A method of sharing read-only elements, such as executable code sequences and constant data, across processing units by designating a master processing unit to store these elements and transmitting them to other units as needed, reducing the need for duplicate storage on each tile.
This approach optimizes memory usage by minimizing the amount of memory required for always-live data, allowing larger models to be run on the chip without increasing memory capacity and reducing the burden on memory resources.
Smart Images

Figure 0007580567000001 
Figure 0007580567000002 
Figure 0007580567000003
Abstract
Description
[Technical field]
[0001] The present disclosure relates to compiling graph-based programs to run on a processing system having one or more processor chips, each having one or more processor modules or "tiles." The present disclosure further relates to a processing system into which the compiled code is loaded. [Background technology]
[0002] Programs are typically written in a high-level programming language. A high-level programming language refers to a language that is abstracted from at least some of the specific architecture of a processor and is therefore more human understandable than the low-level machine code instructions executed by the target processor. Compilation refers to the process of taking a program written in a high-level language and lowering it to a form executable by a processor, i.e., converting a high-level program into a low-level program having machine code instructions executable by a processor. For purposes of this disclosure, an "instruction" refers to a machine code instruction, i.e., an instance of a set of basic instruction types that an execution unit of a processor is configured to recognize and execute. This set is referred to in the art as the instruction set of the processor. Each instruction type in the instruction set is defined by a different respective opcode mapping to a corresponding type of operation in the execution unit, and by zero or more operand fields for carrying respective zero or more operands of the operation.
[0003] Currently, high-level programs often have the form of a graph. For example, this may be the case when a processor has multiple processor modules, often also called "tiles". Each tile has its own memory and execution units (usually each configured with the same instruction set). These tiles are connected to each other via on-chip interconnects that allow pieces of code running on different tiles to communicate with each other between tiles on the same chip (i.e., die). Also, in some cases, a system may have multiple chips, each with multiple tiles. In this case, the chips may be connected to each other via external interconnects that allow tiles on different chips to communicate with each other. A graph describes multiple data nodes, compute vertices, and edges between the nodes and / or vertices. It is the task of the compiler to determine, among other things, which data nodes and which vertices should be implemented on which tiles. Thus, separate parts of the program code can be executed in parallel on different ones of the tiles. Thus, multiple independent processing resources can be connected to each other with a high level of parallelism.
[0004] An exemplary application of parallel processing is found in machine intelligence. As is well known to those skilled in the art of machine intelligence, machine intelligence algorithms are based on performing iterative updates to a "knowledge model", which can be represented by a network of multiple interconnected nodes or "neurons". Each neuron represents a function of its inputs. Some neurons receive inputs to the network, some receive inputs from one or more other neurons, while the outputs of some neurons form the inputs of the other neurons, and the outputs of some neurons provide the output of the network. Furthermore, the function in each neuron is often parameterized by one or more individual parameters, called weights (not necessarily meaning multiplicative weights, although that is one possibility). In the learning stage, the aim is to find values for the various weights based on a set of empirical input data, such that the network as a whole will generate the desired output for a range of possible inputs. Various algorithms for doing this are known in the art, such as the backpropagation algorithm based on stochastic gradient descent. Over multiple iterations based on the input data, the weights are gradually tuned to reduce the error, and the network converges towards a solution. The trained model can then be used in subsequent stages to perform output predictions given a prescribed set of inputs, or to perform inferences about the inputs (causes) given a prescribed set of outputs.
[0005] The implementation of each neuron involves processing data, and the interconnections of the graph correspond to the data exchanged between neurons. Typically, at least some of the processing of each neuron can be performed independently of some or all of the other neurons in the network, and large neural networks offer great opportunities for parallelism.
[0006] Graph-based approaches are in no way limited to multi-tile processors or parallel processing, nor are they limited to neural networks or machine intelligence applications: in general, graphs can be used to describe arbitrarily complex flows or interrelationships between operations and data.
[0007] To maximize the usefulness of parallel processing, it is desirable to have as many tasks executed in parallel as a particular chip will allow; that is, ideally all tiles are active (executing code) simultaneously for a large portion of the time. For a tile to be active, its execution units are executing instructions that form part of a local program that is stored in the tile's local memory. Some types of graphs (notably machine learning and neural network graphs) require the same operations to be executed simultaneously in multiple tiles. To achieve this, the same local program needs to be available on each tile. This can be achieved by pulling down a compiled version of the program onto each tile when the chip is configured to implement the graph. Summary of the Invention [Problem to be solved by the invention]
[0008] The inventors have recognized that this places capacity demands on the local memory of each tile in the chip. If a local program were permanently stored in binary (machine-readable) form on the tile, it would use up its memory space, regardless of whether it is currently being executed by the tile. Such permanent storage is often referred to as "baking" the binary.
[0009] The inventors have further recognized that similar considerations apply to data that may be provided to a local program: This data may include constants that are required by the program and need to be replicated across all tiles that have a particular program that requires the constants.
[0010] This disclosure addresses these and other challenges. [Means for solving the problem]
[0011] One aspect of the disclosure provides a method for storing code on a computer having a plurality of processing units, each processing unit having a local memory configured to store read-only elements including executable code sequences, and an execution stage for executing at least some of the executable code sequences stored in the local memory, the method comprising: identifying at least one of a plurality of processing units of a computer as a master processing unit; compiling a read-only element including an executable code sequence for loading into a processing unit of a computer to allocate at least one shareable read-only element to said master processing unit; storing, in a local memory of the master processing unit, at least one shareable read-only element designated for use by an execution stage of at least one other processing unit, and a transmit exchange code sequence designated for execution in the execution stage of the master processing unit at a time determined at compile time, for the processing unit to identify the shareable read-only element and generate a message having the shareable read-only data element to be transmitted for receipt by the at least one other processing unit; has.
[0012] The shareable read-only element may comprise executable code sequences that are executed in an execution stage of at least one other processing unit.
[0013] For example, an executable code sequence may comprise an instance of a vertex in an application graph.
[0014] In another example, the executable code sequence may comprise control code for managing the execution of the code sequence within a processing unit of a computer.
[0015] In another example, a shareable read-only element has a constant value, which is: Vertex state, Vertex Descriptor, and Field data, It may be one of:
[0016] In some embodiments, compiling includes allocating at least one non-sharable read-only element to at least one of a plurality of processing units.
[0017] In some embodiments, the at least one shareable read-only element is contained within a shared data structure having a plurality of shareable read-only elements.
[0018] Allocating the at least one shareable read-only element can include allocating a plurality of shareable read-only elements to respective addresses of each of the processing units and resolving address constraints of the shareable read-only elements.
[0019] In some embodiments, the method includes storing in a local memory of the at least one other processing unit a received exchange code sequence designated for execution in an execution stage of the at least one other processing unit, the received exchange code sequence causing the at least one other processing unit to store a shareable read-only element received in the message at an assigned address in the local memory of the at least one other processing unit.
[0020] In some embodiments, allocating at least one shareable read-only element to the master processing unit comprises: identifying at least one shared data structure having a plurality of shareable read-only elements within a program flow to be compiled; comparing a storage requirement in memory of the shared data structure with a storage requirement in memory of the transmit exchange code sequence; determining whether to assign the read-only elements to the master processing unit as a shareable data structure or whether to replicate the data structure on multiple processing units based on the comparison; has.
[0021] The program flow can represent an application graph.
[0022] Another aspect of the present disclosure provides a computer, the computer comprising: a plurality of processing units, each processing unit having a local memory configured to store read-only elements including executable code sequences and an execution stage for executing at least some of the executable code sequences stored in the local memory, wherein at least one of the plurality of processing units comprises a master processing unit; the local memory is configured to store at least one shareable read-only element designated for use by an execution stage of the at least one other processing unit, and a transmit exchange code sequence designated for execution in an execution stage of the master processing unit, causing the master processing unit to identify the shareable read-only element and generate a message to be transmitted for receipt by the at least one other processing unit; In this case, the at least one other processing unit stores in its local memory a receiving exchange code sequence that causes the at least one other processing unit to receive the shareable read-only element from the message and store it at an address in its local memory only for the usage period, and the at least one other processing unit is configured to delete the shareable read-only element from its local memory after the usage period. There is no need to have a deletion policy for removing the shareable read-only element from the local memory. In some embodiments, when a new value is written, the value can be overwritten as determined at compile time. At compile time, points in the program that are no longer needed are noted, meaning that it can be overwritten later. This may not be immediately overwritten, in fact it may not be overwritten at all, and may depend on whether the compiler finds another variable that is written later that can be assigned to an overlapping address.
[0023] A message generated by the sending exchange code may have a read address where the shareable data read-only element is to be stored in at least one other processing unit. The read address may be located in the message or in the exchange code. In some embodiments, an address for writing received data is defined in the receiving exchange code.
[0024] At least one shareable read-only element stored in the memory of the master processing unit may form part of a shared data structure having a plurality of shareable read-only elements.
[0025] In some embodiments, the computer has multiple master processing units.
[0026] A shared data structure may contain an executable code sequence or a set of constant values.
[0027] In some embodiments, the step of allocating at least one shareable read-only element to the master processing unit comprises: identifying at least one shared data structure having a plurality of shareable read-only elements within a program flow to be compiled; comparing a storage requirement in memory of the shared data structure with a storage requirement in memory of the transmit exchange code sequence; determining whether to assign the read-only elements to a master processing unit as a shareable data structure or whether to replicate the data structure on multiple processing units based on the comparison; has.
[0028] The program flow can represent an application graph.
[0029] To assist in understanding embodiments of the present disclosure and to illustrate how such embodiments may be practiced, reference should be made to the accompanying drawings, in which: [Brief description of the drawings]
[0030] [Figure 1] FIG. 1 is a schematic block diagram of a system having multiple tiles. [Diagram 2] FIG. 2 is a schematic block diagram of a processor module. [Diagram 3]4 shows a tile that stores a code sequence with pointers that address different variables. [Figure 4] A set of tiles that store variables subject to the same address constraint is shown. [Figure 4A-4B] Different sets of variables are shown. [Diagram 5] 3 illustrates the exchange of data between different tiles. [Figure 6] A set of tiles is shown that stores a pointer to a register that holds an address. [Figure 7] 4 shows a tile that stores a pointer with a two-dimensional vector. [Figure 8] Indicates a tile that stores a pointer with a vector list. [Figure 9] 1 illustrates a method for compiling a program. [Figure 10] 1 illustrates a schematic of a portion of the input graph. [Figure 11] 1 shows a schematic representation of the vertices of a graph with incoming and outgoing edges. [Figure 12] 2 shows a schematic of two equivalent graph representations. [Figure 13] 1 is a schematic flow diagram of a constraint solver process. [Figure 14] An example of a program on each of the two tiles is shown below. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0031] In the embodiments of the invention described below, a computer and a method of compiling for the computer are described, where memory usage can be optimized by identifying read-only elements that can be shared among processing units of the computer. The terms "shared structure" or "shared data structure" are used herein to mean read-only elements that can be shared. If multiple processing units need the same read-only elements, one option is to include a suitable shared data structure in each program compiled for each processing unit so that a copy exists on the computer. According to an embodiment of the invention, an alternative technique is provided, where the shared data structure is stored in the master processing unit and transmitted to one or more other processing units when needed. There is a trade-off between the amount of memory required to store the shared data structure and the associated communication and time overhead when the program is running, as well as the storage of exchange code required to share the data structure among the processing units. If the shared data structure is relatively small (in terms of memory resources consumed), it may be relatively appropriate to replicate it across multiple processing units in the compiled program, rather than using the sharing technique of the described embodiment.
[0032] In one aspect described herein, an analysis is performed that informs whether to use a sharing scheme or whether to replicate data structures across multiple processing units.
[0033] A read-only element may be a code or a constant variable.
[0034] FIG. 1 shows an exemplary processing system in the form of a computer 100 on which compiled programs may be executed according to the embodiments disclosed herein. The computer has a number of processor modules 4a, 4b, 4c, etc., referred to as tiles. The tiles 4a, 4b, 4c may be implemented on one or more processor chips 2, where there are multiple tiles 4 on each chip (i.e., die). With reference to FIG. 2, each individual tile, e.g., tile 4a, has its own individual processing unit 10, each processing unit having its own individual execution unit 18 for executing machine code instructions. Each individual tile also has its own individual memory 22a for storing data and code. Thus, the computer 100 supports a high level of parallelism, thereby enabling parallel execution of different individual parts of an overall program on different tiles 4a, 4b, 4c, etc. For example, chip 2 could have >10, >20, >50, >100, >200, >500, or even >1000 tiles. For example, in an example implementation, there may be 1216 or 1280 tiles / chip. Furthermore, in an embodiment, each processing unit may have the form of a multi-threaded processing unit for interleaving multiple simultaneous threads through the same pipeline, although this is not required for this purpose.
[0035] The computer 100 also comprises an interconnect 6 having hardware logic forming part of an exchange mechanism that allows different tiles 4a, 4b, 4c, etc. to communicate with each other to exchange data, such that the result of an operation performed by one tile, e.g., tile 4a, can be transmitted to another tile, e.g., tile 4c. The interconnect 6 comprises at least an internal (on-chip) interconnect on the chip 2 for communication between tiles 4a on the same chip 2. According to an embodiment of the invention, the interconnect 6 also allows shared data structures to be exchanged between tile memories.
[0036] As part of the compilation process, different parts of the program are assigned to run on other tiles 4 and to exchange data with each other to work together to implement the overall program as a whole. For example, the program may comprise a machine learning algorithm with a neural network, and different tiles may execute parts of the program that represent different vertices of the neural network. The different parts of the program are configured to be synchronized with each other when compiled according to an appropriate synchronization scheme, such as Bulk Synchronous Parallel (BSP), Rendezvous, or Postbox. Preferably, the BSP scheme is used.
[0037] In accordance with the BSP, each tile executes a compute phase and a swap phase in an alternating manner. In the compute phase, each tile executes one or more computational tasks locally on the tile, but does not communicate any results of the computation with any other of the tiles. In the swap phase, each tile is allowed to swap one or more results of the computation from the previous compute phase with one or more other of the tiles in the group, but does not begin a new compute phase until the tile finishes its swap phase. Furthermore, in accordance with this form of BSP principle, barrier synchronization is placed at the junctions where the transitions are made from the compute phase to the swap phase, or where the transitions are made from the swap phase to the compute phase, or both. That is, (a) all tiles must complete their respective compute phases before any of the tiles in the group are allowed to proceed to the next swap phase, or (b) all tiles in the group must complete their respective swap phases before any of the tiles in the group are allowed to proceed to the next compute phase, or (c) both. As used herein, the phrase "between the compute phase and the exchange phase" encompasses all these options.
[0038] As data is exchanged according to the BSP, each tile notifies the synchronization module of its synchronization state. Once it has been established that each tile is ready to send data, the synchronization process causes the system to enter the exchange phase, during which data values are moved between tiles (actually, between the memories of tiles in a memory-to-memory data move). During the exchange phase, there are no operations that could induce concurrency hazards between tile programs.
[0039] The exchange of data or code between tiles may be by any suitable exchange mechanism. One such mechanism developed by Graphcore is described in our patent applications EP-REF-408525EP and US-20190121387A1, the contents of which are incorporated herein by reference. In the exchange phase, each shared element travels along a connecting wire that provides an exit from the tile to a particular exchange path. At each clock cycle, the shared element travels a particular distance along its path (e.g., from latch to latch) in a pipelined manner. When a shared element is issued from a tile, it is not issued with a header that identifies the receiving tile. Instead, the receiving tile knows that it will be requesting an element from a particular sending tile at a particular time. To receive the element at that particular time, the exchanging receiving tile controls a switch to connect the input of the receiving tile to the exchanging path of the sending tile. This is referred to as "time deterministic." Each tile runs a program that is assigned to it by the programmer or by running a compiler, where the programmer or compiler function has knowledge of what will be sent by a particular tile at a particular time and what needs to be received by a receiving tile at a particular time. To achieve this, SEND instructions are included in the local programs executed by the processors on each tile, where the time of execution of the SEND instruction is predetermined relative to the timing of other instructions executing on other tiles in the computer.
[0040] To implement time determinism, the compiler compiles tiled programs based on the time it takes for an element to travel between receiving tiles at the sending end (inter-tile delay). The compiler's function of compiling a graph is described below. The compiler receives a graph of interconnected nodes and links. The nodes and links may also be referred to as vertices or edges. The compiler compiles the functions in the graph into a number of codelets that are contained in local programs. Each local program is designed to be loaded into a particular tile of the computer. Each program has one or more codelets plus a supervisor subprogram, each of which is formed from a sequence of instructions. In a particular embodiment, the compiler generates programs that are linked together in time, i.e., are time deterministic. To do this, the compiler has access to tile data that includes tile identifiers that inform the relative physical locations of the tiles and therefore the inter-tile delays that the compiler needs to understand in order to generate the local programs in a time deterministic manner. Delays can be calculated based on the tile data. Alternatively, the tile data may contain a data structure in which these delays are available through a look-up table.
[0041] It should be understood that the configuration of FIG. 1 is given only as an example. More generally, the system 100 can have multiple processor modules (processing units) 4 located on the same chip 2 or distributed across multiple chips 2 in one or more processor modules 4 / chip 2. In principle, the techniques described herein can be applied in situations where there are multiple processor modules on the same chip or where processor modules are distributed across multiple chips. However, it is expected that there will be relatively large benefits to using the techniques described herein when sharing data structures between multiple tiles on a chip, especially in environments where there are a large number of tiles / chips (such as 1216 or 1280, as in one of the embodiments described herein). After sharing data structures between multiple tiles in a single chip, there is already a large reduction in the amount of memory used for shared data structures, such that the memory reduction from sharing between chips may be negligible in relation to the total memory used. Furthermore, when sharing between chips, the runtime cost considerations also need to take into account the fact that the total bandwidth between chips will be less than that on a single chip.
[0042] The present disclosure relates to compiling code for a multi-tile chip, for example of the type shown in FIG. 1. To maximize the benefits of concurrency, many tiles may be running the same set of vertices (compute sets) at the same vertex state at the same time. This requires that the necessary code and data be available on these tiles. However, this can result in overlapping memory usage and limit the size of the models that can be run on the chip. To overcome this, the present disclosure allows for the sharing of certain structures between tiles at run-time. FIG. 5 illustrates the core principles discussed herein. These principles reside in how to share certain portions of certain data that are normally always live between multiple tiles. Such portions are sometimes referred to herein as "shared structures". The intended benefits of this implementation are described below. In this environment, the data that is normally always live may be executable code or data elements consumed by the executable code, such as certain variables. The data that is normally always live is read-only data. Such data may be, for example, vertex state data. A vertex state can contain (i) a pointer to data (where the pointer is read-only) and / or (ii) data (which may or may not be read-only). As explained more fully below, for each vertex state structure, a check is performed to see if it contains only pointers and read-only data. If it does, then the vertex state structure is a candidate for sharing. Vertex state structures that contain data that may change are not suitable for sharing in accordance with the techniques described herein.
[0043] One benefit is the ability to share data that was previously constant and always live between multiple tiles, so that it only becomes live when it is needed on the tile. In cases where there is little memory available on a tile, the tile can choose to receive the shared data structures as or when they are needed, instead of continually storing them all the time. This frees up memory capacity on the memory-scarce tile. The shared data structures can be moved to other tiles that have more free space to allocate. Such tiles can be the master or storage tiles to send the shared structures to other tiles.
[0044] Another benefit of the techniques described herein is the ability to reduce duplication of data across tiles by storing a single copy of shared data and broadcasting it as needed to tiles needing the same data.
[0045] It should be noted that the system described herein has particular advantages when used for multicast exchange of data, where a shared data structure is transmitted from a master tile to multiple recipient tiles in the same exchange phase of a synchronized group of tiles, i.e., sharing read-only data elements when needed, rather than storing duplicates on each tile, becomes relatively beneficial as the number of tiles receiving the data increases.
[0046] Also, note that when multiple read-only data elements are shared in an exchange phase, one or more of the read-only data elements may be provided for use in a compute phase that immediately follows the exchange phase in which they were shared. However, one or more of the read-only data elements may also be provided for use in a compute phase that does not immediately follow the exchange phase in which they were shared. For example, a line of code may be shared between a master tile and one or more receiving tiles in an exchange phase. In some cases, the code may define a program that requires execution in a compute phase that does not immediately follow the exchange phase in which the code was received in one or more receiving tiles. Note that the smaller the exchange-compute cycles before the read-only data elements are shared, the greater the conservation benefits.
[0047] In essence, the technique allows a trade-off to be made between the processing cycles required on a tile to exchange data between tiles and the amount of memory required to store data that is always live, with the aim of reducing the strain on memory resources on the tiles where it is most needed.
[0048] FIG. 5 illustrates the principles described herein. FIG. 5 illustrates several tiles 4a, 4b, 4c, 4d, 4e of a chip 2 as shown in FIG. 1. According to one feature described herein, several tiles in the tile array of the chip are assigned to be used as storage tiles for always-live data (shared structure) that is required for use across multiple tiles. For example, in FIG. 5, tiles 4a and 4b are assigned as storage tiles. These may be referred to as master tiles herein. It should be understood that the term master tiles does not imply any particular hierarchical structure or control function, but only means that these tiles are storage tiles for always-live data that may be used in other tiles in the system 2. Each master tile has a memory. In FIG. 5, tile 4a is shown to have memory 22a, and tile 4b is shown to have memory 22b. Each memory has different portions or regions that will be described below. Certain parts of the memory may be allocated to store always-live data 55a, 55b, which may be shared with other tiles in the chip 2. Other parts or regions of the memory may be allocated to be used only in operation when the local tile (e.g., local tiles 4a, 4b) is performing its processing function. That is, the memory 22a, 22b on each tile may hold a mixture of always-live data that may be shared between other tiles and always-live data that may be used only on that tile. There is also a certain amount of address space in the memory allocated for writing and reading variables processed by the local tile. The always-live data that is available for exchange can be copied to other tiles via an exchange mechanism implemented on the chip 2, instead of being permanently stored in binary code for each tile.For example, arrow 100c represents a situation where a portion of data 55a from memory 22a is provided to another tile 4c via the chip's swap mechanism. Similarly, arrow 100d represents the sharing of this same portion of data 55a with an alternative tile 4d, and arrow 100e represents the sharing of this portion of data 55a with a further alternative tile 4e. Note that these arrows are only schematic, and in a practical embodiment, the sharing is via interconnect 6. Note that portions of data 55b from memory 22b may be swapped as well. Note also that different portions of memory 22a may be shared between different tiles (this need not always be the same portion broadcast to tiles 4c, 4d, 4e, etc.). It should be further noted that although only five tiles are shown in Figure 5, in reality the array may have many tiles, as described with reference to Figure 1, where a small number of tiles are assigned as master (storage) tiles, and another set of tiles are assigned to receive live data as and when needed. In this environment, the small number of tiles is considered to be two or three, but could be any number if not the complete set of tiles in the array on any particular chip. In general, this would lose its usefulness unless less than one-third of the total number of tiles on the chip are designated as storage tiles, with the remaining tiles designated as recipient tiles.
[0049] By not requiring the completeness of the always-live data to be available in every tile of the chip that may need these items, the amount of memory used to store the always-live data at any one time in the execution of a program can be reduced, allowing larger models to fit on a chip without increasing the number of tiles or the amount of memory required for the model.
[0050] The exchange mechanism uses an exchange code sequence with a set of instructions provided in the local program in each tile 4. This exchange code sequence needs to be executed by the tile's execution unit 18 each time data needs to be exchanged between another tile on the chip. The shared data could be the output (result) of local processing as described herein and / or it could be a shared structure. The exchange of data between tiles is via the interconnect 6. The address in memory where the received data is stored is determined at compile time as described herein. Note that the exchange sequence includes code to send data from the storage tile to the receiving tile. The exchange code on the receiving tile is used to enable receipt of the data. Also note that the location of the exchange code in the local program is the responsibility of the compiler at compile time. When the code compiled and stored on the chip is for executing a model in the form of a graph as described herein, the data that is always live is: host and global exchange packet headers, stack, Vertex instance, Copy Descriptor, Vector List Descriptor, Vertex field data, Control code, Vertex Code, Internal and host exchange codes, The present invention may have one or more of the following:
[0051] Each of these may have different memory storage requirements, for example requiring a different number of bytes.
[0052] In the following, the techniques are described in the context of sharing the categories of vertex codes, vertex states, and control codes, and it will be readily appreciated that the techniques described herein may also be applied to other types of data that are always live in memory.
[0053] As described in more detail herein, vertex code is code that is added to a graph and generated for codelets used by vertices added to the compute set. One copy of vertex code is needed for each vertex instantiated on each tile.
[0054] A vertex state defines the members of an instantiation of a vertex class on each tile.
[0055] The control code includes generated code for executing all vertices in the compute set, for handling the control flow, and for performing other control functions in the control programs that form part of the local program on each tile. As mentioned above, the term "shared structure" is used herein to denote an always-live data item that is exchanged between tiles. That is, the shared structure can be sent from one of the master (storage) tiles to one or more receiving tiles at the time that it is needed by the receiving tile. The time at which the shared structure is needed by the receiving tile is determined at compile time. Note that this is not an absolute time, but a time relative to other aspects of the program running on the receiving tile. The compiler knows the execution sequence of the program across all of the tiles and can schedule the exchange of the shared structure at the appropriate time.
[0056] When compiling a program tree for a particular model, the compiler may introduce a shared structure exchange code sequence at a given point in the program tree. Such a shared structure exchange code sequence allows the shared structure to be exchanged at that point in the program. A liveness analysis of the program tree may be performed before attempting to insert a new shared structure exchange code sequence at a point where it is determined that changing this and storing the associated shared structure on each tile would increase the overall maximum live memory. That is, by comparing the size of the shared structure with the size of the exchange code sequences used to send and receive it, it is determined that an overall reduction in the maximum live memory of the entire program (across all tiles) can be achieved. Note that "size" refers to the number of bytes required to store the shared structure in memory.
[0057] By using what is referred to herein as a "same address constraint," it is possible to increase the amount of data that is common across tiles (ie, by increasing the size of the shared structures).
[0058] FIG. 3 shows read-only data such as a code sequence, which includes, for example, first and second pointers P1, P2. It should be understood that two pointers are an example and there can be one or more pointers. Each pointer could be 4 bytes in length. It should be understood that the pointers can be of any type or length. Various formats of pointers are described below. The read-only data can be a shared structure 55a installed in a portion of memory 22a on the master tile 4a. When the code needs to be used in a set of receiving tiles (in this case, as shown by way of example, an exchange code sequence is executed by the execution unit on tile 4a to send the shared structure 55a to receiving tiles 4b and 4c). The code can be received and installed in ADDRi in tile 4b. The code can be installed in ADDRj in tile 4c.
[0059] Note that it is not necessary for incoming read-only data, such as code portions, to be stored at the same address in each of the receiving tiles, if the local program compiled for each receiving tile knows where to place the code in order to execute it. However, when the code contains one or more pointers, as in this example, these pointers can address variables used by the code. Figure 3 shows four separate variables (VAR1, VAR2, VAR3, VAR4), where VAR1 and VAR2 are located on tile 4b, and VAR3 and VAR4 are located on tile 4c. The variables are not located in a shared structure, but are pointed to from the structure. The variables do not need to have the same value or size.
[0060] Applying the same address constraint to variables VAR1 and VAR3 ensures that they are allocated at the same address. Thus, if VAR1 is stored at ADDR1 in tile 4b, then VAR3 is also stored at ADDR1 in tile 4c. The same pointer or pointers in the shared structure can be used to reference both. In a corresponding manner, VAR2 and VAR4 can also be address constrained and pointed to.
[0061] For example, pointer P1 can address variable VAR1 and pointer P2 can address variable VAR2. A relatively complex pointer format is described below. If the same address constraint is applied, variable VAR1 is constrained to be stored at a specific address in tile 4b and VAR3 is constrained to be held at the same address in tile 4c. For example, ADDR1 can be used to store VAR1 / VAR3 in both tiles. Note that all tiles have a common addressing policy. Similarly, variable VAR2 can also be stored at ADDR2 in tile 4b and VAR4 can also be stored at ADDR2 in tile 4c. Thus, regardless of whether the code portion runs on tile 4b or tile 4c, pointer P1 always points to variables VAR1 / VAR3 at ADDR1 and pointer P2 always points to variables VAR2 / VAR4 at ADDR2.
[0062] For example, the sequence of instructions within a vertex code fragment can essentially be used in all of the tiles within the chip responsible for executing the vertex code. Vertex state or control code can be shared by using pointers to access data (variables).
[0063] In the case of shared vertex states, the variables would represent the data that the vertices are acting on (i.e. the variables that the vertices are connected to the graph via edges), and consequently, in the case of shared control code, the variables could represent the vertex states (the execution instructions that may occur as the shared control code points to the vertex states).
[0064] Different sharing structures may be used for code and data, since other constraints on memory layout may mean that in some cases it is not always possible to store them together. It is possible for the control code, as well as the vertex state it references, to be shared, in which case pointers in the shared control code will point to addresses inside the vertex state sharing structure, and the vertex state sharing structure will be co-address constrained.
[0065] A variable can be co-address constrained as long as the tile is not already co-address constrained with any other variables that intersect with the set of tiles for the set of variables being constrained.
[0066] For example, see Figure 4. In Figure 4A, a first set of tiles is shown as Tile 1, Tile 2, and Tile 3. Variable A is located on Tile 1, variable B is located on Tile 2, and variable C is located on Tile 3. Variables A, B, and C represent a set of variables subject to same-address constraint. If variables A, B, and C are located within the same equal address set, then the addresses of each variable on each respective tile are constrained to be the same. This is shown in Figure 4 on ADDR1.
[0067] Consider now a further set of variables D, E, and F to be stored on tiles 1, 4, and 5 (see FIG. 4A). Similar constraints apply. In this case, only variables A and D are located on the same tile, so that while variables A and D can be assigned at different addresses, there can be two identical sets of addresses, as well as variables B and C, and E and F, which are constrained to the same addresses as in tile 1 (shown in dotted state within tile 1).
[0068] Figure 4 shows two sets of variables whose locations in the address space of the tiled memory are indicated by the location of the associated rectangle. Variables A, B, and C are address constrained. Thus, in set 1, variable A is located at ADDR1 on tile 1, variable B is located at ADDR1 on tile 2, and variable C is located at ADDR1 on tile 3. In the second set, variables D, E, and F are constrained to be assigned at the same address ADDR2. Since A and D are located on the same tile (tile 1), they cannot be assigned at the same address; the addresses of A, B, and C must be different from D, E, and F.
[0069] However, consider the alternative case of Figure 4B, where the first set of variables is A on tile 1, B on tile 2, and C on tile 3, and the second set of variables is D on tile 1, B on tile 2, and C on tile 3. Note that in Figure 4B it is not possible to same-address constrain these two sets because variables B and C would need to be located at the same address, which would have the effect that variables A and D would also need to be located at the same address. However, this would create a clash since variables A and D are both in tile 1.
[0070] Note that prior to allocation, addresses ADDR1 and 2 are not default address locations, although they will become default address locations after the compiler finishes allocating addresses for the code as a whole, but they are marked as address constrained.
[0071] There are several formats of pointers inside the vertex states that can be constrained: if these can be constrained, then the vertex states can form part of a shared structure.
[0072] The vertex state structure is stored in memory, which may contain a pointer, in which case, at some offset inside the vertex state structure, the value of that memory location is the address of the block of memory to which the pointer is pointing.
[0073] The simplest form of pointer format is a one-dimensional vector. They simply point to a contiguous block of memory. To share them, this block of memory must have the same address constraint. For example, referring to Figure 6, pointer Pn points to location ADDRn in a block of memory forming part of memory 22a. ADDRn holds the variable VAR.
[0074] Another format of the pointer is a two-dimensional vector that includes an extra level of direction. A base pointer Pb points to a contiguous block B of other pointers P1, P2, etc. With reference to FIG. 7, Pb identifies a memory location at address ADDRq, which identifies the base of block B. For example, the vertex field data described above may have a block of pointers. In order to share this, the contiguous block of pointers needs to be address constrained. Note that vertex codes may be shared and / or vertex states may be shared. The choice of whether to share vertex states is independent of whether to share vertex codes.
[0075] Another form of pointer is a data structure such as a vector list, which includes an extra level of direction (like the two-dimensional vector mentioned above), where the extra level is also a contiguous block of memory, see FIG. V1 The memory block ADDRv that is pointed to (via register 26) is the base pointer P b1 ADDRw is a layer of indirection that contains an offset into the second level of memory ADDRw, represented by . The location of the outer memory location is baked into the vertex state, which means that this layer must also be constrained or the shared internal state will not be identical. The vector list has two pointers stored in the vertex state. One is a pointer P to a block of memory containing the offset. r1 and the other is a base pointer P to which an offset is added to form the address of the variable that the vector list references. B1 To share the vertex state that contains the vector list, the address of the block of memory that contains the offset must be constrained to the same address, and in this case, the memory location that the base pointer is pointing to must also be constrained to the same address.
[0076] If it is not possible to generate a shared structure that represents the fragment of the vertex state to which a set of variables is constrained, the compiler will attempt to address-constrain a relatively small subset of the variables as part of constraining the vertex state to two identical fragments. This can provide multiple copies of a shared structure containing the vertex state for a local tiled program.
[0077] Vertex code can also be compiled into a shared structure. Unlike vertex state, each of which is specific to a single instance of a vertex in a compute set, vertex code is reused across the lifetime of a program. Vertex code can be formed as a shared structure in the following manner:
[0078] According to one approach, all vertex codes are stored on a single master (storage tile) and a shared structure is dynamically constructed containing the vertex codes needed for the lifetime of the shared structure.
[0079] According to another approach, a shared structure is built at compile time so that any vertex code used in multiple compute sets is copied.
[0080] The second approach is simpler than the first, but it does use relatively large amounts of memory across the chip. However, it has been found that the extra memory required to copy the vertex code does not have a significant impact on the simplicity. Each vertex has a type that defines its inputs and outputs, and code that is executed when the vertex runs. Each instance of a particular type is often referred to as a codelet. Multiple vertices can have the same codelet. Each vertex has a separate vertex state structure, but the same code is used for all vertices that share the same codelet.
[0081] Consider a scenario where there are two compute sets: compute set A containing vertices of types C0 and C1, and compute set B containing vertices of types C0 and C2. A copy of the shared structure may be inserted in front of each compute set, containing C0 and C1 in compute set A's copy of the previous shared structure, and C0 and C2 in compute set B's copy of the previous shared structure. In this case, two shared structures are created on the master tile, one containing C0 and C1 and one containing C0 and C2, i.e., C0 is copied and stored twice on the master tile. The benefit of copying C0 is that all of the vertex code needed for each shared structure copy is located in one contiguous block and is easy to copy.
[0082] This also allows code to be shared such that everything the code references through pointers is itself shared or co-address constrained.
[0083] The control code has different program types with supervisor code depending on the function being implemented. For each different type of control code program, a different permutation of the supervisor code is placed in the shared structure, and the control program on each tile uses a call instruction to branch to the correct offset and branches back to the control program when it reaches the end of the shared program.
[0084] In some applications, each program may have only a small amount of assembly code. For example, the control code required to execute a vertex in a compute may be as little as four instructions, but this is by way of example only and other numbers of instructions can be used. In such cases, there is a relatively large benefit to be gained by sharing a program between consecutive programs that have been folded into one. This can be achieved by obtaining a union of all tiles between the two sharing programs.
[0085] FIG. 14 shows an example of a logic flow that may be implemented in each of the two tiles. Tile 4a is the master tile in this environment, and tile 4c is one of several receiving tiles. Tile 4c is responsible for executing compute sets, which may be, for example, a set of vertices. The same vertex may run on different vertex states. These compute sets may be precompiled into individual tiles, or may themselves be shared from the master tile. The control code that controls the execution of the vertices and / or vertex states on which the compute sets run may be shared. According to the shared structure paradigm herein, this requires first receiving these shared structures from the master tile. The receiving tile 4c first performs a step of performing an exchange using the exchange code to receive a first shared structure, such as a vertex state or control code. The compute sets CS1, CS2 are executed under the control of the control code on the first vertex state, and the results are copied to local memory (on the tile). After this, the same tile may need to execute the same compute sets CS1, CS2 on a different data set representing a second vertex state. Another exchange step is performed to receive a second shared data structure for the second vertex state. Note that the shared data structures may be exchanged before each stage of execution when needed, or there may be a look-ahead function that receives the compute sets a few cycles before they are needed.
[0086] The master tile 4a is shown as having a sequence of steps to perform the exchange, each sending live data to the receiving tiles 4c at all times (for example, shared data structures are sent when needed by the receiving tiles, as determined at compile time) and in reality the master tile will perform additional functions, but for the purposes of this description its core function is to send shared structures to the receiving tiles.
[0087] Note that the timing of the exchanges performed in the master tile relative to the execution of the compute sets in the receiving tiles is determined by the compiler at compile time, before each local program is stored in its respective tile.
[0088] 2 provides a schematic example of a processor module, or tile, such as tile 4a. In the case of multiple tiles, in some embodiments, each tile may have an identical instance of processor module 4. Note, however, that stored data held in memory 22a may differ between tiles, as described herein. Processing unit 10 includes execution units 18, one or more register files 26, an instruction fetch stage (not shown), and an instruction decoding stage (not shown).
[0089] The memory 22a has a number of separate memory banks or regions 230, 231, 232, etc. In an embodiment, each bank 23 is 16kB in size, but any suitable size may be implemented. As noted above, certain regions of the memory 22a are configured to store data that is acted upon by code executed by the execution units 18, and data resulting from operations performed by the code executed by the execution units 18. Other regions of the memory 22a are used to store the code itself. Other regions of the memory may store shared structures. The execution units 18 are configured to receive and execute machine code instructions 27 fetched from the memory 22a by the fetch stage and decoded by the decoding stage. The execution units 18 are configured to recognize a particular instruction set that defines a type of instruction, where each instruction type is defined by a different individual opcode and has a corresponding zero or more operand fields. Each of the instructions 27 issued into the execution units 18 is an instance of one of these instruction types defined by the instruction set of the execution units 18.
[0090] These instruction types may include memory access instructions (load and store type instructions), logic instructions (integer arithmetic and floating point instructions), and control instructions (for managing local programs). Execution unit 18 has a load-store unit (LSU) 55 for executing instances of memory access instructions, an integer arithmetic logic unit (IALU) 56 for executing instances of integer arithmetic instructions, and a floating point logic unit (FPU) 59 for executing instances of floating point instructions. Execution unit 18 has further units (not shown) for executing instances of control instructions. Execution unit 18 has hardware logic configured to be triggered by the opcode of each instruction to perform a corresponding operation related to the type of instruction executed.
[0091] Each memory access instruction, when executed, triggers the load-store unit (LSU) 55 to perform at least one load operation or one store operation depending on the particular type of memory access instruction. A load operation involves reading data from a source address in memory 22a into at least one of the registers in one of the register files 26. The source memory address and the register location are specified by the operands of the instruction. In an embodiment, as described above, the source memory address is specified using a pointer (i.e., the operands of the instruction do not directly specify a memory address but rather identify a register in one of the register files 26 in which the source memory address is held). A store operation involves saving data from at least one of the register files 26 to a destination address in memory 22a. The destination memory address and the register location are specified by the operands of the instruction. In an embodiment, the destination memory address is specified using a pointer (i.e., the operands of the instruction identify a register in one of the register files 26 in which the destination memory address is held). Different pointer formats can have different levels of direction, as described above.
[0092] Logical instructions, such as floating point and integer arithmetic instructions, trigger the floating point unit (FPU) 59 or integer logic unit (IALU) 56 to perform the type of mathematical operation mapped to the opcode. The operands of an instruction may have one or more source operands, which specify one or more source registers from which values are to be acted upon, and one or more destination operands, which specify one or more destination registers into which one or more results of the operation performed by the instruction are to be placed. For example, a simple addition instruction will typically have at least three operands, two sources and one destination. When executed, this causes the execution unit 18 to take values in two source registers, add them together, and place the resulting sum in a destination register. Similar logic is applied, for example, for simple subtraction, multiplication, and division instructions. Various other types of logical instructions may also be included in the instruction set, such as vector multiplication, matrix multiplication, and convolution instructions. The control instructions are executed to manage the local program as described above.
[0093] Thus, code running on the processing module can be used to read data from memory 22a into register file 26, perform operations on the data in register file 26, store results back to memory 22a, and manage program flow.
[0094] Instructions are executed over a sequence of instruction issue cycles. In each instruction issue cycle, the fetch stage provides at least one instruction 29 to the execution unit 18 for execution. In embodiments, the execution unit 18 may be pipelined. Furthermore, in some embodiments, the execution unit 18 may have multiple parallel pipelines.
[0095] In an embodiment, processing unit 10 may be a multi-threaded processing unit, also referred to as a barrel thread processing unit, meaning that the fetch stage is configured to fetch instructions from different program threads, interleaving them in time through execution units 18 in different time slots, typically according to a round robin or weighted round robin schedule. More generally, execution units 18 could have a single pipeline or may not need to be pipelined, and processing unit 10 could be multi-threaded or configured to execute only a single program thread.
[0096] FIG. 9 shows an apparatus for compiling high-level graph-based programs into low-level machine code programs for execution on a computer system 100 such as that described in connection with FIGS. 1 and 2.
[0097] The apparatus comprises a computer 504, which could have the form of a server having one or more server units at one or more geographic sites, or one or more user terminals such as desktop computers, or a combination of a server and one or more user terminals. The computer 504 is configured to run a compiler 508, having the form of software stored on a computer readable storage (e.g., one or more internal and / or external magnetic disk drives and / or EEPROM) of the computer 504, configured to run on one or more processors (e.g., one or more CPUs) of the computer 504. The compiler 508, when running on the computer 504, is configured to receive an input graph 502 and then compile the input graph 502 to generate an executable program 506 that can run on a multi-tile computer system 100 such as that described in connection with Figures 1 and 2.
[0098] An example of an input graph is shown in Figure 10. The input graph 502 has a number of data nodes 512, a number of compute vertices 514, and a number of directed edges 516, each connecting between a respective pair of data nodes and vertices.
[0099] Each data node 512 represents a data element, which in this specification means a variable. Note that in a computing or computer science environment, the term "variable" does not necessarily mean that the value of the variable must change at run time, it can change or it can remain constant (i.e., a constant can be considered a type of variable in the computing sense). This is the sense in which the term "variable" is used in this specification. Also, to avoid confusion with other environments, the term "data element" may be adopted. Note also that the data elements or variables referred to in this specification mean a numerical data object or a structure abstracted from a particular value of that object at any one time. For example, a variable or data element could be a numerical object labeled Var1 in a high-level language that can have a constant value or whose value can change one or more times during execution of a compiled program.
[0100] Each edge 516 represents an output from a compute vertex 514 to a data node 512, or vice versa. Each compute vertex 514 (i.e., compute node) represents one or more operations to be performed on one or more inputs received on one or more edges output from one or more data nodes 512, with one or more results being output from the respective compute vertex 514 to one or more data nodes 512 (typically one or more other data nodes) on one or more output edges. It should also be understood that the particular graph topology shown in FIG. 10 is merely an example, and that in practice the graph 502 would tend to have many more nodes 512, edges 516, and vertices 514, potentially in more complex configurations. FIG. 10 can be considered to show an example fragment of a graph for illustrative purposes. It should also be noted that the input graph 502 is shown generally as originating from outside the computer 504, which is one possibility, but that it could also originate from within the same computer 504 (e.g., authored and / or stored on top of it using a suitable authoring tool not shown).
[0101] The input graph 502 can be designed by a human developer (a "developer" here could be a person or a team) to implement the data flow and operations desired by the developer. For example, the graph 502 can have tensorflow as part of a neural network. Note that in the case where the graph 502 implements a neural network, each node or "neuron" of the neural network can have one or more compute vertices 514 and one or more data nodes 512 of the graph 502 (i.e., of the program structure of the program). That is, the topography of the neural network can be described at a higher level of abstraction than the graph 502 of the program.
[0102] FIG. 11 shows an example of a particular compute vertex 514 with an input X from a data node 512 representing a first variable A, and an output Y to a second data node 512 representing a second variable B. As also shown, the vertex 514 may also have one or more codelets 518. A codelet is a particular type of thread, often referred to as an "atomic" thread. It has all of the input information it needs to execute from the time the thread begins (starts), i.e., it does not get any input from any other part of the program or from memory after it is started. Furthermore, no other part of the program will use any output (results) of the thread until it finishes (completes). It is guaranteed to finish unless it encounters an error. Some literature also defines a codelet as stateless, i.e., as one that cannot inherit any information from its first execution if it is run twice, but this further definition is not necessarily adopted here. Codelets are a convenient way to partition graph 502 so that, when pulled down by compiler 508, vertices 514 are relatively easily separable between different threads, tiles 4, and / or chips 2. In an embodiment, each vertex 514 may be formed exclusively from codelets, although this is not required in all embodiments, and more generally, vertices 514 may represent any portion of code.
[0103] Also note that in some representations, the same graph 502 may be equivalently represented by compute nodes (vertices) interconnected by edges, with data elements (variables) shown as annotations on the edges rather than explicitly as data nodes 512. This is shown on the left hand side of FIG. 12. Either representation may be used equivalently. It should be understood that data annotations on edges are roughly equivalent ways of describing data nodes, and the way these are presented to a human developer in any given tool and in any given perspective does not substantially preclude the fact that items of data that may be called data nodes still exist in the underlying computational structure of the graph and can still be read onto the data nodes 512 disclosed herein. In other words, the data-annotated edge representation is a contemplated way of representing a data node with an incoming edge from one compute vertex and an outgoing edge to another vertex (see FIG. 12). It should be understood that the latter terminology is employed herein for the sake of conceptual explanation, and that in effect the graph claimed herein refers to the underlying computational graph, not the conceptual or graphical manner in which it is presented to a human. That is, graph 502 refers to the underlying data structure having functions and the flow of data through the functions, where functions may be referred to as compute vertices 514, data inputs to and from such functions may be referred to as data nodes 512, and any logical flow of data into or out of a function / vertex is referred to as an edge.
[0104] When the compiler 508 compiles the graph 502 and thereby pulls it down to run on one or more execution units of one or more processor modules 4, the low-level implementation of the incoming edges 516 may have load operations performed by load-type instructions, and the low-level implementation of the outgoing edges 516 may have store operations performed by store-type instructions.
[0105] According to an embodiment of the present disclosure, compiler 508 includes an allocator 511 that includes a constraint solver configured to apply one or more constraints when compiling graph 502 .
[0106] As part of compiling the high-level graph 502, the compiler 508 breaks the graph down into, for example, individual tiles 4a, 4b, 4c, etc. on the chip 2. Each tile has variables allocated for the edges 516 described in the high-level graph. Each variable is allocated a contiguous portion of memory space in memory 22a, which may be one or more contiguous bytes of memory (i.e., a given variable cannot be allocated to a non-contiguous portion of memory). Note also that reference to a variable anywhere does not preclude the option of a constant. The term "data element" may be used to replace the term "variable" anywhere in this specification. Thus, a "data element" or a "variable" could include code. There may be different kinds of variables. For example, a distinction may be made between variables that were present in the high-level graph provided by the user and variables that are present in the low-level graph on which the compiler operates.
[0107] For example, there are no variables containing code in the input graph created by the user: the user specifies the code to be executed by selecting the codelet to use, but the storage for this code is implicit and there is no possibility to access it in the high-level graph. As part of the compilation process, the high-level input graph is transformed into a lower level graph, where anything that requires storage can be represented as variables containing vertex states and vertex codes.
[0108] 13 shows a flowchart of an exemplary method that may be performed by a constraint solver in allocator 511 to allocate different variables corresponding to edges 516 to individual regions in memory 22 for solving their constraints. In summary, the method involves going through a list of all variables in order, and for each variable, allocating it to a portion of memory that will not collide with any pre-allocated variables in the list.
[0109] The actual memory addresses are assigned in several steps towards the end of the compilation process. To assign addresses, first constraints are defined. If a decision is made to share a data structure (rather than copy across processing units), one or more address constraints can be provided. Note that in situations where a shared data structure (e.g., a function call or other jump) contains a pointer to something else, the variable it points to must also be constrained to be located at the same address on all tiles where the code is shared.
[0110] To facilitate larger scale sharing, a same-address constraint is added to the allocator, which specifies that the set of variables across multiple tiles must be allocated at the same address.
[0111] In step S0, all variables with the same address constraint are first allocated across tiles, and unconstrained variables are allocated later on a tile-by-tile basis.
[0112] A same-address constrained variable set is treated as a single variable with the union of all equivalence class interferences of all variables on each tile in the set, as well as the union of interferences between variables with which they share element constraints. Equivalence classes are described below. Allocation occurs in a similar manner from this point forward for all same-address constrained set variables. Once all constrained variables have been allocated, these allocations are distributed to individual tile allocators in step S5, and allocation continues tile-by-tile for the remaining unconstrained variables, as described below.
[0113] In step S10, the method includes, for each tile, assigning an order to the unconstrained variables for that tile. Any order can be used. In an embodiment, a particular order can be used as an optimization to improve compilation time and / or quality of allocation (i.e., the amount of tile memory required). However, the method will still work regardless of the order used, and will only be slightly slower than if one of the optimizations were used. For example, the order could instead be random. Thus, whatever order is chosen, step S10 will result in an ordered list of variables waiting for allocation.
[0114] In step S20, the method comprises selecting the first unconstrained variable in the list to begin the allocation. In step S30, the method comprises finding space in memory 22a for the current variable under consideration, which at this point (first iteration) is the first variable in the list. Note that the constrained variables have at this point already been allocated to memory locations. When selecting an area of memory for the first variable, the allocation of any same-address constrained variables must be taken into account. The first variable may have other non-relational constraints, such as, for example, selecting an address range within a specified type of memory. In step S40, the method comprises allocating the current variable under consideration to the selected area in memory 22.
[0115] In step S50, the method includes determining whether the variable assigned in step S40 was the last one in the list. If not, the method returns to step S30 to search the memory 22a for allocating the next variable in the ordered list. This now needs to take into account any relational constraints as well as any non-relational constraints. For example, a relational constraint may be that the data of two variables cannot be read from or stored in the same memory bank 23 at the same time. In an embodiment, this may be implemented as a constraint that variables cannot be assigned to the same bank if their data are "live" for at least a portion of the same time, i.e., for overlapping periods of time. In this specification, when a variable is said to be "live", this refers to the time in run-time between the variable's data being written to memory 22a and it being read by the program. To evaluate whether this constraint is satisfied, the constraint solver 511 may perform a "liveness" analysis to determine which variables are live over time and which variables are live at overlapping times after the program is compiled and executed. If two variables are live at overlapping times, they may be said to conflict or interfere with each other (in the sense that if the compiler 508 were to attempt to assign them to the same memory bank 23, the access logic of the memory bank 23 would not be able to service both of them at the same time).
[0116] Thus, in step S30, for each but the first variable in the ordered list, the method comprises finding an area of memory 22a for the variable that does not collide (interfere) with any other previously assigned variables (any other preceding variables in the ordered list). That is, it finds an address range in memory bank 23 that is not shared between any other previously assigned variables that will be live for at least a portion of the same time. In other words, the current variable in the list is assigned to the remaining address space in memory 22a that is not contained (yet to be assigned) in the same bank 23 as any other conflicting already assigned variables. In step S40, the method comprises assigning the current variable in the list to the selected area in memory 22a.
[0117] If, in step S50, it is determined that the last variable in the list has been assigned, the method proceeds to step S70, where compilation for that tile is completed. When all tiles are completed, an executable program may be generated, where the assigned memory address space is each used to store the data of the respective variables, from which the data will be loaded (and potentially saved again if necessary) when needed at run-time. Compilation may, of course, involve other conventional compilation steps as will be familiar to those skilled in the art.
[0118] As mentioned above, in an embodiment, the ordered list determined in step S10 may simply have any order, although in a preferred embodiment, the particular order is selected to attempt to optimize the speed of the constraint solving process, which may include any one, more than one, or all of several techniques.
[0119] In an embodiment, step S10 may include ordering the variables according to a particular metric or metrics. For example, one way to order the variables is by size (i.e. the amount of space they occupy in memory), where larger sized variables are higher on the list and smaller sized variables are lower. This means that larger variables are allocated first and smaller ones later. This tends to be faster and improve packing because there is a greater opportunity to insert smaller variables around larger ones than if the allocation were performed otherwise. For similar reasons, another way to order the variables is by the amount of time they have been live, where longer live variables are placed higher on the list and allocated first, and shorter live variables are lower on the list and allocated after the longer live variables. Another example metric for ordering variables is by the size of the program line range in which the variables are live, and again, the reasoning is similar (starting by allocating the longest-lived variables first, and then inserting relatively short-lived variables around them).
[0120] In embodiments, a combination of two or more of these and / or other metrics could be used to order the variables, such as, for example, ordering first by size and then ordering any variables of the same size by liveness time, or vice versa.
[0121] Alternatively or additionally, the ordering in step S10 may include grouping the variables into "equivalence classes." Each equivalence class is a set of variables that each interfere with some or all of the same other variables. For example, if variables A and B both interfere with variables D, C, and E, then A and B may be placed in one equivalence class, while D, C, and E may be placed in another equivalence class (note that A and B overlap in time with C, which does not necessarily mean that A and B overlap with each other). In structured programs, there is a tendency for groups of variables that interfere with the same other variables. In an embodiment, the ordering may include ordering the equivalence classes according to metrics such as the number of variables in the class (largest classes first), the total size of the class in bytes (largest classes first), the total live time covered by the class (longest live classes first), etc. The advantage of grouping into equivalence classes is that the processing time of the constraint solver process is reduced, because it means that the constraint solver in allocator 511 does not have to recalculate the collision information for each individual variable in a class.
[0122] In embodiments, variables may also be ordered within the equivalence classes, again according to a metric such as variable size or liveness time, etc. Thus, variables may be ordered first by class and then by one or more metrics within each class.
[0123] In an embodiment, a variable constraint builder in the constraint solver builds pairwise constraints with the type of associated constraint being imposed. Non-associated constraint information is also extracted from the high-level constraint description by the constraint builder.
[0124] Graph liveness analysis groups similarly affected variables into equivalence classes, which reduces the burden of maintaining liveness information for each variable separately. Liveness analysis also builds a table of which equivalence classes may or may not interfere with each other (i.e., which variables may or may not be live at the same time). This information, along with variable constraint information, is used by the memory allocator.
[0125] In an embodiment, the following steps are followed by the memory allocator function in the constraint solver 511 for each tile: i. Receive same-address constrained assignments for same-address constrained variables. ii. Order the equivalence classes according to some metric. Common metrics used are the size of the total variables in the equivalence class or the number of classes it interferes with. iii. Order the variables within each equivalence class according to some metric. Common metrics used are size and alignment. iv. The ordering of variable assignments is performed according to the ordering of the equivalence classes determined by steps i and ii. v. For each variable v in the ordered equivalence classes, find space in memory such that all constraints on the variable are satisfied, and v does not clash with any variables already allocated for equivalence classes that interfere with the class to which v belongs. The constraints on the variables include all association and non-association constraints. In the case of association constraints, this means that if v has an association constraint with v1 and v1 is already allocated, then the association constraint must be satisfied along with the non-association constraint. If a variable with which v shares an association constraint is not allocated, then only the non-association constraint is satisfied.
[0126] It should be understood that the above-described embodiments are described by way of example only. Other variations or use cases of the disclosed techniques may become apparent to those of ordinary skill in the art given the disclosure herein. The scope of the disclosure is limited only by the appended claims, and not by the described embodiments.
Claims
1. 1. A method for storing code on a computer having multiple processing units, comprising: Each processing unit has a local memory configured to store read-only elements including executable code sequences, and an execution stage for executing at least some of the executable code sequences stored in the local memory, the method comprising: identifying at least one of a plurality of processing units of the computer as a master processing unit; compiling a read-only element including an executable code sequence for loading into said processing unit of said computer to allocate at least one shareable read-only element to said master processing unit; storing, in the local memory of the master processing unit, at least one shareable read-only element designated for use by an execution stage of at least one other of the processing units, and a transmit exchange code sequence designated at a compile-time determined time to be operated on in the execution stage of the master processing unit, for the processing unit to identify the shareable read-only element and generate a message having the shareable read-only data element to be transmitted for receipt by at least one other processing unit; The method according to claim 1,
2. The method of claim 1 , wherein the shareable read-only elements comprise executable code sequences that are executed in the execution stage of at least one other processing unit.
3. The method of claim 2 , wherein the executable code sequence comprises an instance of a vertex in an application graph.
4. 3. The method of claim 2, wherein the executable code sequence comprises control code for managing execution of the code sequence within the processing unit of the computer.
5. The method of claim 1 , wherein the shareable read-only element has a constant value.
6. The constant value is Vertex state, Vertex Descriptor, and Field data, 6. The method of claim 5, wherein the
7. The method of claim 1 , wherein the compiling comprises allocating at least one non-sharable read-only element to at least one of the plurality of processing units.
8. 8. The method of claim 1, wherein the at least one shareable read-only element is contained within a shared data structure having a plurality of shareable read-only elements.
9. 9. The method of claim 1, wherein allocating the at least one shareable read-only element comprises allocating a plurality of shareable read-only elements for respective addresses of each of the processing units and resolving address constraints of the shareable read-only elements.
10. storing in said local memory of said at least one other processing unit a received exchange code sequence designated for execution in said execution stage of said at least one other processing unit; 10. A method according to any one of claims 1 to 9, wherein the receiving exchange code sequence causes the at least one other processing unit to store the shareable read-only element received in the message at an assigned address in the local memory of the at least one other processing unit.
11. Allocating at least one shareable read-only element to the master processing unit comprises: identifying at least one shared data structure having a plurality of shareable read-only elements in a program flow to be compiled; comparing a storage requirement in memory of the shared data structure with a storage requirement in memory of the transmit exchange code sequence; determining whether to assign the read-only elements as a shareable data structure to the master processing unit or whether to replicate the data structure across multiple processing units based on the comparison; 11. The method according to any one of claims 1 to 10, comprising:
12. The method of claim 11 , wherein the program flow represents an application graph.
13. A computer comprising: a plurality of processing units, each processing unit having a local memory configured to store read-only elements including executable code sequences, and an execution stage for executing at least some of the executable code sequences stored in the local memory, at least one of the plurality of processing units having a master processing unit; the local memory is configured to store at least one sharable read-only element designated for use by an execution stage of at least one other processing unit, and a transmit exchange code sequence designated for execution in the execution stage of the master processing unit, causing the master processing unit to identify the sharable read-only element and generate a message to be transmitted for receipt by at least one other processing unit; at least one other processing unit stores in its local memory a receive exchange code sequence that causes the at least one other processing unit to receive the shareable read-only element from the message and store it at an address in its local memory only for a period of use, and the at least one other processing unit is configured to delete the shareable read-only element from its local memory after the period of use.
14. 14. The computer of claim 13, wherein the message generated by the sending exchange code includes an address where the shareable data read-only element is to be stored in at least one other processing unit.
15. 15. A computer according to claim 13 or 14, wherein the at least one shareable read-only element stored in the memory of the master processing unit forms part of a shared data structure having a plurality of shareable read-only elements.
16. A computer according to any one of claims 13 to 15, comprising a plurality of master processing units.
17. 16. The computer of claim 15, wherein the shared data structure comprises executable code sequences.
18. 16. The computer of claim 15, wherein the shared data structure has a constant set of values.
Citation Information
Patent Citations
Multiprocessor processor
JP1994060047A
Gateway Pull Model
US20200174828A1
