44#include <map>
55#include <sstream>
66#include <vector>
7+ #include <tuple>
78#include <chrono>
9+ #include <limits>
810#define float_sw4 double
911#include "SW4CKConfig.h"
1012#include "foralls.h"
@@ -20,6 +22,7 @@ class Sarray {
2022 void init ();
2123 void init2 ();
2224 double norm ();
25+ std ::tuple < double ,double > minmax ();
2326 int m_nc , m_ni , m_nj , m_nk ;
2427 int m_ib , m_ie , m_jb , m_je , m_kb , m_ke ;
2528 ssize_t m_base ;
@@ -104,6 +107,15 @@ double Sarray::norm() {
104107 for (size_t i = 0 ; i < size / 8 ; i ++ ) ret += m_data [i ] * m_data [i ];
105108 return ret ;
106109}
110+ std ::tuple < double ,double > Sarray ::minmax (){
111+ double min = std ::numeric_limits < double > ::max ();
112+ double max = std ::numeric_limits < double > ::min ();
113+ for (size_t i = 0 ; i < size / 8 ; i ++ ) {
114+ min = std ::min (min ,m_data [i ]);
115+ max = std ::max (max ,m_data [i ]);
116+ }
117+ return std ::make_tuple (min ,max );
118+ }
107119
108120void curvilinear4sg_ci (
109121 int ifirst , int ilast , int jfirst , int jlast , int kfirst , int klast ,
@@ -253,13 +265,17 @@ int main(int argc, char* argv[]) {
253265#endif
254266 auto stop = std ::chrono ::high_resolution_clock ::now ();
255267 std ::cout <<"\nTotal kernel runtime = " <<std ::chrono ::duration_cast < std ::chrono ::milliseconds > (stop - start ).count ()<<"\n\n" ;
268+ auto minmax = arrays [i ]["a_Uacc" ]-> minmax ();
269+ std ::cout << "MIN = " << std ::defaultfloat << std ::setprecision (20 )
270+ << std ::get < 0 > (minmax )<<"\nMAX = " <<std ::get < 1 > (minmax ) << "\n\n" ;
271+ double norm = arrays [i ]["a_Uacc" ]-> norm ();
256272 std ::cout << "Norm of output " << std ::hexfloat
257- << arrays [ i ][ "a_Uacc" ] -> norm () << "\n" ;
273+ << norm << "\n" ;
258274 std ::cout << "Norm of output " << std ::defaultfloat << std ::setprecision (20 )
259- << arrays [ i ][ "a_Uacc" ] -> norm () << "\n" ;
275+ << norm << "\n" ;
260276 //const double exact_norm = 9.86238393426104e+17;
261277 const double exact_norm = 202.0512747393526638 ; // for init2
262- double err = (arrays [ i ][ "a_Uacc" ] -> norm () - exact_norm ) / exact_norm * 100 ;
278+ double err = (norm - exact_norm ) / exact_norm * 100 ;
263279 std ::cout << "Error = " << std ::setprecision (2 ) << err << " %\n" ;
264280 }
265281}
0 commit comments