Abstract:
The invention relates to methods of simulation of a plurality of processors running on a plurality of cores, to multi-core microprocessor systems in which such methods may be carried out, and to computer program products configured to perform a simulation of a plurality of processors, running on a plurality of cores. According to a first aspect of the invention, there is provided a method of running a plurality of simulated processors on a plurality of cores, in which simulation of the processors is performed in parallel on the plurality of cores.

Description:
BACKGROUND OF THE INVENTION 
       [0001]    1. Field of the Invention 
         [0002]    The field of the invention relates to methods of simulation of a plurality of processors running on a plurality of cores, to multi-core microprocessor systems in which such methods may be carried out, and to computer program products operable to perform a simulation of a plurality of processors, runnable on a plurality of cores. 
         [0003]    2. Technical Background 
         [0004]    The advent of multi-core microprocessors, i.e. processors which contain two or more execution units which can run concurrently, has opened up a new range of possibilities for high speed simulation. There are, however, a number of challenges as, in order to take full advantage of the potential simulation speed benefit offered by multi-core machines, any simulator running on such a machine must be able to make effective use of the parallelism offered by the multi-core technology. 
         [0005]    For clarity, the term ‘core’ will be used to refer to any one core of a multi-core processor within the host machine(s) and the term ‘processor’ will refer to the simulated processor, i.e. the model of a processor, on which the instruction set is being run. 
         [0006]    A multi-core processor is a single computing component with two or more independent (or mostly independent) actual central processing units (CPUs) (called “cores”), which are the units that read and execute program instructions. The instructions may be ordinary CPU instructions such as add, move data, and branch, but the multiple cores can run multiple instructions at the same time, increasing overall speed for programs amenable to parallel computing. Manufacturers typically integrate the cores onto a single integrated circuit die (known as a chip multiprocessor or CMP), or onto multiple dies in a single chip package. 
         [0007]    The improvement in performance gained by the use of a multi-core processor depends very much on the software algorithms used and their implementation. In particular, possible gains are limited by the fraction of the software that can be run in parallel simultaneously on multiple cores. Most applications, however, are not accelerated so much unless programmers invest a prohibitive amount of effort in re-programming the whole problem. 
         [0008]    Maximizing the utilization of the computing resources provided by multi-core processors typically requires adjustments both to the operating system (OS) support and to existing application software. 
         [0009]    Integration of a multi-core chip drives chip production yields down and they are more difficult to manage thermally than lower-density single-chip designs. 
         [0010]    3. Discussion of Related Art 
         [0011]    CN102591759(A) and CN102591759(B) disclose, in their own terminology, a clock precision parallel simulation system for an on-chip multi-core processor, which comprises a processor subsystem, a storage subsystem and a simulation object subsystem. The system is characterized in that a module interlayer is arranged between the processor subsystem and the simulation object subsystem in the system and used for implementation of mapping from a logic processor to a simulation object machine, the module interlayer comprises a core module, a mapping interconnection network, a share cache memory, a memory and storage modules for other simulation object structures, wherein the core module is in one-to-one correspondence to a processor core and a private primary cache memory. Point-to-point synchronization is realized between the core module and the storage modules, and group synchronization is realized among the storage modules. The system has higher degree of parallelism and higher speed-up ratio, and performance of the system is promoted under the condition that delicate modeling of each component of the multi-core processor is maintained. 
       SUMMARY OF THE INVENTION 
       [0012]    According to a first aspect of the invention, there is provided a method of running a plurality of simulated processors on a plurality of cores, in which simulation of the processors is performed in parallel on the plurality of cores. 
         [0013]    An advantageous technical effect is that parallel processing is provided for a plurality of simulated processors. The technical effect operates at the level of the architecture of the computer component implementing the method; the technical effect is produced irrespective of the data being processed or the applications being run. Furthermore, a computer implementing the first aspect of the invention operates in a new way. 
         [0014]    The method may be one applying to a timeslice of the plurality of simulated processors runnable on the plurality of cores, the method including the steps of:
   (i) determining an instruction list for each processor for the timeslice;   (ii) allocating processors which have not yet been simulated in the timeslice to run on any available cores;   (iii) for each allocated processor, running to the end of the timeslice and saving the simulation state of the processor as it completes the timeslice, and   (iv) returning to step (ii) unless the plurality of processors have all been simulated in this timeslice.   
 
         [0019]    The method may be one wherein the number of the plurality of simulated processors exceeds the number of the plurality of cores. 
         [0020]    The method may be one wherein the number of the plurality of simulated processors does not exceed the number of the plurality of cores. 
         [0021]    The method may be one in which the method is repeated for a set of consecutive timeslices. 
         [0022]    The method may be one further including a method of ensuring correct synchronization of a plurality of simulated processors, the plurality of simulated processors running on a plurality of cores, the method applying to a timeslice of the plurality of simulated processors running on the plurality of cores, including: 
         [0023]    running each processor on a core, and for each processor, suspending the processor if a synch event is found, or running the processor to the end of the timeslice, if a synch event is not found. 
         [0024]    An advantageous technical effect is that data structure consistency is supported, which strongly reduces the occurrences of crashes, or use of erroneous data, by a computer implementing this aspect of the invention. The technical effect operates at the level of the architecture of the computer component; the technical effect is produced irrespective of the data being processed or the applications being run. Furthermore, the computer implementing this aspect of the invention operates in a new way. The computer is a better computer in the sense of running more efficiently and effectively as a computer. 
         [0025]    The method may be one including the steps of:
   (i) determining an instruction list for each processor for the timeslice;   (ii) allocating processors which have not yet been simulated in the timeslice to run on any available cores;   (iii) if a synch event is found for a processor, running the processor to just before the synch event, suspending the processor, and saving the simulation time and the simulation state of the processor;   (iv) if a synch event is not found for a processor, running to the end of the timeslice and saving the simulation state of the processor as it completes the timeslice, and   (v) returning to step (ii) unless the plurality of processors have all been simulated in this timeslice.   
 
         [0031]    The method may be one further including a method of completing a timeslice of a simulation of a plurality of processors running on a plurality of cores, in which a plurality of processors have been suspended, including: 
         [0032]    running the suspended processors, consecutively in the order of their earliest simulation time, on the same core, to ensure data structure consistency. 
         [0033]    An advantageous technical effect is that data structure consistency is supported, which strongly reduces the occurrences of crashes, or use of erroneous data, by a computer implementing this aspect of the invention. The technical effect operates at the level of the architecture of a computer or of a computer component; the technical effect is produced irrespective of the data being processed or the applications being run. Furthermore, the computer implementing this aspect of the invention operates in a new way. The computer is a better computer in the sense of running more efficiently and effectively as a computer. 
         [0034]    The method may be one including the steps of:
   (i) reading a list of remaining suspended processors;   (ii) checking the simulation time for each suspended processor;   (iii) running the processor with the earliest simulation time, and removing that processor from the list;   (iv) if a synch event is found, suspending the process, saving the simulation state and time, adding the processor back to the list of remaining suspended processors and returning to step (i);   (v) running to the end of the timeslice and saving the simulation, and   (vi) repeating steps (i) to (v) until the list is empty,   wherein step (iii) is performed on the same core, to ensure data structure consistency.   
 
         [0042]    The method may be one further including a method of timeslicing instruction sets for a plurality of processors to be simulated using a plurality of cores, including the steps of:
   (i) determining a timeslice time period;   (ii) for each processor model, consulting a record of its timing information;   (iii) for each simulated processor, estimating how many instructions will be run in the time period, using the results of step (ii);   (iv) determining an instruction list for each simulated processor, according to the results of (iii), for a timeslice.   
 
         [0047]    An advantageous technical effect is that different processors can be simulated using a plurality of cores, because for each processor model, a record is consulted of its timing information. This means that a greater set of simulations are possible, because the simulation is not limited to a single model of processor. The technical effect operates at the level of the architecture of the computer; the technical effect is produced irrespective of the data being processed or the applications being run. Furthermore, the computer implementing this aspect of the invention operates in a new way. 
         [0048]    The method may be one further including the step of:
   (v) repeating (i) to (iv) for a set of consecutive timeslices.   
 
         [0050]    The method may be one wherein a time period is user-defined. 
         [0051]    The method may be one wherein a time period is pre-defined. 
         [0052]    The method may be one wherein a single core runs a single processor&#39;s instruction list at any one time. 
         [0053]    According to a second aspect of the invention, there is provided a multi-core microprocessor system including a plurality of execution units which can run concurrently, the system configured to run a plurality of simulated processors on a plurality of cores, in which simulation of the processors is performable in parallel on the plurality of cores. 
         [0054]    The multi-core microprocessor system may be configured to complete a timeslice of a simulation of a plurality of processors running on a plurality of cores, configured to:
   (i) determine an instruction list for each processor for the timeslice;   (ii) allocate processors which have not yet been simulated in the timeslice to run on any available cores;   (iii) for each allocated processor, run to the end of the timeslice and save the simulation state of the processor as it completes the timeslice, and   (iv) return to (ii) unless the plurality of processors have all been simulated in this timeslice.   
 
         [0059]    The multi-core microprocessor system may be one wherein the number of the plurality of simulated processors exceeds the number of the plurality of cores. 
         [0060]    The multi-core microprocessor system may be one wherein the number of the plurality of simulated processors does not exceed the number of the plurality of cores. 
         [0061]    The multi-core microprocessor system may be one configured to repeat for a set of consecutive timeslices. 
         [0062]    The multi-core microprocessor system may be one configured to ensure correct synchronization of a plurality of simulated processors, the plurality of simulated processors running on a plurality of cores, the system configured to run a timeslice of the plurality of simulated processors running on the plurality of cores, the system configured to: 
         [0063]    run each processor on a core, and for each processor, suspend the processor if a synch event is found, or run the processor to the end of the timeslice, if a synch event is not found. 
         [0064]    The multi-core microprocessor system may be one configured to:
   (i) determine an instruction list for each processor for the timeslice;   (ii) allocate processors which have not yet been simulated in the timeslice to run on any available cores;   (iii) if a synch event is found for a processor, run the processor to just before the synch event, suspend the processor, and save the simulation time and the simulation state of the processor;   (iv) if a synch event is not found for a processor, run to the end of the timeslice and save the simulation state of the processor as it completes the timeslice, and   (v) return to (ii) unless the plurality of processors have all been simulated in this timeslice.   
 
         [0070]    The multi-core microprocessor system may be one configured to complete a timeslice of a simulation of a plurality of processors running on a plurality of cores, in which a plurality of processors have been suspended, the system configured to: 
         [0071]    run the suspended processors, consecutively in the order of their earliest simulation time, on the same core, to ensure data structure consistency. 
         [0072]    The multi-core microprocessor system may be one configured to:
   (i) read a list of remaining suspended processors;   (ii) check the simulation time for each suspended processor;   (iii) run the processor with the earliest simulation time, and remove that processor from the list;   (iv) if a synch event is found, suspend the process, save the simulation state and time, add the processor back to the list of remaining suspended processors and return to (i);   (v) run to the end of the timeslice and save the simulation, and   (vi) repeat items (i) to (v) until the list is empty,   wherein item (iii) is performed on the same core, to ensure data structure consistency.   
 
         [0080]    The multi-core microprocessor system may be one further configured to timeslice instruction sets for a plurality of processors to be simulated using a plurality of cores, the system configured to:
   (i) determine a timeslice time period;   (ii) for each processor model, consult a record of its timing information;   (iii) for each simulated processor, estimate how many instructions will be run in the time period, using the results of (ii);   (iv) determine an instruction list for each simulated processor, according to the results of (iii), for a timeslice.   
 
         [0085]    The multi-core microprocessor system may be further configured to:
   (v) repeat (i) to (iv) for a set of consecutive timeslices.   
 
         [0087]    The multi-core microprocessor system may be one wherein a time period is user-defined. 
         [0088]    The multi-core microprocessor system may be one wherein a time period is pre-defined. 
         [0089]    The multi-core microprocessor system may be one wherein a single core runs a single processor&#39;s instruction list at any one time. 
         [0090]    According to a third aspect of the invention, there is provided a computer program product operable to run a plurality of simulated processors on a plurality of cores, in which simulation of the processors is performed in parallel on the plurality of cores. 
         [0091]    The computer program product may be operable to complete a timeslice of a simulation of the plurality of simulated processors runnable on the plurality of cores, the computer program product operable to:
   (i) determine an instruction list for each processor for the timeslice;   (ii) allocate processors which have not yet been simulated in the timeslice to run on any available cores;   (iii) for each allocated processor, run to the end of the timeslice and save the simulation state of the processor as it completes the timeslice, and   (iv) return to (ii) unless the plurality of processors have all been simulated in this timeslice.   
 
         [0096]    The computer program product may be one wherein the number of the plurality of simulated processors exceeds the number of the plurality of cores. 
         [0097]    The computer program product may be one wherein the number of the plurality of simulated processors does not exceed the number of the plurality of cores. 
         [0098]    The computer program product may be one in which the program is executable for a set of consecutive timeslices. 
         [0099]    The computer program product may be one further operable to ensure correct synchronization of a plurality of simulated processors, the plurality of simulated processors runnable on a plurality of cores, the computer program product operable to apply to a timeslice of the plurality of simulated processors running on the plurality of cores, the computer program product operable to: 
         [0100]    run each processor on a core, and for each processor, suspend the processor if a synch event is found, or run the processor to the end of the timeslice, if a synch event is not found. 
         [0101]    The computer program product may be one further operable to:
   (i) determine an instruction list for each processor for the timeslice;   (ii) allocate processors which have not yet been simulated in the timeslice to run on any available cores;   (iii) if a synch event is found for a processor, run the processor to just before the synch event, suspend the processor, and save the simulation time and the simulation state of the processor;   (iv) if a synch event is not found for a processor, run to the end of the timeslice and save the simulation state of the processor as it completes the timeslice, and   (v) return to (ii) unless the plurality of processors have all been simulated in this timeslice.   
 
         [0107]    The computer program product may be one further operable to complete a timeslice of a simulation of a plurality of processors running on a plurality of cores, in which a plurality of processors have been suspended, operable to: 
         [0108]    run the suspended processors, consecutively in the order of their earliest simulation time, on the same core, to ensure data structure consistency. 
         [0109]    The computer program product may be one operable to:
   (i) read a list of remaining suspended processors;   (ii) check the simulation time for each suspended processor;   (iii) run the processor with the earliest simulation time, and remove that processor from the list;   (iv) if a synch event is found, suspend the process, save the simulation state and time, add the processor back to the list of remaining suspended processors and return to (i);   (v) run to the end of the timeslice and save the simulation, and   (vi) repeat (i) to (v) until the list is empty,   wherein (iii) is performed on the same core, to ensure data structure consistency.   
 
         [0117]    The computer program product may be one further operable to timeslice instruction sets for a plurality of processors to be simulated using a plurality of cores, operable to:
   (i) determine a timeslice time period;   (ii) for each processor model, consult a record of its timing information;   (iii) for each simulated processor, estimate how many instructions will be run in the time period, using the results of (ii);   (iv) determine an instruction list for each simulated processor, according to (iii), for a timeslice.   
 
         [0122]    The computer program product may be one further operable to:
   (v) repeat (i) to (iv) for a set of consecutive timeslices.   
 
         [0124]    The computer program product may be one wherein a time period is user-defined. 
         [0125]    The computer program product may be one wherein a time period is pre-defined. 
         [0126]    The computer program product may be one wherein a single core runs a single processor&#39;s instruction list at any one time. 
         [0127]    There is provided a computer including a multi-core microprocessor system of any aspect of the second aspect of the invention. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0128]    The above and other aspects of the invention will now be described, by way of example only, with reference to the following Figures, in which: 
           [0129]      FIG. 1  shows a schematic example of instruction sets for each of n Processors (P 1 -Pn). 
           [0130]      FIG. 2  shows a schematic example in which instruction sets are split into timeslices which represent different numbers of instructions per processor. 
           [0131]      FIG. 3  shows an example of a simple algorithm for the allocation of simulated processors to the available cores to run for a given timeslice. 
           [0132]      FIG. 4  shows an example of a modified algorithm to deal with synchronisation of processors. 
           [0133]      FIG. 5  shows an example of running a sweep pass for suspended processors. 
       
    
    
     DETAILED DESCRIPTION 
       [0134]    There is provided a method of fast multi-processor simulation on multi-core machines. The technique uses the fact that, the majority of time, the processors will be working independently of each other. Hence it is possible to run the simulated processors independently on each of the cores, as far as the number of cores allows, for most of the time. Special care may only be required when inter-processor communication takes place, either directly or by access to the same data. 
       Simulation of Parallel Processors 
       [0135]    Each of the processors included in the simulation has an instruction set associated with it. See  FIG. 1  for example. At the start of the simulation, the instruction set is split into a number of time periods or “timeslices”. Each timeslice represents a different number of instructions for each processor. See  FIG. 2  for example. A timeslice period can be either user defined or set by the system. 
         [0136]    Once the length of the timeslice has been determined, an estimate is made (see  FIG. 3  for example) of how many instructions each simulated processor will run in this time period  300 . The number of instructions per processor is estimated using the timing information in the processor model which forms part of the simulation. An algorithm is then used to allocate the simulated processors to the available cores for each timeslice. 
         [0137]    Once the instruction lists have been determined for each processor for the timeslice, the next task is to run each simulated processor&#39;s instruction list on one of the cores available within the machine or machines on which the simulation is to be run. A single core runs a single processor&#39;s instruction list at any one time. The instruction list is allocated to one of the cores available  310 . If the number of available cores is greater than the number of simulated processors then all the simulated processors will be run concurrently, with each instruction set being run as an independent process, each on a different core. If, as is more likely, the number of simulated processors exceeds the number of cores available then an alternative technique needs to be employed. In this case, if there are M cores and N simulated processors, the first M processors will be run through the first timeslice. Each of the simulated processors is run in a process on a separate core in the machine. 
         [0138]    Generally during the simulation, each processor can run independently until the end of the timeslice. As each of the simulated processors reaches the end of the set of instructions allocated to it for that timeslice, it is marked as complete and the state of the simulated processor is saved  320 . Once this process is complete, a new set of instructions for the same timeslice but for a different simulated processor is allocated to that core. This continues until all of the simulated processors&#39; instruction sets have been run  330 . If a particular core reaches the end of the instruction set for a given timeslice and there are no further processor instructions sets to be simulated for that timeslice, then the core process sleeps until all the other active cores have completed the instruction sets for that timeslice. When all instruction sets for a given timeslice have been completed, the simulation will repeat the process for the next timeslice  340 . 
       Inter-Processor Communication and Synchronization 
       [0139]    The detail described above assumes that there is no interaction taking place between the simulated processors and each can therefore be allowed to run entirely independently of the other simulated processors in the system. This is unlikely to be the case for the entire simulation as there are a number of types of event which could invalidate this assumption. A simulated processor may need to communicate with another by writing to a communication channel, an example of which could be a shared memory or a FIFO (First In, First Out). In this case, the order in which the data is read and written needs to be managed carefully to ensure that the correct data is read. It is also possible that one or more of the simulated processors may need to perform some input or output to the overall system or a simulated processor may also need to update critical simulator structures such as the allocation, or reallocation, of memory. In each of these cases, and any other cases requiring synchronisation, an additional step must be followed to ensure that all simulated processors are correctly synchronised with the rest of the system. See  FIG. 4  for example. 
         [0140]    The initial steps for a timeslice containing a synchronisation event are identical to those without such an event. First the instruction list for each processor is determined for the timeslice  400 . Next, processors which have not been simulated in this timeslice are allocated to run on any available cores  410 . This runs either until completion of the instruction list for that processor within the given timeslice as before  430  or until a synchronisation event is encountered  440 . If a synchronisation event is found within the instruction list for any given processor then that processor runs just to just before the synchronisation event and is suspended  440 . The simulation state and time at the point of suspension are recorded. This frees this core and, just as in the simple algorithm, it now checks to see if there are any further processors which need to be simulated. If there are, the next one is allocated to the core which has just completed the process with the synchronisation event; if not the core process sleeps. 
         [0141]    When all the simulated processors have either completed or been suspended by a synchronisation event  460 , an additional step, known as a sweep pass  470 , needs to be performed for each of the suspended processors before moving to the next timeslice  480 . 
         [0142]    This sweep pass is performed for each of the suspended processors in turn. See  FIG. 5  for example. Each of these processors is run consecutively on a single core to ensure data structure consistency. The suspended processors will still have instructions for the current timeslice to complete  500 , as they have been suspended before reaching the end of the timeslice. For each timeslice the simulation must verify whether there are suspended processors or not and run the sweep pass on each one until all have run to the list of instructions allocated for the timeslice  510 . The simulation time of each suspended processor was saved along with the simulation state as the processor was suspended. The simulator will compare the saved simulation times  520 , at which each processor was suspended, to find the one that has the earliest simulation time  530 . This processor will be the one which had the first synchronisation event. It will now be restarted from the saved state and time data and will be allowed to run, either to completion or until the next communication event  540 . If the simulated processor runs to completion on the sweep pass, it will complete normally to the end of the list of instructions for that timeslice and the simulation state will be saved  550 . 
         [0143]    The processor will then be removed from the list of those which still need to be run. If the processor has a further synchronisation event then it will again suspend just prior to that synchronisation event  570 , as it did in the initial run, and simulation time and state will be saved. The suspended processor will then be re-added to the list of those which need to complete a sweep pass with new simulation time and state data. This sequence will be repeated until all the simulated processors have completed the timeslice. Once all of the sweep passes have been completed, this is the end of the timeslice and simulation will move to the next timeslice  560  and begin the process again until all the timeslices complete, marking the end of the simulation. 
       Note 
       [0144]    It is to be understood that the above-referenced arrangements are only illustrative of the application for the principles of the present invention. Numerous modifications and alternative arrangements can be devised without departing from the spirit and scope of the present invention. While the present invention has been shown in the drawings and fully described above with particularity and detail in connection with what is presently deemed to be the most practical and preferred example(s) of the invention, it will be apparent to those of ordinary skill in the art that numerous modifications can be made without departing from the principles and concepts of the invention as set forth herein.