From: Mathieu Desnoyers Date: Thu, 6 Jun 2013 15:59:16 +0000 (-0400) Subject: rcuja: 2d distribution sum improvement X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7f14b43af6d0ae0f3201c2cb8cfae80eb74f0d17;p=userspace-rcu.git rcuja: 2d distribution sum improvement Perform inner loop in 2 checks instead of 4. Signed-off-by: Mathieu Desnoyers --- diff --git a/rcuja/rcuja.c b/rcuja/rcuja.c index c609595..a608dd7 100644 --- a/rcuja/rcuja.c +++ b/rcuja/rcuja.c @@ -1091,17 +1091,18 @@ void ja_node_sum_distribution_2d(enum ja_recompact mode, continue; for (bit_i = 0; bit_i < JA_BITS_PER_BYTE; bit_i++) { for (bit_j = 0; bit_j < bit_i; bit_j++) { - if ((v & (1U << bit_i)) && (v & (1U << bit_j))) { - nr_2d_11[bit_i][bit_j]++; - } - if ((v & (1U << bit_i)) && !(v & (1U << bit_j))) { - nr_2d_10[bit_i][bit_j]++; - } - if (!(v & (1U << bit_i)) && (v & (1U << bit_j))) { - nr_2d_01[bit_i][bit_j]++; - } - if (!(v & (1U << bit_i)) && !(v & (1U << bit_j))) { - nr_2d_00[bit_i][bit_j]++; + if (v & (1U << bit_i)) { + if (v & (1U << bit_j)) { + nr_2d_11[bit_i][bit_j]++; + } else { + nr_2d_10[bit_i][bit_j]++; + } + } else { + if (v & (1U << bit_j)) { + nr_2d_01[bit_i][bit_j]++; + } else { + nr_2d_00[bit_i][bit_j]++; + } } } } @@ -1133,17 +1134,18 @@ void ja_node_sum_distribution_2d(enum ja_recompact mode, continue; for (bit_i = 0; bit_i < JA_BITS_PER_BYTE; bit_i++) { for (bit_j = 0; bit_j < bit_i; bit_j++) { - if ((v & (1U << bit_i)) && (v & (1U << bit_j))) { - nr_2d_11[bit_i][bit_j]++; - } - if ((v & (1U << bit_i)) && !(v & (1U << bit_j))) { - nr_2d_10[bit_i][bit_j]++; - } - if (!(v & (1U << bit_i)) && (v & (1U << bit_j))) { - nr_2d_01[bit_i][bit_j]++; - } - if (!(v & (1U << bit_i)) && !(v & (1U << bit_j))) { - nr_2d_00[bit_i][bit_j]++; + if (v & (1U << bit_i)) { + if (v & (1U << bit_j)) { + nr_2d_11[bit_i][bit_j]++; + } else { + nr_2d_10[bit_i][bit_j]++; + } + } else { + if (v & (1U << bit_j)) { + nr_2d_01[bit_i][bit_j]++; + } else { + nr_2d_00[bit_i][bit_j]++; + } } } } @@ -1167,17 +1169,18 @@ void ja_node_sum_distribution_2d(enum ja_recompact mode, continue; for (bit_i = 0; bit_i < JA_BITS_PER_BYTE; bit_i++) { for (bit_j = 0; bit_j < bit_i; bit_j++) { - if ((i & (1U << bit_i)) && (i & (1U << bit_j))) { - nr_2d_11[bit_i][bit_j]++; - } - if ((i & (1U << bit_i)) && !(i & (1U << bit_j))) { - nr_2d_10[bit_i][bit_j]++; - } - if (!(i & (1U << bit_i)) && (i & (1U << bit_j))) { - nr_2d_01[bit_i][bit_j]++; - } - if (!(i & (1U << bit_i)) && !(i & (1U << bit_j))) { - nr_2d_00[bit_i][bit_j]++; + if (i & (1U << bit_i)) { + if (i & (1U << bit_j)) { + nr_2d_11[bit_i][bit_j]++; + } else { + nr_2d_10[bit_i][bit_j]++; + } + } else { + if (i & (1U << bit_j)) { + nr_2d_01[bit_i][bit_j]++; + } else { + nr_2d_00[bit_i][bit_j]++; + } } } } @@ -1196,17 +1199,18 @@ void ja_node_sum_distribution_2d(enum ja_recompact mode, if (mode == JA_RECOMPACT_ADD_NEXT || mode == JA_RECOMPACT_ADD_SAME) { for (bit_i = 0; bit_i < JA_BITS_PER_BYTE; bit_i++) { for (bit_j = 0; bit_j < bit_i; bit_j++) { - if ((n & (1U << bit_i)) && (n & (1U << bit_j))) { - nr_2d_11[bit_i][bit_j]++; - } - if ((n & (1U << bit_i)) && !(n & (1U << bit_j))) { - nr_2d_10[bit_i][bit_j]++; - } - if (!(n & (1U << bit_i)) && (n & (1U << bit_j))) { - nr_2d_01[bit_i][bit_j]++; - } - if (!(n & (1U << bit_i)) && !(n & (1U << bit_j))) { - nr_2d_00[bit_i][bit_j]++; + if (n & (1U << bit_i)) { + if (n & (1U << bit_j)) { + nr_2d_11[bit_i][bit_j]++; + } else { + nr_2d_10[bit_i][bit_j]++; + } + } else { + if (n & (1U << bit_j)) { + nr_2d_01[bit_i][bit_j]++; + } else { + nr_2d_00[bit_i][bit_j]++; + } } } }