禁用FORTRAN中的矢量化循环? [英] Disable vectorized looping in FORTRAN?

查看:237
本文介绍了禁用FORTRAN中的矢量化循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在FORTRAN中绕过循环向量化?我正在写一个特定项目的F77标准,但是GNU gfortran通过现代的FORTRAN编译,比如F95。有谁知道某些FORTRAN标准是否避免了循环向量化,或者gfortran中有任何标志/选项可以关闭它?

更新:所以,我认为最终的解决方案我的具体问题不得不与FORTRAN DO循环做,而不允许更新迭代变量。提及这一点可以在@High Performance Mark的相关主题回复中找到... 循环矢量化以及如何避免它



<进入FORT,RAN为避难所提供服务。>

Fortran标准一般都没有说明如何实现语言,而是让编译器编写人员能够更好地确定在任何语言的任何特性上实现语言的最佳或好的选项芯片架构。



当你写你想要绕过循环矢量化时,你的意思是什么?在下一句话中,建议FORTRAN77程序不可用?如果CPU能够遵守它们,现代CPU的编译器生成向量指令是非常正常的。这是真的,无论编程语言的版本是什么。



如果你真的不想生成向量指令,那么你必须检查gfortran文档小心 - 这不是我使用的编译器,所以我不能指出特定的选项或标志。您可能希望查看其针对特定体系结构代码生成的功能,特别注意SSE级别。



您可能能够将编译器强制转换为非矢量化循环if所有的循环都是显式的(所以不需要全数组操作),并且如果使代码很难以其他方式进行矢量化(例如循环迭代之间的依赖关系)。但是一个好的现代编译器,没有任何干扰,会试着用它来为自己的好处引入循环。



对我来说,试图强制编译器违背其性质,也许你可以解释为什么你想更详细地做这件事。


Is it possible to bypass loop vectorization in FORTRAN? I'm writing to F77 standards for a particular project, but the GNU gfortran compiles up through modern FORTRANs, such as F95. Does anyone know if certain FORTRAN standards avoided loop vectorization or if there are any flags/options in gfortran to turn this off?

UPDATE: So, I think the final solution to my specific problem has to "DO" with the FORTRAN DO loops not allowing the updating of the iteration variable. Mention of this can be found in @High Performance Mark's reply on this related thread... Loop vectorization and how to avoid it

[Into the FORT, RAN the noobs for shelter.]

解决方案

The Fortran standards are generally silent on how the language is to be implemented, leaving that to the compiler writers who are in a better position to determine the best, or good (and bad) options for implementation of the language's various features on whatever chip architecture(s) they are writing for.

What do you mean when you write that you want to bypass loop vectorisation ? And in the next sentence suggest that this would be unavailable to FORTRAN77 programs ? It is perfectly normal for a compiler for a modern CPU to generate vector instructions if the CPU is capable of obeying them. This is true whatever version of the language the program is written in.

If you really don't want to generate vector instructions then you'll have to examine the gfortran documentation carefully -- it's not a compiler I use so I can't point you to specific options or flags. You might want to look at its capabilities for architecture-specific code generation, paying particular attention to SSE level.

You might be able to coerce the compiler into not vectorising loops if all your loops are explicit (so no whole-array operations) and if you make your code hard to vectorise in other ways (dependencies between loop iterations for example). But a good modern compiler, without interference, is going to try its damndest to vectorise loops for your own good.

It seems rather perverse to me to try to force the compiler to go against its nature, perhaps you could explain why you want to do that in more detail.

这篇关于禁用FORTRAN中的矢量化循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆