Commits (10)
......@@ -38,35 +38,53 @@ if ( NOT BUILD_SUBPROJECT )
endif()
set(hdrs
include/common.h
include/libdraw.h
include/libhqr.h
include/queue.h
include/libhqr_internal.h
include/libhqr_queue.h
)
set(srcs
src/libhqr.c
src/libhqr_dbg.c
src/libhqr_systolic.c
# Low level tree functions
src/low_flat.c
src/low_binary.c
src/low_fibonacci.c
src/low_greedy.c
src/low_greedy1p.c
src/low_adaptiv.c
# High level tree functions
src/high_flat.c
src/high_binary.c
src/high_fibonacci.c
src/high_greedy.c
# Direct access tree functions
src/systolic.c
src/svd.c
src/hqr.c
src/mtxtree.c
# Others
src/check.c
src/gendot.c
src/gensvg.c
src/queue.c
src/treedraw.c
src/treewalk.c
)
include_directories(include)
add_library(hqr ${srcs})
set_property(TARGET hqr PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
target_link_libraries( hqr m )
add_subdirectory(testings)
install(FILES
include/libhqr.h
include/libhqr_common.h
# include/libhqr_dbg.h
DESTINATION include/libhqr )
DESTINATION include )
install(TARGETS hqr DESTINATION lib)
install(TARGETS hqr
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
#generate_hqr_pkgconfig_file()
generate_hqr_pkgconfig_file()
#-- Add a custom target to generate tags
add_custom_target (tags
......
###
#
# @copyright (c) 2009-2014 The University of Tennessee and The University
# of Tennessee Research Foundation.
# All rights reserved.
# @copyright (c) 2012-2017 Inria. All rights reserved.
# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
#
###
#
# - Find HQR include dirs and libraries
# Use this module by invoking find_package with the form:
# find_package(HQR
# [REQUIRED]) # Fail with error if hqr is not found
#
# This module finds headers and hqr library.
# Results are reported in variables:
# HQR_FOUND - True if headers and requested libraries were found
# HQR_INCLUDE_DIRS - hqr include directories
# HQR_LIBRARY_DIRS - Link directories for hqr libraries
# HQR_LIBRARIES - hqr component libraries to be linked
#
# The user can give specific paths where to find the libraries adding cmake
# options at configure (ex: cmake path/to/project -DHQR_DIR=path/to/hqr):
# HQR_DIR - Where to find the base directory of hqr
# HQR_INCDIR - Where to find the header files
# HQR_LIBDIR - Where to find the library files
# The module can also look for the following environment variables if paths
# are not given as cmake variable: HQR_DIR, HQR_INCDIR, HQR_LIBDIR
#=============================================================================
# Copyright 2012-2017 Inria
# Copyright 2012-2013 Emmanuel Agullo
# Copyright 2012-2013 Mathieu Faverge
# Copyright 2012 Cedric Castagnede
# Copyright 2013-2017 Florent Pruvost
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file MORSE-Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of Morse, substitute the full
# License text for the above reference.)
if (NOT HQR_FOUND)
set(HQR_DIR "" CACHE PATH "Installation directory of HQR library")
if (NOT HQR_FIND_QUIETLY)
message(STATUS "A cache variable, namely HQR_DIR, has been set to specify the install directory of HQR")
endif()
endif()
set(ENV_HQR_DIR "$ENV{HQR_DIR}")
set(ENV_HQR_INCDIR "$ENV{HQR_INCDIR}")
set(ENV_HQR_LIBDIR "$ENV{HQR_LIBDIR}")
set(HQR_GIVEN_BY_USER "FALSE")
if ( HQR_DIR OR ( HQR_INCDIR AND HQR_LIBDIR) OR ENV_HQR_DIR OR (ENV_HQR_INCDIR AND ENV_HQR_LIBDIR) )
set(HQR_GIVEN_BY_USER "TRUE")
endif()
# Optionally use pkg-config to detect include/library dirs (if pkg-config is available)
# -------------------------------------------------------------------------------------
include(FindPkgConfig)
find_package(PkgConfig QUIET)
if(PKG_CONFIG_EXECUTABLE AND NOT HQR_GIVEN_BY_USER)
pkg_search_module(HQR hqr)
if (NOT HQR_FIND_QUIETLY)
if (HQR_FOUND AND HQR_LIBRARIES)
message(STATUS "Looking for HQR - found using PkgConfig")
#if(NOT HQR_INCLUDE_DIRS)
# message("${Magenta}HQR_INCLUDE_DIRS is empty using PkgConfig."
# "Perhaps the path to hqr headers is already present in your"
# "C(PLUS)_INCLUDE_PATH environment variable.${ColourReset}")
#endif()
else()
message(STATUS "${Magenta}Looking for HQR - not found using PkgConfig."
"\n Perhaps you should add the directory containing hqr.pc to the"
"\n PKG_CONFIG_PATH environment variable.${ColourReset}")
endif()
endif()
endif(PKG_CONFIG_EXECUTABLE AND NOT HQR_GIVEN_BY_USER)
if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HQR_FOUND) OR (HQR_GIVEN_BY_USER) )
if (NOT HQR_FIND_QUIETLY)
message(STATUS "Looking for HQR - PkgConfig not used")
endif()
# Looking for include
# -------------------
# Add system include paths to search include
# ------------------------------------------
unset(_inc_env)
set(ENV_HQR_DIR "$ENV{HQR_DIR}")
set(ENV_HQR_INCDIR "$ENV{HQR_INCDIR}")
if(ENV_HQR_INCDIR)
list(APPEND _inc_env "${ENV_HQR_INCDIR}")
elseif(ENV_HQR_DIR)
list(APPEND _inc_env "${ENV_HQR_DIR}")
list(APPEND _inc_env "${ENV_HQR_DIR}/include")
else()
if(WIN32)
string(REPLACE ":" ";" _inc_env "$ENV{INCLUDE}")
else()
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{C_INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{CPATH}")
list(APPEND _inc_env "${_path_env}")
string(REPLACE ":" ";" _path_env "$ENV{INCLUDE_PATH}")
list(APPEND _inc_env "${_path_env}")
endif()
endif()
list(APPEND _inc_env "${CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES}")
list(APPEND _inc_env "${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
list(REMOVE_DUPLICATES _inc_env)
# Try to find the hqr header in the given paths
# -------------------------------------------------
# call cmake macro to find the header path
if(HQR_INCDIR)
set(HQR_HQR.h_DIRS "HQR_libhqr.h_DIRS-NOTFOUND")
find_path(HQR_libhqr.h_DIRS
NAMES libhqr.h
HINTS ${HQR_INCDIR})
else()
if(HQR_DIR)
set(HQR_libhqr.h_DIRS "HQR_libhqr.h_DIRS-NOTFOUND")
find_path(HQR_libhqr.h_DIRS
NAMES libhqr.h
HINTS ${HQR_DIR}
else()
set(HQR_libhqr.h_DIRS "HQR_libhqr.h_DIRS-NOTFOUND")
find_path(HQR_libhqr.h_DIRS
NAMES libhqr.h
HINTS ${_inc_env}
PATH_SUFFIXES "hqr")
endif()
endif()
mark_as_advanced(HQR_libhqr.h_DIRS)
# Add path to cmake variable
# ------------------------------------
if (HQR_libhqr.h_DIRS)
set(HQR_INCLUDE_DIRS "${HQR_libhqr.h_DIRS}")
else ()
set(HQR_INCLUDE_DIRS "HQR_INCLUDE_DIRS-NOTFOUND")
if(NOT HQR_FIND_QUIETLY)
message(STATUS "Looking for hqr -- libhqr.h not found")
endif()
endif ()
if (HQR_INCLUDE_DIRS)
list(REMOVE_DUPLICATES HQR_INCLUDE_DIRS)
endif ()
# Looking for lib
# ---------------
# Add system library paths to search lib
# --------------------------------------
unset(_lib_env)
set(ENV_HQR_LIBDIR "$ENV{HQR_LIBDIR}")
if(ENV_HQR_LIBDIR)
list(APPEND _lib_env "${ENV_HQR_LIBDIR}")
elseif(ENV_HQR_DIR)
list(APPEND _lib_env "${ENV_HQR_DIR}")
list(APPEND _lib_env "${ENV_HQR_DIR}/lib")
else()
if(WIN32)
string(REPLACE ":" ";" _lib_env "$ENV{LIB}")
else()
if(APPLE)
string(REPLACE ":" ";" _lib_env "$ENV{DYLD_LIBRARY_PATH}")
else()
string(REPLACE ":" ";" _lib_env "$ENV{LD_LIBRARY_PATH}")
endif()
list(APPEND _lib_env "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
list(APPEND _lib_env "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
endif()
endif()
list(REMOVE_DUPLICATES _lib_env)
# Try to find the hqr lib in the given paths
# ----------------------------------------------
# call cmake macro to find the lib path
if(HQR_LIBDIR)
set(HQR_hqr_LIBRARY "HQR_hqr_LIBRARY-NOTFOUND")
find_library(HQR_hqr_LIBRARY
NAMES hqr
HINTS ${HQR_LIBDIR})
else()
if(HQR_DIR)
set(HQR_hqr_LIBRARY "HQR_hqr_LIBRARY-NOTFOUND")
find_library(HQR_hqr_LIBRARY
NAMES hqr
HINTS ${HQR_DIR}
PATH_SUFFIXES lib lib32 lib64)
else()
set(HQR_hqr_LIBRARY "HQR_hqr_LIBRARY-NOTFOUND")
find_library(HQR_hqr_LIBRARY
NAMES hqr
HINTS ${_lib_env})
endif()
endif()
mark_as_advanced(HQR_hqr_LIBRARY)
# If found, add path to cmake variable
# ------------------------------------
if (HQR_hqr_LIBRARY)
get_filename_component(hqr_lib_path ${HQR_hqr_LIBRARY} PATH)
# set cmake variables (respects naming convention)
set(HQR_LIBRARIES "${HQR_hqr_LIBRARY}")
set(HQR_LIBRARY_DIRS "${hqr_lib_path}")
else ()
set(HQR_LIBRARIES "HQR_LIBRARIES-NOTFOUND")
set(HQR_LIBRARY_DIRS "HQR_LIBRARY_DIRS-NOTFOUND")
if(NOT HQR_FIND_QUIETLY)
message(STATUS "Looking for hqr -- lib hqr not found")
endif()
endif ()
if (HQR_LIBRARY_DIRS)
list(REMOVE_DUPLICATES HQR_LIBRARY_DIRS)
endif ()
# check a function to validate the find
if(HQR_LIBRARIES)
set(REQUIRED_INCDIRS)
set(REQUIRED_LIBDIRS)
set(REQUIRED_LIBS)
# HQR
if (HQR_INCLUDE_DIRS)
set(REQUIRED_INCDIRS "${HQR_INCLUDE_DIRS}")
endif()
if (HQR_LIBRARY_DIRS)
set(REQUIRED_LIBDIRS "${HQR_LIBRARY_DIRS}")
endif()
set(REQUIRED_LIBS "${HQR_LIBRARIES}")
# set required libraries for link
set(CMAKE_REQUIRED_INCLUDES "${REQUIRED_INCDIRS}")
set(CMAKE_REQUIRED_LIBRARIES)
foreach(lib_dir ${REQUIRED_LIBDIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES "-L${lib_dir}")
endforeach()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${REQUIRED_LIBS}")
string(REGEX REPLACE "^ -" "-" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
# test link
unset(HQR_WORKS CACHE)
include(CheckFunctionExists)
check_function_exists(libhqr_hqr_init HQR_WORKS)
mark_as_advanced(HQR_WORKS)
if(NOT HQR_WORKS)
if(NOT HQR_FIND_QUIETLY)
message(STATUS "Looking for hqr : test of libhqr_hqr_init with hqr library fails")
message(STATUS "CMAKE_REQUIRED_LIBRARIES: ${CMAKE_REQUIRED_LIBRARIES}")
message(STATUS "CMAKE_REQUIRED_INCLUDES: ${CMAKE_REQUIRED_INCLUDES}")
message(STATUS "Check in CMakeFiles/CMakeError.log to figure out why it fails")
endif()
endif()
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES)
endif(HQR_LIBRARIES)
endif( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HQR_FOUND) OR (HQR_GIVEN_BY_USER) )
if (HQR_LIBRARIES)
if (HQR_LIBRARY_DIRS)
list(GET HQR_LIBRARY_DIRS 0 first_lib_path)
else()
list(GET HQR_LIBRARIES 0 first_lib)
get_filename_component(first_lib_path "${first_lib}" PATH)
endif()
if (${first_lib_path} MATCHES "/lib(32|64)?$")
string(REGEX REPLACE "/lib(32|64)?$" "" not_cached_dir "${first_lib_path}")
set(HQR_DIR_FOUND "${not_cached_dir}" CACHE PATH "Installation directory of HQR library" FORCE)
else()
set(HQR_DIR_FOUND "${first_lib_path}" CACHE PATH "Installation directory of HQR library" FORCE)
endif()
endif()
mark_as_advanced(HQR_DIR)
mark_as_advanced(HQR_DIR_FOUND)
# check that HQR has been found
# -------------------------------
include(FindPackageHandleStandardArgs)
if (PKG_CONFIG_EXECUTABLE AND HQR_FOUND)
find_package_handle_standard_args(HQR DEFAULT_MSG
HQR_LIBRARIES)
else()
find_package_handle_standard_args(HQR DEFAULT_MSG
HQR_LIBRARIES
HQR_WORKS)
endif()
# - Try to find LibHQR
# Once done this will define
# LIBHQR_FOUND - System has LibHQR
# LIBHQR_INCLUDE_DIRS - The LibHQR include directories
# LIBHQR_LIBRARIES - The libraries needed to use LibHQR
# LIBHQR_DEFINITIONS - Compiler switches required for using LIBHQR
find_package(PkgConfig)
pkg_check_modules(PC_LIBHQR QUIET libhqr)
set(LIBHQR_DEFINITIONS ${PC_LIBHQR_CFLAGS_OTHER})
find_path(
LIBHQR_INCLUDE_DIR
libhqr.h
HINTS ${PC_LIBHQR_INCLUDEDIR}
${PC_LIBHQR_INCLUDE_DIRS}
)
find_library(
LIBHQR_LIBRARY
NAMES hqr
HINTS ${PC_LIBHQR_LIBDIR} ${PC_LIBHQR_LIBRARY_DIRS}
)
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments
# and set LIBHQR_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(
LIBHQR DEFAULT_MSG LIBHQR_LIBRARY LIBHQR_INCLUDE_DIR)
mark_as_advanced(LIBHQR_INCLUDE_DIR LIBHQR_LIBRARY )
set(LIBHQR_LIBRARIES ${LIBHQR_LIBRARY} )
set(LIBHQR_INCLUDE_DIRS ${LIBHQR_INCLUDE_DIR} )
......@@ -33,26 +33,26 @@
# used in CLEAN_LIB_LIST
#
###
macro(CONVERT_LIBSTYLE_TO_PKGCONFIG _liblist)
set(${_liblist}_CPY "${${_liblist}}")
set(${_liblist} "")
foreach(_dep ${${_liblist}_CPY})
if (${_dep} MATCHES "^/")
get_filename_component(dep_libname ${_dep} NAME)
get_filename_component(dep_libdir ${_dep} DIRECTORY)
string(REPLACE "lib" "" dep_libname "${dep_libname}")
string(REPLACE ".so" "" dep_libname "${dep_libname}")
string(REPLACE ".a" "" dep_libname "${dep_libname}")
string(REPLACE ".dylib" "" dep_libname "${dep_libname}")
string(REPLACE ".dll" "" dep_libname "${dep_libname}")
list(APPEND ${_liblist} -L${dep_libdir} -l${dep_libname})
elseif(NOT ${_dep} MATCHES "^-")
list(APPEND ${_liblist} "-l${_dep}")
else()
list(APPEND ${_liblist} ${_dep})
endif()
endforeach()
endmacro(CONVERT_LIBSTYLE_TO_PKGCONFIG)
# macro(CONVERT_LIBSTYLE_TO_PKGCONFIG _liblist)
# set(${_liblist}_CPY "${${_liblist}}")
# set(${_liblist} "")
# foreach(_dep ${${_liblist}_CPY})
# if (${_dep} MATCHES "^/")
# get_filename_component(dep_libname ${_dep} NAME)
# get_filename_component(dep_libdir ${_dep} DIRECTORY)
# string(REPLACE "lib" "" dep_libname "${dep_libname}")
# string(REPLACE ".so" "" dep_libname "${dep_libname}")
# string(REPLACE ".a" "" dep_libname "${dep_libname}")
# string(REPLACE ".dylib" "" dep_libname "${dep_libname}")
# string(REPLACE ".dll" "" dep_libname "${dep_libname}")
# list(APPEND ${_liblist} -L${dep_libdir} -l${dep_libname})
# elseif(NOT ${_dep} MATCHES "^-")
# list(APPEND ${_liblist} "-l${_dep}")
# else()
# list(APPEND ${_liblist} ${_dep})
# endif()
# endforeach()
# endmacro(CONVERT_LIBSTYLE_TO_PKGCONFIG)
###
#
......@@ -60,22 +60,22 @@ endmacro(CONVERT_LIBSTYLE_TO_PKGCONFIG)
# used in GENERATE_PKGCONFIG_FILE
#
###
macro(CLEAN_LIB_LIST _package)
list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_LIBS)
list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_LIBS_PRIVATE)
list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_REQUIRED)
list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_REQUIRED_PRIVATE)
convert_libstyle_to_pkgconfig(${_package}_PKGCONFIG_LIBS)
convert_libstyle_to_pkgconfig(${_package}_PKGCONFIG_LIBS_PRIVATE)
string(REPLACE ";" " " ${_package}_PKGCONFIG_LIBS "${${_package}_PKGCONFIG_LIBS}")
string(REPLACE ";" " " ${_package}_PKGCONFIG_LIBS_PRIVATE "${${_package}_PKGCONFIG_LIBS_PRIVATE}")
string(REPLACE ";" " " ${_package}_PKGCONFIG_REQUIRED "${${_package}_PKGCONFIG_REQUIRED}")
string(REPLACE ";" " " ${_package}_PKGCONFIG_REQUIRED_PRIVATE "${${_package}_PKGCONFIG_REQUIRED_PRIVATE}")
endmacro(CLEAN_LIB_LIST)
#macro(CLEAN_LIB_LIST _package)
# list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_LIBS)
# list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_LIBS_PRIVATE)
# list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_REQUIRED)
# list(REMOVE_DUPLICATES ${_package}_PKGCONFIG_REQUIRED_PRIVATE)
# convert_libstyle_to_pkgconfig(${_package}_PKGCONFIG_LIBS)
# convert_libstyle_to_pkgconfig(${_package}_PKGCONFIG_LIBS_PRIVATE)
# string(REPLACE ";" " " ${_package}_PKGCONFIG_LIBS "${${_package}_PKGCONFIG_LIBS}")
# string(REPLACE ";" " " ${_package}_PKGCONFIG_LIBS_PRIVATE "${${_package}_PKGCONFIG_LIBS_PRIVATE}")
# string(REPLACE ";" " " ${_package}_PKGCONFIG_REQUIRED "${${_package}_PKGCONFIG_REQUIRED}")
# string(REPLACE ";" " " ${_package}_PKGCONFIG_REQUIRED_PRIVATE "${${_package}_PKGCONFIG_REQUIRED_PRIVATE}")
#endmacro(CLEAN_LIB_LIST)
###
#
# GENERATE_PKGCONFIG_FILE: generate files libhqr.pc
# GENERATE_PKGCONFIG_FILE: generate files hqr.pc
#
###
macro(GENERATE_HQR_PKGCONFIG_FILE)
......@@ -85,9 +85,9 @@ macro(GENERATE_HQR_PKGCONFIG_FILE)
set(HQR_PKGCONFIG_REQUIRED "")
set(HQR_PKGCONFIG_REQUIRED_PRIVATE "")
clean_lib_list(LIBHQR)
#clean_lib_list(HQR)
set(_output_libhqr_file "${CMAKE_BINARY_DIR}/hqr.pc")
set(_output_hqr_file "${CMAKE_BINARY_DIR}/hqr.pc")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/lib/pkgconfig/hqr.pc.in"
"${_output_hqr_file}"
......@@ -97,6 +97,7 @@ macro(GENERATE_HQR_PKGCONFIG_FILE)
FILES ${_output_hqr_file}
DESTINATION lib/pkgconfig
)
endmacro(GENERATE_HQR_PKGCONFIG_FILE)
##
......
......@@ -18,23 +18,24 @@
#ifndef _LIBHQR_H_
#define _LIBHQR_H_
#include <stdio.h>
#include "libhqr_common.h"
#ifdef BEGIN_C_DECLS
#undef BEGIN_C_DECLS
#endif
#ifdef END_C_DECLS
#undef END_C_DECLS
#endif
#if defined(c_plusplus) || defined(__cplusplus)
# define BEGIN_C_DECLS extern "C" {
# define END_C_DECLS }
#else
# define BEGIN_C_DECLS /* empty */
# define END_C_DECLS /* empty */
#endif
BEGIN_C_DECLS
static inline int libhqr_imin(int a, int b){
return (a > b) ? b : a;
}
static inline int libhqr_imax(int a, int b){
return (a > b) ? a : b;
}
static inline int libhqr_iceil(int a, int b){
return (a + b - 1) / b;
}
/**
* @brief Define which tree level the tile belongs to.
*
......@@ -50,8 +51,8 @@ static inline int libhqr_iceil(int a, int b){
* matrices.
*
* @remark LIBHQR_KILLED_BY_TS needs to be 0 for all variant of QR
* factorizations in order to distinguish TT kernels from TS kernels in
* compuations
* factorizations in order to easily distinguish TT kernels from TS kernels in
* computations.
*
*/
typedef enum libhqr_type_ {
......@@ -74,47 +75,42 @@ typedef enum libhqr_tree_ {
LIBHQR_FIBONACCI_TREE = 2,
LIBHQR_BINARY_TREE = 3,
LIBHQR_GREEDY1P_TREE = 4,
} libqr_tree_e;
} libhqr_tree_e;
/**
* @brief Define the type of factorization to apply: QR or LQ.
*/
typedef enum libhqr_typefacto_ {
typedef enum libhqr_facto_ {
LIBHQR_QR = 0, /**< QR factorization will be performed, and A shape is considered */
LIBHQR_LQ = 1, /**< LQ factorization will be performed, and A^t shape is considered */
} libhqr_typefacto_e;
} libhqr_facto_e;
/**
* @brief Minimal structure to define the shape of the matrix to factorize.
* @brief Minimal matrix description stucture.
*
* This structure describes the dimension of the matrix to factorize in number
* of tiles: mt-by-nt. When provided, nodes and p provides the total number of
* nodes involved in the computation, and the P parameter of 2D bloc-cyclic
* distributions of the tiles. LibHQR doesn't support any other distribtions for
* now.
*/
typedef struct libhqr_tiledesc_s{
int mt; /**< The number of rows of tiles */
int nt; /**< The number of columns of tiles */
typedef struct libhqr_matrix_s {
int mt; /**< The number of rows of tiles in the matrix */
int nt; /**< The number of columns of tiles in the matrix */
int nodes; /**< The number of nodes involved in the data distribution */
int p; /**< The number of nodes per column in the data distribution */
} libhqr_tiledesc_t;
} libhqr_matrix_t;
/**
* @brief Minimal structure to stock the information for each tile
* @brief Hierarchical tree structure for QR/LQ factorization like kernels.
*
* This structure holds the functions that allows one to traverse the tree, or
* to know form each node which ones are its neigbours in the reduction trees.
*
*/
typedef struct libhqr_tileinfo_s{
int type; /**< The type of the tile */
int currpiv; /**< Number of the time annihilating the current tile */
int nextpiv; /**< The next tile killed by the tile */
int prevpiv; /**< The previous tile killed by the tile */
int first_nextpiv; /**< The first next tile killed */
int first_prevpiv; /**< The first previous tile killed */
} libhqr_tileinfo_t;
struct libhqr_tree_s;
typedef struct libhqr_tree_s libhqr_tree_t;
typedef struct libhqr_context_s libhqr_context_t;
/**
* @brief Hierarchical tree structure for QR/LQ factorization like kernels.
*/
struct libhqr_tree_s {
/**
* @brief Return the number of geqrt/gelqt kernels in the column/row k
......@@ -186,6 +182,7 @@ struct libhqr_tree_s {
*/
int (*prevpiv)(const libhqr_tree_t *qrtree, int k, int p, int m);
int init; /**< Internal variable */
int mt; /**< Number of rows of tile A if QR factorization, and in A^t if LQ
factorization */
int nt; /**< Number of tile reflectors to compute. This is equal to
......@@ -199,53 +196,58 @@ struct libhqr_tree_s {
tree: hqr, systolic, svd, ...) */
};
int libhqr_systolic_init( libhqr_tree_t *qrtree,
libhqr_typefacto_e trans, libhqr_tiledesc_t *A,
int p, int q );
void libhqr_systolic_finalize( libhqr_tree_t *qrtree );
/**
* @name Initialization/Finalization functions
* @{
*/
int libhqr_init_sys( libhqr_tree_t *qrtree,
libhqr_facto_e trans, libhqr_matrix_t *A,
int p, int q );
int libhqr_svd_init( libhqr_tree_t *qrtree,
libhqr_typefacto_e trans, libhqr_tiledesc_t *A,
int libhqr_init_svd( libhqr_tree_t *qrtree,
libhqr_facto_e trans, libhqr_matrix_t *A,
int type_hlvl, int p, int nbcores_per_node, int ratio );
int libhqr_hqr_init( libhqr_tree_t *qrtree,
libhqr_typefacto_e trans, libhqr_tiledesc_t *A,
int libhqr_init_hqr( libhqr_tree_t *qrtree,
libhqr_facto_e trans, libhqr_matrix_t *A,
int type_llvl, int type_hlvl,
int a, int p, int domino, int tsrr );
void libhqr_hqr_finalize( libhqr_tree_t *qrtree );
void libhqr_finalize( libhqr_tree_t *qrtree );
void libhqr_matrix_init(libhqr_tree_t *qrtree, const libhqr_tree_t *qrtree_init);
int rdmtx_gettype(const libhqr_tree_t *qrtree, int k, int m);
int rdmtx_currpiv(const libhqr_tree_t *qrtree, int k, int m);
int rdmtx_nextpiv(const libhqr_tree_t *qrtree, int k, int p, int m);
int rdmtx_prevpiv(const libhqr_tree_t *qrtree, int k, int p, int m);
void libhqr_matrix_finalize(libhqr_tree_t *qrtree);
/*
* function for drawing the tree
/**
* @}
* @name Function to walk the tree in correct order for STF programing model
* @{
*/
void libhqr_walk_stepk( const libhqr_tree_t *qrtree, int k, int *tiles );
void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles);
void draw_rectangle(int k, int p, int m, int step_m, FILE *file);
void draw_lines(const libhqr_tree_t *qrtree, int k, int *tiles, int *step, FILE *file);
void draw_horizontal_line(int k, int p, int m, int step_p, int step_m, FILE *file);
void draw_vertical_line(int k, int p, int m, int step_m, FILE *file);
void libhqr_print_tree(const libhqr_tree_t *qrtree, libhqr_tiledesc_t *matrix);
/**
* @}
* @name Drawing functions
* @{
*/
void libhqr_print_dag( const libhqr_tree_t *qrtree,
const char *filename );
void libhqr_print_svg( const libhqr_tree_t *qrtree,
const char *filename );
/*
* Debugging functions
/**
* @}
* @name Checking/Debugging functions
* @{
*/
int libhqr_check ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree );
void libhqr_print_type ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree );
void libhqr_print_pivot ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree );
void libhqr_print_nbgeqrt( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree );
void libhqr_print_perm ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int *perm );
void libhqr_print_next_k ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k );
void libhqr_print_prev_k ( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k );
void libhqr_print_geqrt_k( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k );
int libhqr_tree_check ( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree );
void libhqr_tree_print_dag ( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, char *filename );
void libhqr_tree_print_type ( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree );
void libhqr_tree_print_pivot ( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree );
void libhqr_tree_print_nbgeqrt( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree );
void libhqr_tree_print_perm ( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int *perm );
void libhqr_tree_print_next_k ( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int k );
void libhqr_tree_print_prev_k ( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int k );
void libhqr_tree_print_geqrt_k( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int k );
/**
* @}
*/
END_C_DECLS
......
/**
*
* @file libhqr_common.h
*
* Header file for common macro
*
* @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
* @version 1.0.0
* @author Raphael Boucherie
* @author Mathieu Faverge
* @date 2017-04-05
*
*/
#ifndef _LIBHQR_COMMON_H_
#define _LIBHQR_COMMON_H_
#undef BEGIN_C_DECLS
#undef END_C_DECLS
#if defined(c_plusplus) || defined(__cplusplus)
# define BEGIN_C_DECLS extern "C" {
# define END_C_DECLS }
#else
# define BEGIN_C_DECLS /* empty */
# define END_C_DECLS /* empty */
#endif
#endif /* _LIBHQR_COMMON_H_ */
/**
*
* @file libhqr_draw.h
*
* Header file for all the functions of drawing.
*
* @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
* @version 1.0.0
* @author Raphael Boucherie
* @author Mathieu Faverge
* @date 2017-04-04
*
**/
#ifndef _LIBHQR_DRAW_H_
#define _LIBHQR_DRAW_H_
#include "libhqr_common.h"
BEGIN_C_DECLS
#define WIDTH 50
#define HEIGHT 50
#define SIZE 100
/*
* Clobal array for color
*/
extern char *color[4];
/*
* function for treedraw
*/
void libhqr_writeheader(FILE *file);
void libhqr_writeend(FILE *file);
void libhqr_drawTT(int x, int y, int w, int h, int k, FILE *file);
void libhqr_drawTS(int x, int y, int w, int h, int k, FILE *file);
void libhqr_drawline(int x1, int y1, int x2, int y2, int k, FILE *file);
END_C_DECLS
#endif /* _LIBHQR_DRAW_H_ */
/**
*
* @file libhqr.h
*
* @copyright 2010-2017 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
*
* @copyright 2012-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
* @version 1.0.0
* @author Raphael Boucherie
* @author Mathieu Faverge
* @date 2017-03-21
*
*/
#ifndef _LIBHQR_INTERNAL_H_
#define _LIBHQR_INTERNAL_H_
#include "libhqr.h"
#include <stdio.h>
#include <assert.h>
#define PRINT_PIVGEN 0
#ifdef PRINT_PIVGEN
#define myassert( test ) {if ( ! (test) ) return -1;}
#else
#define myassert(test) {assert((test)); return -1;}
#endif
typedef enum qrtree_type_ {
LIBHQR_QRTREE_UNSET = 0,
LIBHQR_QRTREE_HQR,
LIBHQR_QRTREE_SVD,
LIBHQR_QRTREE_SYS,
LIBHQR_QRTREE_MTX,
} qrtree_type_e;
struct hqr_args_s;
typedef struct hqr_args_s hqr_args_t;
struct hqr_subpiv_s;
typedef struct hqr_subpiv_s hqr_subpiv_t;
/**
* @brief jhj
*/
struct hqr_args_s {
int domino; /**< Switch to enable/disable the domino tree linking high and lw level reduction trees */
int tsrr; /**< Switch to enable/disable round-robin on TS to optimise pipelining between TS and local tree */
hqr_subpiv_t *llvl;
hqr_subpiv_t *hlvl;
int *perm;
};
struct hqr_subpiv_s {
/**
* currpiv
* @param[in] arg pointer to the qr_piv structure
* @param[in] k step in the factorization
* @param[in] m line you want to eliminate
*
* @return the annihilator p used with m at step k
*/
int (*currpiv)(const hqr_subpiv_t *arg, int k, int m);
/*
* nextpiv
* @param[in] arg pointer to the qr_piv structure
* @param[in] k step in the factorization
* @param[in] p line currently used as an annihilator
* @param[in] m line actually annihilated.
* m = MT to find the first time p is used as an annihilator during step k
*
* @return the next line m' using the line p as annihilator during step k
* mt if p will never be used again as an annihilator.
*/
int (*nextpiv)(const hqr_subpiv_t *arg, int k, int p, int m);
/*
* prevpiv
* @param[in] arg pointer to the qr_piv structure
* @param[in] k step in the factorization
* @param[in] p line currently used as an annihilator
* @param[in] m line actually annihilated.
* m = p to find the last time p has been used as an annihilator during step k
*
* @return the previous line m' using the line p as annihilator during step k
* mt if p has never been used before that as an annihilator.
*/
int (*prevpiv)(const hqr_subpiv_t *arg, int k, int p, int m);
int *ipiv;
int minMN;
int ldd;
int a;
int p;
int domino;
};
/**
* @brief Minimal structure to store the information related to each tile.
*/
typedef struct libhqr_tile_info_s {
int type; /**< The type of the reduction applied to the tile (@sa libhqr_type_e) */
int currpiv; /**< The row index of the pivot for this tile */
int nextpiv; /**< The next tile for which the currpiv is a pivot */
int prevpiv; /**< The previous tile for which currpiv was a pivot */
int first_nextpiv; /**< If type != 0, the first tile for which this tile is a pivot */
int first_prevpiv; /**< If type != 0, the last tile for which this tile is a pivot */
} libhqr_tile_info_t;
static inline int libhqr_imin(int a, int b){
return (a > b) ? b : a;
}
static inline int libhqr_imax(int a, int b){
return (a > b) ? a : b;
}
static inline int libhqr_iceil(int a, int b){
return (a + b - 1) / b;
}
/* Number of extra tile of type 1 between the tile of type 3 and the first of nb11 */
#define nbextra1_formula (( (k % pa) > (pa - p) ) ? (-k)%pa + pa : 0)
/*
* Common functions
*/
/* int hqr_getnbgeqrf( const libhqr_tree_t *qrtree, int k ); */
/* int hqr_getm( const libhqr_tree_t *qrtree, int k, int i ); */
/* int hqr_geti( const libhqr_tree_t *qrtree, int k, int m ); */
/* int hqr_gettype( const libhqr_tree_t *qrtree, int k, int m ); */
/*
* Subtree for low-level
*/
void libhqr_matrix_init(libhqr_tree_t *qrtree, const libhqr_tree_t *qrtree_init);
int rdmtx_gettype(const libhqr_tree_t *qrtree, int k, int m);
int rdmtx_currpiv(const libhqr_tree_t *qrtree, int k, int m);
int rdmtx_nextpiv(const libhqr_tree_t *qrtree, int k, int p, int m);
int rdmtx_prevpiv(const libhqr_tree_t *qrtree, int k, int p, int m);
void libhqr_matrix_finalize(libhqr_tree_t *qrtree);
/*
* function for drawing the tree
*/
void draw_rectangle(int k, int p, int m, int step_m, FILE *file);
void draw_lines(const libhqr_tree_t *qrtree, int k, int *tiles, int *step, FILE *file);
void draw_horizontal_line(int k, int p, int m, int step_p, int step_m, FILE *file);
void draw_vertical_line( int k, int p, int m, int step_m, FILE *file);
/**
* @name Low level trees
* @{
*/
void hqr_low_flat_init ( hqr_subpiv_t *arg );
void hqr_low_binary_init ( hqr_subpiv_t *arg );
void hqr_low_fibonacci_init( hqr_subpiv_t *arg, int minMN );
void hqr_low_greedy_init ( hqr_subpiv_t *arg, int minMN );
void hqr_low_greedy1p_init ( hqr_subpiv_t *arg, int minMN );
void svd_low_adaptiv_init ( hqr_subpiv_t *arg, int gmt, int gnt, int nbcores, int ratio );
/**
* @}
*
* @name High level trees
* @{
*/
void hqr_high_flat_init ( hqr_subpiv_t *arg );
void hqr_high_binary_init ( hqr_subpiv_t *arg );
void hqr_high_fibonacci_init( hqr_subpiv_t *arg );
void hqr_high_greedy_init ( hqr_subpiv_t *arg, int minMN );
void hqr_high_greedy1p_init ( hqr_subpiv_t *arg );
/**
* @}
*/
void libhqr_fct_to_mtx( const libhqr_tree_t *in, libhqr_tree_t *out );
#endif /* _LIBHQR_INTERNAL_H_ */
......@@ -16,10 +16,6 @@
#ifndef _LIBHQR_QUEUE_H_
#define _LIBHQR_QUEUE_H_
#include "libhqr_common.h"
BEGIN_C_DECLS
typedef struct libhqr_queue_tile_s {
struct libhqr_queue_tile_s *prev;
struct libhqr_queue_tile_s *next;
......@@ -27,11 +23,9 @@ typedef struct libhqr_queue_tile_s {
} libhqr_queue_tile_t;
libhqr_queue_tile_t *libhqr_queue_tile_new (void);
void libhqr_queue_tile_push (libhqr_queue_tile_t ** queue_tile, int numero);
int libhqr_queue_tile_head (libhqr_queue_tile_t ** queue_tile);
int libhqr_queue_tile_pop (libhqr_queue_tile_t ** queue_tile);
void libhqr_queue_tile_delete(libhqr_queue_tile_t ** queue_tile);
END_C_DECLS
void libhqr_queue_tile_push (libhqr_queue_tile_t **queue_tile, int numero);
int libhqr_queue_tile_head (libhqr_queue_tile_t **queue_tile);
int libhqr_queue_tile_pop (libhqr_queue_tile_t **queue_tile);
void libhqr_queue_tile_delete(libhqr_queue_tile_t **queue_tile);
#endif /* _LIBHQR_QUEUE_H_ */
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include
Name: HQR
Description: Build and Visualize Trees for Hierachical QR Factorizations
Version: @HQR_VERSION_MAJOR@.@HQR_VERSION_MINOR@.@HQR_VERSION_MICRO@
Cflags: -I${includedir}
Libs: -L${libdir} @HQR_PKGCONFIG_LIBS@
Libs.private: @HQR_PKGCONFIG_LIBS_PRIVATE@
Requires: @HQR_PKGCONFIG_REQUIRED@
Requires.private: @HQR_PKGCONFIG_REQUIRED_PRIVATE@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include/libhqr
Name: libhqr
Description: Build and Visualize Tree of Hierachical QR Factorization
Version: @LIBHQR_VERSION_MAJOR@.@LIBHQR_VERSION_MINOR@.@LIBHQR_VERSION_MICRO@
Cflags: -I${includedir}
Libs: -L${libdir} @LIBHQR_PKGCONFIG_LIBS@
Libs.private: @LIBHQR_PKGCONFIG_LIBS_PRIVATE@
Requires: @LIBHQR_PKGCONFIG_REQUIRED@
Requires.private: @LIBHQR_PKGCONFIG_REQUIRED_PRIVATE@
/**
*
* @file libhqr_dbg.c
* @file check.c
*
* @copyright 2010-2017 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
......@@ -15,7 +15,7 @@
* @date 2017-03-21
*
*/
#include "libhqr.h"
#include "libhqr_internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -30,7 +30,8 @@
return ret; \
}
int libhqr_tree_check( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree)
int
libhqr_check( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree)
{
int minMN = libhqr_imin(A->mt, A->nt );
int i, m, k, nb;
......@@ -43,8 +44,8 @@ int libhqr_tree_check( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree)
* Check Formula for NB geqrt
*/
{
/* libhqr_tree_print_type( A, qrtree ); */
/* libhqr_tree_print_nbgeqrt( A, qrtree ); */
/* libhqr_print_type( A, qrtree ); */
/* libhqr_print_nbgeqrt( A, qrtree ); */
check = 1;
for (k=0; k<minMN; k++) {
nb = 0;
......@@ -73,7 +74,7 @@ int libhqr_tree_check( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree)
int prevm = -1;
check = 1;
for (k=0; k<minMN; k++) {
/* libhqr_tree_print_geqrt_k( A, qrtree, k ); */
/* libhqr_print_geqrt_k( A, qrtree, k ); */
nb = qrtree->getnbgeqrf( qrtree, k );
prevm = -1;
for (i=0; i < nb; i++) {
......@@ -134,8 +135,8 @@ int libhqr_tree_check( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree)
nb++;
}
if ( nb > 1 ) {
libhqr_tree_print_next_k( A, qrtree, k);
libhqr_tree_print_prev_k( A, qrtree, k);
libhqr_print_next_k( A, qrtree, k);
libhqr_print_prev_k( A, qrtree, k);
printf(" ----------------------------------------------------\n"
" - a = %d, p = %d, M = %d, N = %d\n"
......@@ -146,8 +147,8 @@ int libhqr_tree_check( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree)
return 3;
}
else if ( nb == 0 ) {
libhqr_tree_print_next_k( A, qrtree, k);
libhqr_tree_print_prev_k( A, qrtree, k);
libhqr_print_next_k( A, qrtree, k);
libhqr_print_prev_k( A, qrtree, k);
printf(" ----------------------------------------------------\n"
" - a = %d, p = %d, M = %d, N = %d\n"
......@@ -177,8 +178,8 @@ int libhqr_tree_check( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree)
nb++;
}
if ( nb > 1 ) {
libhqr_tree_print_next_k( A, qrtree, k);
libhqr_tree_print_prev_k( A, qrtree, k);
libhqr_print_next_k( A, qrtree, k);
libhqr_print_prev_k( A, qrtree, k);
printf(" ----------------------------------------------------\n"
" - a = %d, p = %d, M = %d, N = %d\n"
......@@ -189,8 +190,8 @@ int libhqr_tree_check( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree)
return 3;
}
else if ( nb == 0 ) {
libhqr_tree_print_next_k( A, qrtree, k);
libhqr_tree_print_prev_k( A, qrtree, k);
libhqr_print_next_k( A, qrtree, k);
libhqr_print_prev_k( A, qrtree, k);
printf(" ----------------------------------------------------\n"
" - a = %d, p = %d, M = %d, N = %d\n"
......@@ -224,8 +225,8 @@ int libhqr_tree_check( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree)
prev = qrtree->prevpiv(qrtree, k, m, next);
if ( start != prev ) {
libhqr_tree_print_next_k( A, qrtree, k);
libhqr_tree_print_prev_k( A, qrtree, k);
libhqr_print_next_k( A, qrtree, k);
libhqr_print_prev_k( A, qrtree, k);
printf(" ----------------------------------------------------\n"
" - a = %d, p = %d, M = %d, N = %d\n"
......@@ -246,7 +247,8 @@ int libhqr_tree_check( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree)
return 0;
}
void libhqr_tree_print_type( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree )
void
libhqr_print_type( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree )
{
int minMN = libhqr_imin(A->mt, A->nt );
int m, k;
......@@ -282,7 +284,8 @@ void libhqr_tree_print_type( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree )
}
}
void libhqr_tree_print_pivot( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree )
void
libhqr_print_pivot( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree )
{
int minMN = libhqr_imin(A->mt, A->nt );
int m, k;
......@@ -317,7 +320,8 @@ void libhqr_tree_print_pivot( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree )
}
}
void libhqr_tree_print_next_k( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int k )
void
libhqr_print_next_k( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k )
{
int m, s;
printf("\n------------ Next (k = %d)--------------\n", k);
......@@ -336,7 +340,8 @@ void libhqr_tree_print_next_k( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int
}
}
void libhqr_tree_print_prev_k( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int k )
void
libhqr_print_prev_k( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k )
{
int m, s;
printf("\n------------ Prev (k = %d)--------------\n", k);
......@@ -355,7 +360,8 @@ void libhqr_tree_print_prev_k( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int
}
}
void libhqr_tree_print_perm( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int *perm )
void
libhqr_print_perm( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int *perm )
{
int minMN = libhqr_imin(A->mt, A->nt );
int m, k;
......@@ -380,7 +386,8 @@ void libhqr_tree_print_perm( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int *p
printf( "\n" );
}
void libhqr_tree_print_nbgeqrt( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree )
void
libhqr_print_nbgeqrt( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree )
{
int minMN = libhqr_imin(A->mt, A->nt );
int m, k, nb;
......@@ -408,7 +415,8 @@ void libhqr_tree_print_nbgeqrt( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree )
printf( "\n" );
}
void libhqr_tree_print_geqrt_k( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int k )
void
libhqr_print_geqrt_k( const libhqr_matrix_t *A, const libhqr_tree_t *qrtree, int k )
{
int i, m, nb;
(void)A;
......@@ -426,125 +434,3 @@ void libhqr_tree_print_geqrt_k( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, int
}
printf( "\n" );
}
/* static int libhqr_tree_getinon0( const libhqr_tree_t *qrtree, */
/* const int k, int i, int mt ) */
/* { */
/* int j; */
/* for(j=k; j<mt; j++) { */
/* if ( libhqr_tree_gettype( qrtree, k, j ) != 0 ) */
/* i--; */
/* if ( i == -1 ) */
/* break; */
/* } */
/* return qrtree->perm[k*(qrtree->desc->mt+1) + j]; */
/* } */
#define DAG_HEADER "digraph G { orientation=portrait; \n"
#define DAG_FOOTER "} // close graph\n"
#define DAG_LABELNODE "%d [label=\"%d\",color=white,pos=\"-1.,-%d.!\"]\n"
#define DAG_LENGTHNODE "l%d [label=\"%d\",color=white,pos=\"%d.,0.5!\"]\n"
#define DAG_INVISEDGE "%d->%d [style=\"invis\"];\n"
#define DAG_STARTNODE "p%d_m%d_k%d [shape=point,width=0.1, pos=\"%d.,-%d.!\",color=\"%s\"];\n"
#define DAG_NODE "p%d_m%d_k%d [shape=point,width=0.1, pos=\"%d.,-%d.!\",color=\"%s\"];\n"
#define DAG_FIRSTEDGE_PIV "%d->p%d_m%d_k0\n"
#define DAG_FIRSTEDGE_TS "%d->p%d_m%d_k0 [style=dotted,width=0.1]\n"
#define DAG_FIRSTEDGE_TT "%d->p%d_m%d_k0 [style=dotted,width=0.1]\n"
#define DAG_EDGE_PIV "p%d_m%d_k%d->p%d_m%d_k%d [width=0.1,color=\"%s\"]\n"
#define DAG_EDGE_TS "p%d_m%d_k%d->p%d_m%d_k%d [style=dotted, width=0.1,color=\"%s\"]\n"
#define DAG_EDGE_TT "p%d_m%d_k%d->p%d_m%d_k%d [style=dashed, width=0.1,color=\"%s\"]\n"
char *color[] = {
"red",
"blue",
"green",
"orange",
"cyan",
"purple",
"yellow",
};
#define DAG_NBCOLORS 7
void libhqr_tree_print_dag( libhqr_tiledesc_t *A, libhqr_tree_t *qrtree, char *filename )
{
int *pos, *next, *done;
int k, m, n, lpos, prev, length;
int minMN = libhqr_imin( A->mt, A->nt );
FILE *f = fopen( filename, "w" );
done = (int*)malloc( A->mt * sizeof(int) );
pos = (int*)malloc( A->mt * sizeof(int) );
next = (int*)malloc( A->mt * sizeof(int) );
memset(pos, 0, A->mt * sizeof(int) );
memset(next, 0, A->mt * sizeof(int) );
/* Print header */
fprintf(f, DAG_HEADER ); /*, A->mt+2, minMN+2 );*/
for(m=0; m < A->mt; m++) {
fprintf(f, DAG_LABELNODE, m, m, m);
}
for(k=0; k<minMN; k++ ) {
int nb2reduce = A->mt - k - 1;
for(m=k; m < A->mt; m++) {
fprintf(f, DAG_STARTNODE, m, A->mt, k, pos[m], m, color[ (m%qrtree->p) % DAG_NBCOLORS ]);
next[m] = qrtree->nextpiv( qrtree, k, m, A->mt);
}
while( nb2reduce > 0 ) {
memset(done, 0, A->mt * sizeof(int) );
for(m=A->mt-1; m > (k-1); m--) {
n = next[m];
if ( next[n] != A->mt )
continue;
if ( n != A->mt ) {
lpos = libhqr_imax( pos[m], pos[n] );
lpos++;
pos[m] = lpos;
pos[n] = lpos;
fprintf(f, DAG_NODE, m, n, k, pos[m], m, color[ (m%qrtree->p) % DAG_NBCOLORS ]);
prev = qrtree->prevpiv( qrtree, k, m, n );
fprintf(f, DAG_EDGE_PIV,
m, prev, k,
m, n, k,
color[ (m%qrtree->p) % DAG_NBCOLORS ]);
prev = qrtree->prevpiv( qrtree, k, n, n );
if ( qrtree->gettype(qrtree, k, n) == 0 )
fprintf(f, DAG_EDGE_TS,
n, prev, k,
m, n, k,
color[ (m%qrtree->p) % DAG_NBCOLORS ]);
else
fprintf(f, DAG_EDGE_TT,
n, prev, k,
m, n, k,
color[ (m%qrtree->p) % DAG_NBCOLORS ]);
next[m] = qrtree->nextpiv( qrtree, k, m, n);
done[m] = done[n] = 1;
nb2reduce--;
}
}
}
}
length = 0;
for(m=0; m < A->mt; m++) {
length = libhqr_imax(length, pos[m]);
}
length++;
for(k=0; k<length; k++)
fprintf(f, DAG_LENGTHNODE, k, k, k);
fprintf(f, DAG_FOOTER);
printf("Tic Max = %d\n", length-1);
fclose( f );
free(pos);
free(next);
}
/**
*
* @file gendot.c
*
* @copyright 2010-2017 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
*
* @copyright 2012-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
* @version 1.0.0
* @author Raphael Boucherie
* @author Mathieu Faverge
* @date 2017-03-21
*
*/
#include "libhqr_internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define DAG_HEADER "digraph G { orientation=portrait; \n"
#define DAG_FOOTER "} // close graph\n"
#define DAG_LABELNODE "%d [label=\"%d\",color=white,pos=\"-1.,-%d.!\"]\n"
#define DAG_LENGTHNODE "l%d [label=\"%d\",color=white,pos=\"%d.,0.5!\"]\n"
#define DAG_INVISEDGE "%d->%d [style=\"invis\"];\n"
#define DAG_STARTNODE "p%d_m%d_k%d [shape=point,width=0.1, pos=\"%d.,-%d.!\",color=\"%s\"];\n"
#define DAG_NODE "p%d_m%d_k%d [shape=point,width=0.1, pos=\"%d.,-%d.!\",color=\"%s\"];\n"
#define DAG_FIRSTEDGE_PIV "%d->p%d_m%d_k0\n"
#define DAG_FIRSTEDGE_TS "%d->p%d_m%d_k0 [style=dotted,width=0.1]\n"
#define DAG_FIRSTEDGE_TT "%d->p%d_m%d_k0 [style=dotted,width=0.1]\n"
#define DAG_EDGE_PIV "p%d_m%d_k%d->p%d_m%d_k%d [width=0.1,color=\"%s\"]\n"
#define DAG_EDGE_TS "p%d_m%d_k%d->p%d_m%d_k%d [style=dotted, width=0.1,color=\"%s\"]\n"
#define DAG_EDGE_TT "p%d_m%d_k%d->p%d_m%d_k%d [style=dashed, width=0.1,color=\"%s\"]\n"
char *color[] = {
"red",
"blue",
"green",
"orange",
"cyan",
"purple",
"yellow",
};
#define DAG_NBCOLORS 7
void
libhqr_print_dot( const libhqr_tree_t *qrtree,
const char *filename )
{
int *pos, *next, *done;
int k, m, n, lpos, prev, length;
int minMN = libhqr_imin( qrtree->mt, qrtree->nt );
FILE *f = fopen( filename, "w" );
done = (int*)malloc( qrtree->mt * sizeof(int) );
pos = (int*)malloc( qrtree->mt * sizeof(int) );
next = (int*)malloc( qrtree->mt * sizeof(int) );
memset(pos, 0, qrtree->mt * sizeof(int) );
memset(next, 0, qrtree->mt * sizeof(int) );
/* Print header */
fprintf(f, DAG_HEADER ); /*, A->mt+2, minMN+2 );*/
for(m=0; m < qrtree->mt; m++) {
fprintf(f, DAG_LABELNODE, m, m, m);
}
for(k=0; k<minMN; k++ ) {
int nb2reduce = qrtree->mt - k - 1;
for(m=k; m < qrtree->mt; m++) {
fprintf(f, DAG_STARTNODE, m, qrtree->mt, k, pos[m], m, color[ (m%qrtree->p) % DAG_NBCOLORS ]);
next[m] = qrtree->nextpiv( qrtree, k, m, qrtree->mt);
}
while( nb2reduce > 0 ) {
memset(done, 0, qrtree->mt * sizeof(int) );
for(m=qrtree->mt-1; m > (k-1); m--) {
n = next[m];
if ( next[n] != qrtree->mt )
continue;
if ( n != qrtree->mt ) {
lpos = libhqr_imax( pos[m], pos[n] );
lpos++;
pos[m] = lpos;
pos[n] = lpos;
fprintf(f, DAG_NODE, m, n, k, pos[m], m, color[ (m%qrtree->p) % DAG_NBCOLORS ]);
prev = qrtree->prevpiv( qrtree, k, m, n );
fprintf(f, DAG_EDGE_PIV,
m, prev, k,
m, n, k,
color[ (m%qrtree->p) % DAG_NBCOLORS ]);
prev = qrtree->prevpiv( qrtree, k, n, n );
if ( qrtree->gettype(qrtree, k, n) == 0 )
fprintf(f, DAG_EDGE_TS,
n, prev, k,
m, n, k,
color[ (m%qrtree->p) % DAG_NBCOLORS ]);
else
fprintf(f, DAG_EDGE_TT,
n, prev, k,
m, n, k,
color[ (m%qrtree->p) % DAG_NBCOLORS ]);
next[m] = qrtree->nextpiv( qrtree, k, m, n);
done[m] = done[n] = 1;
nb2reduce--;
}
}
}
}
length = 0;
for(m=0; m < qrtree->mt; m++) {
length = libhqr_imax(length, pos[m]);
}
length++;
for(k=0; k<length; k++)
fprintf(f, DAG_LENGTHNODE, k, k, k);
fprintf(f, DAG_FOOTER);
printf("Tic Max = %d\n", length-1);
fclose( f );
free(pos);
free(next);
}
/**
*
* @file gensvg.c
*
* File for algorithm of treewalking.
*
* @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
* @version 1.0.0
* @author Raphael Boucherie
* @author Mathieu Faverge
* @date 2017-03-21
*
*/
#include "libhqr_internal.h"
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#define WIDTH 50
#define HEIGHT 50
#define SIZE 100
/*
* Global array for color
*/
char *colortree[] = {"red", "blue", "green", "orange", "cyan", "purple", "yellow" };
#define NBCOLORS (sizeof( colortree ) / sizeof( char* ))
/*
* functions writing in the svg file
*/
static void
drawsvg_header( FILE *file )
{
int rc;
<