当前位置: 首页>>代码示例>>C++>>正文


C++ detail::copy_to_buffer方法代码示例

本文整理汇总了C++中detail::copy_to_buffer方法的典型用法代码示例。如果您正苦于以下问题:C++ detail::copy_to_buffer方法的具体用法?C++ detail::copy_to_buffer怎么用?C++ detail::copy_to_buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在detail的用法示例。


在下文中一共展示了detail::copy_to_buffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: reduce_impl

                template<typename T, typename Op> void reduce_impl(const alps::mpi::communicator & comm, T const & in_values, Op op, int root, boost::false_type, boost::false_type) {
                    using alps::hdf5::is_vectorizable;
                    if (is_vectorizable(in_values)) {
                        using alps::hdf5::get_extent;
                        typedef typename alps::hdf5::scalar_type<T>::type scalar_type;
                        std::vector<std::size_t> extent(get_extent(in_values));
			std::vector<scalar_type> in_buffer(std::accumulate(extent.begin(), extent.end(), 1, std::multiplies<std::size_t>()));
                        using detail::copy_to_buffer;
                        copy_to_buffer(in_values, in_buffer, 0, typename hdf5::is_content_continuous<T>::type());

                        // using boost::mpi::reduce;
                        // reduce(comm, &in_buffer.front(), in_buffer.size(), op, root);

                        using alps::mpi::get_mpi_datatype;
                        MPI_Reduce(&in_buffer.front(), NULL, in_buffer.size(), get_mpi_datatype(scalar_type()), alps::mpi::is_mpi_op<Op, scalar_type>::op(), root, comm);

                    } else
                        throw std::logic_error("No alps::mpi::reduce available for this type " + std::string(typeid(T).name()) + ALPS_STACKTRACE);
                }
开发者ID:aeantipov,项目名称:ALPSCore,代码行数:19,代码来源:mpi.hpp

示例2: S

                /** @brief Copy a container value into a buffer.

                    The container value is of type T which ultimately
                    holds values of a scalar type S (T can, e.g., be a
                    container of containers of containers... of
                    S). The values are copied from `values` to
                    `buffer[offset]`.

                    @param values: container to copy from;
                    @param buffer: vector to copy to, starting from offset;
                    @param offset: position in the buffer to copy to;
                    @returns the new offset pointing right after the last used position in the buffer.
                 */
                template<typename T, typename S> std::size_t copy_to_buffer(T const & values, std::vector<S> & buffer, std::size_t offset, boost::false_type) {
                    /// FIXME!! BUG: if `T` is not vectorizable it may not have `begin()` and `end()` methods nor `const_iterator` type. This function won't be called --- but it gives compilation error! 
                    for(typename T::const_iterator it = values.begin(); it != values.end(); ++it)
                        offset = copy_to_buffer(*it, buffer, offset, typename hdf5::is_continuous<typename T::value_type>::type());
                    return offset;
                }
开发者ID:aeantipov,项目名称:ALPSCore,代码行数:19,代码来源:mpi.hpp


注:本文中的detail::copy_to_buffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。