scoreboard_check_stage.hh (11308:7d8836fd043d) scoreboard_check_stage.hh (11394:2bc2120ad76b)
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 contributors
18 * may be used to endorse or promote products derived from this software
19 * 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 * Author: Sooraj Puthoor
34 */
35
36#ifndef __SCOREBOARD_CHECK_STAGE_HH__
37#define __SCOREBOARD_CHECK_STAGE_HH__
38
39#include <cstdint>
40#include <string>
41#include <utility>
42#include <vector>
43
44class ComputeUnit;
45class Wavefront;
46
47struct ComputeUnitParams;
48
49enum WAVE_STATUS
50{
51 BLOCKED = 0,
52 READY
53};
54
55/*
56 * Scoreboard check stage.
57 * All wavefronts are analyzed to see if they are ready
58 * to be executed this cycle. Both structural and data
59 * hazards are considered while marking a wave "ready"
60 * for execution. After analysis, the ready waves are
61 * added to readyList.
62 */
63class ScoreboardCheckStage
64{
65 public:
66 ScoreboardCheckStage(const ComputeUnitParams* params);
67 ~ScoreboardCheckStage();
68 void init(ComputeUnit *cu);
69 void exec();
70
71 // Stats related variables and methods
72 const std::string& name() const { return _name; }
73 void regStats();
74
75 private:
76 void collectStatistics(Wavefront *curWave, int unitId);
77 void initStatistics();
78 ComputeUnit *computeUnit;
79 uint32_t numSIMDs;
80 uint32_t numMemUnits;
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 contributors
18 * may be used to endorse or promote products derived from this software
19 * 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 * Author: Sooraj Puthoor
34 */
35
36#ifndef __SCOREBOARD_CHECK_STAGE_HH__
37#define __SCOREBOARD_CHECK_STAGE_HH__
38
39#include <cstdint>
40#include <string>
41#include <utility>
42#include <vector>
43
44class ComputeUnit;
45class Wavefront;
46
47struct ComputeUnitParams;
48
49enum WAVE_STATUS
50{
51 BLOCKED = 0,
52 READY
53};
54
55/*
56 * Scoreboard check stage.
57 * All wavefronts are analyzed to see if they are ready
58 * to be executed this cycle. Both structural and data
59 * hazards are considered while marking a wave "ready"
60 * for execution. After analysis, the ready waves are
61 * added to readyList.
62 */
63class ScoreboardCheckStage
64{
65 public:
66 ScoreboardCheckStage(const ComputeUnitParams* params);
67 ~ScoreboardCheckStage();
68 void init(ComputeUnit *cu);
69 void exec();
70
71 // Stats related variables and methods
72 const std::string& name() const { return _name; }
73 void regStats();
74
75 private:
76 void collectStatistics(Wavefront *curWave, int unitId);
77 void initStatistics();
78 ComputeUnit *computeUnit;
79 uint32_t numSIMDs;
80 uint32_t numMemUnits;
81 uint32_t numGlbMemPipes;
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__
81 uint32_t numShrMemPipes;
82
83 // flag per vector SIMD unit that is set when there is at least one
84 // WF that has a vector ALU instruction as the oldest in its
85 // Instruction Buffer
86 std::vector<bool> *vectorAluInstAvail;
87 int lastGlbMemSimd;
88 int lastShrMemSimd;
89
90 int *glbMemInstAvail;
91 int *shrMemInstAvail;
92 // List of waves which are ready to be scheduled.
93 // Each execution resource has a ready list
94 std::vector<std::vector<Wavefront*>*> readyList;
95
96 // Stores the status of waves. A READY implies the
97 // wave is ready to be scheduled this cycle and
98 // is already present in the readyList
99 std::vector<std::vector<std::pair<Wavefront*, WAVE_STATUS>>*>
100 waveStatusList;
101
102 std::string _name;
103};
104
105#endif // __SCOREBOARD_CHECK_STAGE_HH__