From patchwork Mon Feb 29 15:55:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 593070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 40B48140216 for ; Tue, 8 Mar 2016 04:35:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=S8nxvY0R; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :resent-from:resent-date:resent-message-id:resent-to:message-id :in-reply-to:references:from:date:subject:to; q=dns; s=default; b= FlMRaCg6ex70WmW6t8lHJwhwC2+WsRFszOwDh9Jd72/DJrJLUO+wWXMSdii8Of/l 44ohlUU3xq+T+Br/CCYHKq3u3LCorLpDGTH4pTx2raXM0d1i5OLCPWxFDVrJWSHc NpSSZgY8ujtJZ71Nw9jiWSm5l4CNvIQfUH2uo9Qwd1k= 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 :resent-from:resent-date:resent-message-id:resent-to:message-id :in-reply-to:references:from:date:subject:to; s=default; bh=yo2R AIk+Y6YnAYh/R7I4CBUHr28=; b=S8nxvY0RMTt+PdVoHOe79Tkwn+t/bls5tR7V VfJjCDOl+ZKxWucPn9UcgqJVGMyqKkLY1NvhDsq0thfYiMji/EImrWiN7L+2KJ6P PbA5ZdO6YhTXtBZo77gqSujYK0roB6xVrKq13NHHECu//7qPKX5eiNff9C4dI1qb DNFmBmM= Received: (qmail 114247 invoked by alias); 7 Mar 2016 17:34:31 -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 114174 invoked by uid 89); 7 Mar 2016 17:34:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=foo4 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 07 Mar 2016 17:34:25 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1B37AADA9 for ; Mon, 7 Mar 2016 17:34:22 +0000 (UTC) Resent-From: Martin Jambor Resent-Date: Mon, 7 Mar 2016 18:34:22 +0100 Resent-Message-ID: <20160307173422.GB23597@virgil.suse.cz> Resent-To: GCC Patches Message-Id: In-Reply-To: References: From: Martin Jambor Date: Mon, 29 Feb 2016 16:55:44 +0100 Subject: [hsa testsuite 1/5] Gridification tests To: GCC Patches X-IsSubscribed: yes Hi, the patch below adds a DejaGNU effective target predicate (is that the correct dejagnu term?) offload_hsa so that selected tests can be run only if the hsa offloading is enabled. I hope it is fairly standard stuff. Additionally, it adds one C/C++ and one Fortran testsuite to check that gridification happens. Tested, both with and without HSA enabled. OK for trunk? Thanks, Martin 2016-02-10 Martin Jambor * target-supports.exp (check_effective_target_offload_hsa): New. * c-c++-common/gomp/gridify-1.c: New test. * gfortran.dg/gomp/gridify-1.f90: Likewise. --- gcc/testsuite/c-c++-common/gomp/gridify-1.c | 54 ++++++++++++++++++++++++++++ gcc/testsuite/gfortran.dg/gomp/gridify-1.f90 | 16 +++++++++ gcc/testsuite/lib/target-supports.exp | 8 +++++ 3 files changed, 78 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/gomp/gridify-1.c create mode 100644 gcc/testsuite/gfortran.dg/gomp/gridify-1.f90 diff --git a/gcc/testsuite/c-c++-common/gomp/gridify-1.c b/gcc/testsuite/c-c++-common/gomp/gridify-1.c new file mode 100644 index 0000000..ba7a866 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/gridify-1.c @@ -0,0 +1,54 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target offload_hsa } */ +/* { dg-options "-fopenmp -fdump-tree-omplower-details" } */ + +void +foo1 (int n, int *a, int workgroup_size) +{ + int i; +#pragma omp target +#pragma omp teams thread_limit(workgroup_size) +#pragma omp distribute parallel for shared(a) firstprivate(n) private(i) + for (i = 0; i < n; i++) + a[i]++; +} + +void +foo2 (int j, int n, int *a) +{ + int i; +#pragma omp target teams +#pragma omp distribute parallel for shared(a) firstprivate(n) private(i) firstprivate(j) + for (i = j + 1; i < n; i++) + a[i] = i; +} + +void +foo3 (int j, int n, int *a) +{ + int i; +#pragma omp target teams +#pragma omp distribute parallel for shared(a) firstprivate(n) private(i) firstprivate(j) + for (i = j + 1; i < n; i += 3) + a[i] = i; +} + +void +foo4 (int j, int n, int *a) +{ +#pragma omp parallel + { + #pragma omp single + { + int i; +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for shared(a) firstprivate(n) private(i) firstprivate(j) + for (i = j + 1; i < n; i += 3) + a[i] = i; + } + } +} + + +/* { dg-final { scan-tree-dump-times "Target construct will be turned into a gridified GPGPU kernel" 4 "omplower" } } */ diff --git a/gcc/testsuite/gfortran.dg/gomp/gridify-1.f90 b/gcc/testsuite/gfortran.dg/gomp/gridify-1.f90 new file mode 100644 index 0000000..00ff7f5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/gridify-1.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! { dg-require-effective-target offload_hsa } +! { dg-options "-fopenmp -fdump-tree-omplower-details" } */ + +subroutine vector_square(n, a, b) + integer i, n, b(n), a(n) +!$omp target teams +!$omp distribute parallel do + do i=1,n + b(i) = a(i) * a(i) + enddo +!$omp end distribute parallel do +!$omp end target teams +end subroutine vector_square + +! { dg-final { scan-tree-dump "Target construct will be turned into a gridified GPGPU kernel" "omplower" } } diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 0b4252f..fac4c3c 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -6936,3 +6936,11 @@ proc check_effective_target_offload_nvptx { } { int main () {return 0;} } "-foffload=nvptx-none" ] } + +# Return 1 if the compiler has been configured with hsa offloading. + +proc check_effective_target_offload_hsa { } { + return [check_no_compiler_messages offload_hsa assembly { + int main () {return 0;} + } "-foffload=hsa" ] +}