Commit 59bf716e by Tom Vierjahn

pvt.16.12.0

parent f6cd539f
......@@ -147,6 +147,8 @@ application::setup_ui
mp_perf_data_viewer_widget_bottom->hide();
mp_main_splitter->setGeometry(0, 0, 1440, 873);
//mp_main_splitter->setGeometry(0, 0, 1075, 536);
mp_main_splitter->show();
}
......
......@@ -34,7 +34,7 @@ set(SourceFiles
include/pvt/data_array.hpp
include/pvt/dft.hpp
include/pvt/dft_inverse.hpp
include/pvt/directed_variation.hpp
include/pvt/directed_variance.hpp
include/pvt/export_flags.hpp
include/pvt/fft.hpp
include/pvt/fft_helper.hpp
......@@ -87,7 +87,7 @@ set(SourceFiles
src/correlation_computer.cpp
src/dft.cpp
src/dft_inverse.cpp
src/directed_variation.cpp
src/directed_variance.cpp
src/fft.cpp
src/fft_statistics.cpp
src/nop.cpp
......
......@@ -79,18 +79,23 @@ public:
coordinate .begin(),
0);
}
std::vector<std::size_t> get_coordinate(std::size_t index) const
template <typename T>
void get_coordinate(std::size_t index, std::vector<T>& coordinate) const
{
std::vector<std::size_t> coordinate(m_num_dimensions, 0);
std::transform(
m_dimension_sizes .begin(),
m_dimension_sizes .end (),
m_dimension_offsets.begin(),
coordinate.begin(),
coordinate .begin(),
[index] (std::size_t size, std::size_t offset)
{
return (index / offset) % size;
});
}
std::vector<std::size_t> get_coordinate(std::size_t index) const
{
std::vector<std::size_t> coordinate(m_num_dimensions, 0);
get_coordinate(index, coordinate);
return coordinate;
}
......
//==============================================================================
// pvt performance visualization toolkit
//
// Copyright (c) 2014-2016 RWTH Aachen University, Germany,
// Virtual Reality & Immersive Visualisation Group.
//==============================================================================
// License
//
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// In the future, we may decide to add a commercial license
// at our own discretion without further notice.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//==============================================================================
#ifndef PVT_DIRECTED_VARIANCE_HPP_
#define PVT_DIRECTED_VARIANCE_HPP_
#include <pvt/api.hpp>
#include <pvt/data_array.hpp>
namespace pvt
{
class fft;
//------------------------------------------------------------------------------
class PVT_API directed_variance : public data_array<double>
{
public:
directed_variance(std::size_t dimension_count);
void compute(const fft& fft);
};
}
#endif // #ifndef PVT_DIRECTED_VARIANCE_HPP_
//------------------------------------------------------------------------------
// pvt performance visualization toolkit
//
// Copyright (c) 2014-2016 RWTH Aachen University, Germany,
// Virtual Reality & Immersive Visualisation Group.
//------------------------------------------------------------------------------
// License
//
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// In the future, we may decide to add a commercial license
// at our own discretion without further notice.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//------------------------------------------------------------------------------
#ifndef PVT_DIRECTED_VARIATION_HPP_
#define PVT_DIRECTED_VARIATION_HPP_
#include <algorithm>
#include <cmath>
#include <vector>
#include <pvt/api.hpp>
namespace pvt {
class severity_view;
//------------------------------------------------------------------------------
class PVT_API directed_variation
{
public:
directed_variation(std::size_t num_dimensions)
: m_directed_variation(num_dimensions, 0.0)
, m_mean (0.0)
, m_variance (0.0)
{
}
double get_mean () const
{
return m_mean;
}
double get_variance () const
{
return m_variance;
}
double get_std_deviation() const
{
return sqrt(m_variance);
}
double& at(std::size_t index)
{
return m_directed_variation.at(index);
}
const double& at(std::size_t index) const
{
return m_directed_variation.at(index);
}
double& operator[](std::size_t index)
{
return m_directed_variation[index];
}
const double& operator[](std::size_t index) const
{
return m_directed_variation[index];
}
std::vector<double>::iterator begin()
{
return m_directed_variation.begin();
}
std::vector<double>::const_iterator begin() const
{
return m_directed_variation.begin();
}
std::vector<double>::iterator end()
{
return m_directed_variation.end();
}
std::vector<double>::const_iterator end() const
{
return m_directed_variation.end();
}
std::size_t size() const
{
return m_directed_variation.size();
}
void set_to_zero()
{
std::for_each(m_directed_variation.begin(),
m_directed_variation.end(),
[](double& v) { v = 0.0; });
m_mean = 0.0;
m_variance = 0.0;
}
void compute(const severity_view& severity_view);
void dump (const std::string& filename) const;
bool read (const std::string& filename,
const severity_view& severity_view);
private:
std::vector<double> m_directed_variation;
double m_mean;
double m_variance;
};
} // namespace pvt
#endif // #ifndef PVT_DIRECTED_VARIATION_HPP_
......@@ -31,14 +31,17 @@ namespace pvt {
//------------------------------------------------------------------------------
enum export_flags
{
export_nothing = 0x00,
export_metadata = 0x01,
export_severities = 0x01 << 1,
export_fft = 0x01 << 2,
export_data = export_severities | export_fft,
export_metadata_only = export_metadata,
export_all = 0xff,
recompute_spectra = 0x0100 << 2
export_nothing = 0x00,
export_metadata = 0x01,
export_severities = 0x01 << 1,
export_fft = 0x01 << 2,
export_directed_variances = 0x01 << 3,
export_data = export_severities | export_fft | export_directed_variances,
export_metadata_only = export_metadata,
export_directed_variances_only = export_directed_variances,
export_all = 0xff,
recompute_spectra = 0x0100 << 2,
recompute_directed_variances = 0x0100 << 3
};
} // namespace pvt
......
......@@ -38,8 +38,6 @@
namespace pvt {
class directed_variation;
//------------------------------------------------------------------------------
class PVT_API fft
{
......@@ -53,6 +51,8 @@ public:
, m_normalizer (1.0 /
static_cast<double>(cart_topo_idx.get_num_positions()))
, m_is_guaranteed_zero(false)
, m_non_redundant_last_dimension
(cart_topo_idx.get_dimension_sizes().back() % 2 == 0)
{
}
......@@ -94,7 +94,11 @@ public:
{
return sqrt(get_variance());
}
void get_directed_variation(directed_variation& directed_variation) const;
double get_spectral_energy (std::size_t i) const
{
return mod_sq_at(i) * m_normalizer * m_normalizer;
}
void clear_dc()
{
......@@ -181,6 +185,73 @@ public:
/// \todo Check if this is guaranteed for all possible cases
bool is_guaranteed_zero() const { return m_is_guaranteed_zero; }
template <typename T>
void convert_to_frequency
(std::size_t frequency_index,
std::vector<T>& frequency ) const
{
m_cart_topo_idx.get_coordinate(frequency_index, frequency);
}
template <typename T>
void convert_to_dc_centered_frequency
(std::size_t frequency_index,
std::vector<T>& frequency ) const
{
convert_to_frequency(frequency_index, frequency);
const auto dc_shift_callable =
[]
(std::size_t frequency_component,
std::size_t dimension_size)
{
const auto half_dimension_size = dimension_size / 2;
const auto in_upper_half =
frequency_component > half_dimension_size;
const auto shift =
static_cast<double>(in_upper_half) *
static_cast<double>(dimension_size);
return static_cast<double>(frequency_component) - shift;
};
std::transform( frequency.begin(),
--frequency.end (),
m_cart_topo_idx.get_dimension_sizes().begin(),
frequency.begin(),
dc_shift_callable);
}
template <typename T>
T get_frequency_norm_squared(const std::vector<T> frequency) const
{
const auto add_squared_callable =
[](T result, T element)
{
return result + element * element;
};
return std::accumulate(frequency.begin(),
frequency.end (),
0.0,
add_squared_callable);
}
template <typename T>
T get_frequency_norm (const std::vector<T> frequency) const
{
return sqrt(get_frequency_norm_squared(frequency));
}
template <typename T>
bool is_on_boundary (const std::vector<T>& frequency) const
{
return
(frequency.back() == 0) ||
((frequency.back() == static_cast<T>(
m_cart_topo_idx.get_dimension_sizes().back() - 1))
&&
m_non_redundant_last_dimension);
}
private:
double mod_sq_at(std::size_t i) const
{
......@@ -193,6 +264,7 @@ private:
double m_normalizer;
bool m_is_guaranteed_zero;
bool m_non_redundant_last_dimension;
};
} // namespace pvt
......
......@@ -57,7 +57,7 @@ public:
}
/// \todo Better take CartesianTopology as parameter in all related c'tors?
/// \todo Better take cartesian_topology as parameter in all related c'tors?
fft_statistics()
: fft_statistics(num_attributes)
{
......@@ -89,7 +89,7 @@ public:
severity_view.get_performance_data()->
get_fft_statistics(severity_view, *this);
}
/// \todo Implement in order to allow for getting FftStatistics via PerfDataFile interface, in a similar way as DirectedVariation.
/// \todo Implement in order to allow for getting fft_statistics via perf_data_file interface, similar to directed_variance.
void compute(const fft& fft);
private:
......
......@@ -39,7 +39,7 @@ namespace pvt {
template <typename T> class data_array;
class cartesian_topology;
class cnode;
class directed_variation;
class directed_variance;
class fft;
class fft_statistics;
class metric;
......@@ -99,16 +99,16 @@ public:
const std::vector<const metric*>& metric_ids,
const std::vector<const cnode *>& cnode_ids ) const = 0;
virtual double get_severity (const severity_view& severity_view ) const = 0;
virtual double get_severity (const severity_view& severity_view ) const = 0;
virtual void get_severities (const severity_view& severity_view,
data_array<double>& severities ) const = 0;
data_array<double>& severities ) const = 0;
virtual void get_fft (const severity_view& severity_view,
fft& fft ) const = 0;
fft& fft ) const = 0;
virtual void get_fft_statistics (const severity_view& severity_view,
fft_statistics& fft_statistics ) const = 0;
virtual void get_directed_variation (const severity_view& severity_view,
directed_variation& directed_variation) const = 0;
virtual double get_autocorrelation_off_dc(const severity_view& severity_view ) const = 0;
fft_statistics& fft_statistics ) const = 0;
virtual void get_directed_variance (const severity_view& severity_view,
directed_variance& directed_variance) const = 0;
virtual double get_autocorrelation_off_dc(const severity_view& severity_view ) const = 0;
protected:
std::string m_filename;
......
......@@ -47,7 +47,7 @@
namespace pvt {
class correlated_severity_view;
class directed_variation;
class directed_variance;
class fft;
class fft_statistics;
class severity_view;
......@@ -131,8 +131,8 @@ public:
fft& fft ) const;
void get_fft_statistics (const severity_view& severity_view,
fft_statistics& fft_statistics) const;
void get_directed_variation (const severity_view& severity_view,
directed_variation& directed_variation) const;
void get_directed_variance (const severity_view& severity_view,
directed_variance& directed_variance) const;
double get_mean (const severity_view& severity_view) const;
double get_variance (const severity_view& severity_view) const;
double get_standard_deviation (const severity_view& severity_view) const;
......
......@@ -27,12 +27,13 @@
#define PVT_PERF_DATA_CACHE_CNODE_HPP_
#include <algorithm>
#include <cmath>
#include <vector>
#include <pvt/api.hpp>
#include <pvt/cnode.hpp>
#include <pvt/data_array.hpp>
#include <pvt/directed_variation.hpp>
#include <pvt/directed_variance.hpp>
#include <pvt/severity_view.hpp>
#include <pvt/suitable_3d_view_computer.hpp>
......@@ -72,10 +73,10 @@ public:
return std::isfinite(relative_severity) ? relative_severity : 0.0;
}
const directed_variation& get_directed_variation(const cnode* p_cnode)
const directed_variance& get_directed_variance(const cnode* p_cnode)
{
check_and_update_directed_variation(p_cnode);
return m_directed_variations[p_cnode->get_id()];
check_and_update_directed_variance(p_cnode);
return m_directed_variances[p_cnode->get_id()];
}
bool is_suitable_3d_view (const cnode* p_cnode)
......@@ -98,9 +99,9 @@ public:
{
for (std::size_t i = 0; i < m_dirty_severities.size(); ++i)
{
m_dirty_severities [i] = true;
m_dirty_directed_variations[i] = true;
m_dirty_suitable_3d_views [i] = true;
m_dirty_severities [i] = true;
m_dirty_directed_variance[i] = true;
m_dirty_suitable_3d_views[i] = true;
}
}
......@@ -112,12 +113,12 @@ private:
}
void update_severity (const cnode* p_cnode);
void check_and_update_directed_variation(const cnode* p_cnode)
void check_and_update_directed_variance (const cnode* p_cnode)
{
if (m_dirty_directed_variations[p_cnode->get_id()])
update_directed_variation(p_cnode);
if (m_dirty_directed_variance[p_cnode->get_id()])
update_directed_variance(p_cnode);
}
void update_directed_variation (const cnode* p_cnode);
void update_directed_variance (const cnode* p_cnode);
void check_and_update_suitable_3d_view (const cnode* p_cnode)
{
......@@ -126,20 +127,20 @@ private:
}
void update_suitable_3d_view (const cnode* p_cnode);
const severity_view* mp_severity_view;
data_array<double> m_severities_load_buffer;
const severity_view* mp_severity_view;
data_array<double> m_severities_load_buffer;
std::vector<double> m_severities_total;
std::vector<double> m_severities_self;
std::vector<bool> m_dirty_severities;
std::vector<double> m_severities_total;
std::vector<double> m_severities_self;
std::vector<bool> m_dirty_severities;
std::vector<directed_variation> m_directed_variations;
std::vector<bool> m_dirty_directed_variations;
std::vector<directed_variance> m_directed_variances;
std::vector<bool> m_dirty_directed_variance;
suitable_3d_view_computer m_suitable_3d_view_computer;
std::vector<bool> m_suitable_3d_view;
std::vector<bool> m_suitable_3d_view_in_children;
std::vector<bool> m_dirty_suitable_3d_views;
suitable_3d_view_computer m_suitable_3d_view_computer;
std::vector<bool> m_suitable_3d_view;
std::vector<bool> m_suitable_3d_view_in_children;
std::vector<bool> m_dirty_suitable_3d_views;
};
} // namespace pvt
......
......@@ -26,21 +26,26 @@
#ifndef PVT_SUITABLE_3D_VIEW_COMPUTER_HPP_
#define PVT_SUITABLE_3D_VIEW_COMPUTER_HPP_
#include <algorithm>
#include <cassert>
#include <vector>
#include <pvt/api.hpp>
#include <pvt/directed_variation.hpp>
namespace pvt {
class directed_variance;
class severity_view;
//------------------------------------------------------------------------------
class PVT_API suitable_3d_view_computer
{
public:
suitable_3d_view_computer(std::size_t num_dimensions)
: m_threshold (0.01)
, m_filter_dimension_enabled(num_dimensions, false)
: m_num_dimensions (num_dimensions)
, m_threshold (0.01)
, m_severity_threshold (0.01)
, m_use_dimension_for_detection(num_dimensions, 1.0)
{
}
......@@ -56,24 +61,36 @@ public:
bool get_filter_dimension_enabled(std::size_t index) const
{
return m_filter_dimension_enabled[index];
return !static_cast<bool>(m_use_dimension_for_detection[index]);
}
void set_filter_dimension_enabled(std::size_t index, bool enabled)
void set_filter_dimension_enabled(std::size_t index, bool filtered)
{
assert(index <= m_filter_dimension_enabled.size());
m_filter_dimension_enabled[index] = enabled;
assert(index <= m_use_dimension_for_detection.size());
m_use_dimension_for_detection[index] = static_cast<double>(!filtered);
}
void set_filter_dimension_enabled(const std::vector<bool>& other )
{
assert(other.size() == m_filter_dimension_enabled.size());
m_filter_dimension_enabled = other;
assert(other.size() == m_use_dimension_for_detection.size());
std::transform(other.begin(),
other.end (),
m_use_dimension_for_detection.begin(),
[](bool filtered)
{
return static_cast<double>(!filtered);
});
}
bool is_suitable_3d_view (const directed_variation& directed_variation) const;
bool is_suitable_3d_view(const severity_view& severity_view ) const;
bool is_suitable_3d_view(const directed_variance& directed_variance,
double mean ) const;
bool is_severe_enough (const severity_view& severity_view ) const;
private:
double m_threshold;
std::vector<bool> m_filter_dimension_enabled;
std::size_t m_num_dimensions;
double m_threshold;
double m_severity_threshold;
std::vector<double> m_use_dimension_for_detection;
};
} // namespace pvt
......
//==============================================================================
// pvt performance visualization toolkit
//
// Copyright (c) 2014-2016 RWTH Aachen University, Germany,
// Virtual Reality & Immersive Visualisation Group.
//==============================================================================
// License
//
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// In the future, we may decide to add a commercial license
// at our own discretion without further notice.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//==============================================================================
#include <cmath>
#include <pvt/directed_variance.hpp>
#include <pvt/fft.hpp>
namespace pvt
{
//------------------------------------------------------------------------------
directed_variance::directed_variance
(std::size_t dimension_count) : data_array<double>(dimension_count)
{
zero();
}
//------------------------------------------------------------------------------
void
directed_variance::compute
(const fft& fft)
{
zero();
std::vector<double> curr_frequency(size(), 0.0);
for (std::size_t i = 1; i < fft.get_num_data(); ++i)
{
const double curr_spectral_energy =
fft.get_spectral_energy(i);
fft.convert_to_dc_centered_frequency(i, curr_frequency);
const bool not_on_boundary =
!fft.is_on_boundary(curr_frequency);
const double inverse_norm_squared =
1.0 / fft.get_frequency_norm_squared(curr_frequency);
// Add spectral energy to directed variance.
const auto add_weighted_spectral_energy_callable =
[curr_spectral_energy,
inverse_norm_squared,
not_on_boundary ]
(double curr_directed_variance ,
double curr_frequency_component)
{
return
curr_directed_variance +
(1.0 + static_cast<double>(not_on_boundary)) *
inverse_norm_squared *
curr_frequency_component * curr_frequency_component *
curr_spectral_energy;
};
std::transform(begin(),
end (),
curr_frequency.begin(),
begin(),
add_weighted_spectral_energy_callable);
}
}
} // namespace pvt
\ No newline at end of file
//------------------------------------------------------------------------------
// pvt performance visualization toolkit
//
// Copyright (c) 2014-2016 RWTH Aachen University, Germany,
// Virtual Reality & Immersive Visualisation Group.
//------------------------------------------------------------------------------
// License
//
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// In the future, we may decide to add a commercial license
// at our own discretion without further notice.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//------------------------------------------------------------------------------
#include <cassert>
#include <cstdio>