95 const std::string& expr_string,
96 const std::size_t& cost)
102 std::vector<T> v0(vec_size, T(2.1234567890));
103 std::vector<T> v1(vec_size, T(3.1234567890));
104 std::vector<T> v2(vec_size, T(5.1234567890));
108 symbol_table_t symbol_table;
109 symbol_table.add_vector(
"v0",v0);
110 symbol_table.add_vector(
"v1",v1);
111 symbol_table.add_vector(
"v2",v2);
112 symbol_table.add_package(vecops_package);
114 expression_t expression;
115 expression.register_symbol_table(symbol_table);
119 if (!parser.compile(expr_string,expression))
121 printf(
"[load_expression] - Parser Error: %s\tExpression: %s\n",
122 parser.error().c_str(),
123 expr_string.c_str());
125 return std::numeric_limits<T>::quiet_NaN();
134 for (std::size_t r = 0; r <
rounds; ++r)
136 total += expression.value();
142 printf(
"Total Time:%10.7f Rate:%11.3fevals/sec Perf: %5.3fGFLOPS Expression: %s\n",
145 (
rounds * vec_size * cost) / (1e+9 * timer.
time()),
146 expr_string.c_str());
148 printf(
"run_expression_benchmark() - Error running benchmark for expression: %s\n",
149 expr_string.c_str());
185 std::ifstream stream(file_name.c_str());
189 printf(
"run_file_benchmark() - Failed to open file: %s\n",
195 std::vector<std::string> expr_list;
197 while (std::getline(stream, line))
201 else if (
'#' == line[0])
204 expr_list.push_back(line);
209 for (std::size_t i = 0; i < expr_list.size(); ++i)
211 total_time += run_expression_benchmark<T>(vec_size,expr_list[i],0);
214 printf(
"Total Time:%10.7f\n", total_time);
217int main(
int argc,
char* argv[])
219 const std::size_t vec_size = ((argc >= 2) ? atoi(argv[1]) : 100000);
220 const std::string file_name = ((argc > 3) ? argv[2] :
"" );
224 case 2 : run_benchmark <numeric_type>(vec_size );
break;
225 case 3 : run_file_benchmark<numeric_type>(vec_size,file_name);
break;