Commit b26f57eb authored by incardon's avatar incardon

Added missing files

parent 8ddecca5
SUBDIRS = src
bin_PROGRAMS =
\ No newline at end of file
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CANONICAL_SYSTEM
AC_CONFIG_SRCDIR([src/main.cpp])
AM_INIT_AUTOMAKE
AC_CONFIG_HEADER([src/config.h])
m4_ifdef([MYSQL_FOUND],,[m4_include([m4/ax_lib_mysql.m4])])
m4_ifdef([AX_CHECK_COMPILER_FLAGS],,[m4_include([m4/ax_check_compiler_flags.m4])])
m4_ifdef([ACX_PTHREAD],,[m4_include([m4/acx_pthread.m4])])
m4_ifdef([AX_CHECK_CL],,[m4_include([m4/ax_opencl.m4])])
m4_ifdef([AX_BOOST_BASE],,[m4_include([m4/ax_boost_base.m4])])
m4_ifdef([AX_BOOST_PROGRAM_OPTIONS],,[m4_include([m4/ax_boost_program_options.m4])])
m4_ifdef([AX_BOOST_THREAD],,[m4_include([m4/ax_boost_thread.m4])])
m4_ifdef([ACX_MPI],,[m4_include([m4/acx_mpi.m4])])
m4_ifdef([AX_OPENMP],,[m4_include([m4/ax_openmp.m4])])
m4_ifdef([AX_GCC_X86_CPUID],,[m4_include([m4/ax_gcc_x86_cpuid.m4])])
m4_ifdef([AX_GCC_ARCHFLAG],,[m4_include([m4/ax_gcc_archflag.m4])])
m4_ifdef([AX_CUDA],,[m4_include([m4/ax_cuda.m4])])
CXXFLAGS+=" --std=c++11 "
NVCCFLAGS=" "
INCLUDES_PATH=" "
# Checks for programs.
AC_PROG_CXX
# Checks g++ flags
AC_CANONICAL_HOST
# Check target architetture
AX_GCC_ARCHFLAG([], [CXXFLAGS="$CXXFLAGS $ax_cv_gcc_archflag"], [])
###### Check for debug compilation
AC_MSG_CHECKING(whether to build with debug information)
debuger=no
AC_ARG_ENABLE(debug,
AC_HELP_STRING(
[--enable-debug],
[enable debug data generation (def=no)]
),
debuger="$enableval"
)
AC_MSG_RESULT($debuger)
if test x"$debuger" = x"yes"; then
AC_DEFINE([DEBUG_MODE],[],[Debug])
AC_DEFINE([DEBUG],[],[Debug])
CXXFLAGS="$CXXFLAGS -g3 -Wall -O0 "
NVCCFLAGS+="$NVCCFLAGS -g -O0 "
else
CXXFLAGS="$CXXFLAGS -Wall -O3 -g3 "
NVCCFLAGS+="$NVCCFLAGS -O3 "
fi
## Check for memcheck
AC_MSG_CHECKING(whether to build with memcheck capabilities)
debuger=no
AC_ARG_ENABLE(memcheck,
AC_HELP_STRING(
[--enable-memcheck],
[enable memory check (def=no)]
),
memcheck="$enableval"
)
AC_MSG_RESULT($memcheck)
if test x"$memcheck" = x"yes"; then
AC_DEFINE([MEMLEAK_CHECK],[],[Memory check, corruption and leak])
fi
#########
####### include OpenFPM_devices include path
INCLUDES_PATH+="-I. -I../../metis_install/include -I../../OpenFPM_IO/src -I../../OpenFPM_data/src -I../../OpenFPM_devices/src -I../../OpenFPM_vcluster/src/"
####### Checking for GPU support
AX_CUDA
AC_MSG_CHECKING(whether to build with GPU support)
gpu_support=no
AC_ARG_ENABLE(gpu,
AC_HELP_STRING(
[--enable-gpu],
[enable gpu support]
),
gpu_support="$enableval"
)
AC_MSG_RESULT($gpu_support)
if test x"$gpu_support" = x"yes"; then
AC_DEFINE([GPU],[],[GPU support])
fi
# Set this conditional if cuda is wanted
AM_CONDITIONAL(BUILDCUDA, test ! x$NVCC = x"no")
###########################
no_avx=no
no_sse42=no
no_sse41=no
no_sse3=no
no_sse2=no
no_sse=no
no_mmx=no
AX_CHECK_COMPILER_FLAGS([-msse4.2],[CXXFLAGS="$CXXFLAGS -mavx"],[no_avx=yes])
AX_CHECK_COMPILER_FLAGS([-msse4.2],[CXXFLAGS="$CXXFLAGS -msse4.2"],[no_sse42=yes])
AX_CHECK_COMPILER_FLAGS([-msse4.1],[CXXFLAGS="$CXXFLAGS -msse4.1"],[no_sse41=yes])
AX_CHECK_COMPILER_FLAGS([-msse3],[CXXFLAGS="$CXXFLAGS -msse3"],[no_sse3=yes])
AX_CHECK_COMPILER_FLAGS([-msse2],[CXXFLAGS="$CXXFLAGS -msse2"],[no_sse2=yes])
AX_CHECK_COMPILER_FLAGS([-msse],[CXXFLAGS="$CXXFLAGS -msse"],[no_sse=yes])
AX_CHECK_COMPILER_FLAGS([-mmmx],[CXXFLAGS="$CXXFLAGS -mmmx"],[no_mmx=yes])
AX_CHECK_COMPILER_FLAGS([-Wno-unused-but-set-variable],[CXXFLAGS="$CXXFLAGS -Wno-unused-but-set-variable"],[])
AC_SUBST(NVCCFLAGS)
AC_SUBST(INCLUDES_PATH)
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
echo ""
echo "***********************************"
echo "* *"
arch_str="${ax_cv_gcc_archflag#-march=#-mtune=}"
arch_str="${arch_str#-mtune=}"
n_arch_str=${#arch_str}
for (( X=0; X<23-n_arch_str; X++ ))
do
arch_str="$arch_str "
done
echo "* arch: $arch_str*"
if [ test x"$no_sse42" = x"no" ]; then
echo "* sse4.2: yes *"
else
echo "* sse4.2: no *"
fi
if [ test x"$no_sse41" = x"no" ]; then
echo "* sse4.1: yes *"
else
echo "* sse4.1: no *"
fi
if [ test x"$no_sse3" = x"no" ]; then
echo "* sse3: yes *"
else
echo "* sse3: no *"
fi
if [ test x"$no_sse2" = x"no" ]; then
echo "* sse2: yes *"
else
echo "* sse2: no *"
fi
if [ test x"$no_sse" = x"no" ]; then
echo "* sse: yes *"
else
echo "* sse: no *"
fi
if [ test x"$no_mmx" = x"no" ]; then
echo "* mmx: yes *"
else
echo "* mmx: no *"
fi
if [ test x"$profiler" = x"yes" ]; then
echo "* profiler: yes *"
else
echo "* profiler: no *"
fi
if [ test x"$debuger" = x"yes" ]; then
echo "* debug: yes *"
else
echo "* debug: no *"
fi
if [ test x"$no_64" = x"no" ]; then
echo "* 64 bit: yes *"
else
echo "* 64 bit: no *"
fi
if [ test x"$gpu_support" = x"no" ]; then
echo "* gpu: no *"
else
echo "* gpu: yes *"
fi
echo "* *"
echo "***********************************"
This diff is collapsed.
/*
* dec_optimize.hpp
*
* Created on: Jan 16, 2015
* Author: i-bird
*/
#ifndef DEC_OPTIMIZE_HPP_
#define DEC_OPTIMIZE_HPP_
#include "Graph/CartesianGraphFactory.hpp"
#include "map_graph.hpp"
#include "metis_util.hpp"
#include "dec_optimizer.hpp"
#undef GS_SIZE
#define GS_SIZE 8
BOOST_AUTO_TEST_SUITE( dec_optimizer_test )
BOOST_AUTO_TEST_CASE( dec_optimizer_test_use)
{
CartesianGraphFactory<3,Graph_CSR<nm_v,nm_e>> g_factory;
CartesianGraphFactory<3,Graph_CSR<nm_part_v,nm_part_e>> g_factory_part;
// Cartesian grid
std::vector<size_t> sz;
sz.push_back(4);
sz.push_back(4);
sz.push_back(1);
// Box
Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});
// Graph to decompose
Graph_CSR<nm_v,nm_e> g = g_factory.construct<nm_e::communication,float,2,0,1,2>(sz,box);
// Processor graph
Graph_CSR<nm_part_v,nm_part_e> gp = g_factory_part.construct<NO_EDGE,float,2>(sz,box);
// Convert the graph to metis
Metis<Graph_CSR<nm_v,nm_e>> met(g,16);
// decompose
met.decompose<nm_part_v::id>(gp);
met.decompose<nm_v::id>();
// optimize
dec_optimizer<3,Graph_CSR<nm_v,nm_e>> d_o(g,sz);
grid_key_dx<3> keyZero(0,0,0);
d_o.optimize<nm_v::sub_id,nm_v::id>(keyZero,g);
// Write the VTK file
VTKWriter<Graph_CSR<nm_part_v,nm_part_e>> vtk(gp);
vtk.write("vtk_partition.vtk");
VTKWriter<Graph_CSR<nm_v,nm_e>> vtk2(g);
vtk2.write("vtk_partition2.vtk");
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* DEC_OPTIMIZE_HPP_ */
/*
* gargabe.hpp
*
* Created on: Jan 13, 2015
* Author: i-bird
*/
#ifndef GARGABE_HPP_
#define GARGABE_HPP_
template <unsigned int j, unsigned int i, typename Graph> void optimize(size_t start_p, Graph & graph)
{
// We assume that Graph is the rapresentation of a cartesian graph
// this mean that the direction d is at the child d
// Create an Hyper-cube
HyperCube<dim> hyp;
// Get the number of wavefronts
size_t n_wf = hyp.getNumberOfElements_R(0);
// Get the number of intersecting wavefront
// Get the number of sub-dimensional common wavefront
// basically are a list of all the subdomain common to two or more
// Create n_wf wavefront queue
openfpm::vector<wavefront> v_w;
v.reserve(n_wf);
// direction of expansion
size_t domain_id = 0;
int exp_dir = 0;
bool can_expand = true;
// while is possible to expand
while (can_expand)
{
// for each direction of expansion expand the wavefront
for (int d = 0 ; d < n_wf ; d++)
{
// get the wavefront at direction d
openfpm::vector<size_t> & wf_d = v_w.get<wavefront::domains>(d);
// flag to indicate if the wavefront can expand
bool w_can_expand = true;
// for each subdomain
for (size_t sub = 0 ; sub < wf_d.size() ; sub++)
{
// check if the adjacent domain in direction d exist
// and is of the same id
// get the starting subdomain
size_t sub_w = wf_d.get<0>(sub);
// we get the processor id of the neighborhood sub-domain on direction d
size_t exp_p = graph.getChild(sub_w,d).get<j>();
// we check if it is the same processor id
if (exp_p != domain_id)
{
w_can_expand = false;
}
}
// if we can expand the wavefront expand it
if (w_can_expand == true)
{
// for each subdomain
for (size_t sub = 0 ; sub < wf_d.size() ; sub++)
{
// update the position of the wavefront
wf_d.get<0>(sub) = wf_d.get<0>(sub) + gh.stride(d);
}
// here we add sub-domains to all the other queues
// get the face of the hyper-cube
SubHyperCube<dim,dim-1> sub_hyp = hyp.getSubHyperCube(d);
std::vector<comb<dim>> q_comb = sub_hyp.getCombinations_R(dim-2);
}
}
}
// For each point in the Hyper-cube check if we can move the wave front
}
#endif /* GARGABE_HPP_ */
This diff is collapsed.
#include <iostream>
#include "Graph/CartesianGraphFactory.hpp"
#define BOOST_DISABLE_ASSERTS
#define BOOST_TEST_MODULE "C++ test module for OpenFPM_pdata project"
#include <boost/test/included/unit_test.hpp>
#include <grid_dist.hpp>
#include "Point_test.hpp"
#include "Decomposition/CartDecomposition.hpp"
#include "memory/HeapMemory.hpp"
#include "Space/Shape/Box.hpp"
#include "util.hpp"
#include "hypercube_unit_test.hpp"
#include "CartesianGraphFactory_unit_test.hpp"
#include "metis_util_unit_test.hpp"
#include "dec_optimizer_unit_test.hpp"
/*
* metis_util.hpp
*
* Created on: Nov 21, 2014
* Author: Pietro Incardona
*/
#ifndef METIS_UTIL_HPP
#define METIS_UTIL_HPP
#include <iostream>
#include "metis.h"
#include "VTKWriter.hpp"
/*! \brief Metis graph structure
*
* Metis graph structure
*
*/
struct Metis_graph
{
//! The number of vertices in the graph
idx_t * nvtxs;
//! number of balancing constrains
//! more practical, are the number of weights for each vertex
//! PS even we you specify vwgt == NULL ncon must be set at leat to
//! one
idx_t * ncon;
//! For each vertex it store the adjacency lost start for the vertex i
idx_t * xadj;
//! For each vertex it store a list of all neighborhood vertex
idx_t * adjncy;
//! Array that store the weight for each vertex
idx_t * vwgt;
//! Array of the vertex size, basically is the total communication amount
idx_t * vsize;
//! The weight of the edge
idx_t * adjwgt;
//! number of part to partition the graph
idx_t * nparts;
//! Desired weight for each partition (one for each constrain)
real_t * tpwgts;
//! For each partition load imbalance tollerated
real_t * ubvec;
//! Additional option for the graph partitioning
idx_t * options;
//! return the total comunication cost for each partition
idx_t * objval;
//! Is a output vector containing the partition for each vertex
idx_t * part;
};
//! Balance communication and computation
#define BALANCE_CC 1
//! Balance communication computation and memory
#define BALANCE_CCM 2
//! Balance computation and comunication and others
#define BALANCE_CC_O(c) c+1
/*! \brief Helper class to define Metis graph
*
* \tparam graph structure that store the graph
*
*/
template<typename Graph>
class Metis
{
// Graph in metis reppresentation
Metis_graph Mg;
// Original graph
Graph & g;
/*! \brief Construct Adjacency list
*
* \param g Graph
*
*/
void constructAdjList(Graph & g)
{
// create xadj and adjlist
Mg.xadj = new idx_t[g.getNVertex()+1];
Mg.adjncy = new idx_t[g.getNEdge()];
//! Get a vertex iterator
auto it = g.getVertexIterator();
//! starting point in the adjacency list
size_t prev = 0;
// actual position
size_t id = 0;
// for each vertex calculate the position of the starting point in the adjacency list
while (it.isNext())
{
// Calculate the starting point in the adjacency list
Mg.xadj[id] = prev;
// Create the adjacency list
for (size_t s = 0 ; s < g.getNChilds(it) ; s++)
{Mg.adjncy[prev+s] = g.getChild(it,s);}
// update the position for the next vertex
prev += g.getNChilds(it);
++it;
id++;
}
// Fill the last point
Mg.xadj[id] = prev;
}
public:
/*! \brief Constructor
*
* Construct a metis graph from Graph_CSR
*
* \param g Graph we want to convert to decompose
* \param nc number of partitions
*
*/
Metis(Graph & g, size_t nc)
:g(g)
{
// Get the number of vertex
Mg.nvtxs = new idx_t[1];
Mg.nvtxs[0] = g.getNVertex();
// Set the number of constrains
Mg.ncon = new idx_t[1];
Mg.ncon[0] = 1;
// construct the adjacency list
constructAdjList(g);
// Set to null the weight of the vertex
Mg.vwgt = NULL;
// Put the total communication size to NULL
Mg.vsize = NULL;
// Set to null the weight of the edge
Mg.adjwgt = NULL;
// Set the total number of partitions
Mg.nparts = new idx_t[1];
Mg.nparts[0] = nc;
// Set to null the desired weight for each partition (one for each constrain)
Mg.tpwgts = NULL;
//! Set to null the partition load imbalance tollerace
Mg.ubvec = NULL;
//! Set tp null additional option for the graph partitioning
Mg.options = NULL;
//! set the objective value
Mg.objval = new idx_t[1];
//! Is an output vector containing the partition for each vertex
Mg.part = new idx_t[g.getNVertex()];
}
/*! \brief destructor
*
* Destructor, It destroy all the memory allocated
*
*/
~Metis()
{
// Deallocate the Mg structure
if (Mg.nvtxs != NULL)
{
delete [] Mg.nvtxs;
}
if (Mg.ncon != NULL)
{
delete [] Mg.ncon;
}
if (Mg.xadj != NULL)
{
delete [] Mg.xadj;
}
if (Mg.adjncy != NULL)
{
delete [] Mg.adjncy;
}
if (Mg.vwgt != NULL)
{
delete [] Mg.vwgt;
}
if (Mg.adjwgt != NULL)
{
delete [] Mg.adjwgt;
}
if (Mg.nparts != NULL)
{
delete [] Mg.nparts;
}
if (Mg.tpwgts != NULL)
{
delete [] Mg.tpwgts;
}
if (Mg.ubvec != NULL)
{
delete [] Mg.ubvec;
}
if (Mg.options != NULL)
{
delete [] Mg.options;
}
if (Mg.objval != NULL)
{
delete [] Mg.objval;
}
if (Mg.part != NULL)
{
delete [] Mg.part;
}
}
/*! \brief Decompose the graph
*
* \tparam i which property store the decomposition
*
*/
template<unsigned int i>
void decompose()
{
// Decompose
METIS_PartGraphKway(Mg.nvtxs,Mg.ncon,Mg.xadj,Mg.adjncy,Mg.vwgt,Mg.vsize,Mg.adjwgt,
Mg.nparts,Mg.tpwgts,Mg.ubvec,Mg.options,Mg.objval,Mg.part);
// vertex id
size_t id = 0;