From patchwork Thu Oct 18 15:28:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10647517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 51C1C15E2 for ; Thu, 18 Oct 2018 15:29:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44D7428C76 for ; Thu, 18 Oct 2018 15:29:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3999228DB0; Thu, 18 Oct 2018 15:29:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA1EF28C76 for ; Thu, 18 Oct 2018 15:29:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 53CBB6E0AE; Thu, 18 Oct 2018 15:28:42 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0EA836E00E for ; Thu, 18 Oct 2018 15:28:34 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id 193-v6so743425wme.3 for ; Thu, 18 Oct 2018 08:28:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FKNnijBCogBjwARsSAFqkZlxMQLld3MIdgnPvq6X//s=; b=mp0jyU6qhr8byJU98OWF2+o4lnyCio4WdUYMe+lNXPDN7V9b4Efz2eOjABA1Vm/ZWe LwesT+cmVVo6ntjgB8AkpJ9j8pSpXmOtON4y/MU4lp2ssSeWCe2FdslUYVFJY/BDdOnS ji7MI8qutP1D5xmC8e/mXrsf4Jk2i2gBNNUKU/HP5IVCVLQ3LIhzrZN9rzlB/jocFRNj wmH2y+5iVMrgcNMUWz9X7+n7k3E/8FPde6BKNTYtKvj76T1fk5y0QhM1qYrxhcNHtq6P WayInp/cE/X6k42g8gCJnKmiV6QVE0efxycwLj5aeC2jg4Iq/B7gpHROS9fzfg4lpFTM t2Ug== X-Gm-Message-State: ABuFfoheG6UGUWxL01jdBeCYMv6dqkja7qqb6SKHP6b9ljgaReEmrF7q zwGa6Qr+2b6ifU5OPbajXqHWWQ== X-Google-Smtp-Source: ACcGV61oYPFiXbJ7NWNL3C5c4JXybjcDnOiRCETHKvLbhp4oqFmdg9GCHmfA5nvsqNGyGI9LnyN4cw== X-Received: by 2002:a1c:f003:: with SMTP id a3-v6mr852368wmb.50.1539876512632; Thu, 18 Oct 2018 08:28:32 -0700 (PDT) Received: from localhost.localdomain ([91.110.193.16]) by smtp.gmail.com with ESMTPSA id i6-v6sm19530387wrq.4.2018.10.18.08.28.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 08:28:32 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Thu, 18 Oct 2018 16:28:08 +0100 Message-Id: <20181018152815.31816-11-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181018152815.31816-1-tvrtko.ursulin@linux.intel.com> References: <20181018152815.31816-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH i-g-t 10/17] gem_wsim: Extract str to engine lookup X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Signed-off-by: Tvrtko Ursulin --- benchmarks/gem_wsim.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c index a77a322ee309..17325d2ceaf6 100644 --- a/benchmarks/gem_wsim.c +++ b/benchmarks/gem_wsim.c @@ -319,6 +319,18 @@ wsim_err(const char *fmt, ...) } \ } +static int str_to_engine(const char *str) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(ring_str_map); i++) { + if (!strcasecmp(str, ring_str_map[i])) + return i; + } + + return -1; +} + static struct workload * parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) { @@ -473,22 +485,18 @@ parse_workload(struct w_arg *arg, unsigned int flags, struct workload *app_w) } if ((field = strtok_r(fstart, ".", &fctx)) != NULL) { - unsigned int old_valid = valid; - fstart = NULL; - for (i = 0; i < ARRAY_SIZE(ring_str_map); i++) { - if (!strcasecmp(field, ring_str_map[i])) { - step.engine = i; - if (step.engine == BCS) - bcs_used = true; - valid++; - break; - } - } - - check_arg(old_valid == valid, + i = str_to_engine(field); + check_arg(i < 0, "Invalid engine id at step %u!\n", nr_steps); + if (i >= 0) + valid++; + + step.engine = i; + + if (step.engine == BCS) + bcs_used = true; } if ((field = strtok_r(fstart, ".", &fctx)) != NULL) {