From patchwork Thu Nov 14 16:47:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1194966 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513436-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="lhu70ykx"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DS8n22dQz9sP4 for ; Fri, 15 Nov 2019 03:48:06 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=EUxhbRmUNWhbgM4dWzlIb0myURgueug8J2hffa+dlo044Vmvtu z3rrhYu6+yBXUdzUno5XYcH4mOImPdbE5xVi897VM1O9VJeRReLAa/uDRQQGxxVh lbYpsIRNnVW7WqUdqjtX7oUKawQPpb/2G9kAMWfDsDtiVPftj/MBB+of0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=asVcUSw3psqC41VQ6xZw4ycTkF8=; b=lhu70ykxnhpZFWHP8pXh eEo1aAvuhZM6NtNL8xmwaEbFTq2ARYqU9+ZHizqAuNu5ab+nlCV43pix9CD0lnxu ZvY4S0Sh9sRnW06TAes0ea0XRLQVSXkGuwclDrk3bpA+/oiz4sluF36f1OLmkBJm ugZuAtK7b4im2Q7sbP+24do= Received: (qmail 92415 invoked by alias); 14 Nov 2019 16:47:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 92403 invoked by uid 89); 14 Nov 2019 16:47:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=!$omp, device X-HELO: esa1.mentor.iphmx.com Received: from esa1.mentor.iphmx.com (HELO esa1.mentor.iphmx.com) (68.232.129.153) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Nov 2019 16:47:57 +0000 IronPort-SDR: EfcxXkdbQB/Vbx7qprj0k4473/kq5RvdPLXWviQWXwja+xo8BB6243H5lwexPot3KSvPwr/ayo 4+8q/vcJDvFQgc4lVaxLrgOfBZMs6WLGxLmHnrOe+bJUiGa6B+z0rytJkcYdAu9cnIr5T2U54L Wtooq4W+AwBcyhDdCAZu3NPzLAss/AfdrgppKtrwwcwNP42d1WDTgkDZeyak5DO9wlSMMovmOm q5BgE8ommvE3VQ9v48usUqt84oTVjtno/BN17OKd1O27j/40TC9J1cNvHU/t7Ni+4/wGed3FOj JPg= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 14 Nov 2019 08:47:55 -0800 IronPort-SDR: KE64pkeOApl2j/oxg5SYZyzY74tATtMizSMSEQucyOJm48VyE82blbem38f7pnC1VVPoiRbbiJ HQR4mPD/UpCvPJEfMt4C+4ArgUxswqr9nst9XTjGCACeEWHFWyoZ6Uw+PmlXr8lR00d/hvUXdN NOLk4oINI1hpTPC4ZTLBxIhGF2wumGI4/YwzTYzzCPlJzBgoR6+ZGn08KtbWyIsOXH+8i5M4Ej EBgiDFI1FmNpxHSSYOsbIjkhfKMQVXsZWBZWL6uw4JLB0dACyxAq6WYBZ0UtsU1QcXVEKYEA4m JEc= To: "gcc-patches@gcc.gnu.org" From: Andrew Stubbs Subject: [patch, libgomp] Add tests for print from offload target Message-ID: <763f86ad-c8b0-de34-e752-f591a87ea851@codesourcery.com> Date: Thu, 14 Nov 2019 16:47:49 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 Hi, This patch adds new libgomp tests to ensure that C "printf" and Fortran "write" work correctly within offload kernels. Both should work for amdgcn, but nvptx uses the libgfortran "minimal" mode which lacks "write" support. Obviously, printing from offload kernels is not recommended in production, but can be useful in development. OK to commit? Thanks Andrew Add tests for print from offload target. 2019-11-14 Andrew Stubbs libgomp/ * testsuite/libgomp.c/target-print-1.c: New file. * testsuite/libgomp.fortran/target-print-1.f90: New file. * testsuite/libgomp.oacc-c/print-1.c: New file. * testsuite/libgomp.oacc-fortran/print-1.f90: New file. diff --git a/libgomp/testsuite/libgomp.c/target-print-1.c b/libgomp/testsuite/libgomp.c/target-print-1.c new file mode 100644 index 00000000000..5857b875ced --- /dev/null +++ b/libgomp/testsuite/libgomp.c/target-print-1.c @@ -0,0 +1,17 @@ +/* Ensure that printf on the offload device works. */ + +/* { dg-do run } */ +/* { dg-output "The answer is 42(\n|\r\n|\r)+" } */ + +#include + +int var = 42; + +int +main () +{ +#pragma omp target + { + printf ("The answer is %d\n", var); + } +} diff --git a/libgomp/testsuite/libgomp.fortran/target-print-1.f90 b/libgomp/testsuite/libgomp.fortran/target-print-1.f90 new file mode 100644 index 00000000000..73ee09a2b79 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/target-print-1.f90 @@ -0,0 +1,14 @@ +! Ensure that printf on the offload device works. + +! { dg-do run } +! { dg-output "The answer is 42(\n|\r\n|\r)+" } + +program main + implicit none + integer :: var = 42 + +!$omp target + write (0, '("The answer is ", I2)') var +!$omp end target + +end program main diff --git a/libgomp/testsuite/libgomp.oacc-c/print-1.c b/libgomp/testsuite/libgomp.oacc-c/print-1.c new file mode 100644 index 00000000000..593885b5c2c --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c/print-1.c @@ -0,0 +1,17 @@ +/* Ensure that printf on the offload device works. */ + +/* { dg-do run } */ +/* { dg-output "The answer is 42(\n|\r\n|\r)+" } */ + +#include + +int var = 42; + +int +main () +{ +#pragma acc parallel + { + printf ("The answer is %d\n", var); + } +} diff --git a/libgomp/testsuite/libgomp.oacc-fortran/print-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/print-1.f90 new file mode 100644 index 00000000000..bef664df4fa --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-fortran/print-1.f90 @@ -0,0 +1,14 @@ +! Ensure that printf on the offload device works. + +! { dg-do run } +! { dg-output "The answer is 42(\n|\r\n|\r)+" } + +program main + implicit none + integer :: var = 42 + +!$acc parallel + write (0, '("The answer is ", I2)') var +!$acc end parallel + +end program main