Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28456 Discussions

macro to choose source for 256- vs. 512-bit ISA

TimP
Honored Contributor III
394 Views

I've been in the habit of using __MIC__ to tell the compiler how to vectorize (or not) e.g.

#if __MIC__
          a(:n)= pack(b(:n),b(:n)>0)
#else
          j= 0
          do i= 1,n
            if(b(i) > 0.)then
                j= j+1
                a(j)= b(i)
              endif
            enddo
#endif

or (for the case where the compiler vectorizes for AVX but loses performance)

#if ! __MIC__
!dir$ novector
#endif

Now that compilers support AVX512, it appears that additional macros will be needed, e.g.

#if (! __KNC__) && (! __AVX512F__)

Is there a better way?  Now that both ifort and gfortran are excessively aggressive sometimes about vectorization, I've introduced some conditional real,volatile :: declarations, but this is getting ugly.

I've been going through source code to remove conditional compilations where the latest Intel compilers make the right decision about vectorization, but it seems unlikely that compilers will get any better on this.

 

0 Kudos
1 Reply
Steven_L_Intel1
Employee
394 Views

Tim, we haven't created preprocessor symbols for instruction set subsets. If you know you are going to compile for AVX512 you can define your own symbol and reference it. I don't think our compiler wants to go down the path of specific macros for this sort of thing. Certainly we're interested in test cases where automatic vectorization hurts rather than helps - a Premier Support issue would be best for this sort of thing.

0 Kudos
Reply