local_memory_pipeline.hh revision 11308
12086SN/A/*
22086SN/A * Copyright (c) 2014-2015 Advanced Micro Devices, Inc.
32086SN/A * All rights reserved.
42086SN/A *
52086SN/A * For use for simulation and test purposes only
62086SN/A *
72086SN/A * Redistribution and use in source and binary forms, with or without
82086SN/A * modification, are permitted provided that the following conditions are met:
92086SN/A *
102086SN/A * 1. Redistributions of source code must retain the above copyright notice,
112086SN/A * this list of conditions and the following disclaimer.
122086SN/A *
132086SN/A * 2. Redistributions in binary form must reproduce the above copyright notice,
142086SN/A * this list of conditions and the following disclaimer in the documentation
152086SN/A * and/or other materials provided with the distribution.
162086SN/A *
172086SN/A * 3. Neither the name of the copyright holder nor the names of its contributors
182086SN/A * may be used to endorse or promote products derived from this software
192086SN/A * without specific prior written permission.
202086SN/A *
212086SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
222086SN/A * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
232086SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
242086SN/A * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
252086SN/A * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
262086SN/A * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
272086SN/A * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
282665Ssaidi@eecs.umich.edu * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
292665Ssaidi@eecs.umich.edu * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
302665Ssaidi@eecs.umich.edu * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
312086SN/A * POSSIBILITY OF SUCH DAMAGE.
322086SN/A *
332086SN/A * Author: Sooraj Puthoor
342086SN/A */
352086SN/A
362086SN/A#ifndef __LOCAL_MEMORY_PIPELINE_HH__
372086SN/A#define __LOCAL_MEMORY_PIPELINE_HH__
382086SN/A
392086SN/A#include <queue>
402086SN/A#include <string>
412086SN/A
422086SN/A#include "gpu-compute/misc.hh"
432086SN/A#include "params/ComputeUnit.hh"
442086SN/A#include "sim/stats.hh"
452086SN/A
462152SN/A/*
472152SN/A * @file local_memory_pipeline.hh
482152SN/A *
492086SN/A * The local memory pipeline issues newly created local memory packets
502086SN/A * from pipeline to the LDS. This stage also retires previously issued
512086SN/A * loads and stores that have returned from the LDS.
522152SN/A */
532152SN/A
542152SN/Aclass ComputeUnit;
552152SN/Aclass Wavefront;
562152SN/A
572152SN/Aclass LocalMemPipeline
582152SN/A{
592086SN/A  public:
602086SN/A    LocalMemPipeline(const ComputeUnitParams *params);
612086SN/A    void init(ComputeUnit *cu);
622152SN/A    void exec();
632597SN/A
642597SN/A    template<typename c0, typename c1> void doSmReturn(GPUDynInstPtr m);
652447SN/A
662086SN/A    std::queue<GPUDynInstPtr> &getLMReqFIFO() { return lmIssuedRequests; }
672086SN/A    std::queue<GPUDynInstPtr> &getLMRespFIFO() { return lmReturnedRequests; }
682086SN/A
692152SN/A    bool
702086SN/A    isLMRespFIFOWrRdy() const
712086SN/A    {
722152SN/A        return lmReturnedRequests.size() < lmQueueSize;
732086SN/A    }
742152SN/A
752086SN/A    bool
762152SN/A    isLMReqFIFOWrRdy(uint32_t pendReqs=0) const
772152SN/A    {
782152SN/A        return (lmIssuedRequests.size() + pendReqs) < lmQueueSize;
792152SN/A    }
802152SN/A
812152SN/A    const std::string& name() const { return _name; }
822152SN/A    void regStats();
832152SN/A
842152SN/A  private:
852086SN/A    ComputeUnit *computeUnit;
862086SN/A    std::string _name;
87    int lmQueueSize;
88    Stats::Scalar loadVrfBankConflictCycles;
89    // Local Memory Request Fifo: all shared memory requests
90    // are issued to this FIFO from the memory pipelines
91    std::queue<GPUDynInstPtr> lmIssuedRequests;
92
93    // Local Memory Response Fifo: all responses of shared memory
94    // requests are sent to this FIFO from LDS
95    std::queue<GPUDynInstPtr> lmReturnedRequests;
96};
97
98#endif // __LOCAL_MEMORY_PIPELINE_HH__
99