Skip to content

Commit

Permalink
Merge pull request #298 from garlick/boost_cleanup
Browse files Browse the repository at this point in the history
solve portability issues for Ubuntu 16.04.4 LTS
  • Loading branch information
dongahn authored Mar 30, 2018
2 parents 92fc364 + 6856990 commit 027a522
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 88 deletions.
7 changes: 2 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ AX_FLUX_CORE
AX_BOOST_BASE([1.53.0], [], [AC_MSG_ERROR([Please install boost >= 1.53)])])
AX_BOOST_SYSTEM
AX_BOOST_FILESYSTEM
AC_CHECK_LIB([boost_graph], [exit],
[AC_SUBST([BOOST_GRAPH_LIB], ["-lboost_graph"])
AC_DEFINE([HAVE_BOOST_GRRAPH], [1],
[Define if you have boost_graph])],
[AC_MSG_ERROR([Please install Boost Graph library])])
AX_BOOST_GRAPH
AX_BOOST_REGEX
PKG_CHECK_MODULES([JOBSPEC], [flux-jobspec], [], [])
AC_CHECK_LIB([readline], [readline],
[AC_SUBST([READLINE_LIBS], ["-lreadline"])
Expand Down
2 changes: 1 addition & 1 deletion m4/ax_boost_graph.m4
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ AC_DEFUN([AX_BOOST_GRAPH],
AC_DEFINE(HAVE_BOOST_GRAPH,,[define if the Boost::Graph library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
if test "x$ax_boost_user_graph_lib" = "x"; then
for libextension in `ls -r $BOOSTLIBDIR/libboost_graph* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
for libextension in `ls -r $BOOSTLIBDIR/libboost_graph.* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_GRAPH_LIB="-l$ax_lib"; AC_SUBST(BOOST_GRAPH_LIB) link_graph="yes"; break],
Expand Down
111 changes: 111 additions & 0 deletions m4/ax_boost_regex.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_boost_regex.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_REGEX
#
# DESCRIPTION
#
# Test for Regex library from the Boost C++ libraries. The macro requires
# a preceding call to AX_BOOST_BASE. Further documentation is available at
# <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_REGEX_LIB)
#
# And sets:
#
# HAVE_BOOST_REGEX
#
# LICENSE
#
# Copyright (c) 2008 Thomas Porschberg <[email protected]>
# Copyright (c) 2008 Michael Tindal
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 23

AC_DEFUN([AX_BOOST_REGEX],
[
AC_ARG_WITH([boost-regex],
AS_HELP_STRING([--with-boost-regex@<:@=special-lib@:>@],
[use the Regex library from boost - it is possible to specify a certain library for the linker
e.g. --with-boost-regex=boost_regex-gcc-mt-d-1_33_1 ]),
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ax_boost_user_regex_lib=""
else
want_boost="yes"
ax_boost_user_regex_lib="$withval"
fi
],
[want_boost="yes"]
)
if test "x$want_boost" = "xyes"; then
AC_REQUIRE([AC_PROG_CC])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_CACHE_CHECK(whether the Boost::Regex library is available,
ax_cv_boost_regex,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/regex.hpp>
]],
[[boost::regex r(); return 0;]])],
ax_cv_boost_regex=yes, ax_cv_boost_regex=no)
AC_LANG_POP([C++])
])
if test "x$ax_cv_boost_regex" = "xyes"; then
AC_DEFINE(HAVE_BOOST_REGEX,,[define if the Boost::Regex library is available])
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
if test "x$ax_boost_user_regex_lib" = "x"; then
for libextension in `ls $BOOSTLIBDIR/libboost_regex*.so* $BOOSTLIBDIR/libboost_regex*.dylib* $BOOSTLIBDIR/libboost_regex*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_regex.*\)\.so.*$;\1;' -e 's;^lib\(boost_regex.*\)\.dylib.*;\1;' -e 's;^lib\(boost_regex.*\)\.a.*$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
[link_regex="no"])
done
if test "x$link_regex" != "xyes"; then
for libextension in `ls $BOOSTLIBDIR/boost_regex*.dll* $BOOSTLIBDIR/boost_regex*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_regex.*\)\.dll.*$;\1;' -e 's;^\(boost_regex.*\)\.a.*$;\1;'` ; do
ax_lib=${libextension}
AC_CHECK_LIB($ax_lib, exit,
[BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
[link_regex="no"])
done
fi
else
for ax_lib in $ax_boost_user_regex_lib boost_regex-$ax_boost_user_regex_lib; do
AC_CHECK_LIB($ax_lib, main,
[BOOST_REGEX_LIB="-l$ax_lib"; AC_SUBST(BOOST_REGEX_LIB) link_regex="yes"; break],
[link_regex="no"])
done
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the Boost::Regex library!)
fi
if test "x$link_regex" != "xyes"; then
AC_MSG_ERROR(Could not link against $ax_lib !)
fi
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])
16 changes: 12 additions & 4 deletions resource/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
AM_CXXFLAGS = \
$(WARNING_CXXFLAGS) \
-Wno-unused-local-typedefs \
-Wno-deprecated-declarations \
-Wno-unused-variable \
-Wno-error \
$(CODE_COVERAGE_CXXFLAGS)

AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS) \
$(BOOST_LDFLAGS)

AM_CPPFLAGS = -I$(top_srcdir) $(CZMQ_CFLAGS) $(FLUX_CORE_CFLAGS)
AM_CPPFLAGS = -I$(top_srcdir) $(CZMQ_CFLAGS) $(FLUX_CORE_CFLAGS) \
$(BOOST_CPPFLAGS)

SUBDIRS = planner .

Expand All @@ -25,7 +31,8 @@ utilities_grug2dot_CXXFLAGS = \
utilities_grug2dot_LDADD = \
$(BOOST_SYSTEM_LIB) \
$(BOOST_FILESYSTEM_LIB) \
$(BOOST_GRAPH_LIB)
$(BOOST_GRAPH_LIB) \
$(BOOST_REGEX_LIB)

#.
# resource-query
Expand Down Expand Up @@ -59,5 +66,6 @@ utilities_resource_query_LDADD = \
$(READLINE_LIBS) \
$(BOOST_SYSTEM_LIB) \
$(BOOST_FILESYSTEM_LIB) \
$(BOOST_GRAPH_LIB)
$(BOOST_GRAPH_LIB) \
$(BOOST_REGEX_LIB)

6 changes: 2 additions & 4 deletions resource/dfu_match_id_based.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ class greater_interval_first_t : public dfu_match_cb_t
const std::vector<Flux::Jobspec::Resource> &resources,
const f_resource_graph_t &g, scoring_api_t &dfu)
{
using namespace boost;
using namespace boost::icl;
int score = MATCH_MET;
fold::interval_greater comp;
Expand All @@ -230,7 +229,7 @@ class greater_interval_first_t : public dfu_match_cb_t
break;
}
dfu.transform (subsystem, type,
icl::inserter (comp.ivset, comp.ivset.end ()),
boost::icl::inserter (comp.ivset, comp.ivset.end ()),
fold::to_interval);
dfu.choose_accum_best_k (subsystem, type, count, comp);
}
Expand All @@ -242,7 +241,6 @@ class greater_interval_first_t : public dfu_match_cb_t
const std::vector<Flux::Jobspec::Resource> &resources,
const f_resource_graph_t &g, scoring_api_t &dfu)
{
using namespace boost;
using namespace boost::icl;
int score = MATCH_MET;
int64_t overall;
Expand All @@ -261,7 +259,7 @@ class greater_interval_first_t : public dfu_match_cb_t
break;
}
dfu.transform (subsystem, c_type,
icl::inserter (comp.ivset, comp.ivset.end ()),
boost::icl::inserter (comp.ivset, comp.ivset.end ()),
fold::to_interval);
dfu.choose_accum_best_k (subsystem, c_type, count, comp);
}
Expand Down
11 changes: 5 additions & 6 deletions resource/resource_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ extern "C" {
}

using namespace std;
using namespace boost;
using namespace Flux::resource_model;

/*! Note that this class must be copy-constructible
* required by the concept of the depth first search
* visitor. It must be lightweight.
*/
class dfs_emitter_t : public default_dfs_visitor {
class dfs_emitter_t : public boost::default_dfs_visitor {
public:
dfs_emitter_t ();
dfs_emitter_t (resource_graph_db_t *db_p, resource_gen_spec_t *g);
Expand Down Expand Up @@ -184,7 +183,7 @@ vtx_t dfs_emitter_t::emit_vertex (ggv_t u, gge_t e, const gg_t &recipe,
vtx_t src_v, int i, int sz, int j)
{
resource_graph_db_t &db = *m_db_p;
if (src_v == graph_traits<resource_graph_t>::null_vertex())
if (src_v == boost::graph_traits<resource_graph_t>::null_vertex())
if (db.roots.find (recipe[u].subsystem) != db.roots.end ())
return db.roots[recipe[u].subsystem];

Expand All @@ -193,7 +192,7 @@ vtx_t dfs_emitter_t::emit_vertex (ggv_t u, gge_t e, const gg_t &recipe,
string ssys = recipe[u].subsystem;
int id = 0;

if (src_v == graph_traits<resource_graph_t>::null_vertex()) {
if (src_v == boost::graph_traits<resource_graph_t>::null_vertex()) {
// ROOT!!
db.roots[recipe[u].subsystem] = v;
id = 0;
Expand Down Expand Up @@ -290,7 +289,7 @@ void dfs_emitter_t::tree_edge (gge_t e, const gg_t &recipe)
if (recipe[src_ggv].root) {
//! ROOT
if (m_gen_src_vtx[src_ggv].empty ()) {
vtx_t null_v = graph_traits<resource_graph_t>::null_vertex();
vtx_t null_v = boost::graph_traits<resource_graph_t>::null_vertex();
m_gen_src_vtx[src_ggv].push_back (emit_vertex (src_ggv, e, recipe,
null_v, 0, 1, 0));
}
Expand Down Expand Up @@ -453,7 +452,7 @@ int resource_generator_t::read_graphml (const string &fn, resource_graph_db_t &d
// with emitter visitor.
//
dfs_emitter_t emitter (&db, &m_gspec);
depth_first_search (m_gspec.gen_graph (), visitor (emitter));
depth_first_search (m_gspec.gen_graph (), boost::visitor (emitter));
m_err_msg += emitter.err_message ();

return (m_err_msg == "")? rc : -1;
Expand Down
7 changes: 3 additions & 4 deletions resource/resource_gen_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ extern "C" {
}

using namespace std;
using namespace boost;
using namespace Flux::resource_model;

struct str2enum_t
Expand Down Expand Up @@ -87,7 +86,7 @@ class gg_label_writer_sim_t {
* *
********************************************************************************/

void resource_gen_spec_t::setup_dynamic_property (dynamic_properties &dp, gg_t &g)
void resource_gen_spec_t::setup_dynamic_property (boost::dynamic_properties &dp, gg_t &g)
{
dp.property("root", get(&resource_pool_gen_t::root, g));
dp.property("type", get(&resource_pool_gen_t::type, g));
Expand Down Expand Up @@ -159,7 +158,7 @@ int resource_gen_spec_t::read_graphml (const string &ifn)

try {
boost::read_graphml (in_file, g, dp);
} catch (graph_exception &e) {
} catch (boost::graph_exception &e) {
cerr << e.what () << endl;
rc = -1;
}
Expand Down Expand Up @@ -199,7 +198,7 @@ int resource_gen_spec_t::write_graphviz (const string &ofn, bool simple)
gg_label_writer_sim_t<edg_relation_map_t> ewr (e_rel_map);
boost::write_graphviz (out_file, g, vwr, ewr);
}
} catch (graph_exception &e) {
} catch (boost::graph_exception &e) {
cerr << e.what () << endl;
rc = -1;
}
Expand Down
40 changes: 19 additions & 21 deletions resource/resource_gen_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
namespace Flux {
namespace resource_model {

using namespace boost;

enum gen_meth_t {
MULTIPLY,
ASSOCIATE_IN,
Expand Down Expand Up @@ -66,30 +64,30 @@ struct relation_gen_t {
int as_src_uplvl;
};

typedef adjacency_list<
vecS,
vecS,
directedS,
typedef boost::adjacency_list<
boost::vecS,
boost::vecS,
boost::directedS,
resource_pool_gen_t,
relation_gen_t
> gg_t;

typedef std::string resource_pool_gen_t::* pgen_t;
typedef std::string relation_gen_t::* rgen_t;
typedef graph_traits<gg_t>::vertex_descriptor ggv_t;
typedef graph_traits<gg_t>::edge_descriptor gge_t;
typedef boost::graph_traits<gg_t>::vertex_descriptor ggv_t;
typedef boost::graph_traits<gg_t>::edge_descriptor gge_t;

typedef property_map<gg_t, pgen_t>::type vtx_type_map_t;
typedef property_map<gg_t, pgen_t>::type vtx_basename_map_t;
typedef property_map<gg_t, long resource_pool_gen_t::* >::type vtx_size_map_t;
typedef property_map<gg_t, pgen_t>::type vtx_unit_map_t;
typedef property_map<gg_t, pgen_t>::type vtx_subsystem_map_t;
typedef property_map<gg_t, rgen_t>::type edg_e_subsystem_map_t;
typedef property_map<gg_t, rgen_t>::type edg_relation_map_t;
typedef property_map<gg_t, rgen_t>::type edg_rrelation_map_t;
typedef property_map<gg_t, rgen_t>::type edg_gen_method_map_t;
typedef property_map<gg_t, rgen_t>::type edg_id_method_map_t;
typedef property_map<gg_t, int relation_gen_t::* >::type edg_multi_scale_map_t;
typedef boost::property_map<gg_t, pgen_t>::type vtx_type_map_t;
typedef boost::property_map<gg_t, pgen_t>::type vtx_basename_map_t;
typedef boost::property_map<gg_t, long resource_pool_gen_t::* >::type vtx_size_map_t;
typedef boost::property_map<gg_t, pgen_t>::type vtx_unit_map_t;
typedef boost::property_map<gg_t, pgen_t>::type vtx_subsystem_map_t;
typedef boost::property_map<gg_t, rgen_t>::type edg_e_subsystem_map_t;
typedef boost::property_map<gg_t, rgen_t>::type edg_relation_map_t;
typedef boost::property_map<gg_t, rgen_t>::type edg_rrelation_map_t;
typedef boost::property_map<gg_t, rgen_t>::type edg_gen_method_map_t;
typedef boost::property_map<gg_t, rgen_t>::type edg_id_method_map_t;
typedef boost::property_map<gg_t, int relation_gen_t::* >::type edg_multi_scale_map_t;

class resource_gen_spec_t {
public:
Expand All @@ -101,9 +99,9 @@ class resource_gen_spec_t {
int write_graphviz (const std::string &ofn, bool simple=false);

private:
void setup_dynamic_property (dynamic_properties &dp, gg_t &g);
void setup_dynamic_property (boost::dynamic_properties &dp, gg_t &g);
gg_t g;
dynamic_properties dp;
boost::dynamic_properties dp;
};

} // namespace resource_model
Expand Down
Loading

0 comments on commit 027a522

Please sign in to comment.