Пример #1
0
    mask_type decode_mapping0_unknown(hwloc_topology const& t,
        mapping_type& m, std::size_t size, mask_type mask,
        std::size_t core_base_index, std::size_t thread_index, error_code& ec)
    {
        switch (m[1].type_) {
        case spec_type::core:
            mask = decode_mapping_core(t, m, size, mask, core_base_index,
                thread_index, ec);
            break;

        case spec_type::unknown:
            {
                std::size_t base_index = 0;
                for (std::size_t i = 0; i != core_base_index; ++i)
                    base_index += t.get_number_of_core_pus(i);

                mask = decode_mapping1_unknown(t, m, size, mask, base_index,
                    thread_index, ec);
            }
            break;

        default:
            HPX_THROWS_IF(ec, bad_parameter, "decode_mapping0_unknown",
                boost::str(boost::format("unexpected specification type at "
                    "index one: %x (%s)") %
                        static_cast<unsigned>(m[1].type_) %
                        spec_type::type_name(m[1].type_)));
            break;
        }
        return mask;
    }
Пример #2
0
    mask_type decode_mapping_core(hwloc_topology const& t,
        mapping_type& m, std::size_t size, mask_type mask,
        std::size_t core_base_index, std::size_t thread_index, error_code& ec)
    {
        bounds_type b = extract_bounds(m[1], size, ec);
        if (ec) return 0;

        // We have to account for the thread index at this level if there are
        // no specifications related to processing units.
        std::size_t index = std::size_t(-1);
        if (m[2].type_ == spec_type::unknown && b.size() > 1)
            index = thread_index;

        mask_type core_mask = 0;
        std::size_t core_index = 0;
        for (bounds_type::const_iterator it = b.begin(); it != b.end(); ++it, ++core_index)
        {
            if (index == std::size_t(-1) || core_index == index)
            {
                core_mask |= t.init_core_affinity_mask_from_core(
                    *it+core_base_index, 0);
            }
        }

        core_base_index += *b.begin();
        if (thread_index != std::size_t(-1) && b.size() > 1)
            core_base_index += thread_index;

        std::size_t base_index = 0;
        for (std::size_t i = 0; i != core_base_index; ++i)
            base_index += t.get_number_of_core_pus(i);

        return decode_mapping1_unknown(t, m, size, mask & core_mask,
            base_index, thread_index, ec);
    }