From patchwork Tue Feb 16 16:16:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Schutt X-Patchwork-Id: 79741 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1GGH0i3015342 for ; Tue, 16 Feb 2010 16:17:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757189Ab0BPQRB (ORCPT ); Tue, 16 Feb 2010 11:17:01 -0500 Received: from sentry-three.sandia.gov ([132.175.109.17]:59490 "EHLO sentry-three.sandia.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756888Ab0BPQQ6 (ORCPT ); Tue, 16 Feb 2010 11:16:58 -0500 X-WSS-ID: 0KXXZWA-08-3II-02 X-M-MSG: Received: from sentry.sandia.gov (mm04snlnto.sandia.gov [132.175.109.21]) by sentry-three.sandia.gov (Postfix) with ESMTP id 213E08CB9B8; Tue, 16 Feb 2010 09:16:58 -0700 (MST) Received: from [132.175.109.1] by sentry.sandia.gov with ESMTP (SMTP Relay 01 (Email Firewall v6.3.2)); Tue, 16 Feb 2010 09:16:47 -0700 X-Server-Uuid: AF72F651-81B1-4134-BA8C-A8E1A4E620FF Received: from localhost.localdomain (sale659.sandia.gov [134.253.4.20]) by mailgate.sandia.gov (8.14.1/8.14.1) with ESMTP id o1GGGjkK001176; Tue, 16 Feb 2010 09:16:46 -0700 From: "Jim Schutt" To: linux-rdma@vger.kernel.org cc: sashak@voltaire.com, eitan@mellanox.co.il, kliteyn@mellanox.co.il, jaschut@sandia.gov Subject: [PATCH 2/3] opensm: Fix handling of torus-2QoS topology discovery for radix 4 torus dimensions. Date: Tue, 16 Feb 2010 09:16:44 -0700 Message-ID: <1266337005-29874-3-git-send-email-jaschut@sandia.gov> X-Mailer: git-send-email 1.5.6.GIT In-Reply-To: <1261169461-2516-1-git-send-email-jaschut@sandia.gov> References: <1261169461-2516-1-git-send-email-jaschut@sandia.gov> X-PMX-Version: 5.5.7.378829, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2010.2.16.160618 X-PerlMx-Spam: Gauge=IIIIIIII, Probability=8%, Report=' BODY_SIZE_10000_PLUS 0, TO_NO_NAME 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __URI_NS ' X-TMWD-Spam-Summary: TS=20100216161647; ID=1; SEV=2.3.1; DFV=B2010021615; IFV=NA; AIF=B2010021615; RPD=5.03.0010; ENG=NA; RPDID=7374723D303030312E30413031303230352E34423741433445462E303141363A534346535441543838363133332C73733D312C6667733D30; CAT=NONE; CON=NONE; SIG=AAAAAAAAAAAAAAAAAAAAAAAAfQ== X-MMS-Spam-Filter-ID: B2010021615_5.03.0010 MIME-Version: 1.0 X-WSS-ID: 67641B652EK684198-01-01 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 16 Feb 2010 16:17:03 +0000 (UTC) diff --git a/opensm/opensm/osm_ucast_torus.c b/opensm/opensm/osm_ucast_torus.c index 728e56c..ab0e6a6 100644 --- a/opensm/opensm/osm_ucast_torus.c +++ b/opensm/opensm/osm_ucast_torus.c @@ -1956,38 +1956,16 @@ struct f_switch *tfind_2d_perpendicular(struct t_switch *tsw0, return ffind_2d_perpendicular(tsw0->tmp, tsw1->tmp, tsw2->tmp); } -/* - * These functions return true when it safe to call - * tfind_3d_perpendicular()/ffind_3d_perpendicular(). - */ static -bool safe_x_perpendicular(struct torus *t, int i, int j, int k) +bool safe_x_ring(struct torus *t, int i, int j, int k) { - int jm1, jp1, jp2, km1, kp1, kp2; - - /* - * If the dimensions perpendicular to the search direction are - * not radix 4 torus dimensions, it is always safe to search for - * a perpendicular. - */ - if ((t->y_sz != 4 && t->z_sz != 4) || - (t->flags & Y_MESH && t->flags & Z_MESH) || - (t->y_sz != 4 && (t->flags & Z_MESH)) || - (t->z_sz != 4 && (t->flags & Y_MESH))) - return true; - - jm1 = canonicalize(j - 1, t->y_sz); - jp1 = canonicalize(j + 1, t->y_sz); - jp2 = canonicalize(j + 2, t->y_sz); - - km1 = canonicalize(k - 1, t->z_sz); - kp1 = canonicalize(k + 1, t->z_sz); - kp2 = canonicalize(k + 2, t->z_sz); + int im1, ip1, ip2; + bool success = true; /* - * Here we are checking for enough appropriate links having been - * installed into the torus to prevent an incorrect link from being - * considered as a perpendicular candidate. + * If this x-direction radix-4 ring has at least two links + * already installed into the torus, then this ring does not + * prevent us from looking for y or z direction perpendiculars. * * It is easier to check for the appropriate switches being installed * into the torus than it is to check for the links, so force the @@ -1995,93 +1973,111 @@ bool safe_x_perpendicular(struct torus *t, int i, int j, int k) * * Recall that canonicalize(n - 2, 4) == canonicalize(n + 2, 4). */ - if (((!!t->sw[i][jm1][k] + - !!t->sw[i][jp1][k] + !!t->sw[i][jp2][k] >= 2) && - (!!t->sw[i][j][km1] + - !!t->sw[i][j][kp1] + !!t->sw[i][j][kp2] >= 2))) { - - bool success = true; - - if (t->sw[i][jp2][k] && t->sw[i][jm1][k]) - success = link_tswitches(t, 1, - t->sw[i][jp2][k], - t->sw[i][jm1][k]) - && success; - - if (t->sw[i][jm1][k] && t->sw[i][j][k]) - success = link_tswitches(t, 1, - t->sw[i][jm1][k], - t->sw[i][j][k]) - && success; - - if (t->sw[i][j][k] && t->sw[i][jp1][k]) - success = link_tswitches(t, 1, - t->sw[i][j][k], - t->sw[i][jp1][k]) - && success; - - if (t->sw[i][jp1][k] && t->sw[i][jp2][k]) - success = link_tswitches(t, 1, - t->sw[i][jp1][k], - t->sw[i][jp2][k]) - && success; - - if (t->sw[i][j][kp2] && t->sw[i][j][km1]) - success = link_tswitches(t, 2, - t->sw[i][j][kp2], - t->sw[i][j][km1]) - && success; - - if (t->sw[i][j][km1] && t->sw[i][j][k]) - success = link_tswitches(t, 2, - t->sw[i][j][km1], - t->sw[i][j][k]) - && success; - - if (t->sw[i][j][k] && t->sw[i][j][kp1]) - success = link_tswitches(t, 2, - t->sw[i][j][k], - t->sw[i][j][kp1]) - && success; - - if (t->sw[i][j][kp1] && t->sw[i][j][kp2]) - success = link_tswitches(t, 2, - t->sw[i][j][kp1], - t->sw[i][j][kp2]) - && success; - return success; + if (t->x_sz != 4 || t->flags & X_MESH) + goto out; + + im1 = canonicalize(i - 1, t->x_sz); + ip1 = canonicalize(i + 1, t->x_sz); + ip2 = canonicalize(i + 2, t->x_sz); + + if (!!t->sw[im1][j][k] + + !!t->sw[ip1][j][k] + !!t->sw[ip2][j][k] < 2) { + success = false; + goto out; } - return false; + if (t->sw[ip2][j][k] && t->sw[im1][j][k]) + success = link_tswitches(t, 0, + t->sw[ip2][j][k], + t->sw[im1][j][k]) + && success; + + if (t->sw[im1][j][k] && t->sw[i][j][k]) + success = link_tswitches(t, 0, + t->sw[im1][j][k], + t->sw[i][j][k]) + && success; + + if (t->sw[i][j][k] && t->sw[ip1][j][k]) + success = link_tswitches(t, 0, + t->sw[i][j][k], + t->sw[ip1][j][k]) + && success; + + if (t->sw[ip1][j][k] && t->sw[ip2][j][k]) + success = link_tswitches(t, 0, + t->sw[ip1][j][k], + t->sw[ip2][j][k]) + && success; +out: + return success; } static -bool safe_y_perpendicular(struct torus *t, int i, int j, int k) +bool safe_y_ring(struct torus *t, int i, int j, int k) { - int im1, ip1, ip2, km1, kp1, kp2; + int jm1, jp1, jp2; + bool success = true; /* - * If the dimensions perpendicular to the search direction are - * not radix 4 torus dimensions, it is always safe to search for - * a perpendicular. + * If this y-direction radix-4 ring has at least two links + * already installed into the torus, then this ring does not + * prevent us from looking for x or z direction perpendiculars. + * + * It is easier to check for the appropriate switches being installed + * into the torus than it is to check for the links, so force the + * link installation if the appropriate switches are installed. + * + * Recall that canonicalize(n - 2, 4) == canonicalize(n + 2, 4). */ - if ((t->x_sz != 4 && t->z_sz != 4) || - (t->flags & X_MESH && t->flags & Z_MESH) || - (t->x_sz != 4 && (t->flags & Z_MESH)) || - (t->z_sz != 4 && (t->flags & X_MESH))) - return true; + if (t->y_sz != 4 || (t->flags & Y_MESH)) + goto out; - im1 = canonicalize(i - 1, t->x_sz); - ip1 = canonicalize(i + 1, t->x_sz); - ip2 = canonicalize(i + 2, t->x_sz); + jm1 = canonicalize(j - 1, t->y_sz); + jp1 = canonicalize(j + 1, t->y_sz); + jp2 = canonicalize(j + 2, t->y_sz); - km1 = canonicalize(k - 1, t->z_sz); - kp1 = canonicalize(k + 1, t->z_sz); - kp2 = canonicalize(k + 2, t->z_sz); + if (!!t->sw[i][jm1][k] + + !!t->sw[i][jp1][k] + !!t->sw[i][jp2][k] < 2) { + success = false; + goto out; + } + if (t->sw[i][jp2][k] && t->sw[i][jm1][k]) + success = link_tswitches(t, 1, + t->sw[i][jp2][k], + t->sw[i][jm1][k]) + && success; + + if (t->sw[i][jm1][k] && t->sw[i][j][k]) + success = link_tswitches(t, 1, + t->sw[i][jm1][k], + t->sw[i][j][k]) + && success; + + if (t->sw[i][j][k] && t->sw[i][jp1][k]) + success = link_tswitches(t, 1, + t->sw[i][j][k], + t->sw[i][jp1][k]) + && success; + + if (t->sw[i][jp1][k] && t->sw[i][jp2][k]) + success = link_tswitches(t, 1, + t->sw[i][jp1][k], + t->sw[i][jp2][k]) + && success; +out: + return success; +} + +static +bool safe_z_ring(struct torus *t, int i, int j, int k) +{ + int km1, kp1, kp2; + bool success = true; /* - * Here we are checking for enough appropriate links having been - * installed into the torus to prevent an incorrect link from being - * considered as a perpendicular candidate. + * If this z-direction radix-4 ring has at least two links + * already installed into the torus, then this ring does not + * prevent us from looking for x or y direction perpendiculars. * * It is easier to check for the appropriate switches being installed * into the torus than it is to check for the links, so force the @@ -2089,157 +2085,92 @@ bool safe_y_perpendicular(struct torus *t, int i, int j, int k) * * Recall that canonicalize(n - 2, 4) == canonicalize(n + 2, 4). */ - if (((!!t->sw[im1][j][k] + - !!t->sw[ip1][j][k] + !!t->sw[ip2][j][k] >= 2) && - (!!t->sw[i][j][km1] + - !!t->sw[i][j][kp1] + !!t->sw[i][j][kp2] >= 2))) { - - bool success = true; - - if (t->sw[ip2][j][k] && t->sw[im1][j][k]) - success = link_tswitches(t, 0, - t->sw[ip2][j][k], - t->sw[im1][j][k]) - && success; - - if (t->sw[im1][j][k] && t->sw[i][j][k]) - success = link_tswitches(t, 0, - t->sw[im1][j][k], - t->sw[i][j][k]) - && success; - - if (t->sw[i][j][k] && t->sw[ip1][j][k]) - success = link_tswitches(t, 0, - t->sw[i][j][k], - t->sw[ip1][j][k]) - && success; - - if (t->sw[ip1][j][k] && t->sw[ip2][j][k]) - success = link_tswitches(t, 0, - t->sw[ip1][j][k], - t->sw[ip2][j][k]) - && success; - - if (t->sw[i][j][kp2] && t->sw[i][j][km1]) - success = link_tswitches(t, 2, - t->sw[i][j][kp2], - t->sw[i][j][km1]) - && success; - - if (t->sw[i][j][km1] && t->sw[i][j][k]) - success = link_tswitches(t, 2, - t->sw[i][j][km1], - t->sw[i][j][k]) - && success; - - if (t->sw[i][j][k] && t->sw[i][j][kp1]) - success = link_tswitches(t, 2, - t->sw[i][j][k], - t->sw[i][j][kp1]) - && success; - - if (t->sw[i][j][kp1] && t->sw[i][j][kp2]) - success = link_tswitches(t, 2, - t->sw[i][j][kp1], - t->sw[i][j][kp2]) - && success; - return success; + if (t->z_sz != 4 || t->flags & Z_MESH) + goto out; + + km1 = canonicalize(k - 1, t->z_sz); + kp1 = canonicalize(k + 1, t->z_sz); + kp2 = canonicalize(k + 2, t->z_sz); + + if (!!t->sw[i][j][km1] + + !!t->sw[i][j][kp1] + !!t->sw[i][j][kp2] < 2) { + success = false; + goto out; } - return false; + if (t->sw[i][j][kp2] && t->sw[i][j][km1]) + success = link_tswitches(t, 2, + t->sw[i][j][kp2], + t->sw[i][j][km1]) + && success; + + if (t->sw[i][j][km1] && t->sw[i][j][k]) + success = link_tswitches(t, 2, + t->sw[i][j][km1], + t->sw[i][j][k]) + && success; + + if (t->sw[i][j][k] && t->sw[i][j][kp1]) + success = link_tswitches(t, 2, + t->sw[i][j][k], + t->sw[i][j][kp1]) + && success; + + if (t->sw[i][j][kp1] && t->sw[i][j][kp2]) + success = link_tswitches(t, 2, + t->sw[i][j][kp1], + t->sw[i][j][kp2]) + && success; +out: + return success; } +/* + * These functions return true when it safe to call + * tfind_3d_perpendicular()/ffind_3d_perpendicular(). + */ static -bool safe_z_perpendicular(struct torus *t, int i, int j, int k) +bool safe_x_perpendicular(struct torus *t, int i, int j, int k) { - int im1, ip1, ip2, jm1, jp1, jp2; - /* * If the dimensions perpendicular to the search direction are * not radix 4 torus dimensions, it is always safe to search for * a perpendicular. + * + * Here we are checking for enough appropriate links having been + * installed into the torus to prevent an incorrect link from being + * considered as a perpendicular candidate. */ - if ((t->x_sz != 4 && t->y_sz != 4) || - (t->flags & X_MESH && t->flags & Y_MESH) || - (t->x_sz != 4 && (t->flags & Y_MESH)) || - (t->y_sz != 4 && (t->flags & X_MESH))) - return true; - - im1 = canonicalize(i - 1, t->x_sz); - ip1 = canonicalize(i + 1, t->x_sz); - ip2 = canonicalize(i + 2, t->x_sz); - - jm1 = canonicalize(j - 1, t->y_sz); - jp1 = canonicalize(j + 1, t->y_sz); - jp2 = canonicalize(j + 2, t->y_sz); + return safe_y_ring(t, i, j, k) && safe_z_ring(t, i, j, k); +} +static +bool safe_y_perpendicular(struct torus *t, int i, int j, int k) +{ /* + * If the dimensions perpendicular to the search direction are + * not radix 4 torus dimensions, it is always safe to search for + * a perpendicular. + * * Here we are checking for enough appropriate links having been * installed into the torus to prevent an incorrect link from being * considered as a perpendicular candidate. + */ + return safe_x_ring(t, i, j, k) && safe_z_ring(t, i, j, k); +} + +static +bool safe_z_perpendicular(struct torus *t, int i, int j, int k) +{ + /* + * If the dimensions perpendicular to the search direction are + * not radix 4 torus dimensions, it is always safe to search for + * a perpendicular. * - * It is easier to check for the appropriate switches being installed - * into the torus than it is to check for the links, so force the - * link installation if the appropriate switches are installed. - * - * Recall that canonicalize(n - 2, 4) == canonicalize(n + 2, 4). + * Implement this by checking for enough appropriate links having + * been installed into the torus to prevent an incorrect link from + * being considered as a perpendicular candidate. */ - if (((!!t->sw[im1][j][k] + - !!t->sw[ip1][j][k] + !!t->sw[ip2][j][k] >= 2) && - (!!t->sw[i][jm1][k] + - !!t->sw[i][jp1][k] + !!t->sw[i][jp2][k] >= 2))) { - - bool success = true; - - if (t->sw[ip2][j][k] && t->sw[im1][j][k]) - success = link_tswitches(t, 0, - t->sw[ip2][j][k], - t->sw[im1][j][k]) - && success; - - if (t->sw[im1][j][k] && t->sw[i][j][k]) - success = link_tswitches(t, 0, - t->sw[im1][j][k], - t->sw[i][j][k]) - && success; - - if (t->sw[i][j][k] && t->sw[ip1][j][k]) - success = link_tswitches(t, 0, - t->sw[i][j][k], - t->sw[ip1][j][k]) - && success; - - if (t->sw[ip1][j][k] && t->sw[ip2][j][k]) - success = link_tswitches(t, 0, - t->sw[ip1][j][k], - t->sw[ip2][j][k]) - && success; - - if (t->sw[i][jp2][k] && t->sw[i][jm1][k]) - success = link_tswitches(t, 1, - t->sw[i][jp2][k], - t->sw[i][jm1][k]) - && success; - - if (t->sw[i][jm1][k] && t->sw[i][j][k]) - success = link_tswitches(t, 1, - t->sw[i][jm1][k], - t->sw[i][j][k]) - && success; - - if (t->sw[i][j][k] && t->sw[i][jp1][k]) - success = link_tswitches(t, 1, - t->sw[i][j][k], - t->sw[i][jp1][k]) - && success; - - if (t->sw[i][jp1][k] && t->sw[i][jp2][k]) - success = link_tswitches(t, 1, - t->sw[i][jp1][k], - t->sw[i][jp2][k]) - && success; - return true; - } - return false; + return safe_x_ring(t, i, j, k) && safe_y_ring(t, i, j, k); } /*