From patchwork Tue Aug 22 10:16:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 136495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp3526085vqi; Tue, 22 Aug 2023 03:17:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHt4oU45dcGAjZxcNpH7CrrzrUuMF032kiYkD83IxhE8LkCxKwQpPZ3xK9272MZPw3MdXT X-Received: by 2002:a05:6512:110d:b0:4f8:5f32:b1da with SMTP id l13-20020a056512110d00b004f85f32b1damr8196174lfg.24.1692699448385; Tue, 22 Aug 2023 03:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692699448; cv=none; d=google.com; s=arc-20160816; b=g6pX6Z8sH0o5duJv+s2B48Qmo+w8ARWFs/valieupMSSvIfZBC08aMhGnpokUVJaVe N3MVjGRES5he1S2i4l8SsNaaQy9BAmWQ8pAhufMryZMmONaGeeTPb3lztOavZy2EA5uN jXba6NXrMIWu1AsDItwQBY3VGFWb0a9z7cfRt6uCxyaoFQF9o9oEp8B8e2MCllRrg6HZ SHLAHB4csifdXIz60bgwsNAMCH2okHu7BBB0GJv9Reo08zvq5KDgY19Fuvc02vbf8GL9 Pl0WPXumvLMv7rLt/D2DvalcB8Y2lvqyySatdfrIEkwPNO+TGoaDs5YS8pj2rbMDtnR9 CEwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:from:to :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=gA99IFC0uM0KtKwH8QStVCTNy/pj6UmGibCd3fm+O9g=; fh=ns1UzEDi6lVRp4Cy0Cg+LAgi9hmPeILmbiDmqMkXS/k=; b=dwvn/4RdByVftYnCA29EA0sFG6nAN7kbQxXZceJvOhfl6yOHmMHkR0h60Qv1zJL3TK 9MvNtB1DgwIRdJOKDgOr07TOOuhvEMUYPstdYGceKIOytRmKhEPO4mYNpDZqubMIZOfv 29v7vDkpKm+cmHe0kXRrlMHs9Xt6G196IdbVRrzPxSB2SpTdeGr7GZ3U0NEn7/kA+E3x 9/o1EsQrE80aY1xY5mlwLSj/bh8haHLaZs5O4KQvTSZfZrcHCZMbaYBc9vPWrDeI0Qhd rHIT1uJ3QCEkvwwnClLQP9ipSAdZTAoJaHR29AmRDNGo+R1+d/NUQ9aoyPzk13TXlxtm J8Bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bm6-20020a0564020b0600b00525abcd51c2si7624404edb.555.2023.08.22.03.17.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 03:17:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C264838319C2 for ; Tue, 22 Aug 2023 10:17:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 8FF193858D28 for ; Tue, 22 Aug 2023 10:16:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8FF193858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="6.01,192,1684828800"; d="diff'?scan'208";a="17008050" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 22 Aug 2023 02:16:53 -0800 IronPort-SDR: 0PHmoZNdwDQNJYNNkQzOD+higQQEk9jfrj9gZMui1tu59OXwGrO1KbClLhWaWb/g8TMIbhKyEs B1IcDRZYazSlojbJzuu1UHb0TLebgIHnYirRUWY9+Ekb9xhBP2sOLEHcETy+W7FJj+4hyeniMK 7WCIG5SIJ5xW8PbT+Y5sYHO1ONH4u5qMfO/4+bJcERhJCHrGAvJkTg0RRSgVjWAA29e4NPMF59 z9TX7q58GkHuhqtLKzPJMBNvY7Kua7DRK7zB0Z8SS2xd18aSVtU1TRDfsK34mrQSLtmjy2pA3O mw0= Message-ID: <27594869-f89b-e9c2-828e-dfa143f36e2e@codesourcery.com> Date: Tue, 22 Aug 2023 12:16:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: en-US To: Jakub Jelinek , gcc-patches From: Tobias Burnus Subject: [patch] libgomp.c/simd-math-1.c: Test scalb{, l}n{, f} and un-XFAIL for non-nvptx/amdgcn X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774924016999506404 X-GMAIL-MSGID: 1774924016999506404 As mentioned in the 'libgomp, testsuite: Do not call nonstandard functions on darwin' thread: * scalb was deprecated then deleted in POSIX in favor of scalbn{,f} and scalbln{,f} which take an int or long, respectively, instead of double for the 'exp' argument of 'x * FLT_RADIX ** exp'. It makes sense to test the standard version alongside the deprecated one, especially on systems which don't have the nonstandard function. * The testcase unconditionally used an XFAIL version in the tgamma{,f} test, but the comment indicated that it is only needed for newlib; hence, the XFAIL macro variant is now only used for nvptx and amdgcn. Jakub: Do those changes look good to you? Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 libgomp.c/simd-math-1.c: Test scalb{,l}n{,f} and un-XFAIL for non-nvptx/amdgcn libgomp/ChangeLog: * testsuite/libgomp.c/simd-math-1.c (TEST_FUN2INT): New. (main): Also test __builtin_scalb{,l}n{,f}. Only TEST_FUN_XFAIL tgamma{,f} for nvptx and amdgcn and use TEST_FUN for all other targets. libgomp/testsuite/libgomp.c/simd-math-1.c | 55 +++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/libgomp/testsuite/libgomp.c/simd-math-1.c b/libgomp/testsuite/libgomp.c/simd-math-1.c index dd2077cc597..151698cc7a1 100644 --- a/libgomp/testsuite/libgomp.c/simd-math-1.c +++ b/libgomp/testsuite/libgomp.c/simd-math-1.c @@ -5,6 +5,9 @@ /* { dg-options "-O2 -ftree-vectorize -fno-math-errno" } */ /* { dg-additional-options -foffload-options=amdgcn-amdhsa=-mstack-size=3000000 { target offload_target_amdgcn } } */ +/* Newlib's version of tgammaf is known to have poor accuracy. */ +/* { dg-additional-options "-DXFAIL_TGAMMA=1" { target { nvptx*-*-* amdgcn*-*-* } } } */ + #undef PRINT_RESULT #define VERBOSE 0 #define EARLY_EXIT 1 @@ -144,6 +147,42 @@ void test_##FUN (void) \ }\ test_##FUN (); +#define TEST_FUN2INT(TFLOAT, LOW1, HIGH1, TINT, LOW2, HIGH2, FUN) \ +__attribute__((optimize("no-tree-vectorize"))) \ +__attribute__((optimize("no-unsafe-math-optimizations"))) \ +void check_##FUN (TFLOAT res[N], TFLOAT a[N], TINT b[N]) \ +{ \ + int failed = 0; \ + for (int i = 0; i < N; i++) { \ + TFLOAT expected = FUN (a[i], b[i]); \ + TFLOAT diff = __builtin_fabs (expected - res[i]); \ + int deviation = deviation_##TFLOAT (expected, res[i]); \ + int fail = isnan (res[i]) != isnan (expected) \ + || isinf (res[i]) != isinf (expected) \ + || (diff > EPSILON_##TFLOAT && deviation > 10); \ + failed |= fail; \ + if (VERBOSE || fail) \ + PRINTF (#FUN "(%f,%ld) = %f, expected = %f, diff = %f, deviation = %d %s\n", \ + a[i], (long) b[i], res[i], expected, diff, deviation, fail ? "(!)" : ""); \ + if (EARLY_EXIT && fail) \ + exit (1); \ + } \ +} \ +void test_##FUN (void) \ +{ \ + TFLOAT res[N], a[N]; \ + TINT b[N]; \ + for (int i = 0; i < N; i++) { \ + a[i] = LOW1 + ((HIGH1 - LOW1) / N) * i; \ + b[i] = LOW1 + (i * (HIGH1 - LOW1)) / N; \ + } \ + _Pragma ("omp target parallel for simd map(to:a) map(from:res)") \ + for (int i = 0; i < N; i++) \ + res[i] = FUN (a[i], b[i]); \ + check_##FUN (res, a, b); \ +}\ +test_##FUN (); + int main (void) { TEST_FUN (float, -1.1, 1.1, acosf); @@ -169,6 +208,8 @@ int main (void) TEST_FUN2 (float, -100.0, 100.0, 100.0, -100.0, powf); TEST_FUN2 (float, -50.0, 100.0, -2.0, 40.0, remainderf); TEST_FUN (float, -50.0, 50.0, rintf); + TEST_FUN2INT (float, -50.0, 50.0, int, -10, 32, __builtin_scalbnf); + TEST_FUN2INT (float, -50.0, 50.0, long, -10L, 32L, __builtin_scalblnf); TEST_FUN2 (float, -50.0, 50.0, -10.0, 32.0, __builtin_scalbf); TEST_FUN (float, -10.0, 10.0, __builtin_significandf); TEST_FUN (float, -3.14159265359, 3.14159265359, sinf); @@ -176,8 +217,12 @@ int main (void) TEST_FUN (float, -0.1, 10000.0, sqrtf); TEST_FUN (float, -5.0, 5.0, tanf); TEST_FUN (float, -3.14159265359, 3.14159265359, tanhf); - /* Newlib's version of tgammaf is known to have poor accuracy. */ + +#ifdef XFAIL_TGAMMA TEST_FUN_XFAIL (float, -10.0, 10.0, tgammaf); +#else + TEST_FUN (float, -10.0, 10.0, tgammaf); +#endif TEST_FUN (double, -1.1, 1.1, acos); TEST_FUN (double, -10, 10, acosh); @@ -202,6 +247,8 @@ int main (void) TEST_FUN2 (double, -100.0, 100.0, 100.0, -100.0, pow); TEST_FUN2 (double, -50.0, 100.0, -2.0, 40.0, remainder); TEST_FUN (double, -50.0, 50.0, rint); + TEST_FUN2INT (double, -50.0, 50.0, int, -10, 32, __builtin_scalbn); + TEST_FUN2INT (double, -50.0, 50.0, long, -10, 32, __builtin_scalbln); TEST_FUN2 (double, -50.0, 50.0, -10.0, 32.0, __builtin_scalb); TEST_FUN (double, -10.0, 10.0, __builtin_significand); TEST_FUN (double, -3.14159265359, 3.14159265359, sin); @@ -209,8 +256,12 @@ int main (void) TEST_FUN (double, -0.1, 10000.0, sqrt); TEST_FUN (double, -5.0, 5.0, tan); TEST_FUN (double, -3.14159265359, 3.14159265359, tanh); - /* Newlib's version of tgamma is known to have poor accuracy. */ + +#ifdef XFAIL_TGAMMA TEST_FUN_XFAIL (double, -10.0, 10.0, tgamma); +#else + TEST_FUN (double, -10.0, 10.0, tgamma); +#endif return failed; }