mirror of
https://github.com/mmueller41/mxtasking.git
synced 2026-01-21 12:42:57 +01:00
Allow core sets to be built from a bitset.
This commit is contained in:
@@ -43,6 +43,21 @@ core_set core_set::build(std::uint16_t cores, const Order order)
|
||||
return core_set;
|
||||
}
|
||||
|
||||
core_set core_set::build(std::uint64_t *core_mask, std::uint16_t count)
|
||||
{
|
||||
core_set core_set;
|
||||
for (int c = 0; c < count; ++count)
|
||||
{
|
||||
std::bitset<tasking::config::max_cores()> mask{core_mask[c]};
|
||||
long core = 0;
|
||||
|
||||
while ((core = util::bit_scan_forward(mask.to_ulong())) != -1) {
|
||||
mask.reset(core);
|
||||
core_set.emplace_back(core);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace mx::util {
|
||||
std::ostream &operator<<(std::ostream &stream, const core_set &core_set)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <mx/system/topology.h>
|
||||
#include <mx/tasking/config.h>
|
||||
#include <ostream>
|
||||
#include <mx/util/bits.h>
|
||||
|
||||
namespace mx::util {
|
||||
/**
|
||||
@@ -91,6 +92,8 @@ public:
|
||||
*/
|
||||
static core_set build(std::uint16_t cores, Order order = Ascending);
|
||||
|
||||
static core_set build(std::uint64_t *core_mask, std::uint16_t count);
|
||||
|
||||
bool operator==(const core_set &other) const noexcept
|
||||
{
|
||||
return _core_identifier == other._core_identifier && _size == other._size && _numa_nodes == other._numa_nodes;
|
||||
|
||||
Reference in New Issue
Block a user