1/* 2 * Copyright (c) 2014-2015 Advanced Micro Devices, Inc. 3 * All rights reserved. 4 * 5 * For use for simulation and test purposes only 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above copyright notice, 14 * this list of conditions and the following disclaimer in the documentation 15 * and/or other materials provided with the distribution. 16 * 17 * 3. Neither the name of the copyright holder nor the names of its 18 * contributors may be used to endorse or promote products derived from this 19 * software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 * 33 * Authors: Sooraj Puthoor, 34 * Mark Wyse 35 */ 36 37#ifndef __SCOREBOARD_CHECK_STAGE_HH__ 38#define __SCOREBOARD_CHECK_STAGE_HH__ 39 40#include <cstdint> 41#include <string> 42#include <utility> 43#include <vector> 44 45class ComputeUnit; 46class Wavefront; 47 48struct ComputeUnitParams; 49 50enum WAVE_STATUS 51{ 52 BLOCKED = 0, 53 READY 54}; 55 56/* 57 * Scoreboard check stage. 58 * All wavefronts are analyzed to see if they are ready 59 * to be executed this cycle. Both structural and data 60 * hazards are considered while marking a wave "ready" 61 * for execution. After analysis, the ready waves are 62 * added to readyList. 63 */ 64class ScoreboardCheckStage 65{ 66 public: 67 ScoreboardCheckStage(const ComputeUnitParams* params); 68 ~ScoreboardCheckStage(); 69 void init(ComputeUnit *cu); 70 void exec(); 71 72 // Stats related variables and methods 73 const std::string& name() const { return _name; } 74 void regStats(); 75 76 private: 77 void collectStatistics(Wavefront *curWave, int unitId); 78 void initStatistics(); 79 ComputeUnit *computeUnit; 80 uint32_t numSIMDs; 81 uint32_t numMemUnits; 82 uint32_t numShrMemPipes; 83 84 // flag per vector SIMD unit that is set when there is at least one 85 // WF that has a vector ALU instruction as the oldest in its 86 // Instruction Buffer 87 std::vector<bool> *vectorAluInstAvail; 88 int lastGlbMemSimd; 89 int lastShrMemSimd; 90 91 int *glbMemInstAvail; 92 int *shrMemInstAvail; 93 // List of waves which are ready to be scheduled. 94 // Each execution resource has a ready list 95 std::vector<std::vector<Wavefront*>*> readyList; 96 97 // Stores the status of waves. A READY implies the 98 // wave is ready to be scheduled this cycle and 99 // is already present in the readyList 100 std::vector<std::vector<std::pair<Wavefront*, WAVE_STATUS>>*> 101 waveStatusList; 102 103 std::string _name; 104}; 105 106#endif // __SCOREBOARD_CHECK_STAGE_HH__ 107