simulate.cc (10756:f9c0692f73ec) | simulate.cc (10762:fe0972727902) |
---|---|
1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * Copyright (c) 2013 Advanced Micro Devices, Inc. 4 * Copyright (c) 2013 Mark D. Hill and David A. Wood 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are --- 57 unchanged lines hidden (view full) --- 66thread_loop(EventQueue *queue) 67{ 68 while (true) { 69 threadBarrier->wait(); 70 doSimLoop(queue); 71 } 72} 73 | 1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * Copyright (c) 2013 Advanced Micro Devices, Inc. 4 * Copyright (c) 2013 Mark D. Hill and David A. Wood 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are --- 57 unchanged lines hidden (view full) --- 66thread_loop(EventQueue *queue) 67{ 68 while (true) { 69 threadBarrier->wait(); 70 doSimLoop(queue); 71 } 72} 73 |
74GlobalEvent* 75getLimitEvent(void) { 76 static GlobalSimLoopExitEvent 77 simulate_limit_event(mainEventQueue[0]->getCurTick(), 78 "simulate() limit reached", 0); 79 return &simulate_limit_event; 80} | 74GlobalSimLoopExitEvent *simulate_limit_event = nullptr; |
81 82/** Simulate for num_cycles additional cycles. If num_cycles is -1 83 * (the default), do not limit simulation; some other event must 84 * terminate the loop. Exported to Python via SWIG. 85 * @return The SimLoopExitEvent that caused the loop to exit. 86 */ 87GlobalSimLoopExitEvent * 88simulate(Tick num_cycles) --- 10 unchanged lines hidden (view full) --- 99 // the main thread (the one we're currently running on) 100 // handles queue 0, so we only need to allocate new threads 101 // for queues 1..N-1. We'll call these the "subordinate" threads. 102 for (uint32_t i = 1; i < numMainEventQueues; i++) { 103 threads.push_back(new std::thread(thread_loop, mainEventQueue[i])); 104 } 105 106 threads_initialized = true; | 75 76/** Simulate for num_cycles additional cycles. If num_cycles is -1 77 * (the default), do not limit simulation; some other event must 78 * terminate the loop. Exported to Python via SWIG. 79 * @return The SimLoopExitEvent that caused the loop to exit. 80 */ 81GlobalSimLoopExitEvent * 82simulate(Tick num_cycles) --- 10 unchanged lines hidden (view full) --- 93 // the main thread (the one we're currently running on) 94 // handles queue 0, so we only need to allocate new threads 95 // for queues 1..N-1. We'll call these the "subordinate" threads. 96 for (uint32_t i = 1; i < numMainEventQueues; i++) { 97 threads.push_back(new std::thread(thread_loop, mainEventQueue[i])); 98 } 99 100 threads_initialized = true; |
101 simulate_limit_event = 102 new GlobalSimLoopExitEvent(mainEventQueue[0]->getCurTick(), 103 "simulate() limit reached", 0); |
|
107 } 108 109 inform("Entering event queue @ %d. Starting simulation...\n", curTick()); 110 111 if (num_cycles < MaxTick - curTick()) 112 num_cycles = curTick() + num_cycles; 113 else // counter would roll over or be set to MaxTick anyhow 114 num_cycles = MaxTick; 115 | 104 } 105 106 inform("Entering event queue @ %d. Starting simulation...\n", curTick()); 107 108 if (num_cycles < MaxTick - curTick()) 109 num_cycles = curTick() + num_cycles; 110 else // counter would roll over or be set to MaxTick anyhow 111 num_cycles = MaxTick; 112 |
116 getLimitEvent()->reschedule(num_cycles); | 113 simulate_limit_event->reschedule(num_cycles); |
117 118 GlobalSyncEvent *quantum_event = NULL; 119 if (numMainEventQueues > 1) { 120 if (simQuantum == 0) { 121 fatal("Quantum for multi-eventq simulation not specified"); 122 } 123 124 quantum_event = new GlobalSyncEvent(curTick() + simQuantum, simQuantum, --- 104 unchanged lines hidden --- | 114 115 GlobalSyncEvent *quantum_event = NULL; 116 if (numMainEventQueues > 1) { 117 if (simQuantum == 0) { 118 fatal("Quantum for multi-eventq simulation not specified"); 119 } 120 121 quantum_event = new GlobalSyncEvent(curTick() + simQuantum, simQuantum, --- 104 unchanged lines hidden --- |