> So, Zach and I have hit the same error when interfacing dg-swem with
> HPX+LGD, but here we weren't able to work around it via adding -O3.
> Any ideas for another workaround?
> 
> Thomas said he's suspecting a bug in HPX, but I can't really figure
> out what's going wrong.

As said, I don't understand what you're doing with that code. The
component-registry stuff is very subtle to get right and I don't see any
obvious reason you create your own.

Regards Hartmut
---------------
http://boost-spirit.com
http://stellar.cct.lsu.edu


> 
> Thanks!
> -Andreas
> 
> 
> On 23:49 Sun 15 Nov     , Andreas Schäfer wrote:
> > Heya,
> >
> > I've recently seen some of my HPX applications terminating right
> > before hpx_init() is called. Strangely the build system did seem to
> > determine whether the same code would either run flawlessly, or crash.
> >
> > Please find attached a (sort of) minimal example that reproduces the
> > error. Below is a log of me compiling the code manually. The only
> > difference here is that for the first run I did add -O3, for the
> > second run that option was omitted. Any ideas what's going on here?
> >
> > > gentryx@neuromancer ~ $ time (rm -f test_hpx &&
> /usr/lib64/ccache/bin/g++-4.9.3 -O3    -L/home/gentryx/local_install/lib -
> lhpx test_hpx.cpp   -o test_hpx -std=c++11 -
> I/home/gentryx/local_install/include -
> I/home/gentryx/local_install/include/hpx/external -lboost_chrono -
> lboost_date_time -lboost_filesystem -lboost_program_options -lboost_system
> -lboost_thread -lhpx_init -lhpx -ldl -lrt &&
> LD_LIBRARY_PATH=/home/gentryx/local_install/lib  &&
> LD_LIBRARY_PATH=/home/gentryx/local_install/lib  ./test_hpx)
> > > ok
> > >
> > > real    0m28.162s
> > > user    0m27.490s
> > > sys     0m0.630s
> > >
> > > 23:43:58 - 0
> > > gentryx@neuromancer ~ $ time (rm -f test_hpx &&
> /usr/lib64/ccache/bin/g++-4.9.3    -L/home/gentryx/local_install/lib -lhpx
> test_hpx.cpp   -o test_hpx -std=c++11 -
> I/home/gentryx/local_install/include -
> I/home/gentryx/local_install/include/hpx/external -lboost_chrono -
> lboost_date_time -lboost_filesystem -lboost_program_options -lboost_system
> -lboost_thread -lhpx_init -lhpx -ldl -lrt &&
> LD_LIBRARY_PATH=/home/gentryx/local_install/lib  &&
> LD_LIBRARY_PATH=/home/gentryx/local_install/lib  ./test_hpx)
> > > terminate called after throwing an instance of
> 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_i
> njector<hpx::exception> >'
> > >   what():  attempt to insert a GVA with an invalid type,
> gid({0000000100000001, 0000000000000001}), gva(({0000000100000000,
> 0000000000000000} component_invalid[-1] 1 0xa41640 0)),
> locality({0000000100000000, 0000000000000000}): HPX(bad_parameter)
> > >
> > > real    0m22.700s
> > > user    0m21.910s
> > > sys     0m0.740s
> > >
> > > 23:44:41 - 134
> >
> > Thanks!
> > -Andreas
> >
> >
> > --
> > ==========================================================
> > Andreas Schäfer
> > HPC and Grid Computing
> > Department of Computer Science 3
> > Friedrich-Alexander-Universität Erlangen-Nürnberg, Germany
> > +49 9131 85-27910
> > PGP/GPG key via keyserver
> > http://www.libgeodecomp.org
> > ==========================================================
> >
> > (\___/)
> > (+'.'+)
> > (")_(")
> > This is Bunny. Copy and paste Bunny into your
> > signature to help him gain world domination!
> 
> > #include <iostream>
> > #include <hpx/hpx.hpp>
> >
> > #include <hpx/include/components.hpp>
> > #include <hpx/lcos/broadcast.hpp>
> > #include <hpx/lcos/local/receive_buffer.hpp>
> > #include <hpx/runtime/get_ptr.hpp>
> >
> > namespace {
> > template<typename COMPONENT>
> > class hpx_plugin_exporter_factory;
> >
> > template<typename COMPONENT>
> > class init_registry_factory_static;
> >
> > template<typename T>
> > class hpx_plugin_exporter_registry;
> >
> > }
> >
> > namespace LibGeoDecomp {
> >
> > /**
> >  * Instantiate this template to ensure the instantiation of an HPX
> >  * component template is actually registered. See HPXReceiver for an
> >  * example on how to use this class and its assorted macros.
> >  */
> > template<typename COMPONENT>
> > class HPXComponentRegistrator
> > {
> > public:
> >     virtual ~HPXComponentRegistrator()
> >     {}
> >
> >     static
> hpx::components::component_factory<hpx::components::simple_component<COMPO
> NENT> > *instanceA;
> >     static hpx::components::component_registry<
> hpx::components::simple_component<COMPONENT>,
> ::hpx::components::factory_check> *instanceB;
> >
> >     virtual
> hpx::components::component_factory<hpx::components::simple_component<COMPO
> NENT> > *foo1()
> >     {
> >         instanceA = new
> hpx::components::component_factory<hpx::components::simple_component<COMPO
> NENT> >(0, 0, false);
> >         return instanceA;
> >     }
> >
> >     virtual hpx::components::component_registry<
> hpx::components::simple_component<COMPONENT>,
> ::hpx::components::factory_check> *foo2()
> >     {
> >         instanceB = new hpx::components::component_registry<
> hpx::components::simple_component<COMPONENT>,
> ::hpx::components::factory_check>();
> >         return instanceB;
> >     }
> > };
> >
> > template<typename COMPONENT>
> >
> hpx::components::component_factory<hpx::components::simple_component<COMPO
> NENT> > *HPXComponentRegistrator<COMPONENT>::instanceA;
> >
> > template<typename COMPONENT>
> > hpx::components::component_registry<
> hpx::components::simple_component<COMPONENT>,
> ::hpx::components::factory_check>
> *HPXComponentRegistrator<COMPONENT>::instanceB;
> >
> > }
> >
> > // fixme: lacks deletion of parentheses
> > #define LIBGEODECOMP_REGISTER_HPX_COMPONENT_TEMPLATE(PARAMS, TEMPLATE)
> \
> >     extern "C" __attribute__((visibility ("default")))
> \
> >     std::map<std::string, boost::any> *
> hpx_exported_plugins_list_hpx_factory(); \
> >
> \
> >     namespace {
> \
> >
> \
> >     template<typename COMPONENT>
> \
> >     class hpx_plugin_exporter_factory;
> \
> >
> \
> >     template<PARAMS>
> \
> >     class hpx_plugin_exporter_factory<TEMPLATE > \
> >     {
> \
> >     public:
> \
> >         hpx_plugin_exporter_factory()
> \
> >         {
> \
> >             static hpx::util::plugin::concrete_factory<
> hpx::components::component_factory_base,
> hpx::components::component_factory<hpx::components::simple_component<TEMPL
> ATE>> > cf; \
> >
> hpx::util::plugin::abstract_factory<hpx::components::component_factory_bas
> e>* w = &cf; \
> >
> \
> >             std::string
> actname(typeid(hpx::components::simple_component<TEMPLATE>).name()); \
> >             boost::algorithm::to_lower(actname);
> \
> >             hpx_exported_plugins_list_hpx_factory()->insert(
> std::make_pair(actname, w)); \
> >         }
> \
> >
> \
> >         static hpx_plugin_exporter_factory instance;
> \
> >     };
> \
> >
> \
> >     template<PARAMS>
> \
> >     hpx_plugin_exporter_factory<TEMPLATE>
> hpx_plugin_exporter_factory<TEMPLATE>::instance; \
> >
> \
> >     }
> \
> >
> \
> >     extern "C" __attribute__((visibility ("default")))
> \
> >     std::map<std::string, boost::any>*
> hpx_exported_plugins_list_hpx_factory(); \
> >
> \
> >     namespace {
> \
> >
> \
> >     template<typename COMPONENT>
> \
> >     class init_registry_factory_static;
> \
> >
> \
> >     template<PARAMS>
> \
> >     class init_registry_factory_static<TEMPLATE >
> \
> >     {
> \
> >     public:
> \
> >         init_registry_factory_static<TEMPLATE>()
> \
> >         {
> \
> >             hpx::components::static_factory_load_data_type data = {
> typeid(hpx::components::simple_component<TEMPLATE>).name(),
> hpx_exported_plugins_list_hpx_factory }; \
> >             hpx::components::init_registry_factory(data);
> \
> >         }
> \
> >
> \
> >         static init_registry_factory_static<TEMPLATE> instance;
> \
> >     };
> \
> >
> \
> >     template<PARAMS>
> \
> >     init_registry_factory_static<TEMPLATE>
> init_registry_factory_static<TEMPLATE>::instance; \
> >
> \
> >     }
> \
> >
> \
> >     namespace hpx {
> \
> >     namespace components {
> \
> >
> \
> >     template <PARAMS> struct
> unique_component_name<hpx::components::component_factory<hpx::components::
> simple_component<TEMPLATE > > > \
> >     {
> \
> >         typedef char const* type;
> \
> >
> \
> >         static type call(void)
> \
> >         {
> \
> >             return typeid(hpx::components::simple_component<TEMPLATE
> >).name(); \
> >         }
> \
> >     };
> \
> >
> \
> >     }
> \
> >     }
> \
> >
> \
> >     extern "C" __attribute__((visibility ("default")))
> \
> >     std::map<std::string, boost::any> *
> hpx_exported_plugins_list_hpx_registry(); \
> >
> \
> >     namespace {
> \
> >
> \
> >     template<typename T>
> \
> >     class hpx_plugin_exporter_registry;
> \
> >
> \
> >     template<PARAMS>
> \
> >     class hpx_plugin_exporter_registry<TEMPLATE> \
> >     {
> \
> >     public:
> \
> >         hpx_plugin_exporter_registry()
> \
> >         {
> \
> >             static hpx::util::plugin::concrete_factory<
> hpx::components::component_registry_base,
> hpx::components::component_registry<hpx::components::simple_component<TEMP
> LATE>, ::hpx::components::factory_check> > cf; \
> >
> hpx::util::plugin::abstract_factory<hpx::components::component_registry_ba
> se>* w = &cf; \
> >             std::string
> actname(typeid(hpx::components::simple_component<TEMPLATE>).name()); \
> >             boost::algorithm::to_lower(actname);
> \
> >             hpx_exported_plugins_list_hpx_registry()->insert(
> std::make_pair(actname, w)); \
> >         }
> \
> >
> \
> >         static hpx_plugin_exporter_registry instance;
> \
> >     };
> \
> >
> \
> >     template<PARAMS>
> \
> >     hpx_plugin_exporter_registry<TEMPLATE>
> hpx_plugin_exporter_registry<TEMPLATE>::instance; \
> >
> \
> >     }
> \
> >
> \
> >     namespace hpx {
> \
> >     namespace components {
> \
> >
> \
> >     template <PARAMS>
> \
> >     struct
> unique_component_name<hpx::components::component_registry<hpx::components:
> :simple_component<TEMPLATE >, ::hpx::components::factory_check> > \
> >     {
> \
> >         typedef char const* type;
> \
> >         static type call (void)
> \
> >         {
> \
> >             return typeid(hpx::components::simple_component<TEMPLATE
> >).name(); \
> >         }
> \
> >     };
> \
> >
> \
> >     }
> \
> >     }
> \
> >
> \
> >     namespace hpx {
> \
> >     namespace traits {
> \
> >
> \
> >     template<PARAMS, typename ENABLE>
> \
> >     __attribute__((visibility("default")))
> \
> >     components::component_type component_type_database<CARGO,
> ENABLE>::get() \
> >     {
> \
> >         return value;
> \
> >     }
> \
> >
> \
> >     template<PARAMS, typename ENABLE>
> \
> >     __attribute__((visibility("default")))
> \
> >     void component_type_database<CARGO, ENABLE>::set(
> components::component_type t) \
> >     {
> \
> >         value = t;
> \
> >     }
> \
> >
> \
> >     }
> \
> >     };
> >
> > #define
> LIBGEODECOMP_REGISTER_HPX_COMPONENT_TEMPLATE_INSTANTIATIONS(TYPENAME) \
> >     virtual hpx_plugin_exporter_factory<TYPENAME>
> hpx_plugin_exporter_factory_registration() \
> >     {
> \
> >         return hpx_plugin_exporter_factory<TYPENAME>::instance;
> \
> >     }
> \
> >
> \
> >     virtual init_registry_factory_static<TYPENAME>
> hpx_init_registry_factory_static_registration() \
> >     {
> \
> >         return init_registry_factory_static<TYPENAME>::instance;
> \
> >     }
> \
> >
> \
> >     virtual hpx_plugin_exporter_registry<TYPENAME>
> hpx_plugin_exporter_registry_registration() \
> >     {
> \
> >         return hpx_plugin_exporter_registry<TYPENAME>::instance;
> \
> >     }
> >
> > namespace LibGeoDecomp {
> >
> > template <typename CARGO, typename
> BUFFER=hpx::lcos::local::receive_buffer<CARGO> >
> > class DummyHPXReceiver : public
> hpx::components::simple_component_base<DummyHPXReceiver<CARGO> >
> > {
> > public:
> >     typedef CARGO Cargo;
> >     typedef BUFFER Buffer;
> >
> >     static hpx::future<boost::shared_ptr<DummyHPXReceiver> > make(const
> std::string& name, std::size_t rank = 0)
> >     {
> >         HPXComponentRegistrator<DummyHPXReceiver>
> thisEnsuresHPXRegistrationCodeIsRunPriorToComponentCreation;
> >
> >         hpx::id_type id =
> hpx::new_<DummyHPXReceiver>(hpx::find_here()).get();
> >         hpx::register_with_basename(name, id, rank).get();
> >         return hpx::get_ptr<DummyHPXReceiver>(id);
> >     }
> >
> >     static hpx::future<hpx::id_type> find(const std::string& name)
> >     {
> >         std::vector<hpx::future<hpx::id_type> > ids =
> hpx::find_all_from_basename(name, 1);
> >         if (ids.size() != 1) {
> >             throw std::logic_error("Unexpected amount of
> DummyHPXReceivers found in AGAS, expected exactly 1");
> >         }
> >
> >         return std::move(ids[0]);
> >     }
> >
> >     static std::vector<hpx::future<hpx::id_type> > find_all(const
> std::string& name, std::size_t num)
> >     {
> >         std::vector<hpx::future<hpx::id_type> > ids =
> hpx::find_all_from_basename(name, num);
> >         if (ids.size() != num) {
> >             throw std::logic_error("Unexpected amount of
> DummyHPXReceivers found in AGAS, exected exactly ");
> >         }
> >
> >         return ids;
> >     }
> >
> >     static std::vector<CARGO> allGather(
> >         const CARGO& data,
> >         std::size_t rank,
> >         std::size_t size,
> >         const std::string& name)
> >     {
> >         auto receiver = DummyHPXReceiver<CARGO>::make(name, rank).get();
> >         std::vector<hpx::future<hpx::id_type> > futures =
> DummyHPXReceiver<CARGO>::find_all(name, size);
> >         std::vector<hpx::id_type> ids =
> hpx::util::unwrapped(std::move(futures));
> >         std::vector<CARGO> vec;
> >         vec.reserve(size);
> >
> >         hpx::future<void> future = hpx::lcos::broadcast<typename
> DummyHPXReceiver::receiveAction>(ids, rank, data);
> >         future.wait();
> >
> >         for (std::size_t i = 0; i < size; ++i) {
> >             vec << receiver->get(i).get();
> >         }
> >
> >         return std::move(vec);
> >     }
> >
> >     virtual ~DummyHPXReceiver()
> >     {}
> >
> >     void receive(std::size_t step, Cargo&& val)
> >     {
> >         buffer.store_received(step, std::forward<Cargo>(val));
> >     }
> >     HPX_DEFINE_COMPONENT_ACTION(DummyHPXReceiver, receive,
> receiveAction);
> >
> >     hpx::future<Cargo> get(std::size_t step)
> >     {
> >         return buffer.receive(step);
> >     }
> >
> > private:
> >     Buffer buffer;
> >
> >
> LIBGEODECOMP_REGISTER_HPX_COMPONENT_TEMPLATE_INSTANTIATIONS(DummyHPXReceiv
> er);
> > };
> >
> > }
> >
> > LIBGEODECOMP_REGISTER_HPX_COMPONENT_TEMPLATE(typename CARGO,
> LibGeoDecomp::DummyHPXReceiver<CARGO>)
> >
> > using namespace LibGeoDecomp;
> >
> > int hpx_main(int argc, char **argv)
> > {
> >     std::cout << "ok\n";
> >     std::string name = "foo";
> >     int rank = 0;
> >     int size = 1;
> >
> >     auto receiver = DummyHPXReceiver<int>::make(name, rank).get();
> >         std::vector<hpx::future<hpx::id_type> > futures =
> DummyHPXReceiver<int>::find_all(name, size);
> >         std::vector<hpx::id_type> ids =
> hpx::util::unwrapped(std::move(futures));
> >         std::vector<int> vec;
> >         vec.reserve(size);
> >
> >         hpx::future<void> future =
> hpx::lcos::broadcast<DummyHPXReceiver<int>::receiveAction>(ids, rank,
> rank);
> >
> >         // CoordBox<2> ownBoundingBox;
> >     // std::string broadcastName = "foobar";
> >     // HPXReceiver<CoordBox<2> >::allGather(ownBoundingBox, rank, size,
> broadcastName);
> >
> >     return hpx::finalize();
> > }
> >
> > int main(int argc, char **argv)
> > {
> >     std::vector<std::string> config(1, "hpx.run_hpx_main!=1");
> >     return hpx::init(argc, argv, config);
> >
> > }
> 
> 
> --
> ==========================================================
> Andreas Schäfer
> HPC and Grid Computing
> Department of Computer Science 3
> Friedrich-Alexander-Universität Erlangen-Nürnberg, Germany
> +49 9131 85-27910
> PGP/GPG key via keyserver
> http://www.libgeodecomp.org
> ==========================================================
> 
> (\___/)
> (+'.'+)
> (")_(")
> This is Bunny. Copy and paste Bunny into your
> signature to help him gain world domination!

_______________________________________________
hpx-users mailing list
[email protected]
https://mail.cct.lsu.edu/mailman/listinfo/hpx-users

Reply via email to