本文几乎全部仿照xun的文章

使用Intel(R) Visual Fortran Compiler自动向量化优化代码

重复他的例子从新做一遍用以学习备忘。 也对xun表示感谢,关于Fortran的相关内容可以直接到他的博客中参考。

 

1. Fortran 向量化代码

向量化可以利用CPU的see、3Dnew等指令集,一个时钟周期处理多条数据,大大提高计算速度

 

Intel Fortran 编译学习

 

! Intel Fortran 向量化编译
! ifort c:\xlh.f90 /Qvec_report3 
! 给出提示可向量化的行,在Intel Fortran命令行执行

program a1
	implicit none
	integer::i,j
	real::a(10),b(10),c(10,10),t
	a=1.
	b=0.

	do i=1,10
		b(i)=a(i)*i 	!可向量化
	enddo

	do i=2,10
		a(i)=a(i-1) 	!不可向量化
	enddo

	do j=1,10
		t=a(j)+b(j)
		do i=1,10
		c(i,j)=a(i)+b(i)-t 	!可向量化
		enddo
	enddo

	write(*,*) c
	stop
end program

 

2. 查询可Fortran向量化的语句

 

在Intel Fortran的命令行执行

ifort c:\xlh.f90 /Qvec_report3

 

显示:9,10,12行可向量化

Intel Fortran 编译学习

 

3. Fortran编译成EXE并执行

ifort c:\xlh.f90

默认会在Intel Fortran的安装目录下生成EXE 

C:\Program Files (x86)\Intel\ComposerXE-2011

执行

Intel Fortran 编译学习

http://www.cnblogs.com/ytyt2002ytyt/

杨韬的学习备忘录 YTYT2002YTYT 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2021-12-23
  • 2021-09-26
  • 2021-10-09
猜你喜欢
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案