Optimized Belief Propagation (CPU and GPU)
CPUThreadsPinnedToSocket.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2024 Scott Grauer-Gray
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
27 #include <string>
28 #include <cstdlib>
29 #include "RunEval/RunData.h"
30 #include "RunSettingsConstsEnums.h"
31 
36 public:
45  void operator()(bool cpu_threads_pinned) const {
46  /*if (cpu_threads_pinned) {
47  int success = system("export OMP_PLACES=\"sockets\"");
48  if (success == 0) {
49  std::cout << "export OMP_PLACES=\"sockets\" success" << std::endl;
50  }
51  success = system("export OMP_PROC_BIND=true");
52  if (success == 0) {
53  std::cout << "export OMP_PROC_BIND=true success" << std::endl;
54  }
55  }
56  else {
57  int success = system("export OMP_PLACES=");
58  if (success == 0) {
59  std::cout << "export OMP_PLACES= success" << std::endl;
60  }
61  success = system("export OMP_PROC_BIND=");
62  if (success == 0) {
63  std::cout << "export OMP_PROC_BIND= success" << std::endl;
64  }
65  }*/
66  }
67 
76  RunData pinned_threads_settings;
77  const std::string omp_places_setting = (std::getenv("OMP_PLACES") == nullptr) ? "" : std::getenv("OMP_PLACES");
78  const std::string omp_proc_bind_setting = (std::getenv("OMP_PROC_BIND") == nullptr) ? "" : std::getenv("OMP_PROC_BIND");
79  const bool cpu_threads_pinned = ((omp_places_setting == "sockets") && (omp_proc_bind_setting == "true"));
80  pinned_threads_settings.AddDataWHeader(std::string(run_environment::kCPUThreadsPinnedHeader), cpu_threads_pinned);
81  pinned_threads_settings.AddDataWHeader(std::string(run_environment::kOmpPlacesHeader), omp_places_setting);
82  pinned_threads_settings.AddDataWHeader(std::string(run_environment::kOmpProcBindHeader), omp_proc_bind_setting);
83  return pinned_threads_settings;
84  }
85 };
Declares class to store headers with data corresponding to current program run and evaluation.
Contains namespace with constants and enums related to run environment and settings for run.
Class to adjust and retrieve settings corresponding to CPU threads pinned to socket.
RunData SettingsAsRunData() const
Retrieve environment variable values corresponding to CPU threads being pinned to socket and return a...
void operator()(bool cpu_threads_pinned) const
Adjust setting to specify that CPU threads to be pinned to socket or not. If true,...
Class to store headers with data corresponding to current program run and evaluation.
Definition: RunData.h:42
void AddDataWHeader(const std::string &header, const std::string &data)
Add string data with header describing added data.
Definition: RunData.cpp:49
constexpr std::string_view kCPUThreadsPinnedHeader
constexpr std::string_view kOmpPlacesHeader
constexpr std::string_view kOmpProcBindHeader