From: Matthew Fernandez Date: Thu, 15 Oct 2020 02:32:58 +0000 (-0700) Subject: inline and fuse a number of loops in majorization code X-Git-Tag: 2.46.0~20^2^2~26^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d336cdacee0d51e0974c67010cb4d4a86c526e9c;p=graphviz inline and fuse a number of loops in majorization code This accelerates the Neato example from #1652 by ~9.5%. --- diff --git a/lib/neatogen/stress.c b/lib/neatogen/stress.c index f43ecb39b..8d840e895 100644 --- a/lib/neatogen/stress.c +++ b/lib/neatogen/stress.c @@ -1166,12 +1166,11 @@ int stress_majorization_kD_mkernel(vtx_data * graph, /* Input graph in sparse re /* put into 'dist_accumulator' all squared distances between 'i' and 'i'+1,...,'n'-1 */ for (k = 0; k < dim; k++) { - set_vector_valf(len, coords[k][i], tmp_coords); - vectors_mult_additionf(len, tmp_coords, -1, - coords[k] + i + 1); - square_vec(len, tmp_coords); - vectors_additionf(len, tmp_coords, dist_accumulator, - dist_accumulator); + size_t x; + for (x = 0; x < (size_t)len; ++x) { + float tmp = coords[k][i] + -1.0f * (coords[k] + i + 1)[x]; + dist_accumulator[x] += tmp * tmp; + } } /* convert to 1/d_{ij} */