topology.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright Oliver Kowalke 2017.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <cstdlib>
  6. #include <cstring>
  7. #include <exception>
  8. #include <iostream>
  9. #include <vector>
  10. #include <boost/assert.hpp>
  11. #include <boost/fiber/numa/topology.hpp>
  12. int main( int argc, char * argv[]) {
  13. try {
  14. std::vector< boost::fibers::numa::node > topo = boost::fibers::numa::topology();
  15. for ( auto n : topo) {
  16. std::cout << "node: " << n.id << " | ";
  17. std::cout << "cpus: ";
  18. for ( auto cpu_id : n.logical_cpus) {
  19. std::cout << cpu_id << " ";
  20. }
  21. std::cout << "| distance: ";
  22. for ( auto d : n.distance) {
  23. std::cout << d << " ";
  24. }
  25. std::cout << std::endl;
  26. }
  27. std::cout << "done" << std::endl;
  28. return EXIT_SUCCESS;
  29. } catch ( std::exception const& ex) {
  30. std::cerr << "exception: " << ex.what() << std::endl;
  31. }
  32. return EXIT_FAILURE;
  33. }