summaryrefslogtreecommitdiffstats
path: root/src/dmclock/src/dmclock_recs.h
blob: a7dc441087c608c65265d48fdbf64b7edaffa48e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

/*
 * Copyright (C) 2017 Red Hat Inc.
 *
 * Author: J. Eric Ivancich <ivancich@redhat.com>
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version
 * 2.1, as published by the Free Software Foundation.  See file
 * COPYING.
 */


#pragma once


#include <ostream>
#include <assert.h>


namespace crimson {
  namespace dmclock {
    using Counter = uint64_t;

    // we're abstracting cost to its own type to better allow for
    // future changes; we're assuming that Cost is relatively small
    // and that it would be more efficient to pass-by-value than
    // by-reference.
    using Cost = uint32_t;

    enum class PhaseType : uint8_t { reservation, priority };

    inline std::ostream& operator<<(std::ostream& out, const PhaseType& phase) {
      out << (PhaseType::reservation == phase ? "reservation" : "priority");
      return out;
    }

    struct ReqParams {
      // count of all replies since last request
      uint32_t delta;

      // count of reservation replies since last request
      uint32_t rho;

      ReqParams(uint32_t _delta, uint32_t _rho) :
	delta(_delta),
	rho(_rho)
      {
	assert(rho <= delta);
      }

      ReqParams() :
	ReqParams(0, 0)
      {
	// empty
      }

      ReqParams(const ReqParams& other) :
	delta(other.delta),
	rho(other.rho)
      {
	// empty
      }

      friend std::ostream& operator<<(std::ostream& out, const ReqParams& rp) {
	out << "ReqParams{ delta:" << rp.delta <<
	  ", rho:" << rp.rho << " }";
	return out;
      }
    }; // class ReqParams
  }
}