Skip to content

File base.h

File List > arbitrator > base.h

Go to the documentation of this file

#pragma once

#include <simtix/mem.h>

#include <cstdint>
#include <vector>

#include "sm/thread.h"

namespace simtix {

// Class: BaseArbitrator
//   Interface for the arbitrator that manages the register read/write.
class BaseArbitrator {
 public:
  // Type: OnReady
  //   The arbitrator calls <OnReady> callback when the register read/write is
  //   finished (ready).
  using OnReady = std::function<void()>;

  virtual ~BaseArbitrator() = default;

  // Function: PushRegfileReadReq
  //   Interface for a <Instr> to access regfile for a read.
  //
  // Parameters:
  //   active_threads - Active threads that are requesting to read regfile.
  //   reg_id         - The register id to read.
  //   data           - Pointer to the data buffer for the read data to put.
  //   ready          - Pointer to signal that the register read is finished.
  virtual void PushRegfileReadReq(const std::vector<Thread *> &active_threads,
                                  uint32_t reg_id, int64_t *data,
                                  OnReady on_ready) = 0;

  // Function: PushRegfileWriteReq
  //   Interface for a <Instr> to access regfile for a write.
  //
  // Parameters:
  //   active_threads - Active threads that are requesting to read regfile.
  //   reg_id         - The register id to read.
  //   data           - Pointer to the data buffer for the write data.
  //   ready          - Pointer to signal that the register write is finished.
  virtual void PushRegfileWriteReq(const std::vector<Thread *> &active_threads,
                                   uint32_t reg_id, int64_t *data,
                                   OnReady on_ready) = 0;

  // Function: PushRegfileWriteReq
  //   Interface for a <Instr> to access regfile for a scatter write.
  //
  // Parameters:
  //   active_threads - Active threads that are requesting to read regfile.
  //   reg_id         - The register id to read.
  //   data           - Data to scatter.
  //   ready          - Pointer to signal that the register write is finished.
  virtual void PushRegfileWriteReq(const std::vector<Thread *> &active_threads,
                                   uint32_t reg_id, int64_t data,
                                   OnReady on_ready) = 0;

  // Function: ReadRegfile
  //   Read the regfile data directly. This function is for debugging purpose
  //   only, and <Instr> should not use this function.
  //
  // Parameters:
  //   wid    - The warp id.
  //   tid    - The thread id.
  //   reg_id - The regfile id.
  //
  // Returns:
  //   The regfile data.
  virtual int64_t ReadRegfile(uint32_t wid, uint32_t tid, uint32_t reg_id) = 0;

  // Function: WriteRegfile
  //   Write the regfile data directly. This function is for debugging purpose
  //   only, and <Instr> should not use this function.
  //
  // Parameters:
  //   wid    - The warp id.
  //   tid    - The thread id.
  //   reg_id - The regfile id.
  //   data   - The data to write.
  virtual void WriteRegfile(uint32_t wid, uint32_t tid, uint32_t reg_id,
                            int64_t data) = 0;
};

}  // namespace simtix