BT

Boost 1.61 Brings New Libraries for CPU/CPU Computation, Plugin Management, and More

| by Sergio De Simone Follow 14 Followers on May 17, 2016. Estimated reading time: 2 minutes |

Five months after the introduction of version 1.60, Boost hits version 1.61, adding several new libraries and updating many more.

Boost 1.61 includes four new libraries:

  • Compute, a library providing a C++ interface to multi-core CPU and GPU computing platforms using OpenCL. OpenCL is an open standard enabling the creation of programs that run on a heterogeneous set of compute devices, such as CPUs and GPUs. The library provides classes to manage OpenCL objects such as device, kernel, and command_queues, and functions that allow developers to handle compute devices, transfer data to and from it, and iterate/transform it. This is how you could transfer data to the default compute device, transform it, and then copy it back:
        std::vector<float> host_vector(10000);
        // define host_vector content
    
        // get default device and setup context
        compute::device device = compute::system::default_device();
        compute::context context(device);
        compute::command_queue queue(context, device);
    
        // create a vector on the device
        compute::vector<float> device_vector(host_vector.size(), context);
    
        // transfer data from the host to the device
        compute::copy(
            host_vector.begin(), host_vector.end(), device_vector.begin(), queue
        );
    
        // calculate the square-root of each element in-place
        compute::transform(
            device_vector.begin(),
            device_vector.end(),
            device_vector.begin(),
            compute::sqrt<float>(),
            queue
        );
    
        // copy values back to the host
        compute::copy(
            device_vector.begin(), device_vector.end(), host_vector.begin(), queue
        );
    
  • DLL, a library aimed at enabling the development of cross-platforms, portable plugins. DLL allows developers to load libraries and import native functions and variables, query libraries for sections and symbols, etc. DLL plugins can be defined using the extern “C” and BOOST_SYMBOL_EXPORT. A client program can load a DLL plugin by executing import:
        // variable to hold a pointer to plugin variable
        boost::shared_ptr<my_plugin_api> plugin;
    
        plugin = dll::import<my_plugin_api>(
            full_path_to_library,
            name_of_symbol_to_import,
            dll::load_mode::append_decorations
        );
    
    

    DLL also supports library reference counting to better control the lifetime of a loaded plugin, callback execution on plugin unload and more.

  • Hana, a metaprogramming library that provides high level algorithms to manipulate heterogeneous sequences. In contrast to preexisting metaprogramming libraries such as Boost.MPL and Boost.Fusion, Hana unifies the manipulation of types and values. Hana provides a number of container types, such as tuple, optional, map, etc., and a collection of algorithms that work on them, such as fold, zip, flatten, etc.

  • Metaparse, a library to generate parsers that parse text or code at compile time and return a type, a constant value, a C++ function to be called at runtime, etc. Metaparse is specifically intended for embedded domain specific language creation. Metaparse enables the defintion of context free grammars using an EBNF-like syntax. The main differentiator between Metaparse and Boost.Spirit, a well-known metaprogramming library, is that the latter produces run-time parsers, while Metaparse produces compile-time parsers.

As mentioned, Boost 1.61 also updates many existing libraries, including Multiprecision, Optional, Geometry, and Fusion, among others.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT