// Compatibility function for accessing hwloc_obj_t object memory with different API versions of hwloc
std::size_t
-getHwLocObjectMemory(const hwloc_obj_t obj)
+getHwLocObjectMemory(hwloc_obj_t obj)
{
#if GMX_HWLOC_API_VERSION_IS_2XX
return obj->total_memory;
* were found, the vector will be empty.
*/
const std::vector<hwloc_obj_t>
-getHwLocDescendantsByType(const hwloc_topology_t topo, const hwloc_obj_t obj, const hwloc_obj_type_t type)
+getHwLocDescendantsByType(hwloc_topology_t topo, hwloc_obj_t obj, const hwloc_obj_type_t type)
{
GMX_RELEASE_ASSERT(obj, "NULL hwloc object provided to getHwLocDescendantsByType()");
parseHwLocSocketsCoresThreads(hwloc_topology_t topo,
HardwareTopology::Machine * machine)
{
- const hwloc_obj_t root = hwloc_get_root_obj(topo);
+ hwloc_obj_t root = hwloc_get_root_obj(topo);
std::vector<hwloc_obj_t> hwlocSockets = getHwLocDescendantsByType(topo, root, HWLOC_OBJ_PACKAGE);
machine->logicalProcessorCount = hwloc_get_nbobjs_by_type(topo, HWLOC_OBJ_PU);
}
}
-/*! \brief Read cache information from hwloc topology
+/*! \brief Fill \c machine with cache information from hwloc topology
*
* \param topo hwloc topology handle that has been initialized and loaded
* \param machine Pointer to the machine structure in the HardwareTopology
- * class, where cache data will be filled.
- *
- * \return If any cache data is found the return value is 0, otherwise non-zero.
+ * class, where cache data will be filled if found and valid.
*/
-int
+void
parseHwLocCache(hwloc_topology_t topo,
HardwareTopology::Machine * machine)
{
}
}
}
- return machine->caches.empty();
}
-/*! \brief Read numa information from hwloc topology
+/*! \brief Fill \c machine with numa information from hwloc topology
*
* \param topo hwloc topology handle that has been initialized and loaded
* \param machine Pointer to the machine structure in the HardwareTopology
* completed successfully before calling this one. If this is not the case,
* you will get an error return code.
*
- * \return If the data found makes sense (either in the numa node or the
- * entire machine) the return value is 0, otherwise non-zero.
+ * If the data found makes sense (either in the numa node or the
+ * entire machine) the numa.nodes data structure in
+ * HardwareTopology::Machine will be filled upon exit.
*/
-int
+void
parseHwLocNuma(hwloc_topology_t topo,
HardwareTopology::Machine * machine)
{
- const hwloc_obj_t root = hwloc_get_root_obj(topo);
+ hwloc_obj_t root = hwloc_get_root_obj(topo);
std::vector<hwloc_obj_t> hwlocNumaNodes = getHwLocDescendantsByType(topo, root, HWLOC_OBJ_NUMANODE);
bool topologyOk = true;
}
}
#endif // end if not GMX_HWLOC_API_VERSION_IS_2XX
- if (topologyOk)
- {
- return 0;
- }
- else
+ if (!topologyOk)
{
machine->numa.nodes.clear();
- return -1;
}
-
}
-/*! \brief Read PCI device information from hwloc topology
+/*! \brief Fill \c machine with PCI device information from hwloc topology
*
* \param topo hwloc topology handle that has been initialized and loaded
* \param machine Pointer to the machine structure in the HardwareTopology
- * class, where PCI device information will be filled.
- * *
- * \return If any devices were found the return value is 0, otherwise non-zero.
+ * class, where PCI device information will be filled if found
+ * and valid.
*/
-int
+void
parseHwLocDevices(hwloc_topology_t topo,
HardwareTopology::Machine * machine)
{
- const hwloc_obj_t root = hwloc_get_root_obj(topo);
+ hwloc_obj_t root = hwloc_get_root_obj(topo);
std::vector<hwloc_obj_t> pcidevs = getHwLocDescendantsByType(topo, root, HWLOC_OBJ_PCI_DEVICE);
for (auto &p : pcidevs)
numaId
} );
}
- return pcidevs.empty();
}
void
}
// If we get here, we can get a valid root object for the topology
- *isThisSystem = hwloc_topology_is_thissystem(topo);
+ *isThisSystem = bool(hwloc_topology_is_thissystem(topo));
// Parse basic information about sockets, cores, and hardware threads
if (parseHwLocSocketsCoresThreads(topo, machine) == 0)
}
// Get information about cache and numa nodes
- if (parseHwLocCache(topo, machine) == 0 && parseHwLocNuma(topo, machine) == 0)
+ parseHwLocCache(topo, machine);
+ parseHwLocNuma(topo, machine);
+ if (!machine->caches.empty() && !machine->numa.nodes.empty())
{
*supportLevel = HardwareTopology::SupportLevel::Full;
}
}
// PCI devices
- if (parseHwLocDevices(topo, machine) == 0)
+ parseHwLocDevices(topo, machine);
+ if (!machine->devices.empty())
{
*supportLevel = HardwareTopology::SupportLevel::FullWithDevices;
}
/* Create the root element for the subexpression */
if (!root)
{
- root.reset(new SelectionTreeElement(SEL_ROOT, location));
+ root = std::make_shared<SelectionTreeElement>(SEL_ROOT, location);
subexpr = root;
}
else
{
- subexpr->next.reset(new SelectionTreeElement(SEL_ROOT, location));
- subexpr = subexpr->next;
+ subexpr->next = std::make_shared<SelectionTreeElement>(SEL_ROOT, location);
+ subexpr = subexpr->next;
}
/* Create the subexpression element and
* move the actual subexpression under the created element. */
- subexpr->child.reset(new SelectionTreeElement(SEL_SUBEXPR, location));
+ subexpr->child = std::make_shared<SelectionTreeElement>(SEL_SUBEXPR, location);
_gmx_selelem_set_vtype(subexpr->child, child->v.type);
subexpr->child->child = child->child;
child->child = subexpr->child;
child->next.reset();
sel->cdata->evaluate(data, sel, g);
/* Replace the subexpressions with the result */
- child.reset(new SelectionTreeElement(SEL_CONST, SelectionLocation::createEmpty()));
+ child = std::make_shared<SelectionTreeElement>(SEL_CONST, SelectionLocation::createEmpty());
child->flags = SEL_FLAGSSET | SEL_SINGLEVAL | SEL_ALLOCVAL | SEL_ALLOCDATA;
_gmx_selelem_set_vtype(child, GROUP_VALUE);
child->evaluate = nullptr;
"Unknown type for keyword selection"));
}
/* Initialize the selection element */
- root.reset(new SelectionTreeElement(SEL_EXPRESSION, location));
+ root = std::make_shared<SelectionTreeElement>(SEL_EXPRESSION, location);
_gmx_selelem_set_method(root, kwmethod, scanner);
if (method->type == STR_VALUE)
{
}
else
{
- ref.reset(new SelectionTreeElement(
- SEL_SUBEXPRREF, _gmx_sel_lexer_get_current_location(scanner)));
+ ref = std::make_shared<SelectionTreeElement>(
+ SEL_SUBEXPRREF, _gmx_sel_lexer_get_current_location(scanner));
_gmx_selelem_set_vtype(ref, sel->v.type);
ref->setName(sel->name());
ref->child = sel;
{
SelectionLocation location(_gmx_sel_lexer_get_current_location(scanner));
/* Create the root element */
- root.reset(new SelectionTreeElement(SEL_ROOT, location));
+ root = std::make_shared<SelectionTreeElement>(SEL_ROOT, location);
root->setName(name);
/* Create the subexpression element */
- root->child.reset(new SelectionTreeElement(SEL_SUBEXPR, location));
+ root->child = std::make_shared<SelectionTreeElement>(SEL_SUBEXPR, location);
root->child->setName(name);
_gmx_selelem_set_vtype(root->child, expr->v.type);
root->child->child = expr;