From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 105776 invoked by alias); 7 Jul 2015 12:36:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 105759 invoked by uid 89); 7 Jul 2015 12:36:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 Jul 2015 12:35:59 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-11-FmSojLgKR3mdNR6xBXcgrw-1 Received: from [10.2.207.65] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 7 Jul 2015 13:35:53 +0100 Message-ID: <559BC7A9.3080107@arm.com> Date: Tue, 07 Jul 2015 12:36:00 -0000 From: Alan Lawrence User-Agent: Thunderbird 2.0.0.24 (X11/20101213) MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" Subject: [PATCH 8/16][ARM/AArch64 Testsuite] Add basic fp16 tests In-Reply-To: <559BC6EC.3000907@arm.com> X-MC-Unique: FmSojLgKR3mdNR6xBXcgrw-1 Content-Type: multipart/mixed; boundary="------------050408030809090603070407" X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00481.txt.bz2 This is a multi-part message in MIME format. --------------050408030809090603070407 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable Content-length: 412 These were originally part of=20 https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01340.html but I have moved i= nto=20 their own subdirectory and adapted them to execute on ARM also (as per=20 https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00656.html) gcc/testsuite/ChangeLog: * gcc.target/aarch64/fp16/fp16.exp: New. * gcc.target/aarch64/fp16/f16_convs_1.c: New. * gcc.target/aarch64/fp16/f16_convs_2.c: New. --------------050408030809090603070407 Content-Type: text/x-patch; name=08_fp16_tests.patch Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="08_fp16_tests.patch" Content-length: 4192 commit bc5045c0d3dd34b8cb94910281384f9ab9880325 Author: Alan Lawrence Date: Thu May 7 10:08:12 2015 +0100 (ARM+AArch64) Add gcc.target/aarch64/fp16, f16_conv_[12].c tests diff --git a/gcc/testsuite/gcc.target/aarch64/fp16/f16_convs_1.c b/gcc/test= suite/gcc.target/aarch64/fp16/f16_convs_1.c new file mode 100644 index 0000000..a1c95fd --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fp16/f16_convs_1.c @@ -0,0 +1,34 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mfp16-format=3Dieee" {target "arm*-*-*"} } */ + +extern void abort (void); + +#define EPSILON 0.0001 + +int +main (int argc, char **argv) +{ + float f1 =3D 3.14159f; + float f2 =3D 2.718f; + /* This 'assembler' statement should be portable between ARM and AArch64= . */ + asm volatile ("" : : : "memory"); + __fp16 in1 =3D f1; + __fp16 in2 =3D f2; + + /* Do the addition on __fp16's (implicitly converts both operands to + float32, adds, converts back to f16, then we convert back to f32). */ + __fp16 res1 =3D in1 + in2; + asm volatile ("" : : : "memory"); + float f_res_1 =3D res1; + + /* Do the addition on float32's (we convert both operands to f32, and ad= d, + as above, but skip the final conversion f32 -> f16 -> f32). */ + float f1a =3D in1; + float f2a =3D in2; + float f_res_2 =3D f1a + f2a; + + if (__builtin_fabs (f_res_2 - f_res_1) > EPSILON) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/aarch64/fp16/f16_convs_2.c b/gcc/test= suite/gcc.target/aarch64/fp16/f16_convs_2.c new file mode 100644 index 0000000..6aa3e59 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fp16/f16_convs_2.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mfp16-format=3Dieee" {target "arm*-*-*"} } */ + +extern void abort (void); + +#define EPSILON 0.0001 + +int +main (int argc, char **argv) +{ + int i1 =3D 3; + int i2 =3D 2; + /* This 'assembler' should be portable across ARM and AArch64. */ + asm volatile ("" : : : "memory"); + + __fp16 in1 =3D i1; + __fp16 in2 =3D i2; + + /* Do the addition on __fp16's (implicitly converts both operands to + float32, adds, converts back to f16, then we convert to int). */ + __fp16 res1 =3D in1 + in2; + asm volatile ("" : : : "memory"); + int result1 =3D res1; + + /* Do the addition on int's (we convert both operands directly to int, a= dd, + and we're done). */ + int result2 =3D ((int) in1) + ((int) in2); + + if (__builtin_abs (result2 - result1) > EPSILON) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.target/aarch64/fp16/fp16.exp b/gcc/testsuite= /gcc.target/aarch64/fp16/fp16.exp new file mode 100644 index 0000000..7dc8d65 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/fp16/fp16.exp @@ -0,0 +1,43 @@ +# Tests of 16-bit floating point (__fp16), for both ARM and AArch64. +# Copyright (C) 2015 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Exit immediately if this isn't an ARM or AArch64 target. +if {![istarget arm*-*-*] + && ![istarget aarch64*-*-*]} then { + return +} + +# Load support procs. +load_lib gcc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cC\]]] \ + "" $DEFAULT_CFLAGS + +# All done. +dg-finish --------------050408030809090603070407--