|
30 | 30 | #include <inttypes.h> |
31 | 31 | #include <sys/types.h> |
32 | 32 | #include <sys/wait.h> |
| 33 | +#include <string> |
| 34 | +#include <charconv> |
33 | 35 |
|
34 | 36 | #include "DataBlock.h" |
35 | 37 | #include "DataBlockContainer.h" |
@@ -969,6 +971,33 @@ int Readout::configure(const boost::property_tree::ptree& properties) |
969 | 971 | cfgEquipmentType = cfg.getValue<std::string>(kName + ".equipmentType"); |
970 | 972 | theLog.log(LogInfoDevel, "Configuring equipment %s: %s", kName.c_str(), cfgEquipmentType.c_str()); |
971 | 973 |
|
| 974 | + #ifdef WITH_NUMA |
| 975 | + // configuration parameter: | equipment-* | numaNode | string | auto | If set, memory / thread will try to use given NUMA node. If "auto", will try to guess it for given equipment (eg ROC). | |
| 976 | + std::string cfgNumaNode = "auto"; |
| 977 | + cfg.getOptionalValue<std::string>(kName + ".numaNode", cfgNumaNode); |
| 978 | + int numaNode = -1; |
| 979 | + if (cfgNumaNode == "auto") { |
| 980 | + // equipment-specific method to get preferred NUMA node can not be implemented in a derived class method |
| 981 | + // because we need info here in the equipment base class before allocating the memory |
| 982 | + // call corresponding external function |
| 983 | + extern int getPreferredROCNumaNode(ConfigFile&, std::string); |
| 984 | + if (!cfgEquipmentType.compare("rorc")) { |
| 985 | + numaNode = getPreferredROCNumaNode(cfg, kName); |
| 986 | + } |
| 987 | + } else { |
| 988 | + // try to convert value to int |
| 989 | + int n; |
| 990 | + auto [ptr, ec] = std::from_chars(cfgNumaNode.data(), cfgNumaNode.data() + cfgNumaNode.size(), n); |
| 991 | + if (ec == std::errc{}) { |
| 992 | + numaNode = n; |
| 993 | + } |
| 994 | + } |
| 995 | + if (numaNode >= 0) { |
| 996 | + theLog.log(LogInfoDevel_(3008), "Preferred NUMA node = %d", numaNode); |
| 997 | + numaBind(numaNode); |
| 998 | + } |
| 999 | + #endif |
| 1000 | + |
972 | 1001 | std::unique_ptr<ReadoutEquipment> newDevice = nullptr; |
973 | 1002 | try { |
974 | 1003 | if (!cfgEquipmentType.compare("dummy")) { |
@@ -1006,6 +1035,13 @@ int Readout::configure(const boost::property_tree::ptree& properties) |
1006 | 1035 | continue; |
1007 | 1036 | } |
1008 | 1037 |
|
| 1038 | + #ifdef WITH_NUMA |
| 1039 | + // reset settings after instanciating equipment |
| 1040 | + if (numaNode >= 0) { |
| 1041 | + numaBind(-1); |
| 1042 | + } |
| 1043 | + #endif |
| 1044 | + |
1009 | 1045 | // add to list of equipments |
1010 | 1046 | if (newDevice != nullptr) { |
1011 | 1047 | readoutDevices.push_back(std::move(newDevice)); |
|
0 commit comments