diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2019-03-21 20:44:45 +0100 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gcc.gnu.org> | 2019-03-21 20:44:45 +0100 |
commit | 64a40f1320c0edc160796266876958ffae8fdd96 (patch) | |
tree | c6693f7c88b6234ff4e8278093dafbab7279e3c4 /gcc/fortran/module.c | |
parent | 33fc9dc962db960bde7473ef392ad3f9b4701ced (diff) | |
download | gcc-64a40f1320c0edc160796266876958ffae8fdd96.zip gcc-64a40f1320c0edc160796266876958ffae8fdd96.tar.gz gcc-64a40f1320c0edc160796266876958ffae8fdd96.tar.bz2 |
[PR72741] Encode OpenACC 'routine' directive's level of parallelism inside Fortran module files
If 'use'ing with an old GCC a new module file (with OpenACC 'routine'
directive's level of parallelism encoded), then that expectedly fails as
follows:
f951: Fatal Error: Reading module 'routine_module_mod_1' at line 27 column 21: find_enum(): Enum not found
If 'use'ing with a new GCC an old module file (without OpenACC 'routine'
directive's level of parallelism encoded), then that (silently) continues to
accept the module file, and will proceed with the previous, erroneous behavior.
These seem to be acceptable compromises, instead of incrementing 'MOD_VERSION'.
gcc/fortran/
PR fortran/72741
* module.c (verify_OACC_ROUTINE_LOP_NONE): New function.
(enum ab_attribute): Add AB_OACC_ROUTINE_LOP_GANG,
AB_OACC_ROUTINE_LOP_WORKER, AB_OACC_ROUTINE_LOP_VECTOR,
AB_OACC_ROUTINE_LOP_SEQ.
(attr_bits): Add these.
(mio_symbol_attribute): Handle these.
gcc/testsuite/
PR fortran/72741
* gfortran.dg/goacc/routine-module-1.f90: New file.
* gfortran.dg/goacc/routine-module-2.f90: Likewise.
* gfortran.dg/goacc/routine-module-mod-1.f90: Likewise.
From-SVN: r269855
Diffstat (limited to 'gcc/fortran/module.c')
-rw-r--r-- | gcc/fortran/module.c | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 0c2699c..3d4b17b 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -2011,7 +2011,9 @@ enum ab_attribute AB_OACC_DECLARE_COPYIN, AB_OACC_DECLARE_DEVICEPTR, AB_OACC_DECLARE_DEVICE_RESIDENT, AB_OACC_DECLARE_LINK, AB_OMP_DECLARE_TARGET_LINK, AB_PDT_KIND, AB_PDT_LEN, AB_PDT_TYPE, - AB_PDT_TEMPLATE, AB_PDT_ARRAY, AB_PDT_STRING + AB_PDT_TEMPLATE, AB_PDT_ARRAY, AB_PDT_STRING, + AB_OACC_ROUTINE_LOP_GANG, AB_OACC_ROUTINE_LOP_WORKER, + AB_OACC_ROUTINE_LOP_VECTOR, AB_OACC_ROUTINE_LOP_SEQ }; static const mstring attr_bits[] = @@ -2081,6 +2083,10 @@ static const mstring attr_bits[] = minit ("PDT_TEMPLATE", AB_PDT_TEMPLATE), minit ("PDT_ARRAY", AB_PDT_ARRAY), minit ("PDT_STRING", AB_PDT_STRING), + minit ("OACC_ROUTINE_LOP_GANG", AB_OACC_ROUTINE_LOP_GANG), + minit ("OACC_ROUTINE_LOP_WORKER", AB_OACC_ROUTINE_LOP_WORKER), + minit ("OACC_ROUTINE_LOP_VECTOR", AB_OACC_ROUTINE_LOP_VECTOR), + minit ("OACC_ROUTINE_LOP_SEQ", AB_OACC_ROUTINE_LOP_SEQ), minit (NULL, -1) }; @@ -2128,6 +2134,15 @@ DECL_MIO_NAME (sym_intent) DECL_MIO_NAME (inquiry_type) #undef DECL_MIO_NAME +/* Verify OACC_ROUTINE_LOP_NONE. */ + +static void +verify_OACC_ROUTINE_LOP_NONE (enum oacc_routine_lop lop) +{ + if (lop != OACC_ROUTINE_LOP_NONE) + bad_module ("Unsupported: multiple OpenACC 'routine' levels of parallelism"); +} + /* Symbol attributes are stored in list with the first three elements being the enumerated fields, while the remaining elements (if any) indicate the individual attribute bits. The access field is not @@ -2292,6 +2307,30 @@ mio_symbol_attribute (symbol_attribute *attr) MIO_NAME (ab_attribute) (AB_PDT_ARRAY, attr_bits); if (attr->pdt_string) MIO_NAME (ab_attribute) (AB_PDT_STRING, attr_bits); + switch (attr->oacc_routine_lop) + { + case OACC_ROUTINE_LOP_NONE: + /* This is the default anyway, and for maintaining compatibility with + the current MOD_VERSION, we're not emitting anything in that + case. */ + break; + case OACC_ROUTINE_LOP_GANG: + MIO_NAME (ab_attribute) (AB_OACC_ROUTINE_LOP_GANG, attr_bits); + break; + case OACC_ROUTINE_LOP_WORKER: + MIO_NAME (ab_attribute) (AB_OACC_ROUTINE_LOP_WORKER, attr_bits); + break; + case OACC_ROUTINE_LOP_VECTOR: + MIO_NAME (ab_attribute) (AB_OACC_ROUTINE_LOP_VECTOR, attr_bits); + break; + case OACC_ROUTINE_LOP_SEQ: + MIO_NAME (ab_attribute) (AB_OACC_ROUTINE_LOP_SEQ, attr_bits); + break; + case OACC_ROUTINE_LOP_ERROR: + /* ... intentionally omitted here; it's only unsed internally. */ + default: + gcc_unreachable (); + } mio_rparen (); @@ -2503,6 +2542,22 @@ mio_symbol_attribute (symbol_attribute *attr) case AB_PDT_STRING: attr->pdt_string = 1; break; + case AB_OACC_ROUTINE_LOP_GANG: + verify_OACC_ROUTINE_LOP_NONE (attr->oacc_routine_lop); + attr->oacc_routine_lop = OACC_ROUTINE_LOP_GANG; + break; + case AB_OACC_ROUTINE_LOP_WORKER: + verify_OACC_ROUTINE_LOP_NONE (attr->oacc_routine_lop); + attr->oacc_routine_lop = OACC_ROUTINE_LOP_WORKER; + break; + case AB_OACC_ROUTINE_LOP_VECTOR: + verify_OACC_ROUTINE_LOP_NONE (attr->oacc_routine_lop); + attr->oacc_routine_lop = OACC_ROUTINE_LOP_VECTOR; + break; + case AB_OACC_ROUTINE_LOP_SEQ: + verify_OACC_ROUTINE_LOP_NONE (attr->oacc_routine_lop); + attr->oacc_routine_lop = OACC_ROUTINE_LOP_SEQ; + break; } } } |