/** Print stats out in SS format. */
#define STAT_DISPLAY_COMPAT
+class Callback;
+
/** The current simulated cycle. */
extern Tick curTick;
* @param stream The stream to print to.
*/
virtual void display(std::ostream &stream) const = 0;
+ /**
+ * Reset this stat to the default state.
+ */
+ virtual void reset() = 0;
/**
* Return the number of entries in this stat.
* @return The number of entries.
* @return The value of this stat.
*/
T value(const Params &p) const { return data; }
+ /**
+ * Reset stat value to default
+ */
+ void reset() { data = T(); }
};
/**
* @return The current count.
*/
T value(const Params &p) const { return current; }
+ /**
+ * Reset stat value to default
+ */
+ void reset()
+ {
+ current = T();
+ total = 0;
+ last = curTick;
+ }
};
/**
* @return 1.
*/
virtual size_t size() const { return 1; }
+
+ /**
+ * Reset stat value to default
+ */
+ void reset() { bin.reset(); }
};
//////////////////////////////////////////////////////////////////////
* @return The size of the vector.
*/
virtual size_t size() const { return bin.size(); }
+ /**
+ * Reset stat value to default
+ */
+ virtual void reset() { bin.reset(); }
};
/**
* @return 1.
*/
virtual size_t size() const { return 1; }
+ /**
+ * This stat has no state. Nothing to reset
+ */
+ virtual void reset() { }
};
template <typename T, template <typename T> class Storage, class Bin>
}
}
+ /**
+ * Reset stat value to default
+ */
+ virtual void reset() { bin.reset(); }
};
template <typename T, template <typename T> class Storage, class Bin>
assert (index >= 0 && index < size());
return ScalarProxy<T, Storage, Bin>(*bin, *params, offset + index);
}
+
+ /**
+ * This stat has no state. Nothing to reset.
+ */
+ virtual void reset() { }
};
template <typename T, template <typename T> class Storage, class Bin>
*/
DistStor(const Params ¶ms)
: min_val(INT_MAX), max_val(INT_MIN), underflow(0), overflow(0),
- vec(params.size) {
+ vec(params.size)
+ {
+ reset();
}
+
/**
* Add a value to the distribution for the given number of times.
* @param val The value to add.
rvec, params.min, params.max, params.bucket_size,
params.size);
}
+ /**
+ * Reset stat value to default
+ */
+ void reset()
+ {
+ min_val = INT_MAX;
+ max_val = INT_MIN;
+ underflow = 0;
+ overflow = 0;
+
+ int size = vec.size();
+ for (int i = 0; i < size; ++i)
+ vec[i] = T();
+ }
+
};
void FancyDisplay(std::ostream &stream, const std::string &name,
/**
* Create and initialize this storage.
*/
- FancyStor(const Params &) : sum(0), squares(0), total(0) {}
+ FancyStor(const Params &) : sum(T()), squares(T()), total(0) {}
/**
* Add a value the given number of times to this running average.
* @return True if no samples have been added.
*/
bool zero(const Params &) const { return total == 0; }
+ /**
+ * Reset stat value to default
+ */
+ virtual void reset()
+ {
+ sum = T();
+ squares = T();
+ total = 0;
+ }
};
/**
/**
* Create and initialize this storage.
*/
- AvgFancy(const Params &) : sum(0), squares(0) {}
+ AvgFancy(const Params &) : sum(T()), squares(T()) {}
/**
* Add a value to the distribution for the given number of times.
* @return True if the sum is zero.
*/
bool zero(const Params ¶ms) const { return sum == 0; }
+ /**
+ * Reset stat value to default
+ */
+ virtual void reset()
+ {
+ sum = T();
+ squares = T();
+ }
};
/**
data()->display(stream, myname(), mydesc(), myprecision(), myflags(),
params);
}
+ /**
+ * Reset stat value to default
+ */
+ virtual void reset()
+ {
+ bin.reset();
+ }
};
template <typename T, template <typename T> class Storage, class Bin>
virtual size_t size() const { return bin.size(); }
virtual bool zero() const { return false; }
virtual void display(std::ostream &stream) const;
+ /**
+ * Reset stat value to default
+ */
+ virtual void reset()
+ {
+ bin.reset();
+ }
};
template <typename T, template <typename T> class Storage, class Bin>
data()->display(stream, name.str(), desc.str(),
cstat->myprecision(), cstat->myflags(), cstat->params);
}
+ /**
+ * Proxy has no state. Nothing to reset.
+ */
+ virtual void reset() { }
};
template <typename T, template <typename T> class Storage, class Bin>
}
return reinterpret_cast<Storage *>(ptr);
}
+ void reset()
+ {
+ char *ptr = access();
+ char *flags = ptr + size() * sizeof(Storage);
+ if (!(*flags & 0x1))
+ return;
+
+ Storage *s = reinterpret_cast<Storage *>(ptr);
+ s->reset();
+ }
};
template <class Storage>
}
return reinterpret_cast<Storage *>(ptr + index * sizeof(Storage));
}
+ void reset()
+ {
+ char *ptr = access();
+ char *flags = ptr + size() * sizeof(Storage);
+ if (!(*flags & 0x1))
+ return;
+
+ for (int i = 0; i < _size; ++i) {
+ char *p = ptr + i * sizeof(Storage);
+ Storage *s = reinterpret_cast<Storage *>(p);
+ s->reset();
+ }
+ }
};
};
char ptr[sizeof(Storage)];
public:
+ ~Bin()
+ {
+ reinterpret_cast<Storage *>(ptr)->~Storage();
+ }
+
bool initialized() const { return true; }
void init(const Params ¶ms) {
new (ptr) Storage(params);
assert(initialized());
return reinterpret_cast<Storage *>(ptr);
}
+ void reset()
+ {
+ Storage *s = reinterpret_cast<Storage *>(ptr);
+ s->reset();
+ }
};
template <class Storage>
public:
VectorBin() : ptr(NULL) { }
- ~VectorBin() {
- if (initialized())
- delete [] ptr;
+ ~VectorBin()
+ {
+ if (!initialized())
+ return;
+
+ for (int i = 0; i < _size; ++i) {
+ char *p = ptr + i * sizeof(Storage);
+ reinterpret_cast<Storage *>(p)->~Storage();
+ }
+ delete [] ptr;
}
+
bool initialized() const { return ptr != NULL; }
void init(int s, const Params ¶ms) {
assert(s > 0 && "size must be positive!");
assert(index >= 0 && index < size());
return reinterpret_cast<Storage *>(ptr + index * sizeof(Storage));
}
+ void reset()
+ {
+ for (int i = 0; i < _size; ++i) {
+ char *p = ptr + i * sizeof(Storage);
+ Storage *s = reinterpret_cast<Storage *>(p);
+ s->reset();
+ }
+ }
};
};
else
return root->size();
}
+
+ /**
+ * Formulas don't need to be reset
+ */
+ virtual void reset() {}
};
/**
void check();
void dump(std::ostream &stream);
+void reset();
+void regReset(Callback *cb);
inline Detail::Temp
operator+(Detail::Temp l, Detail::Temp r)
CXX= g++
CURDIR?= $(shell /bin/pwd)
-SRCDIR?= .
+SRCDIR?= ..
TARGET?= alpha
-TEST_SRCDIR?= $(SRCDIR)
-ARCH_SRCDIR?= $(SRCDIR)/../arch/$(TARGET)
-BASE_SRCDIR?= $(SRCDIR)/../base
-SIM_SRCDIR?= $(SRCDIR)/../sim
-CACHE_SRCDIR?= $(SRCDIR)/../sim/cache
-OLD_SRCDIR= $(SRCDIR)/../old
+TEST_SRCDIR?= $(SRCDIR)/test
+ARCH_SRCDIR?= $(SRCDIR)/arch/$(TARGET)
+BASE_SRCDIR?= $(SRCDIR)/base
+SIM_SRCDIR?= $(SRCDIR)/sim
+CACHE_SRCDIR?= $(SRCDIR)/sim/cache
+OLD_SRCDIR= $(SRCDIR)/old
vpath % $(TEST_SRCDIR)
vpath % $(BASE_SRCDIR)
vpath % $(CACHE_SRCDIR)
vpath % $(OLD_SRCDIR)
-INCLDIRS= -I$(ARCH_SRCDIR) -I$(BASE_SRCDIR) -I$(SIM_SRCDIR) \
- -I$(CACHE_SRCDIR) -I$(OLD_SRCDIR)
-CCFLAGS= -g -O0 -MMD -I. $(INCLDIRS) -I- -DTRACING_ON=0
+CCFLAGS= -g -O0 -MMD -I. -I$(SRCDIR) -I- -DTRACING_ON=0
default:
@echo "You must specify a target"
+targetarch:
+ ln -s ../arch/$(TARGET) targetarch
+
bitvectest: bitvectest.o
$(CXX) $(LFLAGS) -o $@ $^
rangetest: rangetest.o str.o
$(CXX) $(LFLAGS) -o $@ $^
-stattest: statistics.o stattest.o cprintf.o misc.o omisc.o str.o
+stattest: cprintf.o hostinfo.o misc.o sim_stats.o sim_time.o \
+ statistics.o stattest.o str.o
$(CXX) $(LFLAGS) -o $@ $^
strnumtest: strnumtest.o str.o
tokentest: tokentest.o str.o
$(CXX) $(LFLAGS) -o $@ $^
-tracetest: tracetest.o trace.o trace_flags.o cprintf.o str.o misc.o omisc.o
+tracetest: tracetest.o trace.o trace_flags.o cprintf.o str.o misc.o
$(CXX) $(LFLAGS) -o $@ $^
clean: