Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29391 ディスカッション

Working with sample codes for vectorization

Fortran10
初心者
4,219件の閲覧回数

I am using this exercise of vectorization:

 

oneAPI-samples/DirectProgramming/Fortran/DenseLinearAlgebra/vectorize-vecmatmult at master · oneapi-src/oneAPI-samples · GitHub

 

I am using the Windows 10 operating system and command line ( Not the MVS ).

 

My questions is:

 

  • What is the Windows version of the command:

ifort -real-size 64 -qopt-report=2 -qopt-report-phase=vec -D ALIGNED -ipo src/matvec.f90 src/driver.f90 -o MatVector

 

specifically how to instruct the aligned command there? Or how to use command line directives? How to specify the option?

 

 

 

 

0 件の賞賛
1 解決策
TobiasK
モデレーター
4,137件の閲覧回数

Hi @Fortran10


most Linux command line options translate to Windows with the same name but '/' instead of '-'

In the developers guide and reference we always list the option for Linux as well for Windows:

e.g. -D becomes /D

https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-2/d.html


元の投稿で解決策を見る

16 返答(返信)
andrew_4619
名誉コントリビューター III
4,161件の閲覧回数

/[no]align
analyze and reorder memory layout for variables and arrays
/align:<keyword>
specify how data items are aligned
keywords: all (same as /align), none (same as /noalign),
[no]commons, [no]dcommons,
[no]qcommons, [no]zcommons,
rec1byte, rec2byte, rec4byte,
rec8byte, rec16byte, rec32byte,
array8byte, array16byte, array32byte,
array64byte, array128byte, array256byte,
[no]records, [no]sequence

 

TobiasK
モデレーター
4,138件の閲覧回数

Hi @Fortran10


most Linux command line options translate to Windows with the same name but '/' instead of '-'

In the developers guide and reference we always list the option for Linux as well for Windows:

e.g. -D becomes /D

https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-2/d.html


Fortran10
初心者
4,101件の閲覧回数

The developer guide says D :

 

Defines a symbol name that can be associated with an optional value.

 

What is the symbol here? and how optional value is related to ALIGNED. These two things are not very straightforward from here.

 

My initial guess was, "It is used to define Directives." D for Directive and is used in combination with ALIGNED to inform the compiler that I want to use the Compiler directive i.e. ALIGNED.

 

 

 

 

 

jimdempseyatthecove
名誉コントリビューター III
4,080件の閲覧回数

@TobiasK last post referred to "/" verses "-" for option indicator on command line. The D was simply a place holder, and not to be construed with an actual switch.

 

FWIW

 

/Dnewsymbol /Dnewvalue=1

...

!$if defined(newsymbol) then

! conditional code 

!$endif

...

!$if (newvalue==1) then

! conditional code 

!$endif

 

Jim Dempsey

TobiasK
モデレーター
4,005件の閲覧回数

 

In addition to what Jim said, if you look into the source code of driver.f90:

https://github.com/oneapi-src/oneAPI-samples/blob/master/DirectProgramming/Fortran/DenseLinearAlgebra/vectorize-vecmatmult/src/driver.f90

 

You notice some #if defined structure as Jim wrote.

That means, such a file must be processed by a preprocessor. Either you use a standalone preprocessor as cpp or fpp or you just instruct to compiler to call the preprocessor before the actual code compilation via /fpp or /cpp compiler flags.

 

It does not do anything at the compile step, all it affects is prior the compilation.

 

In the driver example you see some

 

!DIR$ IF DEFINED(ALIGNED)
 integer, parameter      :: ROWBUF=3
!DIR$ ELSE
 integer, parameter      :: ROWBUF=0
!DIR$ END IF

 

if you invoke the compiler with /fpp /D ALINGED the actual Fortran file will be: (because ALIGNED is defined by \D)

 

 integer, parameter      :: ROWBUF=3

 

if you invoke the compiler with /fpp /d XYZ the actual Fortran file will be: (because ALINGED is not defined by \D)

 

 integer, parameter      :: ROWBUF=0

 

So think of preprocessing as an automated text editor.

 

Best

Tobias

 

Fortran10
初心者
3,593件の閲覧回数

using /fpp /DALIGNED shows this error:

 

fpp_ALIGNED.PNG

 

without using /fpp it does not show any error:

 

ALIGNED_QxHost.PNG

Fortran10
初心者
3,976件の閲覧回数

Performance baseline

I do not actually see any improvement

Using /fpp 

fpp.PNG

 

without /fpp

no_fpp.PNG

 

My computer details are

11th Gen Intel(R) Core(TM) i5-11500 @ 2.70GHz

 

I tried this with both 16 and 64 bytes (driver.f90 file), but still no improvement.

!DIR$ attributes align : 16 :: a,b,c

jimdempseyatthecove
名誉コントリビューター III
3,937件の閲覧回数

If you are on an Intel CPU, try adding option /QxHost

If AMD, try adding /QxAVX

 

Also, it may be helpful to build optimized code with generating and keeping debug symbols, then running under VTune. Ignore the runtimes but use VTune to show the Disassembly.

With this, you can verify two things:

a) Was the ALIGNED code vectorized.

b) Was the not ALIGNED code not vectorized.

 

Jim Dempsey

 

Fortran10
初心者
3,897件の閲覧回数

Thanks for the hint. I will have a look at VTune. That tool seems to be very informative in understanding vectorization.

Steve_Lionel
名誉コントリビューター III
3,806件の閲覧回数

@jimdempseyatthecove wrote:

If you are on an Intel CPU, try adding option /QxHost

If AMD, try adding /QxAVX

 

 


If non-Intel CPU, /arch:AVX . /QxAVX will cause a run-time error when the program starts on non-Intel CPUs.

P.S. Jim, please check your messages here on the forum.

Barbara_P_Intel
従業員
3,921件の閲覧回数

@Fortran10, I see a couple of typos in the compiler options in your screenshot using /fpp. Should be 

/DALIGNED

You also might want to update to the latest release of ifort. Yours is 1.5+ years old.

 

Fortran10
初心者
3,829件の閲覧回数

I did following steps to update:

 

1. download the BaseKit

download_baseKit.png

2. Install

installed_baseKit.PNG

 3. Download the HPC Kit shows that error 

HPC_kit.PNG

 

4. Separate downloading the Fortran compiler

 

fortran_compiler_Separate_download.PNG

 

5. Download folder looks like

 

download_baseKit_and_Fortran_compiler.PNG

 

 

 

 

 

6. Running Fortran code shows error

intel_error.PNG

7. Start menu: 

 

Intel_settings_in_start_menu.PNG

 

So what should be done now ? 

 

Fortran10
初心者
3,593件の閲覧回数

I removed the installed version.

 

1)  Now i have installed the version 2023.1.0.47256.

 

version.PNG

 

That seems to work fine.

 

2)   However using /fpp /DALIGNED shows error:

 

 

fpp_ALIGNED.PNG

 

3)   Without using /fpp , I do not see any error.

 

ALIGNED_QxHost.PNG

 

4)    Also, the use of /Qipo does not improve performance.

 

DALIGNED_QxHost_Qipo.PNG

Fortran10
初心者
3,898件の閲覧回数

@Barbara_P_Intel Thanks for the clarification.

 

I have performed the following tests with these outputs.

 

Seems like

 

  • /fpp /DALIGNED should always be used with /QxHost.
  • /QxHost alone is producing the same performance without using /fpp /DALIGNED.

QxHost and Aligned test.PNG

 

So does that mean aligning data is not compatible here?

 

  • The use of /Qipo however improves the performance

 

Qipo test.PNG

 

@Barbara_P_Intel Thanks for notifying me, I will try to install the new release this coming weekend and will perform the same results.

Barbara_P_Intel
従業員
3,860件の閲覧回数

@Fortran10, there's still a typo regarding /DALIGNED in your screen shot.

 

jimdempseyatthecove
名誉コントリビューター III
3,577件の閲覧回数

You Are combining fpp and having /DALIGNED and testing !DIR$ IF DEFIGNED(ALIGNED)

The /DALIGNED is going to set ALIGNED=1

Then fpp is going to replace the text "ALIGNED" with its content "1", and the literal 1 is not a definable variable/macro.

When you use fpp in combination with compiler directives you should be aware of these types of conflicting usage.

 

Because these sources have no #xxx preprocessor directives, you can remove the /fpp from your command line.

 

Jim Dempsey

返信