diff options
Diffstat (limited to 'src/dmclock/src/dmclock_recs.h')
-rw-r--r-- | src/dmclock/src/dmclock_recs.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/dmclock/src/dmclock_recs.h b/src/dmclock/src/dmclock_recs.h new file mode 100644 index 000000000..a7dc44108 --- /dev/null +++ b/src/dmclock/src/dmclock_recs.h @@ -0,0 +1,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 + } +} |