Optimized Belief Propagation (CPU and GPU)
RunSettings.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 
28 #ifndef RUNSETTINGS_H_
29 #define RUNSETTINGS_H_
30 
31 #include <optional>
32 #include <string_view>
33 #include <thread>
34 #include <ranges>
35 #include <set>
36 #include "RunEval/RunData.h"
37 #include "InputSignature.h"
38 #include "RunSettingsConstsEnums.h"
40 
41 namespace run_environment {
42 
43 inline unsigned int GetBytesAlignMemory(AccSetting accel_setting) {
44  //avx512 requires data to be aligned on 64 bytes
45  return ((accel_setting == AccSetting::kAVX512) ||
46  (accel_setting == AccSetting::kAVX512_F16)) ?
47  64 :
48  32;
49 }
50 
58 template <AccSetting ACCELERATION_SETTING>
59 inline RunData RunSettings() {
60  //initialize run data to store run settings
61  RunData curr_run_data;
62 
63  //add number of CPU threads to run data
64  curr_run_data.AddDataWHeader(
65  std::string(kNumCPUThreadsHeader),
66  std::thread::hardware_concurrency());
67 
68  //add acceleration setting to run data
69  curr_run_data.AddDataWHeader(
70  std::string(kBytesAlignMemHeader),
71  GetBytesAlignMemory(ACCELERATION_SETTING));
72 
73  //add CPU threads picked to socket info to run data
74  curr_run_data.AppendData(
75  CPUThreadsPinnedToSocket().SettingsAsRunData());
76 
77  //return run data that corresponds to current run settings
78  return curr_run_data;
79 }
80 
85  std::vector<unsigned int> datatypes_eval_sizes;
88  std::pair<std::array<unsigned int, 2>, std::set<std::array<unsigned int, 2>>>
90  std::string run_name;
91  //path to baseline runtimes for optimized and single thread runs along with
92  //description
93  std::optional<std::array<std::string_view, 2>> baseline_runtimes_path_desc;
94  std::vector<std::pair<std::string, std::vector<InputSignature>>>
97 
103  void RemoveParallelParamBelowMinThreads(unsigned int min_threads) {
104  std::erase_if(p_params_default_alt_options.second,
105  [min_threads](const auto& p_params) {
106  return p_params[0] < min_threads; });
107  }
108 
114  void RemoveParallelParamAboveMaxThreads(unsigned int max_threads) {
115  std::erase_if(p_params_default_alt_options.second,
116  [max_threads](const auto& p_params) {
117  return p_params[0] > max_threads; });
118  }
119 };
120 
121 };
122 
123 #endif /* RUNSETTINGS_H_ */
Declares class for setting and retrieving setting of CPU threads pinned to socket.
Declares class for defining input signature for evaluation run that consists of evaluation set number...
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.
Class to store headers with data corresponding to current program run and evaluation.
Definition: RunData.h:42
void AppendData(const RunData &rundata)
Append current RunData with input RunData.
Definition: RunData.cpp:99
void AddDataWHeader(const std::string &header, const std::string &data)
Add string data with header describing added data.
Definition: RunData.cpp:49
Constants and enums related to run environment and settings for run.
Definition: RunSettings.h:41
constexpr std::string_view kBytesAlignMemHeader
AccSetting
Enum for acceleration setting.
RunData RunSettings()
Generate RunData object that contains description header with corresponding value for each run settin...
Definition: RunSettings.h:59
constexpr std::string_view kNumCPUThreadsHeader
unsigned int GetBytesAlignMemory(AccSetting accel_setting)
Definition: RunSettings.h:43
OptParallelParamsSetting
Enum to specify if optimizing parallel parameters per kernel or using same parallel parameters across...
TemplatedItersSetting
Enum that specifies whether or not to use templated counts for the number of iterations in processing...
Structure that stores settings for current implementation run.
Definition: RunSettings.h:84
TemplatedItersSetting templated_iters_setting
Definition: RunSettings.h:86
std::optional< std::array< std::string_view, 2 > > baseline_runtimes_path_desc
Definition: RunSettings.h:93
std::vector< unsigned int > datatypes_eval_sizes
Definition: RunSettings.h:85
std::pair< std::array< unsigned int, 2 >, std::set< std::array< unsigned int, 2 > > > p_params_default_alt_options
Definition: RunSettings.h:89
OptParallelParamsSetting opt_parallel_params_setting
Definition: RunSettings.h:87
std::vector< std::pair< std::string, std::vector< InputSignature > > > subset_desc_input_sig
Definition: RunSettings.h:95
void RemoveParallelParamBelowMinThreads(unsigned int min_threads)
Remove parallel parameters with less than specified number of threads.
Definition: RunSettings.h:103
void RemoveParallelParamAboveMaxThreads(unsigned int max_threads)
Remove parallel parameters with greater than specified number of threads.
Definition: RunSettings.h:114