Commit 15b5b10c authored by Mathieu Faverge's avatar Mathieu Faverge

Merge branch 'plugins/matrix-visualizer' into 'master'

Plugins/matrix visualizer

Closes #6

See merge request !5
parents 0068063a 1f693732
# Atom editor
.clang_complete
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# Coverages files
*.gcov
*.gcno
*.gcda
# Cmake files
CMakeCache.txt
CMakeFiles
CMakeScripts
CPackLists.txt
CPackConfig.cmake
CPackSourceConfig.cmake
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
# Generated directories
plugins/*/*_autogen
src/*_autogen
build*
.vs
# Generated files
src/common/ViteConfig.hpp
toto.trace
log.txt
# QT files
src/interface/vite.qrc.depends
src/qrc_vite.cpp
moc*
ui*
# Binary
vite
#
#
#
#
### ViTE optional plugins
......@@ -7,6 +7,8 @@ option(VITE_PLUGINS_DISTRIBUTIONS
"Enable the distribution plugin." OFF)
option(VITE_PLUGINS_TRACEINFOS
"Enable the TraceInfos plugin." OFF)
option(VITE_PLUGINS_MATRIX_VISUALIZER
"Enable the MatrixVisualizer plugin." OFF)
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_BINARY_DIR}/src/common)
......@@ -18,3 +20,7 @@ endif( VITE_PLUGINS_DISTRIBUTIONS )
if( VITE_PLUGINS_TRACEINFOS )
add_subdirectory(TraceInfos)
endif( VITE_PLUGINS_TRACEINFOS )
if( VITE_PLUGINS_MATRIX_VISUALIZER )
add_subdirectory(MatrixVisualizer)
endif( VITE_PLUGINS_MATRIX_VISUALIZER )
......@@ -34,4 +34,4 @@ IF(USE_QT5)
qt5_use_modules(Distribution Widgets Core)
ENDIF(USE_QT5)
install(TARGETS Distribution DESTINATION ${HOME}/.vite)
\ No newline at end of file
install(TARGETS Distribution DESTINATION $ENV{HOME}/.vite)
###
#
# This file is part of the ViTE project.
#
# This software is governed by the CeCILL-A license under French law
# and abiding by the rules of distribution of free software. You can
# use, modify and/or redistribute the software under the terms of the
# CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
# URL: "http://www.cecill.info".
#
# @version 1.2.0
# @authors COULOMB Kevin
# @authors FAVERGE Mathieu
# @authors JAZEIX Johnny
# @authors LAGRASSE Olivier
# @authors MARCOUEILLE Jule
# @authors NOISETTE Pascal
# @authors REDONDY Arthur
# @authors VUCHENER Clément
# @authors RICHART Nicolas
#
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
configure_file(
"Configuration.in"
"Configuration.hpp"
)
set (MATRIXVISUALIZER_hdrs
MatrixVisualizer.hpp
Configuration.hpp
Helper.hpp
Parsers/Parser.hpp
Parsers/SymbolParser.hpp
Parsers/OrderParser.hpp
Parsers/ValuesParser.hpp
Formats/SymbolMatrix.hpp
Parsers/Readers/Pastix.hpp
Windows/MatrixWindow.hpp
Windows/MatrixGLWidget.hpp
Common/Zooming.hpp
)
set (MATRIXVISUALIZER_srcs
MatrixVisualizer.cpp
Helper.cpp
Formats/SymbolMatrix.cpp
Parsers/SymbolParser.cpp
Parsers/OrderParser.cpp
Parsers/ValuesParser.cpp
Parsers/Readers/Pastix.cpp
Windows/MatrixWindow.cpp
Windows/MatrixGLWidget.cpp
Common/Zooming.cpp
)
set (MATRIXVISUALIZER_forms_tmp
Plugin.ui
)
IF(USE_QT5)
QT5_WRAP_UI(MATRIXVISUALIZER_forms
${MATRIXVISUALIZER_forms_tmp}
)
else(USE_QT5)
QT4_WRAP_UI(MATRIXVISUALIZER_forms
${MATRIXVISUALIZER_forms_tmp}
)
endif(USE_QT5)
include_directories(${CMAKE_BINARY_DIR}/plugins/MatrixVisualizer)
add_library(MatrixVisualizer SHARED ${MATRIXVISUALIZER_srcs} ${MATRIXVISUALIZER_forms})
#############################################
# QT5
#############################################
IF(USE_QT5)
qt5_use_modules(MatrixVisualizer Widgets Core Xml OpenGL UiTools)
ELSE(USE_QT5)
qt4_use_modules(MatrixVisualizer Core Xml OpenGL UiTools)
ENDIF(USE_QT5)
TARGET_LINK_LIBRARIES(MatrixVisualizer
${QT_LIBRARIES}
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${Boost_LIBRARIES}
)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
TARGET_LINK_LIBRARIES(MatrixVisualizer
rt
)
ADD_DEFINITIONS("-DBOOST_GZIP")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF(VITE_ENABLE_VBO)
TARGET_LINK_LIBRARIES(MatrixVisualizer
${GLEW_LIBRARY}
)
ENDIF(VITE_ENABLE_VBO)
install(TARGETS MatrixVisualizer DESTINATION $ENV{HOME}/.vite)
#include <assert.h>
#include "Zooming.hpp"
#include "../Helper.hpp"
Zooming::Zooming(symbol_matrix_t* matrix)
: m_matrix(matrix)
{
// Fill correct colors
move(0.f, 1.f, 0.f, 1.f);
}
Zooming::~Zooming()
{
}
GLfloat Zooming::getColor(int x, int y)
{
return m_colors[x][y];
}
void Zooming::move(double xStart, double xEnd, double yStart, double yEnd)
{
symbol_cblk_t* cblk;
symbol_blok_t* blok;
int i, j, m, n;
// Check positions
assert( xEnd >= xStart );
assert( yEnd >= yStart );
assert( yEnd >= xStart );
// Check for out of bounds
assert( xStart >= 0. );
assert( yStart >= 0. );
assert( xEnd <= 1. );
assert( yEnd <= 1. );
// Convert to column/row indexes
int startCol = xStart * m_matrix->m_colsnbr;
int endCol = xEnd * m_matrix->m_colsnbr - 1;
int startRow = yStart * m_matrix->m_rowsnbr;
int endRow = yEnd * m_matrix->m_rowsnbr - 1;
// Find first cblk
int startCblk = 0;
int endCblk = 0;
// Search for beginnings
cblk = m_matrix->m_cblktab;
for (i = 0; i < m_matrix->m_cblknbr; ++i, cblk++)
{
if ( (cblk->m_fcolnum <= startCol) && (startCol <= cblk->m_lcolnum) )
{
startCblk = i;
startCol = cblk->m_fcolnum;
}
if ( (cblk->m_fcolnum <= startRow) && (startRow <= cblk->m_lcolnum) )
{
startRow = cblk->m_fcolnum;
}
if ( (cblk->m_fcolnum <= endCol) && (endCol <= cblk->m_lcolnum) )
{
endCblk = i+1;
endCol = cblk->m_lcolnum;
}
if ( (cblk->m_fcolnum <= endRow) && (endRow <= cblk->m_lcolnum) )
{
endRow = cblk->m_lcolnum;
}
}
int nb_cols = endCol - startCol + 1;
int nb_rows = endRow - startRow + 1;
for (i = 0; i < DEFAULT_LEVEL_POWER_2; ++i)
{
for (j = 0; j < DEFAULT_LEVEL_POWER_2; ++j)
{
m_colors[i][j] = 1.f;
}
}
float xCoeff = (float)DEFAULT_LEVEL_POWER_2 / ((float)nb_cols);
float yCoeff = (float)DEFAULT_LEVEL_POWER_2 / ((float)nb_rows);
cblk = m_matrix->m_cblktab + startCblk;
for (i = startCblk; i < endCblk; ++i, cblk++)
{
int fbloknum = cblk[0].m_bloknum;
int lbloknum = cblk[1].m_bloknum;
// Get first block size in col from x to xEnd
int x = (cblk->m_fcolnum - startCol) * xCoeff;
int xEnd = (cblk->m_lcolnum - startCol) * xCoeff;
xEnd = ( xEnd > x+1 ) ? xEnd : x+1;
blok = m_matrix->m_bloktab + fbloknum;
for (j = fbloknum; j < lbloknum; ++j, blok++)
{
if ( (blok->m_lrownum < startRow) ||
(blok->m_frownum > endRow ) )
{
continue;
}
// Get first block size in row from y to yEnd
int y = (blok->m_frownum - startRow) * yCoeff;
int yEnd = (blok->m_lrownum - startRow) * yCoeff;
yEnd = ( yEnd > y+1 ) ? yEnd : y+1;
for( m=x; m<xEnd; m++ )
{
for( n=y; n<yEnd; n++ )
{
m_colors[m][n] = 0.0f;
}
}
}
}
}
#ifndef QUADTREE_HPP
#define QUADTREE_HPP
#include <QtOpenGL/QtOpenGL>
#include "../Formats/SymbolMatrix.hpp"
class Zooming
{
public:
static const int DEFAULT_LEVEL = 10;
static const int DEFAULT_LEVEL_POWER_2 = 1024;
public:
Zooming(symbol_matrix_t* matrix);
~Zooming();
GLfloat getColor(int x, int y);
void move(double xStart, double xEnd, double yStart, double yEnd);
private:
symbol_matrix_t *m_matrix;
GLfloat m_colors[DEFAULT_LEVEL_POWER_2][DEFAULT_LEVEL_POWER_2];
};
#endif
#ifndef CONFIGURATION_HPP
#define CONFIGURATION_HPP
#cmakedefine USE_QT5
#endif
#include "SymbolMatrix.hpp"
#include "../Helper.hpp"
#include <cstdlib>
#include <cstring>
#include <cmath>
static inline int32_t imin(int32_t a, int32_t b)
{
return (a < b) ? a : b;
}
static inline int32_t imax(int32_t a, int32_t b)
{
return (a > b) ? a : b;
}
/* Macros */
#define memFree(ptr) free((void*)(ptr))
#define memFree_null(ptr) do \
{ \
memFree( ptr ); \
(ptr) = nullptr; \
} while(0)
void symbol_matrix_init(symbol_matrix_t* matrix)
{
memset(matrix, 0, sizeof(symbol_matrix_t));
return;
}
void symbol_matrix_deinit(symbol_matrix_t* matrix)
{
if (matrix->m_sndetab != nullptr)
{
memFree_null(matrix->m_sndetab);
}
if (matrix->m_cblktab != nullptr)
{
memFree_null(matrix->m_cblktab);
}
if (matrix->m_bloktab != nullptr)
{
memFree_null(matrix->m_bloktab);
}
if (matrix->m_browtab != nullptr)
{
memFree_null(matrix->m_browtab);
}
memset(matrix, 0, sizeof(symbol_matrix_t));
return;
}
#include <iostream>
void symbol_matrix_print_stats(symbol_matrix_t* matrix)
{
symbol_cblk_t* cblk;
symbol_blok_t* blok;
int32_t itercblk, dof;
int32_t sndenbr, cblknbr, bloknbr;
int32_t cblkmin, cblkmax;
int32_t blokmin, blokmax;
double cblkavg1, blokavg1;
double cblkavg2, blokavg2;
size_t mem = 0;
sndenbr = matrix->m_sndenbr;
cblknbr = matrix->m_cblknbr;
bloknbr = matrix->m_bloknbr;
cblkmin = INT32_MAX;
cblkmax = 0;
cblkavg1 = 0.0;
cblkavg2 = 0.0;
blokmin = INT32_MAX;
blokmax = 0;
blokavg1 = 0.0;
blokavg2 = 0.0;
cblk = matrix->m_cblktab;
blok = matrix->m_bloktab;
for (itercblk = 0; itercblk < cblknbr; ++itercblk, ++cblk)
{
int32_t iterblok = cblk[0].m_bloknum + 1;
int32_t lbloknum = cblk[1].m_bloknum;
int32_t colnbr = cblk->m_lcolnum - cblk->m_fcolnum + 1;
cblkmin = imin(cblkmin, colnbr);
cblkmax = imax(cblkmax, colnbr);
cblkavg1 += colnbr;
cblkavg2 += colnbr * colnbr;
blok++;
/* Only extra diagonal */
for (; iterblok < lbloknum; ++iterblok, ++blok)
{
int32_t rownbr = blok->m_lrownum - blok->m_frownum + 1;
blokmin = imin(blokmin, rownbr);
blokmax = imax(blokmax, rownbr);
blokavg1 += rownbr;
blokavg2 += rownbr * rownbr;
}
}
dof = matrix->m_dof;
if (dof < 1)
{
Helper::log(LogStatus::WARNING, "DOF lower than 1 so statistics might be wrong !");
dof = 1;
}
blokmin *= dof;
blokmax *= dof;
cblkmin *= dof;
cblkmax *= dof;
cblkavg1 = (cblkavg1 * (double)dof) / (double)cblknbr;
blokavg1 = (blokavg1 * (double)dof) / (double)bloknbr;
cblkavg2 = sqrt( ((cblkavg2 * (double)dof * (double)dof) / (double)cblknbr) - cblkavg1 * cblkavg1);
blokavg2 = sqrt( ((blokavg2 * (double)dof * (double)dof) / (double)bloknbr) - blokavg1 * blokavg1);
/* Compute symbol matrix space */
mem = sizeof(symbol_matrix_t);
mem += sizeof(symbol_cblk_t) * (cblknbr + 1);
mem += sizeof(symbol_blok_t) * matrix->m_bloknbr;
mem += sizeof(int32_t) * bloknbr;
Helper::set_infos(
"Symbol Matrix statistics:\n"
" Number of superndoes %10ld\n"
" Number of cblk %10ld\n"
" Number of blok %10ld\n"
" Cblk width min %10ld\n"
" Cblk width max %10ld\n"
" Cblk width avg %11.2lf\n"
" Cblk width stdev %11.2lf\n"
" Blok height min %10ld\n"
" Blok height max %10ld\n"
" Blok height avg %11.2lf\n"
" Blok height stdev %11.2lf\n"
" Matrix structure space %11.2lf %cB\n",
(long)sndenbr, (long)cblknbr, (long)bloknbr,
(long)cblkmin, (long)cblkmax, cblkavg1, cblkavg2,
(long)blokmin, (long)blokmax, blokavg1, blokavg2,
print_get_value( mem ), print_get_units( mem ) );
}
#ifndef SYMBOL_MATRIX_HPP
#define SYMBOL_MATRIX_HPP
#include <cstdint>
typedef struct symbol_cblk_s
{
int32_t m_snodeid; // Id of the supernodes this cblk belongs to
int32_t m_fcolnum; // First column index
int32_t m_lcolnum; // Last column index (inclusive)
int32_t m_bloknum; // First blok in column
int32_t m_flags; // Flags
} symbol_cblk_t;
typedef struct symbol_blok_s
{
int32_t m_frownum; // First row index
int32_t m_lrownum; // Last row index (inclusive)
int32_t m_lcblknm; // Local column blok
int32_t m_fcblknm; // Facing column blok
uint32_t m_localization; // Localization
int32_t m_flags;
} symbol_blok_t;
#define BLOK_FLAG_IN_TREE 1
/*
How localization works ?
=> See Z-curve identification
We use Z-curve to ID the quadtree nodes and we flip the bit of the level.
For example if we are in the third level of quadtreefication and we have the ID 2:
0000 0000 0001 0010
^ ^
| ID of the node
Bit flipped for the level
With this technique we can store a 32 bits localization to allow 15 levels of details
and know the parents of any node due to the Z-curve :D
*/
typedef struct symbol_matrix_s
{
int32_t m_baseval;
int32_t m_dof;
int32_t m_sndenbr; // Supernodes number (= cblknbr if no order file)
int32_t m_cblknbr; // Column blocks number
int32_t m_bloknbr; // Block number
int32_t m_colsnbr; // Column number
int32_t m_rowsnbr; // Row number
int32_t* m_sndetab;
symbol_cblk_t* m_cblktab;
symbol_blok_t* m_bloktab;
int32_t* m_browtab;
} symbol_matrix_t;
void symbol_matrix_init(symbol_matrix_t* matrix);
void symbol_matrix_deinit(symbol_matrix_t* matrix);
void symbol_matrix_print_stats(symbol_matrix_t* matrix);
#endif
#include "Helper.hpp"
#include <cstdarg>
#include <iostream>
#include "MatrixVisualizer.hpp"
namespace Helper
{
void log(LogStatus status, const char* format, ...)
{
va_list ap;
va_start(ap, format);
Matrix_visualizer::get_instance()->log(status, format, ap);
va_end(ap);
}
void set_infos(const char* format, ...)
{
va_list ap;
va_start(ap, format);
Matrix_visualizer::get_instance()->set_infos(format, ap);
va_end(ap);
}
}
#ifndef HELPER_HPP
#define HELPER_HPP
enum LogStatus
{
MESSAGE,
WARNING,
FATAL,
COUNT
};
static inline double
print_get_value( double flops )
{
static double ratio = (double)(1<<10);
int unit = 0;
while ( (flops > ratio) && (unit < 9) ) {
flops /= ratio;
unit++;
}
return flops;
}
static inline char
print_get_units( double flops )
{
static char units[9] = { ' ', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' };
static double ratio = (double)(1<<10);
int unit = 0;
while ( (flops > ratio) && (unit < 9) ) {
flops /= ratio;
unit++;
}
return units[unit];
}
namespace Helper
{
void log(LogStatus status, const char* format, ...);
void set_infos(const char* format, ...);
}
#endif
#include "MatrixVisualizer.hpp"
#include "Configuration.hpp"
#include <QFileDialog>
Matrix_visualizer* Matrix_visualizer::s_plugin = nullptr;
SymbolParser Matrix_visualizer::s_symbol_parser;
OrderParser Matrix_visualizer::s_order_parser;
ValuesParser Matrix_visualizer::s_values_parser;
Matrix_window* Matrix_visualizer::s_matrix_window = nullptr;
symbol_matrix_t* Matrix_visualizer::s_matrix = nullptr;
// Functions to initialize the plugin in ViTE
Plugin *create() { return Matrix_visualizer::get_instance(); }
Matrix_visualizer* Matrix_visualizer::get_instance()
{
if (NULL == s_plugin)
{
s_plugin = new Matrix_visualizer();
}
return s_plugin;
}
// Plugin implementation itself
Matrix_visualizer::Matrix_visualizer() {
setupUi(this);
s_plugin = this;
// For windows dev (pc: orange)
this->line_edit_symbol->setText("/home/mathieu/1-PaStiX/pastix/build/pastix-JLjWM5/symbgen");
}
Matrix_visualizer::~Matrix_visualizer(){
}
void Matrix_visualizer::init(){
}
void Matrix_visualizer::clear(){
}
void Matrix_visualizer::set_arguments(std::map<std::string /*argname*/, QVariant* /*argValue*/>){