From patchwork Tue Oct 2 06:04:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 977650 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42PTP10DlMz9sCw for ; Tue, 2 Oct 2018 16:13:41 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="ZLGcLSpq"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42PTP05MkmzF3Df for ; Tue, 2 Oct 2018 16:13:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="ZLGcLSpq"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42PTBc5G5fzF3Bw for ; Tue, 2 Oct 2018 16:04:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="ZLGcLSpq"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42PTBc2Q6Xz9shx; Tue, 2 Oct 2018 16:04:40 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1538460280; bh=sVguDMudUbIBDfJG8rRs6RQG5EKxXNaLE+8LdcTSYhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZLGcLSpq131N0Rxr63QY8FgWG5jDlcW+NaXeVwQrqLHqnIRamqOnxYCH1+Bd8mpG8 2vlCWI9bOxi0RrWg+TYCYPTFvEcjft4qv07kFPRsOaQ/WqfLfiRdoevsHAq5k0LWxU VJmRZAraXmZOLJqHzOG8UO+wBNq9aK7hVgZCwz1F/MYR5sO5XM9+Sigiwd2EV6m0UI Y9p9xbLW23O9e8iV/vcEThSblolzuBZeaPDZEhqQhLRRj9aAhzrVZVlLk6nrYRyNDQ xogCn+CM34zjmTcnX39e7IJBsI+q0o9peU4+9ASTaVt44DGUwOl53Felb4LS1jtjoz 8h/BwNg809eUg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 2 Oct 2018 16:04:27 +1000 Message-Id: <20181002060430.3344784-7-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002060430.3344784-1-amitay@ozlabs.org> References: <20181002060430.3344784-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 06/10] main: Convert -p/-c/-t/-a/-l to path based targets X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/main.c | 72 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/src/main.c b/src/main.c index d57ce71..38cd0ea 100644 --- a/src/main.c +++ b/src/main.c @@ -277,6 +277,26 @@ static bool pathsel_add(char *format, ...) return true; } +static bool list_to_string(int *list, int max, char *str, size_t len) +{ + char tmp[16]; + int i; + + memset(str, 0, len); + + for (i=0; i len) { + return false; + } + strcat(str, tmp); + } + } + + return true; +} + static bool parse_options(int argc, char *argv[]) { int c; @@ -286,7 +306,7 @@ static bool parse_options(int argc, char *argv[]) int t_list[MAX_THREADS]; int l_list[MAX_LINUX_CPUS]; int p_count = 0, c_count = 0, t_count = 0, l_count = 0; - int i, j, k; + int i; struct option long_opts[] = { {"all", no_argument, NULL, 'a'}, {"backend", required_argument, NULL, 'b'}, @@ -306,6 +326,7 @@ static bool parse_options(int argc, char *argv[]) {NULL, 0, NULL, 0} }; char *endptr; + char p_str[256], c_str[256], t_str[256]; memset(p_list, 0, sizeof(p_list)); memset(c_list, 0, sizeof(c_list)); @@ -434,6 +455,16 @@ static bool parse_options(int argc, char *argv[]) return false; } + if (pathsel_count > 0 && l_count > 0) { + fprintf(stderr, "Can't mix -l with -P\n"); + return false; + } + + if ((c_count > 0 || t_count > 0 || p_count > 0) && (pathsel_count > 0)) { + fprintf(stderr, "Can't mix -P with -p/-c/-t/-a\n"); + return false; + } + if ((c_count > 0 || t_count > 0) && p_count == 0) { fprintf(stderr, "No processor(s) selected\n"); fprintf(stderr, "Use -p or -a to select processor(s)\n"); @@ -446,25 +477,27 @@ static bool parse_options(int argc, char *argv[]) return false; } - for (i = 0; i < MAX_PROCESSORS; i++) { - if (p_list[i] == 0) - continue; - - processorsel[i] = &chipsel[i][0]; - - for (j = 0; j < MAX_CHIPS; j++) { - if (c_list[j] == 0) - continue; + if (p_count) + if (!list_to_string(p_list, MAX_PROCESSORS, p_str, sizeof(p_str))) + return false; - chipsel[i][j] = &threadsel[i][j][0]; + if (c_count) + if (!list_to_string(c_list, MAX_CHIPS, c_str, sizeof(c_str))) + return false; - for (k = 0; k < MAX_THREADS; k++) { - if (t_list[k] == 0) - continue; + if (t_count) + if (!list_to_string(t_list, MAX_THREADS, t_str, sizeof(t_str))) + return false; - threadsel[i][j][k] = 1; - } - } + if (t_count) { + if (!pathsel_add("pib[%s]/core[%s]/thread[%s]", p_str, c_str, t_str)) + return false; + } else if (c_count) { + if (!pathsel_add("pib[%s]/core[%s]", p_str, c_str)) + return false; + } else if (p_count) { + if (!pathsel_add("pib[%s]", p_str)) + return false; } if (l_count) { @@ -478,9 +511,8 @@ static bool parse_options(int argc, char *argv[]) pir_map(pir, &chip, &core, &thread); - processorsel[chip] = &chipsel[chip][0]; - chipsel[chip][core] = &threadsel[chip][core][0]; - threadsel[chip][core][thread] = 1; + if (!pathsel_add("pib%d/core%d/thread%d", chip, core, thread)) + return false; } } }