[Fortran, PATCH, coarray, v1] Extend caf_*_by_ref () API by a type specifier
Hi all, attached patch fixes an issue with the coarray API. When a component of a derived type coarray was referenced using a caf_*_by_ref () function and that component was not an array with a descriptor, then the type of the component was not known. Which additionally meant, that type conversion was not applied as required. This patch fixes that issue by adding type specifiers to the three caf_*_by_ref-calls and implements the functionality for libcaf_single. This is harmless because other coarray libraries that do not expect this argument just ignore it. Additionally does this patch also provide the first working version of caf_sendget_by_ref in libcaf_single, which previously only lead to a stack corruption and was not usable since the array descriptor rework (nice job, btw). I would like to have this patch in trunk knowing that I am somewhat late, but it would be quite necessary, because as it is now, the coarray feature for derived types is hardly usable. Furthermore do some people name this a regression, because the caf_*_by_ref are also used when the lhs of a caf_get_by_ref() is allocatable which now does not work as expected anymore but before gcc-6 using caf_get() (w/o reallocation) did. Bootstrapped and regtested ok on x86_64-linux/f27. Ok for trunk? - Andre -- Andre Vehreschild * Email: vehre ad gmx dot de gcc/fortran/ChangeLog: 2018-02-18 Andre Vehreschild * gfortran.texi: Document additional src/dst_type. Fix some typos. * trans-decl.c (gfc_build_builtin_function_decls): Declare the new argument of _caf_*_by_ref () with * e { get, send, sendget }. * trans-intrinsic.c (gfc_conv_intrinsic_caf_get): Add the type of the data referenced when generating a call to caf_get_by_ref (). (conv_caf_send): Same but for caf_send_by_ref () and caf_sendget_by_ref (). gcc/testsuite/ChangeLog: 2018-02-18 Andre Vehreschild * gfortran.dg/coarray_alloc_comp_6.f08: New test. * gfortran.dg/coarray_alloc_comp_7.f08: New test. * gfortran.dg/coarray_alloc_comp_8.f08: New test. libgfortran/ChangeLog: 2018-02-18 Andre Vehreschild * caf/libcaf.h: Add type parameters to the caf_*_by_ref prototypes. * caf/single.c (get_for_ref): Simplifications and now respecting the type argument. (_gfortran_caf_get_by_ref): Added source type handing to get_for_ref(). (send_by_ref): Simplifications and respecting the dst_type now. (_gfortran_caf_send_by_ref): Added destination type hand over to send_by_ref(). (_gfortran_caf_sendget_by_ref): Added general support and fixed stack corruption. The function is now really usable. diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index 9ffe6ade661..db48a713661 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -4750,7 +4750,7 @@ remote image identified by the @var{image_index}. @item @emph{Syntax}: @code{void _gfortran_caf_send_by_ref (caf_token_t token, int image_index, gfc_descriptor_t *src, caf_reference_t *refs, int dst_kind, int src_kind, -bool may_require_tmp, bool dst_reallocatable, int *stat)} +bool may_require_tmp, bool dst_reallocatable, int *stat, int dst_type)} @item @emph{Arguments}: @multitable @columnfractions .15 .70 @@ -4774,6 +4774,9 @@ is a full array or component ref. @item @var{stat} @tab intent(out) When non-@code{NULL} give the result of the operation, i.e., zero on success and non-zero on error. When @code{NULL} and an error occurs, then an error message is printed and the program is terminated. +@item @var{dst_type} @tab intent(in) Give the type of the destination. When +the destination is not an array, than the precise type, e.g. of a component in +a derived type, is not known, but provided here. @end multitable @item @emph{NOTES} @@ -4808,7 +4811,7 @@ identified by the @var{image_index}. @item @emph{Syntax}: @code{void _gfortran_caf_get_by_ref (caf_token_t token, int image_index, caf_reference_t *refs, gfc_descriptor_t *dst, int dst_kind, int src_kind, -bool may_require_tmp, bool dst_reallocatable, int *stat)} +bool may_require_tmp, bool dst_reallocatable, int *stat, int src_type)} @item @emph{Arguments}: @multitable @columnfractions .15 .70 @@ -4833,6 +4836,9 @@ array or a component is referenced. @item @var{stat} @tab intent(out) When non-@code{NULL} give the result of the operation, i.e., zero on success and non-zero on error. When @code{NULL} and an error occurs, then an error message is printed and the program is terminated. +@item @var{src_type} @tab intent(in) Give the type of the source. When the +source is not an array, than the precise type, e.g. of a component in a +derived type, is not known, but provided here. @end multitable @item @emph{NOTES} @@ -4868,7 +4874,8 @@ identified by the @var{src_image_index} to a remote image identified by the @code{void _gfortran_caf_sendget_by_ref (caf_token_t dst_token, int
Re: [Fortran, PATCH, coarray, v1] Extend caf_*_by_ref () API by a type specifier
On 02/18/2018 07:39 AM, Andre Vehreschild wrote: Hi all, attached patch fixes an issue with the coarray API. When a component of a derived type coarray was referenced using a caf_*_by_ref () function and that component was not an array with a descriptor, then the type of the component was not known. Which additionally meant, that type conversion was not applied as required. This patch fixes that issue by adding type specifiers to the three caf_*_by_ref-calls and implements the functionality for libcaf_single. This is harmless because other coarray libraries that do not expect this argument just ignore it. Additionally does this patch also provide the first working version of caf_sendget_by_ref in libcaf_single, which previously only lead to a stack corruption and was not usable since the array descriptor rework (nice job, btw). I would like to have this patch in trunk knowing that I am somewhat late, but it would be quite necessary, because as it is now, the coarray feature for derived types is hardly usable. Furthermore do some people name this a regression, because the caf_*_by_ref are also used when the lhs of a caf_get_by_ref() is allocatable which now does not work as expected anymore but before gcc-6 using caf_get() (w/o reallocation) did. Bootstrapped and regtested ok on x86_64-linux/f27. Ok for trunk? - Andre This is OK from the Fortranners perspective. Should touch base with release manager. It looks harmless though it changes coarray API, which is hidden behind -fcoarray= Regards, Jerry
Re: [Fortran, PATCH, coarray, v1] Extend caf_*_by_ref () API by a type specifier
Dear release managers, this patch (for reference https://gcc.gnu.org/ml/fortran/2018-02/msg00124.html) fixes a regression in the coarray api by extending three relatively new functions with one or two arguments, respectively. The patch has been approved by gfortran devs. Asking your approval to merge it: Ok to merge to trunk? Regards, Andre On Sun, 18 Feb 2018 08:53:41 -0800 Jerry DeLisle wrote: > On 02/18/2018 07:39 AM, Andre Vehreschild wrote: > > Hi all, > > > > attached patch fixes an issue with the coarray API. When a component of a > > derived type coarray was referenced using a caf_*_by_ref () function and > > that component was not an array with a descriptor, then the type of the > > component was not known. Which additionally meant, that type conversion was > > not applied as required. This patch fixes that issue by adding type > > specifiers to the three caf_*_by_ref-calls and implements the functionality > > for libcaf_single. This is harmless because other coarray libraries that do > > not expect this argument just ignore it. > > Additionally does this patch also provide the first working version of > > caf_sendget_by_ref in libcaf_single, which previously only lead to a stack > > corruption and was not usable since the array descriptor rework (nice job, > > btw). > > > > I would like to have this patch in trunk knowing that I am somewhat late, > > but it would be quite necessary, because as it is now, the coarray feature > > for derived types is hardly usable. Furthermore do some people name this a > > regression, because the caf_*_by_ref are also used when the lhs of a > > caf_get_by_ref() is allocatable which now does not work as expected anymore > > but before gcc-6 using caf_get() (w/o reallocation) did. > > > > Bootstrapped and regtested ok on x86_64-linux/f27. Ok for trunk? > > > > - Andre > > > > This is OK from the Fortranners perspective. Should touch base with > release manager. It looks harmless though it changes coarray API, which > is hidden behind -fcoarray= > > Regards, > > Jerry -- Andre Vehreschild * Email: vehre ad gmx dot de
Re: [Fortran, PATCH, coarray, v1] Extend caf_*_by_ref () API by a type specifier
Well, after discussing on IRC whether RM should be bothered, I was asked to simplify release managers lives and propose, that if no one objects within one day, I will merge the patch. So any objections? - Andre On Sun, 18 Feb 2018 18:07:28 +0100 Andre Vehreschild wrote: > Dear release managers, > > this patch (for reference > https://gcc.gnu.org/ml/fortran/2018-02/msg00124.html) fixes a regression in > the coarray api by extending three relatively new functions with one or two > arguments, respectively. The patch has been approved by gfortran devs. Asking > your approval to merge it: Ok to merge to trunk? > > Regards, > Andre > > On Sun, 18 Feb 2018 08:53:41 -0800 > Jerry DeLisle wrote: > > > On 02/18/2018 07:39 AM, Andre Vehreschild wrote: > > > Hi all, > > > > > > attached patch fixes an issue with the coarray API. When a component of a > > > derived type coarray was referenced using a caf_*_by_ref () function and > > > that component was not an array with a descriptor, then the type of the > > > component was not known. Which additionally meant, that type conversion > > > was not applied as required. This patch fixes that issue by adding type > > > specifiers to the three caf_*_by_ref-calls and implements the > > > functionality for libcaf_single. This is harmless because other coarray > > > libraries that do not expect this argument just ignore it. > > > Additionally does this patch also provide the first working version of > > > caf_sendget_by_ref in libcaf_single, which previously only lead to a stack > > > corruption and was not usable since the array descriptor rework (nice job, > > > btw). > > > > > > I would like to have this patch in trunk knowing that I am somewhat late, > > > but it would be quite necessary, because as it is now, the coarray feature > > > for derived types is hardly usable. Furthermore do some people name this a > > > regression, because the caf_*_by_ref are also used when the lhs of a > > > caf_get_by_ref() is allocatable which now does not work as expected > > > anymore but before gcc-6 using caf_get() (w/o reallocation) did. > > > > > > Bootstrapped and regtested ok on x86_64-linux/f27. Ok for trunk? > > > > > > - Andre > > > > > > > This is OK from the Fortranners perspective. Should touch base with > > release manager. It looks harmless though it changes coarray API, which > > is hidden behind -fcoarray= > > > > Regards, > > > > Jerry > > -- Andre Vehreschild * Email: vehre ad gmx dot de
Re: [Fortran, PATCH, coarray, v1] Extend caf_*_by_ref () API by a type specifier
Hi all, no objections received therefore committed as r257813. Thanks for fast review Jerry. - Andre On Sun, 18 Feb 2018 18:33:07 +0100 Andre Vehreschild wrote: > Well, after discussing on IRC whether RM should be bothered, I was asked to > simplify release managers lives and propose, that if no one objects within one > day, I will merge the patch. So any objections? > > - Andre > > On Sun, 18 Feb 2018 18:07:28 +0100 > Andre Vehreschild wrote: > > > Dear release managers, > > > > this patch (for reference > > https://gcc.gnu.org/ml/fortran/2018-02/msg00124.html) fixes a regression in > > the coarray api by extending three relatively new functions with one or two > > arguments, respectively. The patch has been approved by gfortran devs. > > Asking your approval to merge it: Ok to merge to trunk? > > > > Regards, > > Andre > > > > On Sun, 18 Feb 2018 08:53:41 -0800 > > Jerry DeLisle wrote: > > > > > On 02/18/2018 07:39 AM, Andre Vehreschild wrote: > > > > Hi all, > > > > > > > > attached patch fixes an issue with the coarray API. When a component of > > > > a derived type coarray was referenced using a caf_*_by_ref () function > > > > and that component was not an array with a descriptor, then the type of > > > > the component was not known. Which additionally meant, that type > > > > conversion was not applied as required. This patch fixes that issue by > > > > adding type specifiers to the three caf_*_by_ref-calls and implements > > > > the functionality for libcaf_single. This is harmless because other > > > > coarray libraries that do not expect this argument just ignore it. > > > > Additionally does this patch also provide the first working version of > > > > caf_sendget_by_ref in libcaf_single, which previously only lead to a > > > > stack corruption and was not usable since the array descriptor rework > > > > (nice job, btw). > > > > > > > > I would like to have this patch in trunk knowing that I am somewhat > > > > late, but it would be quite necessary, because as it is now, the > > > > coarray feature for derived types is hardly usable. Furthermore do some > > > > people name this a regression, because the caf_*_by_ref are also used > > > > when the lhs of a caf_get_by_ref() is allocatable which now does not > > > > work as expected anymore but before gcc-6 using caf_get() (w/o > > > > reallocation) did. > > > > > > > > Bootstrapped and regtested ok on x86_64-linux/f27. Ok for trunk? > > > > > > > > - Andre > > > > > > > > > > This is OK from the Fortranners perspective. Should touch base with > > > release manager. It looks harmless though it changes coarray API, which > > > is hidden behind -fcoarray= > > > > > > Regards, > > > > > > Jerry > > > > > > -- Andre Vehreschild * Email: vehre ad gmx dot de Index: gcc/fortran/ChangeLog === --- gcc/fortran/ChangeLog (Revision 257812) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,13 @@ +2018-02-19 Andre Vehreschild + + * gfortran.texi: Document additional src/dst_type. Fix some typos. + * trans-decl.c (gfc_build_builtin_function_decls): Declare the new + argument of _caf_*_by_ref () with * e { get, send, sendget }. + * trans-intrinsic.c (gfc_conv_intrinsic_caf_get): Add the type of the + data referenced when generating a call to caf_get_by_ref (). + (conv_caf_send): Same but for caf_send_by_ref () and + caf_sendget_by_ref (). + 2018-02-18 Jerry DeLisle PR fortran/84389 Index: gcc/fortran/gfortran.texi === --- gcc/fortran/gfortran.texi (Revision 257812) +++ gcc/fortran/gfortran.texi (Arbeitskopie) @@ -4750,7 +4750,7 @@ @item @emph{Syntax}: @code{void _gfortran_caf_send_by_ref (caf_token_t token, int image_index, gfc_descriptor_t *src, caf_reference_t *refs, int dst_kind, int src_kind, -bool may_require_tmp, bool dst_reallocatable, int *stat)} +bool may_require_tmp, bool dst_reallocatable, int *stat, int dst_type)} @item @emph{Arguments}: @multitable @columnfractions .15 .70 @@ -4774,6 +4774,9 @@ @item @var{stat} @tab intent(out) When non-@code{NULL} give the result of the operation, i.e., zero on success and non-zero on error. When @code{NULL} and an error occurs, then an error message is printed and the program is terminated. +@item @var{dst_type} @tab intent(in) Give the type of the destination. When +the destination is not an array, than the precise type, e.g. of a component in +a derived type, is not known, but provided here. @end multitable @item @emph{NOTES} @@ -4808,7 +4811,7 @@ @item @emph{Syntax}: @code{void _gfortran_caf_get_by_ref (caf_token_t token, int image_index, caf_reference_t *refs, gfc_descriptor_t *dst, int dst_kind, int src_kind, -bool may_require_tmp, bool dst_reallocatable, int *stat)} +bool may_require_tmp, bool dst_reallocatable, int *stat, int src_type)} @item @emph{Arguments}: @multitable @columnfractions .15
Re: [Fortran, PATCH, coarray, v1] Extend caf_*_by_ref () API by a type specifier
Hi Andre, Thanks for your latest work on CAF features. Could you let us know whether this commit should be tested against the OpenCoarrays master branch or another branch? With the master branch, I get one test failure (not counting two known teams failures that are actually false negatives that I need to fix): lib_caf_mpi::sendget_by_ref(): Warning ! sendget_by_ref() is mostly unfunctional due to a design error. Split up your statement with coarray refs on both sides of the assignment when the datatype transfered is non 4-byte-integer compatible. libcaf_mpi RUNTIME ERROR: Cannot convert type 1 kind 4 to type 0 kind 4 Is the above expected? Also, because the message comes from sendget, does that mean it only affects lines that involve three images such as the following: if (this_image()==1) x[2] = x[3] Damian On February 19, 2018 at 9:32:06 AM, Andre Vehreschild (ve...@gmx.de) wrote: Hi all, no objections received therefore committed as r257813. Thanks for fast review Jerry. - Andre On Sun, 18 Feb 2018 18:33:07 +0100 Andre Vehreschild wrote: > Well, after discussing on IRC whether RM should be bothered, I was asked to > simplify release managers lives and propose, that if no one objects within > one > day, I will merge the patch. So any objections? > > - Andre > > On Sun, 18 Feb 2018 18:07:28 +0100 > Andre Vehreschild wrote: > > > Dear release managers, > > > > this patch (for reference > > https://gcc.gnu.org/ml/fortran/2018-02/msg00124.html) fixes a regression in > > > > the coarray api by extending three relatively new functions with one or two > > > > arguments, respectively. The patch has been approved by gfortran devs. > > Asking your approval to merge it: Ok to merge to trunk? > > > > Regards, > > Andre > > > > On Sun, 18 Feb 2018 08:53:41 -0800 > > Jerry DeLisle wrote: > > > > > On 02/18/2018 07:39 AM, Andre Vehreschild wrote: > > > > Hi all, > > > > > > > > attached patch fixes an issue with the coarray API. When a component of > > > > > > > > a derived type coarray was referenced using a caf_*_by_ref () function > > > > and that component was not an array with a descriptor, then the type of > > > > > > > > the component was not known. Which additionally meant, that type > > > > conversion was not applied as required. This patch fixes that issue by > > > > adding type specifiers to the three caf_*_by_ref-calls and implements > > > > the functionality for libcaf_single. This is harmless because other > > > > coarray libraries that do not expect this argument just ignore it. > > > > Additionally does this patch also provide the first working version of > > > > caf_sendget_by_ref in libcaf_single, which previously only lead to a > > > > stack corruption and was not usable since the array descriptor rework > > > > (nice job, btw). > > > > > > > > I would like to have this patch in trunk knowing that I am somewhat > > > > late, but it would be quite necessary, because as it is now, the > > > > coarray feature for derived types is hardly usable. Furthermore do some > > > > > > > > people name this a regression, because the caf_*_by_ref are also used > > > > when the lhs of a caf_get_by_ref() is allocatable which now does not > > > > work as expected anymore but before gcc-6 using caf_get() (w/o > > > > reallocation) did. > > > > > > > > Bootstrapped and regtested ok on x86_64-linux/f27. Ok for trunk? > > > > > > > > - Andre > > > > > > > > > > This is OK from the Fortranners perspective. Should touch base with > > > release manager. It looks harmless though it changes coarray API, which > > > is hidden behind -fcoarray= > > > > > > Regards, > > > > > > Jerry > > > > > > -- Andre Vehreschild * Email: vehre ad gmx dot de
Re: [Fortran, PATCH, coarray, v1] Extend caf_*_by_ref () API by a type specifier
Whoops, hi Damian, sorry for my late reply. I just saw your mail. I am still hanging ~2000 Fortran-Mailinglist mails back and because you copied the mailing list, your mail got filtered to the mailing list folder and I didn't see it in the vast number or unread mails. > Thanks for your latest work on CAF features. Could you let us know whether > this commit should be tested against the OpenCoarrays master branch or > another branch? With the master branch, I get one test failure (not counting > two known teams failures that are actually false negatives that I need to > fix): > > lib_caf_mpi::sendget_by_ref(): Warning ! sendget_by_ref() is mostly > unfunctional due to a design error. Split up your statement with coarray refs > on both sides of the assignment when the datatype transfered is non > 4-byte-integer compatible. libcaf_mpi RUNTIME ERROR: Cannot convert type 1 > kind 4 to type 0 kind 4 > > Is the above expected? Also, because the message comes from sendget, does > that mean it only affects lines that involve three images such as the > following: > > if (this_image()==1) x[2] = x[3] You may test this patch against OpenCoarrays, but without having OC patched it will not benefit from it. I prepared the gfortran patch to fix exactly the above error, but haven't had the time to fix Opencoarrays, too. I'd rather get a better gfortran-8 up and therefore am trying to get pr81773 and 83606 fixed and get them merged into gfortran-8. I follow this strategy, because gcc release cycles are less flexible then OCs. So as soon as I get 81773 and 83606 fixed, I will come back to OC fixing the type issues. Sorry for the delayed response. My time is very limited and this last gfortran fix involved the scalarizer which is a very complicated concept in the gfortran and I haven't worked with before, therefore a steep learning curve. I hope to be on track more often soon. - Andre > > > Damian > > On February 19, 2018 at 9:32:06 AM, Andre Vehreschild (ve...@gmx.de) wrote: > > Hi all, > > no objections received therefore committed as r257813. Thanks for fast > review Jerry. > > - Andre > > On Sun, 18 Feb 2018 18:33:07 +0100 > Andre Vehreschild wrote: > > > Well, after discussing on IRC whether RM should be bothered, I was asked > > to simplify release managers lives and propose, that if no one objects > > within one day, I will merge the patch. So any objections? > > > > - Andre > > > > On Sun, 18 Feb 2018 18:07:28 +0100 > > Andre Vehreschild wrote: > > > > > Dear release managers, > > > > > > this patch (for reference > > > https://gcc.gnu.org/ml/fortran/2018-02/msg00124.html) fixes a regression > > > in the coarray api by extending three relatively new functions with one > > > or two arguments, respectively. The patch has been approved by gfortran > > > devs. Asking your approval to merge it: Ok to merge to trunk? > > > > > > Regards, > > > Andre > > > > > > On Sun, 18 Feb 2018 08:53:41 -0800 > > > Jerry DeLisle wrote: > > > > > > > On 02/18/2018 07:39 AM, Andre Vehreschild wrote: > > > > > Hi all, > > > > > > > > > > attached patch fixes an issue with the coarray API. When a component > > > > > of a derived type coarray was referenced using a caf_*_by_ref () > > > > > function and that component was not an array with a descriptor, then > > > > > the type of the component was not known. Which additionally meant, > > > > > that type conversion was not applied as required. This patch fixes > > > > > that issue by adding type specifiers to the three caf_*_by_ref-calls > > > > > and implements the functionality for libcaf_single. This is harmless > > > > > because other coarray libraries that do not expect this argument just > > > > > ignore it. Additionally does this patch also provide the first > > > > > working version of caf_sendget_by_ref in libcaf_single, which > > > > > previously only lead to a stack corruption and was not usable since > > > > > the array descriptor rework (nice job, btw). > > > > > > > > > > I would like to have this patch in trunk knowing that I am somewhat > > > > > late, but it would be quite necessary, because as it is now, the > > > > > coarray feature for derived types is hardly usable. Furthermore do > > > > > some people name this a regression, because the caf_*_by_ref are also > > > > > used when the lhs of a caf_get_by_ref() is allocatable which now does > > > > > not work as expected anymore but before gcc-6 using caf_get() (w/o > > > > > reallocation) did. > > > > > > > > > > Bootstrapped and regtested ok on x86_64-linux/f27. Ok for trunk? > > > > > > > > > > - Andre > > > > > > > > > > > > > This is OK from the Fortranners perspective. Should touch base with > > > > release manager. It looks harmless though it changes coarray API, > > > > which is hidden behind -fcoarray= > > > > > > > > Regards, > > > > > > > > Jerry > > > > > > > > > > > > > -- > An