Home > Archive > Fortran > September 2005 > CSHIFT in G95 ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi,
I use g95 under IA64, and the CSHIFT function is not recognized as an
intrinsic by g95:
test.f:
do i = 1, n
a(i) = i
end do
call cshift(a,1)
$ g95 daxpy_s.f -o a.out
/tmp/ccW0LQGY.o(.text+0x492): In function `MAIN_':
: undefined reference to `cshift_'
Could you explain to me where is the problem ?
Thank you
| |
| Michael Metcalf 2005-09-21, 7:00 pm |
|
"Chris" <nospam@nospam.com> wrote in message news:dgsbsu$v07$1@io.uvsq.fr...
> Hi,
>
> I use g95 under IA64, and the CSHIFT function is not recognized as an
> intrinsic by g95:
>
> test.f:
>
> do i = 1, n
> a(i) = i
> end do
> call cshift(a,1)
>
> $ g95 daxpy_s.f -o a.out
> /tmp/ccW0LQGY.o(.text+0x492): In function `MAIN_':
> : undefined reference to `cshift_'
>
> Could you explain to me where is the problem ?
It is because cshift is a function, not a subroutine (see also "Fortran
95/2003 Explained", Section 8.13.5).
Regards,
Mike Metcalf
| |
|
| Hi, cshift is a function, not a subroutine. That's the problem there.
Maybe what you want is:
a = cshift(a,1)
FJRA
| |
|
| FJRA wrote:
>Hi, cshift is a function, not a subroutine. That's the problem there.
>Maybe what you want is:
>
>a = cshift(a,1)
>
>
> FJRA
>
>
>
It works fine, thanks a lot !
Furthermore what about the time complexity of cshift ? I mean, is it
just constant pointer operation or a linear memcopy ?
| |
| Jan Vorbrüggen 2005-09-22, 7:57 am |
| > Furthermore what about the time complexity of cshift ? I mean, is it
> just constant pointer operation or a linear memcopy ?
It cannot be just a pointer operation, as you can do a CSHIFT on the
second (or is it the first?) dimension of a 2D array, i.e., a part that
would then be discontiguous in memory.
I put a nested CSHIFT into a widely used benchmark, and from testing I
believe most compilers are able to recognize this as an implied do-loop
with circularly shifted indices, i.e., my impression was that they don't
do memcpys to implement this. OTOH, I have never actually checked the
code underneath.
If you just do an assignment, as in your sample code, I can't see how
this could be implemented any better than using at least two memcpys.
Jan
| |
|
|
> If you just do an assignment, as in your sample code, I can't see how
> this could be implemented any better than using at least two memcpys.
I'd like to apply BLAS 1 functions on loop nest such as:
do i = 1,n
do j = 1,p
do k = 1,q
a(i,k,j) = alpha * a(i,k,j)
enddo
enddo
enddo
which corresponds to a BLAS1.scal on a(.,k,.):
do i = 1,n
do j = 1,p
call sscal(q,alpha, a + offset=j*n*p*q + i , stride=q)
enddo
enddo
(in pseudo-code)
Of course, i'd like to apply the offset to 'a' without losing the
performance gain of sscal...
So i'm looking for an efficient 'offset function' in FORTRAN ?
--chris
| |
| Greg Lindahl 2005-09-22, 6:58 pm |
| In article <dgv0ml$1n4d$1@io.uvsq.fr>, Chris <nospam@nospam.com> wrote:
>I'd like to apply BLAS 1 functions on loop nest such as:
>
>do i = 1,n
> do j = 1,p
> do k = 1,q
> a(i,k,j) = alpha * a(i,k,j)
> enddo
> enddo
>enddo
Have you considered just using the above code? A good compiler will
swap the loops (you have them nested in a bad order) and do a pretty
good job overall on a loop like this. It's only when you get to BLAS
2 and BLAS 3 that handwritten routines typically are a benefit, and
even then you might be surprised how small the benefit is.
-- greg
| |
| Dick Hendrickson 2005-09-22, 6:58 pm |
|
Greg Lindahl wrote:
> In article <dgv0ml$1n4d$1@io.uvsq.fr>, Chris <nospam@nospam.com> wrote:
>
>
>
>
> Have you considered just using the above code? A good compiler will
> swap the loops (you have them nested in a bad order) and do a pretty
> good job overall on a loop like this. It's only when you get to BLAS
> 2 and BLAS 3 that handwritten routines typically are a benefit, and
> even then you might be surprised how small the benefit is.
>
> -- greg
>
Or even just write it as
a(1:n,1:q,1:p) = alpha * a(1:n,1:q,1:p)
and let the optimizer have a go at it.
Dick Hendrickson
| |
|
| Thank you very much for your answers!
And in a general manner, does it exists a way to shift fastly an array ?
|
|
|
|
|