public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* FINDLOC: (was Implement simplification of minloc and maxloc)
       [not found] <8C29278A-72EC-4B43-BC91-C33D0EC716DE@yahoo.com>
@ 2018-01-06 19:28 ` Darrell Reich via fortran
  2018-01-06 21:08   ` Steve Kargl
  2018-01-07 12:33   ` arrl via fortran
  0 siblings, 2 replies; 6+ messages in thread
From: Darrell Reich via fortran @ 2018-01-06 19:28 UTC (permalink / raw)
  To: fortran

PR54613 suggests MAXLOC could be adapted to implement FINDLOC by replacing max with any value. I took a look before it was simplified and the generated C code was over my head. Meanwhile, I am attempting to implement FINDLOC in Fortran.

Does this work on MAXLOC inspire you to be able to implement F08 FINDLOC? The spec is at link below for reference.

https://gcc.gnu.org/wiki/GFortranStandards#Fortran_2008 <https://gcc.gnu.org/wiki/GFortranStandards#Fortran_2008>
http://www.j3-fortran.org/doc/year/10/10-007.pdf <http://www.j3-fortran.org/doc/year/10/10-007.pdf>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FINDLOC: (was Implement simplification of minloc and maxloc)
  2018-01-06 19:28 ` FINDLOC: (was Implement simplification of minloc and maxloc) Darrell Reich via fortran
@ 2018-01-06 21:08   ` Steve Kargl
  2018-01-07 12:33   ` arrl via fortran
  1 sibling, 0 replies; 6+ messages in thread
From: Steve Kargl @ 2018-01-06 21:08 UTC (permalink / raw)
  To: Darrell Reich via fortran

On Sat, Jan 06, 2018 at 11:28:46AM -0800, Darrell Reich via fortran wrote:
>
> PR54613 suggests MAXLOC could be adapted to implement FINDLOC
> by replacing max with any value. I took a look before it was
> simplified and the generated C code was over my head.  Meanwhile,
> I am attempting to implement FINDLOC in Fortran.
> 
> Does this work on MAXLOC inspire you to be able to implementr
> F08 FINDLOC?
> 

Hi Darrell,

Are you asking if someone else is working on findloc,
or are you asking for help in adding findloc to gfortran?

-- 
Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FINDLOC: (was Implement simplification of minloc and maxloc)
  2018-01-06 19:28 ` FINDLOC: (was Implement simplification of minloc and maxloc) Darrell Reich via fortran
  2018-01-06 21:08   ` Steve Kargl
@ 2018-01-07 12:33   ` arrl via fortran
  2018-01-07 13:15     ` Thomas Koenig
  1 sibling, 1 reply; 6+ messages in thread
From: arrl via fortran @ 2018-01-07 12:33 UTC (permalink / raw)
  To: fortran

On 1/6/2018 2:28 PM, Darrell Reich via fortran wrote:
> PR54613 suggests MAXLOC could be adapted to implement FINDLOC by replacing max with any value. I took a look before it was simplified and the generated C code was over my head. Meanwhile, I am attempting to implement FINDLOC in Fortran.
> 
> Does this work on MAXLOC inspire you to be able to implement F08 FINDLOC? The spec is at link below for reference.
> 
> https://gcc.gnu.org/wiki/GFortranStandards#Fortran_2008 <https://gcc.gnu.org/wiki/GFortranStandards#Fortran_2008>
> http://www.j3-fortran.org/doc/year/10/10-007.pdf <http://www.j3-fortran.org/doc/year/10/10-007.pdf>
> 
Do you mean Fortran such as
	i = findlocl(a(:) = val, .true., .false.)
....
    contains
     integer function findlocl(a,val,back)result(i)
     logical a(:),val,back
     integer i
     if(back)then
     do i=size(a),1,-1
       if(a(i).eqv.val)exit
       enddo
     else
     do i=1,size(a)
       if(a(i).eqv.val)exit
       enddo
       endif
       if(i>size(a))i=0
       return
     end function findloc
?
It's faster than ifort findloc.  The apparent advantage of a true
findloc implementation would be ability to terminate all loops early, if
that can be done without losing simd vector performance. In gfortran,
where little of this is vectorizable, this takes several times as long
as a plain search loop, due in part to the effort expended on creating a
new implicit array.
-- 
Tim Prince

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FINDLOC: (was Implement simplification of minloc and maxloc)
  2018-01-07 12:33   ` arrl via fortran
@ 2018-01-07 13:15     ` Thomas Koenig
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Koenig @ 2018-01-07 13:15 UTC (permalink / raw)
  To: tprince, fortran

Am 07.01.2018 um 13:27 schrieb arrl via fortran:
> On 1/6/2018 2:28 PM, Darrell Reich via fortran wrote:
>> PR54613 suggests MAXLOC could be adapted to implement FINDLOC by replacing max with any value. I took a look before it was simplified and the generated C code was over my head. Meanwhile, I am attempting to implement FINDLOC in Fortran.
>>
>> Does this work on MAXLOC inspire you to be able to implement F08 FINDLOC? The spec is at link below for reference.
>>
>> https://gcc.gnu.org/wiki/GFortranStandards#Fortran_2008 <https://gcc.gnu.org/wiki/GFortranStandards#Fortran_2008>
>> http://www.j3-fortran.org/doc/year/10/10-007.pdf <http://www.j3-fortran.org/doc/year/10/10-007.pdf>
>>
> Do you mean Fortran such as
> 	i = findlocl(a(:) = val, .true., .false.)
> ....
>      contains
>       integer function findlocl(a,val,back)result(i)
>       logical a(:),val,back
>       integer i
>       if(back)then
>       do i=size(a),1,-1
>         if(a(i).eqv.val)exit
>         enddo


That's one thing that I have been wondering about. Does it actually
make sense to implement FINDLOC by going backwards throught memory?
This is so much slower than going forward... of course, it
would depend on where the item to be found actually is.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FINDLOC: (was Implement simplification of minloc and maxloc)
@ 2018-01-17  2:37 Darrell Reich via fortran
  0 siblings, 0 replies; 6+ messages in thread
From: Darrell Reich via fortran @ 2018-01-17  2:37 UTC (permalink / raw)
  To: fortran

I am watching the recent discussions of "simplification of MAXLOC" and adding the BACK parameter.
I found the similar FINDLOC PR54613 in the database.
If the proposed solution to copy MAXLOC and add VALUE instead of MAX is valid then what is the level of effort to implement FINDLOC based on the recent improvements to MAXLOC?
Is it buy one get one free or a whole other project to dig into?

Having successfully built gfortran 8 and looking over the C code that implements MAXLOC, I am not in any position to contribute more than a test case at this point but I’m learning.

We’re upgrading from Fortran 77 to Modern Fortran 2008 / 2015 as we read up on the spec for these new intrinsic functions. It has been a long time since I took compiler design on a PDP-11. gcc project is very impressive.

>Are you asking if someone else is working on findloc, or are you asking for help in adding findloc to gfortran?

> PR54613 suggests MAXLOC could be adapted to implement FINDLOC
> by replacing max with any value. I took a look before it was
> simplified and the generated C code was over my head.  Meanwhile,
> I am attempting to implement FINDLOC in Fortran.
> 
> Does this work on MAXLOC inspire you to be able to implementr
> F08 FINDLOC?
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FINDLOC: (was Implement simplification of minloc and maxloc)
@ 2018-01-07 14:24 n8tm via fortran
  0 siblings, 0 replies; 6+ messages in thread
From: n8tm via fortran @ 2018-01-07 14:24 UTC (permalink / raw)
  To: Thomas Koenig, tprince, fortran

The standard requires the back option, which would be needed to find the last match.  In my test case, performance is very poor compared with a simple do loop.  If you're talking about hardware capability for buffering reverse memory access, the last cpu I saw lacking it was Athlon.  It's true the number of hardware supported reverse streams is expected to be small.

Sent via the Samsung Galaxy Tab E, an AT&T 4G LTE tablet
-------- Original message --------From: Thomas Koenig <tkoenig@netcologne.de> Date: 1/7/18  08:15  (GMT-05:00) To: tprince@intelretiree.com, fortran@gcc.gnu.org Subject: Re: FINDLOC: (was Implement simplification of minloc and maxloc) 
Am 07.01.2018 um 13:27 schrieb arrl via fortran:
> On 1/6/2018 2:28 PM, Darrell Reich via fortran wrote:
>> PR54613 suggests MAXLOC could be adapted to implement FINDLOC by replacing max with any value. I took a look before it was simplified and the generated C code was over my head. Meanwhile, I am attempting to implement FINDLOC in Fortran.
>>
>> Does this work on MAXLOC inspire you to be able to implement F08 FINDLOC? The spec is at link below for reference.
>>
>> https://gcc.gnu.org/wiki/GFortranStandards#Fortran_2008 <https://gcc.gnu.org/wiki/GFortranStandards#Fortran_2008>
>> http://www.j3-fortran.org/doc/year/10/10-007.pdf <http://www.j3-fortran.org/doc/year/10/10-007.pdf>
>>
> Do you mean Fortran such as
> 	i = findlocl(a(:) = val, .true., .false.)
> ....
>      contains
>       integer function findlocl(a,val,back)result(i)
>       logical a(:),val,back
>       integer i
>       if(back)then
>       do i=size(a),1,-1
>         if(a(i).eqv.val)exit
>         enddo


That's one thing that I have been wondering about. Does it actually
make sense to implement FINDLOC by going backwards throught memory?
This is so much slower than going forward... of course, it
would depend on where the item to be found actually is.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-01-17  2:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <8C29278A-72EC-4B43-BC91-C33D0EC716DE@yahoo.com>
2018-01-06 19:28 ` FINDLOC: (was Implement simplification of minloc and maxloc) Darrell Reich via fortran
2018-01-06 21:08   ` Steve Kargl
2018-01-07 12:33   ` arrl via fortran
2018-01-07 13:15     ` Thomas Koenig
2018-01-07 14:24 n8tm via fortran
2018-01-17  2:37 Darrell Reich via fortran

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).