- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My question concerns what happens when I call an external subroutine like this:
COMPLEX :: A(100,100,100)
CALL FFT(A(1,1,5:100:5))
Does Fortran,
1) Create a new array on the stack consisting of the subsection, call the routine with it, then copy the new array back to the original? or
2) Somehow magically pass offset and stride information to the subroutine?
I am trying to build up a 3D-FFT from Intel's optimized 1D-FFT in their Math Performance Library. However, their function doesn't allow for arbitrary offset and stride information to be given to the FFT... so I would have to use Fortran90 array sections to achieve this effect.
Thanks for any help!
COMPLEX :: A(100,100,100)
CALL FFT(A(1,1,5:100:5))
Does Fortran,
1) Create a new array on the stack consisting of the subsection, call the routine with it, then copy the new array back to the original? or
2) Somehow magically pass offset and stride information to the subroutine?
I am trying to build up a 3D-FFT from Intel's optimized 1D-FFT in their Math Performance Library. However, their function doesn't allow for arbitrary offset and stride information to be given to the FFT... so I would have to use Fortran90 array sections to achieve this effect.
Thanks for any help!
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It depends. If you've provided an explicit interface for which the corresponding argument is a deferred-shape array (dimensioned as (:,:,:) in this case), AND the actual routine is written that way, then the offset and stride information is "magically passed". Otherwise, a copy on the stack is made, the copy is passed, then the results are copied back to the original array - not the fastest thing in the world.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, let's try this one then. Let's say I have a big matrix and a small matrix:
REAL :: BigM(100,100,100), SmallM(10,10,10), Coefficient
Then I try this:
BigM(5:15,6:16,10:20) = BigM(5:15,6:16,10:20) + Coefficient * SmallM
Is Fortran smart enough to do this without making a copy on the stack?
How can I determine for myself exactly how Fortran is implementing this matrix operation? Is there some sort of listing file I can generate and check?
REAL :: BigM(100,100,100), SmallM(10,10,10), Coefficient
Then I try this:
BigM(5:15,6:16,10:20) = BigM(5:15,6:16,10:20) + Coefficient * SmallM
Is Fortran smart enough to do this without making a copy on the stack?
How can I determine for myself exactly how Fortran is implementing this matrix operation? Is there some sort of listing file I can generate and check?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, this is a completely different question. The compiler tries hard to not generate a temporary in array operations, but I can't say without trying it whether or not a temp is created for this case.
You can generate a listing with machine code and try to figure it out that way. You'd be looking for a large subtract from ESP (the stack pointer) for the temp.
I'll note that in 6.5A, you can get the compiler to give you a run-time message when an array temp is created for passing an argument - /check:arg_temp_created
Steve
You can generate a listing with machine code and try to figure it out that way. You'd be looking for a large subtract from ESP (the stack pointer) for the temp.
I'll note that in 6.5A, you can get the compiler to give you a run-time message when an array temp is created for passing an argument - /check:arg_temp_created
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, after rewriting the code to avoid creating the temporary variable, my iterations have gone from 0.4 sec to 0.04 sec... nice! Thanks Steve!
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page