aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/module.c
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-08-26 09:32:40 +0200
committerTobias Burnus <tobias@codesourcery.com>2020-08-26 09:32:40 +0200
commitd58e7173ef964ddac3ab3ad8cc97de8f9f3b32ee (patch)
tree4554d34bd8b9a0bfc30b1db3dd075f9c09dda41e /gcc/fortran/module.c
parent4797a61cc5024fc9adf5918e9bb2b78988f9e4d4 (diff)
downloadgcc-d58e7173ef964ddac3ab3ad8cc97de8f9f3b32ee.zip
gcc-d58e7173ef964ddac3ab3ad8cc97de8f9f3b32ee.tar.gz
gcc-d58e7173ef964ddac3ab3ad8cc97de8f9f3b32ee.tar.bz2
Fortran: Add 'device_type' clause to OpenMP's declare target
gcc/fortran/ChangeLog: * gfortran.h (enum gfc_omp_device_type): New. (symbol_attribute, gfc_omp_clauses, gfc_common_head): Use it. * module.c (enum ab_attribute): Add AB_OMP_DEVICE_TYPE_HOST, AB_OMP_DEVICE_TYPE_NOHOST and AB_OMP_DEVICE_TYPE_ANY. (attr_bits, mio_symbol_attribute): Handle it. (load_commons, write_common_0): Handle omp_device_type flag. * openmp.c (enum omp_mask1): Add OMP_CLAUSE_DEVICE_TYPE (OMP_DECLARE_TARGET_CLAUSES): Likewise. (gfc_match_omp_clauses): Match 'device_type'. (gfc_match_omp_declare_target): Handle it. * trans-common.c (build_common_decl): Write device-type clause. * trans-decl.c (add_attributes_to_decl): Likewise. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/declare-target-4.f90: New test. * gfortran.dg/gomp/declare-target-5.f90: New test.
Diffstat (limited to 'gcc/fortran/module.c')
-rw-r--r--gcc/fortran/module.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 5114d55..714fbd9 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -2051,7 +2051,8 @@ enum ab_attribute
AB_OMP_REQ_REVERSE_OFFLOAD, AB_OMP_REQ_UNIFIED_ADDRESS,
AB_OMP_REQ_UNIFIED_SHARED_MEMORY, AB_OMP_REQ_DYNAMIC_ALLOCATORS,
AB_OMP_REQ_MEM_ORDER_SEQ_CST, AB_OMP_REQ_MEM_ORDER_ACQ_REL,
- AB_OMP_REQ_MEM_ORDER_RELAXED
+ AB_OMP_REQ_MEM_ORDER_RELAXED, AB_OMP_DEVICE_TYPE_NOHOST,
+ AB_OMP_DEVICE_TYPE_HOST, AB_OMP_DEVICE_TYPE_ANY
};
static const mstring attr_bits[] =
@@ -2132,6 +2133,9 @@ static const mstring attr_bits[] =
minit ("OMP_REQ_MEM_ORDER_SEQ_CST", AB_OMP_REQ_MEM_ORDER_SEQ_CST),
minit ("OMP_REQ_MEM_ORDER_ACQ_REL", AB_OMP_REQ_MEM_ORDER_ACQ_REL),
minit ("OMP_REQ_MEM_ORDER_RELAXED", AB_OMP_REQ_MEM_ORDER_RELAXED),
+ minit ("OMP_DEVICE_TYPE_HOST", AB_OMP_DEVICE_TYPE_HOST),
+ minit ("OMP_DEVICE_TYPE_NOHOST", AB_OMP_DEVICE_TYPE_NOHOST),
+ minit ("OMP_DEVICE_TYPE_ANYHOST", AB_OMP_DEVICE_TYPE_ANY),
minit (NULL, -1)
};
@@ -2397,6 +2401,22 @@ mio_symbol_attribute (symbol_attribute *attr)
== OMP_REQ_ATOMIC_MEM_ORDER_RELAXED)
MIO_NAME (ab_attribute) (AB_OMP_REQ_MEM_ORDER_RELAXED, attr_bits);
}
+ switch (attr->omp_device_type)
+ {
+ case OMP_DEVICE_TYPE_UNSET:
+ break;
+ case OMP_DEVICE_TYPE_HOST:
+ MIO_NAME (ab_attribute) (AB_OMP_DEVICE_TYPE_HOST, attr_bits);
+ break;
+ case OMP_DEVICE_TYPE_NOHOST:
+ MIO_NAME (ab_attribute) (AB_OMP_DEVICE_TYPE_NOHOST, attr_bits);
+ break;
+ case OMP_DEVICE_TYPE_ANY:
+ MIO_NAME (ab_attribute) (AB_OMP_DEVICE_TYPE_ANY, attr_bits);
+ break;
+ default:
+ gcc_unreachable ();
+ }
mio_rparen ();
}
else
@@ -2661,6 +2681,15 @@ mio_symbol_attribute (symbol_attribute *attr)
"relaxed", &gfc_current_locus,
module_name);
break;
+ case AB_OMP_DEVICE_TYPE_HOST:
+ attr->omp_device_type = OMP_DEVICE_TYPE_HOST;
+ break;
+ case AB_OMP_DEVICE_TYPE_NOHOST:
+ attr->omp_device_type = OMP_DEVICE_TYPE_NOHOST;
+ break;
+ case AB_OMP_DEVICE_TYPE_ANY:
+ attr->omp_device_type = OMP_DEVICE_TYPE_ANY;
+ break;
}
}
}
@@ -4849,6 +4878,7 @@ load_commons (void)
p->saved = 1;
if (flags & 2)
p->threadprivate = 1;
+ p->omp_device_type = (gfc_omp_device_type) ((flags >> 2) & 3);
p->use_assoc = 1;
/* Get whether this was a bind(c) common or not. */
@@ -5713,6 +5743,7 @@ write_common_0 (gfc_symtree *st, bool this_module)
flags = p->saved ? 1 : 0;
if (p->threadprivate)
flags |= 2;
+ flags |= p->omp_device_type << 2;
mio_integer (&flags);
/* Write out whether the common block is bind(c) or not. */