20 #define fei_file "test_benchmarks.cpp"
33 template<
typename MAP_TYPE,
typename SET_TYPE>
44 int* indices =
new int[numIndices];
53 table.addIndices(numIndices, indices, numIndices, indices);
62 template<
typename MAP_TYPE,
typename SET_TYPE>
68 double time_taken = time_raggedtable_insert<MAP_TYPE,SET_TYPE>(len);
69 while(time_taken < 1.0) {
71 time_taken = time_raggedtable_insert<MAP_TYPE,SET_TYPE>(len);
77 while(time_taken<5.0) {
78 time_taken += time_raggedtable_insert<MAP_TYPE,SET_TYPE>(len);
82 return((
double)(i*len)/time_taken);
98 FEI_COUT <<
" -----------------------";
110 const char* passfail)
120 if (goldvalue < 0.0)
FEI_COUT <<
"n/a";
131 #if defined(FEI_PLATFORM) && defined(FEI_OPT_LEVEL)
132 osstr <<
"_" << FEI_PLATFORM <<
"_" << FEI_OPT_LEVEL;
134 osstr <<
"_unknown_unknown";
147 <<
" ***** Benchmarks pass if within 10% of 'gold-copy' *****"
150 #if defined(FEI_PLATFORM) && defined(FEI_OPT_LEVEL)
151 FEI_COUT <<
" FEI_PLATFORM: "<<FEI_PLATFORM
152 <<
", FEI_OPT_LEVEL: "<<FEI_OPT_LEVEL
154 FEI_COUT <<
" 'gold-copy' benchmark values will be searched for in ./fei_utest_timings.txt"<<
FEI_ENDL;
157 FEI_COUT <<
" preprocessor macros FEI_PLATFORM and FEI_OPT_LEVEL aren't defined, so"<<
FEI_ENDL;
158 FEI_COUT <<
" ./fei_utest_timings.txt will not be searched for 'gold-copy' benchmark values"<<FEI_ENDL<<
FEI_ENDL;
174 FEI_COUT <<
"Following group of benchmarks inserts integers into ragged tables"
176 <<
"matrix-graph construction) using various data structures."<<
FEI_ENDL
177 <<
"A higher number is better, indicating more insertions"
183 double value, goldvalue;
185 std::string testname;
187 value = benchmark_raggedtable<std::map<int,std::set<int>*>,std::set<int> >();
193 value = benchmark_raggedtable<std::map<int,fei::ctg_set<int>*>,
fei::ctg_set<int> >();
198 if (passfail !=
"passed") returnValue = -1;
210 value = benchmark_raggedtable<snl_fei::MapContig<fei::ctg_set<int>*>,
fei::ctg_set<int> >();
215 if (passfail !=
"passed") returnValue = -1;
227 value = benchmark_raggedtable<FEI_HASH_MAP<int,FEI_HASH_SET<int>*>,FEI_HASH_SET<int> >();
237 if (returnValue != 0) {
243 template<
typename SET_TYPE>
248 SET_TYPE* set_objs =
new SET_TYPE[len];
254 int inner_2 = inner/2;
256 for(
int n=0;
n<len; ++
n) {
258 SET_TYPE& set_ref = set_objs[n];
260 for(
int i=0; i<outer; ++i) {
261 int col_i = col_n+i*outer;
263 for(
int j=0; j<inner_2; ++j) {
264 set_ref.insert(col_i+j);
265 set_ref.insert(col_i+j+inner_2);
273 return(elapsed_time);
276 template<
typename SET_TYPE>
281 SET_TYPE* set_objs =
new SET_TYPE[len];
288 for(
int n=0;
n<len; ++
n) {
290 SET_TYPE& set_ref = set_objs[n];
292 for(
int i=0; i<outer; ++i) {
293 int col_i = col_n+i*outer;
295 for(
int j=0; j<inner/2; ++j) {
296 set_ref.insert2(col_i+j);
297 set_ref.insert2(col_i+j+inner/2);
305 return(elapsed_time);
308 template<
typename SET_TYPE>
314 double time_taken = time_set_insert<SET_TYPE>(len);
315 while(time_taken < 1.0) {
317 time_taken = time_set_insert<SET_TYPE>(len);
323 while(time_taken<5.0) {
324 time_taken += time_set_insert<SET_TYPE>(len);
328 return((
double)(i*len)/time_taken);
331 template<
typename SET_TYPE>
337 double time_taken = time_set_insert2<SET_TYPE>(len);
338 while(time_taken < 1.0) {
340 time_taken = time_set_insert2<SET_TYPE>(len);
346 while(time_taken<5.0) {
347 time_taken += time_set_insert2<SET_TYPE>(len);
351 return((
double)(i*len)/time_taken);
360 FEI_COUT <<
"Following group of benchmarks inserts integers into sorted lists"
361 <<
" (actually"<<FEI_ENDL
362 <<
"sets), which is a sub-task of the ragged-table benchmarks..."<<FEI_ENDL
363 <<
"A higher number is better."<<FEI_ENDL<<
FEI_ENDL;
367 double value, goldvalue;
369 std::string testname;
372 value = benchmark_set<fei::ctg_set<int> >();
378 if (passfail !=
"passed") returnValue = -1;
388 #ifndef FEI_NO_STL_SET
390 value = benchmark_set<std::set<int> >();
399 value = benchmark_set<FEI_HASH_SET<int> >();
411 value = benchmark_set2<fei::ctg_set<int> >();
417 if (passfail !=
"passed") returnValue = -1;
427 if (returnValue != 0) {
439 std::vector<int> stdvector(len);
441 std::vector<int> stdv_dest;
443 int* stdvptr = &(stdvector[0]);
445 for(
int i=0; i<len; ++i) {
450 <<
" binary-searches and inserts on an std::vector" <<
FEI_ENDL
451 <<
" of length " << len <<
": " <<
FEI_ENDL;
455 stdvector.reserve(n*2);
457 std::vector<int>::iterator
459 v_beg = stdvector.begin(),
460 v_end = stdvector.end();
462 for(
int k=0; k<n; ++k) {
463 v_iter = std::lower_bound(v_beg, v_end, k*2);
464 stdvector.insert(v_iter, k*2-1);
465 v_beg = stdvector.begin();
466 v_end = stdvector.end();
void print_benchmark_banner()
double time_set_insert2(int len)
std::string check_test_result(double value, double goldvalue, unsigned margin)
double time_raggedtable_insert(int len)
double benchmark_raggedtable()
double time_set_insert(int len)
const std::string passfail(const bool result)
virtual int firstLocalElem()
test_benchmarks(MPI_Comm comm)
double get_file_benchmark(const char *filename, const char *testname)
virtual int getElemConnectivity(int elemID, int *nodeIDs)
std::string add_macro_values(const char *name)
virtual ~test_benchmarks()
virtual int numNodesPerElem()
virtual int numLocalNodes()
void print_benchmark_line(const char *name, double value, double goldvalue, const char *passfail)
virtual int numLocalElems()
#define FEI_OSTRINGSTREAM