Commit 2d5da2a6 authored by Sebastian Wolf's avatar Sebastian Wolf

Use steady clock in timeings and some TODOs

parent 86b08ec9
......@@ -76,7 +76,7 @@ namespace xerus {
///@brief: Checks whether the relative difference between @a _a and @a _b (i.e. |a-b|/(|a|/2+|b|/2)) is smaller than @a _eps.
template<class T, typename std::enable_if<std::is_floating_point<T>::value, bool>::type = true>
bool approx_equal(T _a, T _b, T _eps = 4*std::numeric_limits<T>::epsilon()) noexcept {
return std::abs(_a-_b) <= _eps*0.5*(std::abs(_a+_b)) || std::abs(_a-_b) < std::numeric_limits<T>::min();
return 2.0*std::abs(_a-_b) <= _eps*(std::abs(_a+_b)) || std::abs(_a-_b) < std::numeric_limits<T>::min();
}
......
......@@ -28,7 +28,6 @@
namespace xerus {
namespace misc {
///@brief: Returns the time since epoche in microseconds.
size_t uTime();
......
......@@ -6,6 +6,7 @@
WARNINGS += -Wall # Show "all" warnings
WARNINGS += -Wextra # Show more warnings
WARNINGS += -pedantic # Strict ISO C++ checks (warn everywhere the ISO says there should be a warning)
WARNINGS += -ftemplate-backtrace-limit=0 # Show arbitrary depth in template instantiations
# Additionall Warnings not aktivated by any level
......
......@@ -29,12 +29,12 @@ namespace xerus {
namespace misc {
size_t uTime() {
return static_cast<size_t>(std::chrono::duration_cast<std::chrono::microseconds>
(std::chrono::system_clock::now().time_since_epoch()).count());
(std::chrono::steady_clock::now().time_since_epoch()).count());
}
size_t mTime() {
return static_cast<size_t>(std::chrono::duration_cast<std::chrono::milliseconds>
(std::chrono::system_clock::now().time_since_epoch()).count());
(std::chrono::steady_clock::now().time_since_epoch()).count());
}
} // namespace misc
} // namespace xerus
......@@ -1164,13 +1164,13 @@ namespace xerus {
void Tensor::ensure_own_data() {
if(is_dense()) {
if(!denseData.unique()) {
if(!denseData.unique()) { // TODO NOT THREADSAFE!
value_t* const oldDataPtr = denseData.get();
denseData.reset(new value_t[size], internal::array_deleter_vt);
misc::copy(denseData.get(), oldDataPtr, size);
}
} else {
if(!sparseData.unique()) {
if(!sparseData.unique()) { // TODO NOT THREADSAFE!
sparseData.reset(new std::map<size_t, value_t>(*sparseData));
}
}
......@@ -1179,11 +1179,11 @@ namespace xerus {
void Tensor::ensure_own_data_no_copy() {
if(is_dense()) {
if(!denseData.unique()) {
if(!denseData.unique()) { // TODO NOT THREADSAFE!
denseData.reset(new value_t[size], internal::array_deleter_vt);
}
} else {
if(!sparseData.unique()) {
if(!sparseData.unique()) { // TODO NOT THREADSAFE!
sparseData.reset(new std::map<size_t, value_t>());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment