Skip to content

Commit

Permalink
clang format the whole desesc
Browse files Browse the repository at this point in the history
  • Loading branch information
renau committed Feb 18, 2023
1 parent 8e6d39e commit db03f4e
Show file tree
Hide file tree
Showing 85 changed files with 636 additions and 802 deletions.
55 changes: 24 additions & 31 deletions core/cachecore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class CacheGeneric {
return line;
}

CacheLine *fillLine(Addr_t addr, Addr_t pc=0) {
CacheLine *fillLine(Addr_t addr, Addr_t pc = 0) {
CacheLine *l = findLine2Replace(addr, pc, false);
I(l);

Expand Down Expand Up @@ -275,7 +275,7 @@ class HawkCache : public CacheGeneric<State, Addr_t> {
typedef typename CacheGeneric<State, Addr_t>::CacheLine Line;

protected:
std::vector<Line> mem;
std::vector<Line> mem;
Line **content;
uint16_t irand;
ReplacementPolicy policy;
Expand Down Expand Up @@ -313,9 +313,7 @@ class HawkCache : public CacheGeneric<State, Addr_t> {
Line *findLinePrivate(Addr_t addr, Addr_t pc = 0);

public:
virtual ~HawkCache() {
delete[] content;
}
virtual ~HawkCache() { delete[] content; }

// TODO: do an iterator. not this junk!!
Line *getPLine(uint32_t l) {
Expand Down Expand Up @@ -354,7 +352,7 @@ class CacheAssoc : public CacheGeneric<State, Addr_t> {
typedef typename CacheGeneric<State, Addr_t>::CacheLine Line;

protected:
std::vector<Line> mem;
std::vector<Line> mem;
Line **content;
uint16_t irand;
ReplacementPolicy policy;
Expand Down Expand Up @@ -420,9 +418,7 @@ class CacheAssoc : public CacheGeneric<State, Addr_t> {
Line *findLinePrivate(Addr_t addr, Addr_t pc = 0);

public:
virtual ~CacheAssoc() {
delete[] content;
}
virtual ~CacheAssoc() { delete[] content; }

// TODO: do an iterator. not this junk!!
Line *getPLine(uint32_t l) {
Expand All @@ -444,8 +440,8 @@ class CacheDM : public CacheGeneric<State, Addr_t> {
typedef typename CacheGeneric<State, Addr_t>::CacheLine Line;

protected:
std::vector<Line> mem;
Line **content;
std::vector<Line> mem;
Line **content;

friend class CacheGeneric<State, Addr_t>;
CacheDM(int32_t size, int32_t blksize, int32_t addrUnit, const std::string &pStr, bool xr);
Expand All @@ -454,9 +450,7 @@ class CacheDM : public CacheGeneric<State, Addr_t> {
Line *findLinePrivate(Addr_t addr, Addr_t pc = 0);

public:
virtual ~CacheDM() {
delete[] content;
};
virtual ~CacheDM() { delete[] content; };

// TODO: do an iterator. not this junk!!
Line *getPLine(uint32_t l) {
Expand All @@ -478,8 +472,8 @@ class CacheDMSkew : public CacheGeneric<State, Addr_t> {
typedef typename CacheGeneric<State, Addr_t>::CacheLine Line;

protected:
std::vector<Line> mem;
Line **content;
std::vector<Line> mem;
Line **content;

friend class CacheGeneric<State, Addr_t>;
CacheDMSkew(int32_t size, int32_t blksize, int32_t addrUnit, const std::string &pStr);
Expand All @@ -488,9 +482,7 @@ class CacheDMSkew : public CacheGeneric<State, Addr_t> {
Line *findLinePrivate(Addr_t addr, Addr_t pc = 0);

public:
virtual ~CacheDMSkew() {
delete[] content;
};
virtual ~CacheDMSkew() { delete[] content; };

// TODO: do an iterator. not this junk!!
Line *getPLine(uint32_t l) {
Expand All @@ -514,7 +506,7 @@ class CacheSHIP : public CacheGeneric<State, Addr_t> {
typedef typename CacheGeneric<State, Addr_t>::CacheLine Line;

protected:
std::vector<Line> mem;
std::vector<Line> mem;
Line **content;
uint16_t irand;
ReplacementPolicy policy;
Expand Down Expand Up @@ -775,8 +767,9 @@ CacheGeneric<State, Addr_t> *CacheGeneric<State, Addr_t>::create(const std::stri
CacheGeneric *cache = 0;

auto fmt_append{append};
if (!fmt_append.empty())
if (!fmt_append.empty()) {
fmt_append += "_";
}

auto size_sec = fmt::format("{}size", fmt_append);
auto line_size_sec = fmt::format("{}line_size", fmt_append);
Expand Down Expand Up @@ -867,11 +860,11 @@ CacheAssoc<State, Addr_t>::CacheAssoc(int32_t size, int32_t assoc, int32_t blksi
zero_line.invalidate();
zero_line.rrip = 0;

mem.resize(numLines+1, zero_line);
mem.resize(numLines + 1, zero_line);
content = new Line *[numLines + 1];

for (uint32_t i = 0; i < numLines; i++) {
content[i] = &mem[i];
content[i] = &mem[i];
}

irand = 0;
Expand Down Expand Up @@ -1210,11 +1203,11 @@ HawkCache<State, Addr_t>::HawkCache(int32_t size, int32_t assoc, int32_t blksize
zero_line.initialize(this);
zero_line.invalidate();

mem.resize(numLines+1, zero_line);
mem.resize(numLines + 1, zero_line);
content = new Line *[numLines + 1];

for (uint32_t i = 0; i < numLines; i++) {
content[i] = &mem[i];
content[i] = &mem[i];
}

irand = 0;
Expand Down Expand Up @@ -1494,11 +1487,11 @@ CacheDM<State, Addr_t>::CacheDM(int32_t size, int32_t blksize, int32_t addrUnit,
zero_line.initialize(this);
zero_line.invalidate();

mem.resize(numLines+1, zero_line);
mem.resize(numLines + 1, zero_line);
content = new Line *[numLines + 1];

for (uint32_t i = 0; i < numLines; i++) {
content[i] = &mem[i];
content[i] = &mem[i];
}
}

Expand Down Expand Up @@ -1543,11 +1536,11 @@ CacheDMSkew<State, Addr_t>::CacheDMSkew(int32_t size, int32_t blksize, int32_t a
zero_line.initialize(this);
zero_line.invalidate();

mem.resize(numLines+1, zero_line);
mem.resize(numLines + 1, zero_line);
content = new Line *[numLines + 1];

for (uint32_t i = 0; i < numLines; i++) {
content[i] = &mem[i];
content[i] = &mem[i];
}
}

Expand Down Expand Up @@ -1711,11 +1704,11 @@ CacheSHIP<State, Addr_t>::CacheSHIP(int32_t size, int32_t assoc, int32_t blksize
zero_line.initialize(this);
zero_line.invalidate();

mem.resize(numLines+1, zero_line);
mem.resize(numLines + 1, zero_line);
content = new Line *[numLines + 1];

for (uint32_t i = 0; i < numLines; i++) {
content[i] = &mem[i];
content[i] = &mem[i];
}

for (uint32_t j = 0; j < (2 ^ log2shct); j++) {
Expand Down
27 changes: 11 additions & 16 deletions core/cachecore_bench.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

#include "benchmark/benchmark.h"

#include "cachecore.hpp"
#include "config.hpp"
#include "report.hpp"
Expand All @@ -13,7 +12,7 @@ class SampleState : public StateGeneric<long> {
bool operator==(SampleState s) const { return id == s.id; }
};

using MyCacheType=CacheGeneric<SampleState, long>;
using MyCacheType = CacheGeneric<SampleState, long>;

MyCacheType *cache;

Expand All @@ -33,7 +32,7 @@ void endBench(const char *str) {

double usecs = (endTime.tv_sec - stTime.tv_sec) * 1000000 + (endTime.tv_usec - stTime.tv_usec);

fprintf(stderr, "%s: %8.2f Maccesses/s %7.3f%%\n", str, nAccess / usecs, 100 * nMisses / nAccess);
fmt::print("{}: {} Maccesses/s {}%\n", str, nAccess / usecs, 100 * nMisses / nAccess);
}

#define MSIZE 256
Expand All @@ -43,7 +42,6 @@ double B[MSIZE][MSIZE];
double C[MSIZE][MSIZE];

void benchMatrix(const char *str) {

startBench();

MyCacheType::CacheLine *line;
Expand Down Expand Up @@ -123,8 +121,7 @@ static void setup_config() {
file.close();
}

static void BM_cachecore(benchmark::State& state) {

static void BM_cachecore(benchmark::State &state) {
Report::init();
Config::init("cachecore.toml");

Expand All @@ -136,7 +133,7 @@ static void BM_cachecore(benchmark::State& state) {

MyCacheType::CacheLine *line = cache->findLine(addr);
if (line) {
fprintf(stderr, "ERROR: Line 0x%lX (0x%lX) found\n", cache->calcAddr4Tag(line->getTag()), addr);
fmt::print("ERROR: Line {:x} ({:x}) found\n", cache->calcAddr4Tag(line->getTag()), addr);
exit(-1);
}
line = cache->fillLine(addr);
Expand All @@ -148,16 +145,15 @@ static void BM_cachecore(benchmark::State& state) {

MyCacheType::CacheLine *line = cache->findLine(addr);
if (line == 0) {
fprintf(stderr, "ERROR: Line (0x%lX) NOT found\n", addr);
fmt::print("ERROR: Line ({:x}) NOT found\n", addr);
exit(-1);
}
if (line->id != i) {
fprintf(stderr,
"ERROR: Line 0x%lX (0x%lX) line->id %d vs id %d (bad LRU policy)\n",
cache->calcAddr4Tag(line->getTag()),
addr,
line->id,
i);
fmt::print("ERROR: Line {:x} ({:x}) line->id {} vs id {} (bad LRU policy)\n",
cache->calcAddr4Tag(line->getTag()),
addr,
line->id,
i);
exit(-1);
}
}
Expand All @@ -178,9 +174,8 @@ BENCHMARK(BM_cachecore)->Arg(2);
BENCHMARK(BM_cachecore)->Arg(4);
#endif

int main(int argc, char* argv[]) {
int main(int argc, char *argv[]) {
setup_config();
benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();
}

2 changes: 1 addition & 1 deletion core/callback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include <algorithm> // std::find()..
#include <vector> // std::vector<>

#include "tqueue.hpp"
#include "fmt/format.h"
#include "iassert.hpp"
#include "pool.hpp"
#include "snippets.hpp"
#include "tqueue.hpp"

/////////////////////////////////////////////////////////////////////////////
//
Expand Down
17 changes: 10 additions & 7 deletions core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void Config::exit_on_error() {
fmt::print("ERROR:{}\n", e);
}

abort(); // Abort no exit to avoid the likely seg-faults of a bad configuration
abort(); // Abort no exit to avoid the likely seg-faults of a bad configuration
}

bool Config::check(const std::string &block, const std::string &name) {
Expand Down Expand Up @@ -193,10 +193,11 @@ int Config::get_integer(const std::string &block, const std::string &name, int f
return 0;
}

if (ent.is_integer())
if (ent.is_integer()) {
val = ent.as_integer();
else
} else {
val = ent.as_floating();
}

if (val < from || val > to) {
errors.emplace_back(fmt::format("conf:{} section:{} field:{} value:{} is not allowed range ({}..<={})\n",
Expand Down Expand Up @@ -236,10 +237,11 @@ int Config::get_integer(const std::string &block, const std::string &name, size_
return 0;
}

if (ent2.is_integer())
if (ent2.is_integer()) {
val = ent2.as_integer();
else
} else {
val = ent2.as_floating();
}

if (val < from || val > to) {
errors.emplace_back(fmt::format("conf:{} section:{} field:{} value:{} is not allowed range ({}..<={})\n",
Expand Down Expand Up @@ -302,10 +304,11 @@ int Config::get_array_integer(const std::string &block, const std::string &name,
}

int val;
if (arr[pos].is_integer())
if (arr[pos].is_integer()) {
val = arr[pos].as_integer();
else
} else {
val = arr[pos].as_floating();
}

add_used(block, name, pos, fmt::format("{}", val));
return val;
Expand Down
2 changes: 1 addition & 1 deletion core/fastqueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ class FastQueue {
Data topNext() const { return getData(getIDFromTop(1)); }

std::size_t size() const { return nElems; }
bool empty() const { return nElems == 0; }
bool empty() const { return nElems == 0; }
};
2 changes: 1 addition & 1 deletion core/pool_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

#include <vector>

#include "threadsafefifo.hpp"
#include "iassert.hpp"
#include "pool.hpp"
#include "snippets.hpp"
#include "threadsafefifo.hpp"

class DummyObjTest {
int32_t c;
Expand Down
6 changes: 3 additions & 3 deletions core/report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ void Report::init() {
}

const std::string Report::get_extension() {

auto pos = report_file.rfind('.');
if (pos == std::string::npos)
if (pos == std::string::npos) {
return "";
}

return report_file.substr(pos+1);
return report_file.substr(pos + 1);
}

void Report::reinit() {
Expand Down
2 changes: 1 addition & 1 deletion core/report.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class Report {
private:
static inline std::string report_file;
static inline int fd = -1;
static inline int fd = -1;

public:
static void init();
Expand Down
3 changes: 2 additions & 1 deletion core/snippets.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// See LICENSE for details.

#include "snippets.hpp"

#include <typeinfo>

#include "snippets.hpp"
#include "iassert.hpp"

int16_t log2i(uint32_t n) {
Expand Down
Loading

0 comments on commit db03f4e

Please sign in to comment.