condition_register_state.cc revision 11308
111308Santhony.gutierrez@amd.com/*
211308Santhony.gutierrez@amd.com * Copyright (c) 2015 Advanced Micro Devices, Inc.
311308Santhony.gutierrez@amd.com * All rights reserved.
411308Santhony.gutierrez@amd.com *
511308Santhony.gutierrez@amd.com * For use for simulation and test purposes only
611308Santhony.gutierrez@amd.com *
711308Santhony.gutierrez@amd.com * Redistribution and use in source and binary forms, with or without
811308Santhony.gutierrez@amd.com * modification, are permitted provided that the following conditions are met:
911308Santhony.gutierrez@amd.com *
1011308Santhony.gutierrez@amd.com * 1. Redistributions of source code must retain the above copyright notice,
1111308Santhony.gutierrez@amd.com * this list of conditions and the following disclaimer.
1211308Santhony.gutierrez@amd.com *
1311308Santhony.gutierrez@amd.com * 2. Redistributions in binary form must reproduce the above copyright notice,
1411308Santhony.gutierrez@amd.com * this list of conditions and the following disclaimer in the documentation
1511308Santhony.gutierrez@amd.com * and/or other materials provided with the distribution.
1611308Santhony.gutierrez@amd.com *
1711308Santhony.gutierrez@amd.com * 3. Neither the name of the copyright holder nor the names of its contributors
1811308Santhony.gutierrez@amd.com * may be used to endorse or promote products derived from this software
1911308Santhony.gutierrez@amd.com * without specific prior written permission.
2011308Santhony.gutierrez@amd.com *
2111308Santhony.gutierrez@amd.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2211308Santhony.gutierrez@amd.com * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2311308Santhony.gutierrez@amd.com * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2411308Santhony.gutierrez@amd.com * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2511308Santhony.gutierrez@amd.com * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2611308Santhony.gutierrez@amd.com * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2711308Santhony.gutierrez@amd.com * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2811308Santhony.gutierrez@amd.com * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2911308Santhony.gutierrez@amd.com * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3011308Santhony.gutierrez@amd.com * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3111308Santhony.gutierrez@amd.com * POSSIBILITY OF SUCH DAMAGE.
3211308Santhony.gutierrez@amd.com *
3311308Santhony.gutierrez@amd.com * Author: John Kalamatianos
3411308Santhony.gutierrez@amd.com */
3511308Santhony.gutierrez@amd.com
3611308Santhony.gutierrez@amd.com#include "gpu-compute/condition_register_state.hh"
3711308Santhony.gutierrez@amd.com
3811308Santhony.gutierrez@amd.com#include "gpu-compute/compute_unit.hh"
3911308Santhony.gutierrez@amd.com#include "gpu-compute/gpu_static_inst.hh"
4011308Santhony.gutierrez@amd.com#include "gpu-compute/shader.hh"
4111308Santhony.gutierrez@amd.com#include "gpu-compute/wavefront.hh"
4211308Santhony.gutierrez@amd.com
4311308Santhony.gutierrez@amd.comConditionRegisterState::ConditionRegisterState()
4411308Santhony.gutierrez@amd.com{
4511308Santhony.gutierrez@amd.com    computeUnit = nullptr;
4611308Santhony.gutierrez@amd.com    c_reg.clear();
4711308Santhony.gutierrez@amd.com    busy.clear();
4811308Santhony.gutierrez@amd.com}
4911308Santhony.gutierrez@amd.com
5011308Santhony.gutierrez@amd.comvoid
5111308Santhony.gutierrez@amd.comConditionRegisterState::setParent(ComputeUnit *_computeUnit)
5211308Santhony.gutierrez@amd.com{
5311308Santhony.gutierrez@amd.com    computeUnit = _computeUnit;
5411308Santhony.gutierrez@amd.com    _name = computeUnit->name() + ".CondRegState";
5511308Santhony.gutierrez@amd.com}
5611308Santhony.gutierrez@amd.com
5711308Santhony.gutierrez@amd.comvoid
5811308Santhony.gutierrez@amd.comConditionRegisterState::init(uint32_t _size)
5911308Santhony.gutierrez@amd.com{
6011308Santhony.gutierrez@amd.com    c_reg.resize(_size);
6111308Santhony.gutierrez@amd.com    busy.resize(_size, 0);
6211308Santhony.gutierrez@amd.com}
6311308Santhony.gutierrez@amd.com
6411308Santhony.gutierrez@amd.comvoid
6511308Santhony.gutierrez@amd.comConditionRegisterState::exec(GPUStaticInst *ii, Wavefront *w)
6611308Santhony.gutierrez@amd.com{
6711308Santhony.gutierrez@amd.com    // iterate over all operands
6811308Santhony.gutierrez@amd.com    for (auto i = 0; i < ii->getNumOperands(); ++i) {
6911308Santhony.gutierrez@amd.com        // is this a condition register destination operand?
7011308Santhony.gutierrez@amd.com        if (ii->isCondRegister(i) && ii->isDstOperand(i)) {
7111308Santhony.gutierrez@amd.com            // mark the register as busy
7211308Santhony.gutierrez@amd.com            markReg(ii->getRegisterIndex(i), 1);
7311308Santhony.gutierrez@amd.com            uint32_t pipeLen =  w->computeUnit->spBypassLength();
7411308Santhony.gutierrez@amd.com
7511308Santhony.gutierrez@amd.com            // schedule an event for marking the register as ready
7611308Santhony.gutierrez@amd.com            w->computeUnit->
7711308Santhony.gutierrez@amd.com                registerEvent(w->simdId, ii->getRegisterIndex(i),
7811308Santhony.gutierrez@amd.com                              ii->getOperandSize(i),
7911308Santhony.gutierrez@amd.com                              w->computeUnit->shader->tick_cnt +
8011308Santhony.gutierrez@amd.com                              w->computeUnit->shader->ticks(pipeLen), 0);
8111308Santhony.gutierrez@amd.com        }
8211308Santhony.gutierrez@amd.com    }
8311308Santhony.gutierrez@amd.com}
84