AArch64: Add OpenMP target compile error tests

Add compile-only OpenMP error tests for target clause used with SVE types.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/sve/gomp/gomp.exp: Test driver.
	* gcc.target/aarch64/sve/gomp/target-device.c: New test.
	* gcc.target/aarch64/sve/gomp/target-link.c: Likewise.
	* gcc.target/aarch64/sve/gomp/target.c: Likewise.
This commit is contained in:
Tejas Belagod 2025-03-31 16:00:31 +05:30
parent b9164bd768
commit 3651de6132
4 changed files with 2353 additions and 0 deletions

View file

@ -0,0 +1,46 @@
# Copyright (C) 2006-2025 Free Software Foundation, Inc.
#
# This file is part of GCC.
#
# GCC 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, or (at your option)
# any later version.
#
# GCC 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
# <http://www.gnu.org/licenses/>.
# GCC testsuite that uses the `dg.exp' driver.
# Exit immediately if this isn't an AArch64 target.
if {![istarget aarch64*-*-*] } then {
return
}
# Load support procs.
load_lib gcc-dg.exp
# Initialize `dg'.
dg-init
if ![check_effective_target_fopenmp] {
return
}
if { [check_effective_target_aarch64_sve] } {
set sve_flags ""
} else {
set sve_flags "-march=armv8.2-a+sve"
}
# Main loop.
dg-runtest [lsort [find $srcdir/$subdir *.c]] "$sve_flags -fopenmp" ""
# All done.
dg-finish

View file

@ -0,0 +1,201 @@
/* { dg-do compile } */
/* { dg-options "-msve-vector-bits=256 -fopenmp -O2" } */
#include <arm_sve.h>
#define N __ARM_FEATURE_SVE_BITS
int64_t __attribute__ ((noipa))
target_device_ptr_vla (svbool_t vp, svint32_t *vptr)
{
int a[N], b[N], c[N];
svint32_t va, vb, vc;
int64_t res;
int i;
#pragma omp parallel for
for (i = 0; i < N; i++)
{
b[i] = i;
c[i] = i + 1;
}
/* { dg-error {SVE type 'svint32_t \*' not allowed in 'target' device clauses} "" { target *-*-* } .+1 } */
#pragma omp target data use_device_ptr (vptr) map (to: b, c)
/* { dg-error {SVE type 'svint32_t \*' not allowed in 'target' device clauses} "" { target *-*-* } .+1 } */
#pragma omp target is_device_ptr (vptr) map (to: b, c) map (from: res)
for (i = 0; i < 8; i++)
{
/* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
vb = *vptr;
/* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+2 } */
/* { dg-error "cannot reference 'svbool_t' object types in 'target' region" "" { target *-*-* } .+1 } */
vc = svld1_s32 (vp, c);
/* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
va = svadd_s32_z (vp, vb, vc);
res = svaddv_s32 (svptrue_b32 (), va);
}
return res;
}
int64_t __attribute__ ((noipa))
target_device_addr_vla (svbool_t vp, svint32_t *vptr)
{
int a[N], b[N], c[N];
svint32_t va, vb, vc;
int64_t res;
int i;
#pragma omp parallel for
for (i = 0; i < N; i++)
{
b[i] = i;
c[i] = i + 1;
}
/* { dg-error "SVE type 'svint32_t' not allowed in 'target' device clauses" "" { target *-*-* } .+1 } */
#pragma omp target data use_device_addr (vb) map (to: b, c)
/* { dg-error {SVE type 'svint32_t \*' not allowed in 'target' device clauses} "" { target *-*-* } .+1 } */
#pragma omp target is_device_ptr (vptr) map (to: b, c) map (from: res)
for (i = 0; i < 8; i++)
{
/* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
vb = *vptr;
/* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+2 } */
/* { dg-error "cannot reference 'svbool_t' object types in 'target' region" "" { target *-*-* } .+1 } */
vc = svld1_s32 (vp, c);
/* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
va = svadd_s32_z (vp, vb, vc);
res = svaddv_s32 (svptrue_b32 (), va);
}
return res;
}
int64_t __attribute__ ((noipa))
target_has_device_addr_vla (svbool_t vp, svint32_t *vptr)
{
int a[N], b[N], c[N];
svint32_t va, vb, vc;
int64_t res;
int i;
#pragma omp parallel for
for (i = 0; i < N; i++)
{
b[i] = i;
c[i] = i + 1;
}
/* { dg-error "SVE type 'svint32_t' not allowed in 'target' device clauses" "" { target *-*-* } .+1 } */
#pragma omp target data use_device_addr (vb) map (to: b, c)
/* { dg-error "SVE type 'svint32_t' not allowed in 'target' device clauses" "" { target *-*-* } .+1 } */
#pragma omp target has_device_addr (vb) map (to: b, c) map (from: res)
for (i = 0; i < 8; i++)
{
/* { dg-error "cannot reference 'svbool_t' object types in 'target' region" "" { target *-*-* } .+1 } */
vb = svld1_s32 (vp, b);
/* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
vc = svld1_s32 (vp, c);
/* { dg-error "cannot reference 'svint32_t' object types in 'target' region" "" { target *-*-* } .+1 } */
va = svadd_s32_z (vp, vb, vc);
res = svaddv_s32 (svptrue_b32 (), va);
}
return res;
}
#define FIXED_ATTR __attribute__ ((arm_sve_vector_bits (N)))
typedef __SVInt32_t v8si FIXED_ATTR;
typedef svbool_t v8bi FIXED_ATTR;
int64_t __attribute__ ((noipa))
target_device_ptr_vls (v8bi vp, v8si *vptr)
{
int a[N], b[N], c[N];
v8si va, vb, vc;
int64_t res;
int i;
#pragma omp parallel for
for (i = 0; i < N; i++)
{
b[i] = i;
c[i] = i + 1;
}
#pragma omp target data use_device_ptr (vptr) map (to: b, c)
#pragma omp target is_device_ptr (vptr) map (to: b, c) map (from: res)
for (i = 0; i < 8; i++)
{
vb = *vptr;
vc = svld1_s32 (vp, c);
va = svadd_s32_z (vp, vb, vc);
res = svaddv_s32 (svptrue_b32 (), va);
}
return res;
}
int64_t __attribute__ ((noipa))
target_device_addr_vls (v8bi vp, v8si *vptr)
{
int a[N], b[N], c[N];
v8si va, vb, vc;
int64_t res;
int i;
#pragma omp parallel for
for (i = 0; i < N; i++)
{
b[i] = i;
c[i] = i + 1;
}
#pragma omp target data use_device_addr (vb) map (to: b, c)
#pragma omp target is_device_ptr (vptr) map (to: b, c) map (from: res)
for (i = 0; i < 8; i++)
{
vb = *vptr;
vc = svld1_s32 (vp, c);
va = svadd_s32_z (vp, vb, vc);
res = svaddv_s32 (svptrue_b32 (), va);
}
return res;
}
int64_t __attribute__ ((noipa))
target_has_device_addr_vls (v8bi vp, v8si *vptr)
{
int a[N], b[N], c[N];
v8si va, vb, vc;
int64_t res;
int i;
#pragma omp parallel for
for (i = 0; i < N; i++)
{
b[i] = i;
c[i] = i + 1;
}
#pragma omp target data use_device_addr (vb) map (to: b, c)
#pragma omp target has_device_addr (vb) map (to: b, c) map (from: res)
for (i = 0; i < 8; i++)
{
vb = svld1_s32 (vp, b);
vc = svld1_s32 (vp, c);
va = svadd_s32_z (vp, vb, vc);
res = svaddv_s32 (svptrue_b32 (), va);
}
return res;
}

View file

@ -0,0 +1,57 @@
/* { dg-do compile } */
/* { dg-options "-msve-vector-bits=256 -fopenmp -O2" } */
#include <arm_sve.h>
#define N __ARM_FEATURE_SVE_BITS
#define FIXED_ATTR __attribute__((arm_sve_vector_bits (N)))
typedef __SVInt32_t v8si FIXED_ATTR;
static v8si local_vec;
#pragma omp declare target link(local_vec)
v8si global_vec;
#pragma omp declare target link(global_vec)
/* { dg-error {SVE type 'svint32_t' does not have a fixed size} "" { target *-*-* } .+1 } */
static svint32_t slocal_vec;
/* { dg-error {'slocal_vec' does not have a mappable type in 'link' clause} "" { target *-*-* } .+1 } */
#pragma omp declare target link(slocal_vec)
void
one_get_inc2_local_vec_vls ()
{
v8si res, res2, tmp;
#pragma omp target map(from: res, res2)
{
res = local_vec;
local_vec = svadd_s32_z (svptrue_b32 (), local_vec, local_vec);
res2 = local_vec;
}
tmp = svadd_s32_z (svptrue_b32 (), res, res);
svbool_t p = svcmpne_s32 (svptrue_b32 (), tmp, res2);
if (svptest_any (svptrue_b32 (), p))
__builtin_abort ();
}
void
one_get_inc3_global_vec_vls ()
{
v8si res, res2, tmp;
#pragma omp target map(from: res, res2)
{
res = global_vec;
global_vec = svadd_s32_z (svptrue_b32 (), global_vec, global_vec);
res2 = global_vec;
}
tmp = svadd_s32_z (svptrue_b32 (), res, res);
svbool_t p = svcmpne_s32 (svptrue_b32 (), tmp, res2);
if (svptest_any (svptrue_b32 (), p))
__builtin_abort ();
}

File diff suppressed because it is too large Load diff