diff --git a/fastlib/u/garryb/nbr/affinity.cc b/fastlib/u/garryb/nbr/affinity.cc index 99dac1398a..2eb6b24bb2 100644 --- a/fastlib/u/garryb/nbr/affinity.cc +++ b/fastlib/u/garryb/nbr/affinity.cc @@ -267,7 +267,7 @@ class AffinityAlpha { void Postprocess(const Param& param, const QPoint& q, index_t q_index, const RNode& r_root) {} void ApplyPostponed(const Param& param, - const QPostponed& postponed, const QPoint& q) {} + const QPostponed& postponed, const QPoint& q, index_t q_i) {} }; struct QMassResult { @@ -490,7 +490,7 @@ class AffinityRho { rho += self_responsibility; } void ApplyPostponed(const Param& param, - const QPostponed& postponed, const QPoint& q) { + const QPostponed& postponed, const QPoint& q, index_t q_index) { #ifdef APPRLX rho += postponed.d_rho; error_buffer += postponed.error_buffer; @@ -817,6 +817,7 @@ void TimeStats(datanode *module, const ArrayList& list) { fx_format_result(module, "med", "%f", v_med/1e6); fx_format_result(module, "max", "%f", v_max/1e6); fx_format_result(module, "avg", "%f", v_avg/1e6); + fx_format_result(module, "sum", "%f", v_avg*list.size()/1e6); } @@ -864,7 +865,7 @@ void AffinityMain(datanode *module, const char *gnp_name) { point->info().alpha.max1 = 0; point->info().alpha.max2 = param.pref; point->info().alpha.max1_index = i; - if (rand() % 16 == 0) { + if (rand() % 2 == 0) { point->info().rho = -param.pref / 2; } else { point->info().rho = 0; @@ -1044,6 +1045,7 @@ void AffinityMain(datanode *module, const char *gnp_name) { iter_times_alpha); TimeStats(fx_submodule(module, "iter_times_total", "iter_times_total"), iter_times_total); + fx_format_result(module, "n_points", "%"LI"d", n_points); // This will take too long if there are too many exemplars. if (n_exemplars >= 10000) { diff --git a/fastlib/u/garryb/nbr/apcluster.c b/fastlib/u/garryb/nbr/apcluster.c index 7c0a42885f..89cf4ee0b4 100644 --- a/fastlib/u/garryb/nbr/apcluster.c +++ b/fastlib/u/garryb/nbr/apcluster.c @@ -276,6 +276,7 @@ int main (int argc, char **argv) } } fx_timer_stop(fx_root, "all_iter"); + /* If clusters were identified, find the assignments and output them */ if (K > 0) { for (j = 0; j < m; j++) @@ -349,6 +350,12 @@ int main (int argc, char **argv) fprintf (stderr, " Similarities of data points to exemplars: %f\n", dpsim); fprintf (stderr, " Preferences of selected exemplars: %f\n", expref); fprintf (stderr, "Number of iterations: %d\n\n", it); + + struct timer *timer_all_iter = fx_timer(fx_root, "all_iter"); + fx_format_result(fx_root, "n_points", "%ld", n); + fx_format_result(fx_root, "avg", "%f", timer_all_iter->total.micros / 1.0e6 / it); + fx_format_result(fx_root, "n_iterations", "%d", it); + fx_format_result(fx_root, "netsim", "%f", netsim); } else fprintf (stderr, "\nDid not identify any clusters\n"); diff --git a/fastlib/u/garryb/nbr/build.py b/fastlib/u/garryb/nbr/build.py index ab718df5dc..b66c53a03d 100644 --- a/fastlib/u/garryb/nbr/build.py +++ b/fastlib/u/garryb/nbr/build.py @@ -32,6 +32,10 @@ binrule(name = "allnn", sources = ["allnn.cc"], deplibs = [":nbr"]) +binrule(name = "tpc", + sources = ["tpc.cc"], + deplibs = [":nbr"]) + binrule(name = "affinity", sources = ["affinity.cc"], deplibs = [":nbr"]) diff --git a/fastlib/u/garryb/nbr/dfs.h b/fastlib/u/garryb/nbr/dfs.h index 19d1f9a553..22efa9e6ee 100644 --- a/fastlib/u/garryb/nbr/dfs.h +++ b/fastlib/u/garryb/nbr/dfs.h @@ -184,7 +184,7 @@ void DualTreeDepthFirst::PushDown_( typename GNP::QResult *q_result = q_results_.StartWrite(q_i); const typename GNP::QPoint *q_point = q_points_.StartRead(q_i); - q_result->ApplyPostponed(param_, q_node_mut->postponed, *q_point); + q_result->ApplyPostponed(param_, q_node_mut->postponed, *q_point, q_i); q_result->Postprocess(param_, *q_point, q_i, *r_root_); q_results_.StopWrite(q_i); q_points_.StopRead(q_i); @@ -354,7 +354,7 @@ void DualTreeDepthFirst::BaseCase_( const typename GNP::QPoint *q_point = q_iter; typename GNP::QResult *q_result = q_results_.StartWrite(q_i); - q_result->ApplyPostponed(param_, q_node_mut->postponed, *q_point); + q_result->ApplyPostponed(param_, q_node_mut->postponed, *q_point, q_i); if (visitor.StartVisitingQueryPoint(param_, *q_point, q_i, *r_node, exclusive_unvisited, q_result, &global_result_)) { diff --git a/fastlib/u/garryb/nbr/gnp.h b/fastlib/u/garryb/nbr/gnp.h index 7d6606db48..8316ab7b53 100644 --- a/fastlib/u/garryb/nbr/gnp.h +++ b/fastlib/u/garryb/nbr/gnp.h @@ -47,18 +47,16 @@ struct BlankQResult { public: OT_DEF(BlankQResult) {} public: - template - void Init(const Param& param, - const Point& q_point, - const RNode& r_root) {} + template + void Init(const Param& param) {} template void Postprocess(const Param& param, - const Point& q_point, + const Point& q_point, index_t q_index, const RNode& r_root) {} template void ApplyPostponed(const Param& param, const QPostponed& postponed, - const Point& q_point) {} + const Point& q_point, index_t q_index) {} }; class BlankGlobalResult { @@ -75,6 +73,7 @@ class BlankGlobalResult { void UndoDelta(const Param& param, const Delta& delta) {} template void Postprocess(const Param& param) {} + void Report(datanode *datanode) {} }; struct BlankQMassResult { diff --git a/fastlib/u/garryb/nbr/nbr_utils.h b/fastlib/u/garryb/nbr/nbr_utils.h index 444f9cc9c7..232333592e 100644 --- a/fastlib/u/garryb/nbr/nbr_utils.h +++ b/fastlib/u/garryb/nbr/nbr_utils.h @@ -198,6 +198,8 @@ class ThreadedDualTreeSolver { } fx_timer_stop(module, "all_threads"); + + global_result_.Report(fx_submodule(module, NULL, "global_result")); } };