Optimized Belief Propagation (CPU and GPU)
RunEvalConstsEnums.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 RUN_EVAL_CONSTS_ENUMS_H_
29 #define RUN_EVAL_CONSTS_ENUMS_H_
30 
31 #include <array>
32 #include <string_view>
33 #include <map>
34 #include <filesystem>
36 
40 namespace run_eval {
41 
43 enum class Status { kNoError, kError };
44 
46 enum class MiddleValData { kAverage, kMedian };
47 
48 //set data types to use in evaluation
49 //by default evaluate using float, double, and half data types
50 //can set to only evaluate specific datatype via preprocessor define
51 #if defined(EVAL_FLOAT_DATATYPE_ONLY)
52  constexpr std::array<size_t, 1> kDataTypesEvalSizes{sizeof(float)};
53 #elif defined(EVAL_DOUBLE_DATATYPE_ONLY)
54  constexpr std::array<size_t, 1> kDataTypesEvalSizes{sizeof(double)};
55 #elif defined(EVAL_HALF_DATATYPE_ONLY)
56  constexpr std::array<size_t, 1> kDataTypesEvalSizes{sizeof(halftype)};
57 #else
58  constexpr std::array<size_t, 3> kDataTypesEvalSizes{
59  sizeof(float), sizeof(double), sizeof(halftype)};
60 #endif //EVAL_FLOAT_DATATYPE_ONLY
61 
62 //set whether or not to run and evaluate alternative optimized implementations
63 //other than the expected fastest implementation available based on
64 //acceleration type
65 #if defined(NO_ALT_OPTIMIZED_IMPS)
66  constexpr bool kRunAltOptimizedImps{false};
67 #else
68  constexpr bool kRunAltOptimizedImps{true};
69 #endif //NO_ALT_OPTIMIZED_IMPS
70 
71 //set templated iterations setting to use in evaluation
72 #if defined(EVAL_NOT_TEMPLATED_ITERS_ONLY)
75 #else
78 #endif //EVAL_NOT_TEMPLATED_ITERS_ONLY
79 
81  constexpr std::array<std::string_view, 2> kBoolValFalseTrueDispStr{"NO", "YES"};
82 
83  //constants for headers corresponding to input, input settings, results, and run success
84  constexpr std::string_view kInputIdxHeader{"Input Index"};
85  constexpr std::string_view kDatatypeHeader{"Data Type"};
86  constexpr std::string_view kLoopItersTemplatedHeader{"Loop Iters Templated"};
87 
89  constexpr std::string_view kMedianOfTestRunsDesc{"(median timing across evaluation runs)"};
90 
92  constexpr std::string_view kAllRunsStr{"All Runs"};
93 
94  //constants for output results for individual and sets of runs
95  constexpr std::string_view kRunResultsDescFileName{"RunResults"};
96  constexpr std::string_view kRunResultsDefaultPParamsDescFileName{"RunResultsDefaultPParams"};
97  constexpr std::string_view kRunResultsWSpeedupsDescFileName{"RunResultsWSpeedups"};
98  constexpr std::string_view kRunResultsDescDefaultPParamsFileName{"ResultsDefaultParallelParams"};
99  constexpr std::string_view kSpeedupsDescFileName{"Speedups"};
100  constexpr std::string_view kEvalAcrossRunsFileName{"EvaluationAcrossRuns"};
101  constexpr std::string_view kCsvFileExtension{".csv"};
102  constexpr std::string_view kOptimizedRuntimeHeader{"Median Optimized Runtime (including transfer time)"};
103  constexpr std::string_view kSingleThreadRuntimeHeader{"Single-Thread CPU run time"};
104 
105  //constant for speedup description for optimized parallel parameters
106  constexpr std::string_view kSpeedupOptParParamsHeader{"Speedup Over Default OMP Thread Count / CUDA Thread Block Dimensions"};
107 
108  //constants for speedups descriptions for alternate data types compared to flot
109  constexpr std::string_view kSpeedupDoubleHeader{"Speedup using double-precision relative to float (actually slowdown)"};
110  constexpr std::string_view kSpeedupHalfHeader{"Speedup using half-precision relative to float"};
111 
112  //constant for speedup description for templated loop iteration count where number
113  //of loop iterations in at least some loops in benchmarks is known at compile time
114  //via template parameter
115  constexpr std::string_view kSpeedupLoopItersCountTemplate{"Speedup w/ templated loop iteration count (known at compile-time)"};
116 
117  //constants for speedup descriptions compared to alternate accelerations
118  constexpr std::string_view kSpeedupCPUVectorization{"Speedup over no CPU vectorization"};
119  constexpr std::string_view kSpeedupVsAvx256Vectorization{"Speedup over AVX256 CPU vectorization"};
120  constexpr std::string_view kSpeedupVsAvx256F16Vectorization{"Speedup over AVX256 (w/ float16) CPU vectorization"};
121  constexpr std::string_view kSpeedupVsAvx512Vectorization{"Speedup over AVX512 CPU vectorization"};
122  constexpr std::string_view kSpeedupVsAvx512F16Vectorization{"Speedup over AVX512 (w/ float16) CPU vectorization"};
123  constexpr std::string_view kSpeedupVsNEONVectorization{"Speedup over NEON CPU vectorization"};
124  constexpr std::string_view kSpeedupVsCUDAAcceleration{"Speedup over CUDA acceleration"};
125 
126  //mapping of alternate acceleration setting to speedup description
127  const std::map<run_environment::AccSetting, const std::string_view> kAltAccToSpeedupDesc{
135  };
136 
137  //constants for implementation result
138  constexpr std::string_view kImpResultsFolderName{"ImpResults"};
139  constexpr std::string_view kImpResultsRunDataFolderName{"RunResults"};
140  constexpr std::string_view kImpResultsRunDataDefaultPParamsFolderName{"RunResultsDefaultPParams"};
141  constexpr std::string_view kImpResultsRunDataWSpeedupsFolderName{"RunResultsWSpeedups"};
142  constexpr std::string_view kImpResultsSpeedupsFolderName{"Speedups"};
143  constexpr std::string_view kImpResultsAcrossArchsFolderName{"ResultsAcrossArchitectures"};
144  constexpr std::string_view kImpResultsRunDataAccFolderName{"RunResultsAcc"};
145 
146  //headers that correspond to unique "signature" set of inputs in run
147  constexpr std::array<std::string_view, 3> kRunInputSigHeaders{
149  constexpr std::size_t kRunInputNumInputIdx{0};
150  constexpr std::size_t kRunInputDatatypeIdx{1};
151  constexpr std::size_t kRunInputLoopItersTemplatedIdx{2};
152 
153  //declare output results type and array containing all output results types
154  enum class OutResults{
156  };
157 
158  //structure containing directory path and description in file name for
159  //each output result file
160  struct OutFileInfo{
161  std::filesystem::path dir_path;
162  std::string_view desc_file_name;
163  };
164 
165  //mapping from output result type to full directory path where results for
166  //type stored and description part of file name
167  const std::map<OutResults, const OutFileInfo> kOutResultsFileInfo{
180  };
181 
182  //mapping from output type to description shown to user
183  const std::map<OutResults, const std::string_view> kOutResultsDesc{
185  "Run inputs and results using default parallel parameters"},
187  "Run inputs and optimized results"},
189  "Speedup results"},
191  "Input/settings/parameters info, detailed timings, and evaluation for "
192  "each run including speedup results"}
193  };
194 };
195 
196 #endif //RUN_EVAL_CONSTS_ENUMS_H_
half halftype
Contains namespace with constants and enums related to run environment and settings for run.
TemplatedItersSetting
Enum that specifies whether or not to use templated counts for the number of iterations in processing...
Namespace with enums and constants for implementation run evaluation.
constexpr std::string_view kInputIdxHeader
constexpr std::string_view kSpeedupVsAvx512F16Vectorization
constexpr std::size_t kRunInputNumInputIdx
constexpr std::string_view kImpResultsRunDataFolderName
constexpr std::string_view kDatatypeHeader
constexpr std::string_view kEvalAcrossRunsFileName
const std::map< run_environment::AccSetting, const std::string_view > kAltAccToSpeedupDesc
constexpr std::string_view kImpResultsRunDataAccFolderName
constexpr std::string_view kRunResultsWSpeedupsDescFileName
constexpr std::size_t kRunInputLoopItersTemplatedIdx
constexpr std::string_view kSingleThreadRuntimeHeader
const std::map< OutResults, const std::string_view > kOutResultsDesc
constexpr std::string_view kRunResultsDefaultPParamsDescFileName
constexpr std::string_view kAllRunsStr
Constant for "all runs" string.
constexpr std::string_view kSpeedupVsCUDAAcceleration
constexpr std::string_view kCsvFileExtension
constexpr std::string_view kImpResultsRunDataDefaultPParamsFolderName
constexpr std::string_view kMedianOfTestRunsDesc
Constant to describing timing as median across evaluation runs.
constexpr std::string_view kSpeedupsDescFileName
constexpr std::string_view kSpeedupDoubleHeader
constexpr std::string_view kRunResultsDescDefaultPParamsFileName
constexpr std::string_view kRunResultsDescFileName
constexpr run_environment::TemplatedItersSetting kTemplatedItersEvalSettings
constexpr std::size_t kRunInputDatatypeIdx
Status
Enum for status to indicate if error or no error.
constexpr std::array< std::string_view, 2 > kBoolValFalseTrueDispStr
Define string for display of "true" and "false" values of bool value.
constexpr std::string_view kOptimizedRuntimeHeader
constexpr std::string_view kImpResultsAcrossArchsFolderName
const std::map< OutResults, const OutFileInfo > kOutResultsFileInfo
constexpr std::string_view kSpeedupVsAvx512Vectorization
constexpr bool kRunAltOptimizedImps
constexpr std::string_view kSpeedupVsAvx256Vectorization
constexpr std::string_view kSpeedupVsAvx256F16Vectorization
constexpr std::array< std::string_view, 3 > kRunInputSigHeaders
constexpr std::string_view kImpResultsSpeedupsFolderName
constexpr std::string_view kSpeedupCPUVectorization
constexpr std::string_view kSpeedupHalfHeader
constexpr std::string_view kSpeedupOptParParamsHeader
constexpr std::string_view kImpResultsRunDataWSpeedupsFolderName
constexpr std::array< size_t, 3 > kDataTypesEvalSizes
constexpr std::string_view kImpResultsFolderName
constexpr std::string_view kLoopItersTemplatedHeader
constexpr std::string_view kSpeedupVsNEONVectorization
constexpr std::string_view kSpeedupLoopItersCountTemplate
MiddleValData
Enum to specify average or median for "middle" value in data.
std::filesystem::path dir_path
std::string_view desc_file_name