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: 1824067 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RVQJ66m4Wz1ybW for ; Tue, 22 Aug 2023 20:17:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D46693854803 for ; Tue, 22 Aug 2023 10:17:08 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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; }