- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have frequently heard that in C++ HPC xeon phi applications, it is beneficial to declare variables as const, if possible. However, I cannot seem to ascertain whether or not this is possible in Fortran. Is there a way to do this type of optimization using ifort
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have seen that used for doubles and ints. Would that work for an array that I am passing to a subroutine as well?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you're asking the wrong question - the question you want to ask is 'what is the most efficient way to pass array arguments?' - this is really what you're after, correct?
Read this: https://software.intel.com/en-us/articles/fortran-array-data-and-arguments-and-vectorization
while written for Xeon Phi it also applies to any Intel processor using the Intel Fortran compilers.
Don't forget that job #1 is to align your data and tell the compiler it is aligned: https://software.intel.com/en-us/articles/data-alignment-to-assist-vectorization. If you're using Phi, YOU MUST ALIGN YOUR DATA for performance. Anything else is window dressing and minor tweaks.
You should read through the rest of the Methodology guide for more details on tuning: https://software.intel.com/en-us/articles/programming-and-compiling-for-intel-many-integrated-core-architecture
Also, I recommend using -fno-alias -fno-fnalias if you're sure your code is not aliasing.
Ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ronald I am not quite sure if that is my question, here is an example of what I am talking about
subroutine calc_sum(A,B,n,sumval) implicit none double precision :: A(n),B(n) double precision :: A1,B1 double precision:: sumval integer :: loop1,loop2 sumval = 0.0d0 do loop1 = 1,n A1 = A(loop1) do loop2 = 1,n B1 = B(loop2) sumval = sumval + A1+B enddo enddo end subroutine
I do not know how to tell the compiler that, for the purposes of this subroutine, the array elements are constant. For instance, if the code I were writing were in C++ (which I don't actually know, so I apologize if there is a typo in the following code) I would write the following
void calc_sum(const double A, const double B, const int n, double sumval)
I have frequently seen these types of optimizations implemented in xeon phi codes. Does the -fno-alias handle this?
Just a side question about alignment, consider the case that A were an array of structures with an odd number of double elements
type a_elements double precision :: a1,a2,a3 end type a_elements type(a_elements) :: A(n)
When I run for a Xeon phi, does EVERY array element have to be aligned or just the first array element? In this example, the first array element, A(1), would be aligned when I compile with -align array64byte, but the remaining array elements would not be. If all array elements need to be aligned, how would I pad this data structure to accomplish this in Fortran?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page