00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "hdyn.h"
00021
00022
00023
00024 local void getq(story* s, char* l, int &i) {i = getiq (s, l);}
00025 local void getq(story* s, char* l, unsigned long &i) {i = getulq(s, l);}
00026 local void getq(story* s, char* l, real &r) {r = getrq (s, l);}
00027 local void getq(story* s, char* l, vector &v) {v = getvq (s, l);}
00028
00029 # define GETLOG(x) if (find_qmatch(b->get_log_story(), #x)) \
00030 getq(b->get_log_story(), #x, \
00031 b->get_kira_counters()->x); \
00032 else \
00033 b->get_kira_counters()->x = 0;
00034
00035
00036
00037 local void putq(story* s, char* l, int i) {putiq (s, l, i);}
00038 local void putq(story* s, char* l, unsigned long i) {putulq(s, l, i);}
00039 local void putq(story* s, char* l, real r) {putrq (s, l, r);}
00040 local void putq(story* s, char* l, vector v) {putvq (s, l, v);}
00041
00042 #define PUTLOG(x) putq(b->get_log_story(), #x, b->get_kira_counters()->x);
00043
00044
00045
00046 #define PRLOGC(x) cerr << #x << " = " << b->get_kira_counters()->x << ", "
00047 #define PRLOGL(x) cerr << #x << " = " << kc->x; \
00048 if (kc_prev) cerr << " (" << kc->x - kc_prev->x << ")"; \
00049 cerr << endl
00050
00051 void initialize_counters_from_log(hdyn* b)
00052 {
00053
00054
00055 b->get_kira_counters()->cpu_time = 0;
00056 GETLOG(total_cpu_time);
00057
00058 GETLOG(step_top_single);
00059 GETLOG(step_top_cm);
00060 GETLOG(step_low_level);
00061 GETLOG(force_correction);
00062
00063 GETLOG(pert_step);
00064 GETLOG(pert_with_list);
00065 GETLOG(pert_without_list);
00066 GETLOG(perturber_overflow);
00067
00068 GETLOG(full_unpert_step);
00069 GETLOG(full_unpert_orbit);
00070 GETLOG(partial_unpert_orbit);
00071
00072 GETLOG(tree_change);
00073 GETLOG(top_level_combine);
00074 GETLOG(low_level_combine);
00075 GETLOG(top_level_split);
00076
00077 GETLOG(leaf_merge);
00078 GETLOG(total_kick);
00079
00080
00081
00082 int nss = 0;
00083
00084 if (find_qmatch(b->get_log_story(), "n_step_slow"))
00085 getiq(b->get_log_story(), "n_step_slow", nss);
00086
00087 if (nss > 0 && find_qmatch(b->get_log_story(), "step_slow"))
00088 getia(b->get_log_story(), "step_slow",
00089 b->get_kira_counters()->step_slow, nss);
00090
00091 GETLOG(dm_escapers);
00092 GETLOG(dm_massloss);
00093
00094 GETLOG(initial_etot);
00095 GETLOG(de_total);
00096 GETLOG(de_merge);
00097 GETLOG(de_tidal_diss);
00098 GETLOG(de_massloss);
00099 GETLOG(de_kick);
00100 }
00101
00102 void write_counters_to_log(hdyn* b)
00103 {
00104
00105
00106 PUTLOG(cpu_time);
00107 PUTLOG(total_cpu_time);
00108
00109 PUTLOG(step_top_single);
00110 PUTLOG(step_top_cm);
00111 PUTLOG(step_low_level);
00112 PUTLOG(force_correction);
00113
00114 PUTLOG(pert_step);
00115 PUTLOG(pert_with_list);
00116 PUTLOG(pert_without_list);
00117 PUTLOG(perturber_overflow);
00118
00119 PUTLOG(full_unpert_step);
00120 PUTLOG(full_unpert_orbit);
00121 PUTLOG(partial_unpert_orbit);
00122
00123 PUTLOG(tree_change);
00124 PUTLOG(top_level_combine);
00125 PUTLOG(low_level_combine);
00126 PUTLOG(top_level_split);
00127
00128
00129
00130 int nss = SLOW_BINS;
00131 while (nss > 0 && b->get_kira_counters()->step_slow[nss-1] <= 0) nss--;
00132
00133 if (nss > 0) {
00134 putiq(b->get_log_story(), "n_step_slow", nss);
00135 putia(b->get_log_story(), "step_slow",
00136 b->get_kira_counters()->step_slow, nss);
00137 }
00138
00139 PUTLOG(leaf_merge);
00140 PUTLOG(total_kick);
00141
00142 PUTLOG(step_stellar);
00143 PUTLOG(step_dmslow);
00144 PUTLOG(step_dmfast);
00145 PUTLOG(step_correct);
00146
00147 PUTLOG(dm_escapers);
00148 PUTLOG(dm_massloss);
00149
00150 PUTLOG(initial_etot);
00151 PUTLOG(de_total);
00152 PUTLOG(de_merge);
00153 PUTLOG(de_tidal_diss);
00154 PUTLOG(de_massloss);
00155 PUTLOG(de_kick);
00156 }
00157
00158 void print_counters(kira_counters* kc,
00159 kira_counters* kc_prev)
00160 {
00161 cerr << "\n Counters: \n";
00162
00163 cerr << " CPU time = " << kc->cpu_time;
00164 if (kc_prev)
00165 cerr << " (delta = " << kc->cpu_time - kc_prev->cpu_time << ")";
00166 cerr << endl;
00167
00168 PRI(4); PRLOGL(step_top_single);
00169 PRI(4); PRLOGL(step_top_cm);
00170 PRI(4); PRLOGL(step_low_level);
00171
00172 PRI(4); PRLOGL(pert_step);
00173 PRI(4); PRLOGL(pert_with_list);
00174 PRI(4); PRLOGL(pert_without_list);
00175 PRI(4); PRLOGL(perturber_overflow);
00176
00177 PRI(4); PRLOGL(force_correction);
00178
00179 PRI(4); PRLOGL(full_unpert_step);
00180 PRI(4); PRLOGL(full_unpert_orbit);
00181 PRI(4); PRLOGL(partial_unpert_orbit);
00182
00183 PRI(4); PRLOGL(tree_change);
00184 PRI(4); PRLOGL(top_level_combine);
00185 PRI(4); PRLOGL(low_level_combine);
00186 PRI(4); PRLOGL(top_level_split);
00187
00188
00189
00190 int nss = SLOW_BINS;
00191 while (nss > 0 && kc->step_slow[nss-1] <= 0) nss--;
00192
00193 cerr << " step_slow =";
00194
00195 if (nss > 0) {
00196 for (int i = 0; i < nss; i++)
00197 cerr << " " << kc->step_slow[i];
00198 cerr << endl;
00199 if (kc_prev) {
00200 cerr << " (";
00201 for (int i = 0; i < nss; i++)
00202 cerr << " " << kc->step_slow[i] - kc_prev->step_slow[i];
00203 cerr << " )" << endl;
00204 }
00205 } else
00206 cerr << " 0" << endl;
00207
00208 PRI(4); PRLOGL(leaf_merge);
00209 PRI(4); PRLOGL(total_kick);
00210 PRI(4); PRLOGL(step_stellar);
00211 PRI(4); PRLOGL(step_dmslow);
00212 PRI(4); PRLOGL(step_dmfast);
00213 PRI(4); PRLOGL(step_correct);
00214
00215 PRI(4); PRLOGL(dm_escapers);
00216 PRI(4); PRLOGL(dm_massloss);
00217
00218 PRI(4); PRLOGL(de_total);
00219 PRI(4); PRLOGL(de_merge);
00220 PRI(4); PRLOGL(de_tidal_diss);
00221 PRI(4); PRLOGL(de_massloss);
00222 PRI(4); PRLOGL(de_kick);
00223
00224 if (kc_prev)
00225 *kc_prev = *kc;
00226 }