From patchwork Tue Sep 29 21:55:40 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 50612 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8TLvHwZ010865 for ; Tue, 29 Sep 2009 21:57:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751510AbZI2V5M (ORCPT ); Tue, 29 Sep 2009 17:57:12 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751657AbZI2V5M (ORCPT ); Tue, 29 Sep 2009 17:57:12 -0400 Received: from qmta02.westchester.pa.mail.comcast.net ([76.96.62.24]:35254 "EHLO QMTA02.westchester.pa.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751510AbZI2V5M (ORCPT ); Tue, 29 Sep 2009 17:57:12 -0400 Received: from OMTA08.westchester.pa.mail.comcast.net ([76.96.62.12]) by QMTA02.westchester.pa.mail.comcast.net with comcast id mbxi1c0070Fqzac52lxGdT; Tue, 29 Sep 2009 21:57:16 +0000 Received: from hal.comcast.net ([75.69.247.31]) by OMTA08.westchester.pa.mail.comcast.net with comcast id mlxG1c00F0hNrtn3UlxGbR; Tue, 29 Sep 2009 21:57:16 +0000 Received: from hal.comcast.net (localhost.localdomain [127.0.0.1]) by hal.comcast.net (8.14.3/8.14.3) with ESMTP id n8TLuBcG028669; Tue, 29 Sep 2009 17:56:16 -0400 Received: (from hnrose@localhost) by hal.comcast.net (8.14.3/8.14.3/Submit) id n8TLteUH028640; Tue, 29 Sep 2009 17:55:40 -0400 Date: Tue, 29 Sep 2009 17:55:40 -0400 From: Hal Rosenstock To: linux-rdma@vger.kernel.org Subject: [PATCHv2] opensm/osm_mesh.c: Add dump_mesh routine at OSM_LOG_DEBUG level Message-ID: <20090929215540.GA28635@comcast.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/opensm/opensm/osm_mesh.c b/opensm/opensm/osm_mesh.c index 260e2f8..53f0f58 100644 --- a/opensm/opensm/osm_mesh.c +++ b/opensm/opensm/osm_mesh.c @@ -1565,6 +1565,63 @@ err: return -1; } +static void dump_mesh(lash_t *p_lash) +{ + osm_log_t *p_log = &p_lash->p_osm->log; + int sw; + int num_switches = p_lash->num_switches; + int dimension; + int i, j, k, n; + switch_t *s, *s2; + char buf[256]; + + OSM_LOG_ENTER(p_log); + + for (sw = 0; sw < num_switches; sw++) { + s = p_lash->switches[sw]; + dimension = s->node->dimension; + n = sprintf(buf, "["); + for (i = 0; i < dimension; i++) { + n += snprintf(buf + n, sizeof(buf) - n, + "%2d", s->node->coord[i]); + if (n > sizeof(buf)) + n = sizeof(buf); + if (i != dimension - 1) { + n += snprintf(buf + n, sizeof(buf) - n, "%s", ","); + if (n > sizeof(buf)) + n = sizeof(buf); + } + } + n += snprintf(buf + n, sizeof(buf) - n, "]"); + if (n > sizeof(buf)) + n = sizeof(buf); + for (j = 0; j < s->node->num_links; j++) { + s2 = p_lash->switches[s->node->links[j]->switch_id]; + n += snprintf(buf + n, sizeof(buf) - n, " [%d]->[", j); + if (n > sizeof(buf)) + n = sizeof(buf); + for (k = 0; k < dimension; k++) { + n += snprintf(buf + n, sizeof(buf) - n, "%2d", + s2->node->coord[k]); + if (n > sizeof(buf)) + n = sizeof(buf); + if (k != dimension - 1) { + n += snprintf(buf + n, sizeof(buf) - n, + ","); + if (n > sizeof(buf)) + n = sizeof(buf); + } + } + n += snprintf(buf + n, sizeof(buf) - n, "]"); + if (n > sizeof(buf)) + n = sizeof(buf); + } + OSM_LOG(p_log, OSM_LOG_DEBUG, "%s\n", buf); + } + + OSM_LOG_EXIT(p_log); +} + /* * osm_do_mesh_analysis */ @@ -1653,6 +1710,9 @@ int osm_do_mesh_analysis(lash_t *p_lash) OSM_LOG(p_log, OSM_LOG_INFO, "%s", buf); } + if (osm_log_is_active(p_log, OSM_LOG_DEBUG)) + dump_mesh(p_lash); + done: mesh_delete(mesh); OSM_LOG_EXIT(p_log);