Browse Source

Switch to debug compiler

Konstantin Ladutenko 10 years ago
parent
commit
843ed2a768
3 changed files with 30 additions and 55 deletions
  1. 12 12
      compare.cc
  2. 17 16
      go.sh
  3. 1 27
      nmie-wrapper.cc

+ 12 - 12
compare.cc

@@ -218,7 +218,7 @@ int main(int argc, char *argv[]) {
     long ctime_nsec, best_c;
 
     //HeapProfilerStart("heapprof");    
-    for (int i = 0; i<150000; ++i) {
+    //for (int i = 0; i<150000; ++i) {
       //for (int i = 0; i<100; ++i) {
       // clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
       // nMie(L, x, m, nt, Theta, &Qext, &Qsca, &Qabs, &Qbk, &Qpr, &g, &Albedo, S1, S2);
@@ -238,24 +238,24 @@ int main(int argc, char *argv[]) {
       
       //printf("-- C/C++ time ratio: %Lg\n", static_cast<long double>(ctime_nsec)/static_cast<long double>(cpptime_nsec));
       //printf("--best C/C++ time ratio: %Lg\n", static_cast<long double>(best_c)/static_cast<long double>(best_cpp));
-    }  
+       //}  
     //HeapProfilerStop();
 
     //printf("--best C/C++ time ratio: %Lg\n", static_cast<long double>(best_c)/static_cast<long double>(best_cpp));
 
-    // clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
+    clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
     nMie(L, x, m, nt, Theta, &Qext, &Qsca, &Qabs, &Qbk, &Qpr, &g, &Albedo, S1, S2);
-    // clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2);
-    //  ctime_nsec = diff(time1,time2).tv_nsec;
-    // printf("-- C time consumed %ld sec : %ld nsec\n",diff(time1,time2).tv_sec, ctime_nsec);
+    clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2);
+     ctime_nsec = diff(time1,time2).tv_nsec;
+    printf("-- C time consumed %ld sec : %ld nsec\n",diff(time1,time2).tv_sec, ctime_nsec);
 
-    // clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
-       ///    nmie::nMie_wrapper(L, x, m, nt, Theta, &Qextw, &Qscaw, &Qabsw, &Qbkw, &Qprw, &gw, &Albedow, S1w, S2w);
-    // clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2);
-    // cpptime_nsec = diff(time1,time2).tv_nsec;
-    // printf("-- C++ time consumed %ld sec : %ld nsec\n",diff(time1,time2).tv_sec,cpptime_nsec);
+    clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
+          nmie::nMie_wrapper(L, x, m, nt, Theta, &Qextw, &Qscaw, &Qabsw, &Qbkw, &Qprw, &gw, &Albedow, S1w, S2w);
+    clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2);
+    cpptime_nsec = diff(time1,time2).tv_nsec;
+    printf("-- C++ time consumed %ld sec : %ld nsec\n",diff(time1,time2).tv_sec,cpptime_nsec);
 
-    // printf("-- C/C++ time ratio: %Lg\n", static_cast<long double>(ctime_nsec)/static_cast<long double>(cpptime_nsec));
+    printf("-- C/C++ time ratio: %Lg\n", static_cast<long double>(ctime_nsec)/static_cast<long double>(cpptime_nsec));
     
     if (has_comment) {
       printf("%6s, %+.5e, %+.5e, %+.5e, %+.5e, %+.5e, %+.5e, %+.5e\n", comment.c_str(), Qext, Qsca, Qabs, Qbk, Qpr, g, Albedo);

+ 17 - 16
go.sh

@@ -5,14 +5,16 @@ rm -f ../scattnlay
 #g++ -Ofast -std=c++11 compare.cc nmie.cc nmie-wrapper.cc -lm -lrt -o scattnlay.bin -static
 # g++ -Ofast -std=c++11 compare.cc nmie.cc nmie-wrapper.cc -lm -lrt -o scattnlay-pg.bin -static -pg
 
-#google profiler
-g++ -Ofast -std=c++11 compare.cc nmie.cc nmie-wrapper.cc -lm -lrt -o scattnlay.bin /usr/lib/libtcmalloc.so.4 -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free 
- g++ -Ofast -std=c++11 compare.cc nmie.cc nmie-wrapper.cc -lm -lrt -o scattnlay-g.bin -ltcmalloc -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -g
+#google profiler  ######## FAST!!!
+# g++ -Ofast -std=c++11 compare.cc nmie.cc nmie-wrapper.cc -lm -lrt -o scattnlay.bin /usr/lib/libtcmalloc.so.4 -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -march=native -mtune=native -msse4.2
 
-#clang++ -g -O1 -fsanitize=address  -fno-optimize-sibling-calls -fno-omit-frame-pointer -std=c++11 compare.cc nmie.cc nmie-wrapper.cc -lm -lrt -o scattnlay.bin
+#  g++ -Ofast -std=c++11 compare.cc nmie.cc nmie-wrapper.cc -lm -lrt -o scattnlay-g.bin -ltcmalloc -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -g
+
+#DEBUG!
+clang++ -g -O1 -fsanitize=address  -fno-optimize-sibling-calls -fno-omit-frame-pointer -std=c++11 compare.cc nmie.cc nmie-wrapper.cc -lm -lrt -o scattnlay.bin
 
 cp scattnlay.bin ../scattnlay
-cp scattnlay-g.bin ../scattnlay-g
+# cp scattnlay-g.bin ../scattnlay-g
 cd tests/shell
 # for file in `ls *.sh`;  do 
 #     if [ "$file" != "test03.sh" ]; then
@@ -25,17 +27,16 @@ cd tests/shell
 #time 
 time $PROGRAM -l 5 0.4642 1.8000 1.7000 0.7114 0.8000 0.7000 0.7393 1.2000 0.0900 0.9168 2.8000 0.2000 1.0000 1.5000 0.4000  -t 0.0 90.0 5 -c test01
 
-#apt-get install oprofile
-echo oprofile
-PROGRAM='../../../scattnlay-g'
-# time ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.4 
-#time 
-rm -rf oprofiletmp
-rm -rf oprofile_data
-time operf $PROGRAM -l 5 0.4642 1.8000 1.7000 0.7114 0.8000 0.7000 0.7393 1.2000 0.0900 0.9168 2.8000 0.2000 1.0000 1.5000 0.4000  -t 0.0 90.0 5 -c test01
-#opreport --symbols > opreport.log
-mkdir oprofiletmp
-opannotate --source --output-dir=./oprofiletmp/
+
+#  #apt-get install oprofile
+# echo oprofile
+# PROGRAM='../../../scattnlay-g'
+# rm -rf oprofiletmp
+# rm -rf oprofile_data
+# time operf $PROGRAM -l 5 0.4642 1.8000 1.7000 0.7114 0.8000 0.7000 0.7393 1.2000 0.0900 0.9168 2.8000 0.2000 1.0000 1.5000 0.4000  -t 0.0 90.0 5 -c test01
+# #opreport --symbols > opreport.log
+# mkdir oprofiletmp
+# opannotate --source --output-dir=./oprofiletmp/
 
 #echo valgring
 # valgrind --tool=callgrind $PROGRAM -l 5 0.4642 1.8000 1.7000 0.7114 0.8000 0.7000 0.7393 1.2000 0.0900 0.9168 2.8000 0.2000 1.0000 1.5000 0.4000  -t 0.0 90.0 5 -c test01

+ 1 - 27
nmie-wrapper.cc

@@ -512,38 +512,12 @@ namespace nmie {
   // Output parameters:                                                               //
   //   D1, D3: Logarithmic derivatives of the Riccati-Bessel functions                //
   //**********************************************************************************//
-//   //ovidio
-//   void MultiLayerMie::calcD1D3(std::complex<double> z, 
-// 		      std::vector<std::complex<double> >& D1,
-// 		      std::vector<std::complex<double> >& D3) {
-
-//   int n;
-//   std::complex<double> nz, PsiZeta;
-
-//   // Downward recurrence for D1 - equations (16a) and (16b)
-//   D1[nmax_] = std::complex<double>(0.0, 0.0);
-//   for (n = nmax_; n > 0; n--) {
-//     nz = double(n)/z;
-//     D1[n - 1] = nz - 1.0/(D1[n] + nz);
-//   }
-
-//   // Upward recurrence for PsiZeta and D3 - equations (18a) - (18d)
-//   PsiZeta = 0.5*(1.0 - std::complex<double>(cos(2.0*z.real()), sin(2.0*z.real()))*exp(-2.0*z.imag()));
-//   D3[0] = std::complex<double>(0.0, 1.0);
-//   for (n = 1; n <= nmax_; n++) {
-//     nz = double(n)/z;
-//     PsiZeta = PsiZeta*(nz - D1[n - 1])*(nz - D3[n - 1]);
-//     D3[n] = D1[n] + std::complex<double>(0.0, 1.0)/PsiZeta;
-//   }
-// }
-
-  //tig
   void MultiLayerMie::calcD1D3(const std::complex<double> z,
 			       std::vector<std::complex<double> >& D1,
 			       std::vector<std::complex<double> >& D3) {
     // Downward recurrence for D1 - equations (16a) and (16b)
     D1[nmax_] = std::complex<double>(0.0, 0.0);
-    const std::complex<double> zinv = 1.0/z;
+    const std::complex<double> zinv = std::complex<double>(1.0, 0.0)/z;
     for (int n = nmax_; n > 0; n--) {
       D1[n - 1] = double(n)*zinv - 1.0/(D1[n] + double(n)*zinv);
     }