有没有办法显示LLVM在哪里进行自动矢量化? [英] Is there a way to show where LLVM is auto vectorising?

查看:176
本文介绍了有没有办法显示LLVM在哪里进行自动矢量化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文:我正在编写的Objective-C库中有多个循环,这些循环处理大型文本数组.我现在可以看到它正在以单线程方式运行.

Context: I have several loops in an Objective-C library I am writing which deal with processing large text arrays. I can see that right now it is running in a single threaded manner.

我了解到LLVM现在具有自动矢量化循环的能力,正如在WWDC上的Apple会议上所描述的那样.但是,这样做的方式非常谨慎,原因之一是由于CPU流水线可能会修改变量.

I understand that LLVM is now capable of auto-vectorising loops, as described at Apple's session at WWDC. It is however very cautious in the way it does it, one reason being the possibility of variables being modified due to CPU pipelining.

我的问题:如何查看LLVM在哪里矢量化了我的代码,更有用的是,我如何接收调试消息来解释为什么它不能对我的代码进行矢量化?我确定它是否可以看到为什么无法对其进行矢量化处理,它可以向我指出这一点,并且我可以进行必要的手动调整以使其可矢量化.

My question: how can I see where LLVM has vectorised my code, and, more usefully, how can I receive debug messages that explain why it can't vectorise my code? I'm sure if it can see why it can't auto-vectorise it, it could point that out to me and I could make the necessary manual adjustments to make it vectorisable.

如果我没有指出这个问题已经或多或少地被问到了,我会很失落,但相当令人费解的是,

I would be remiss if I didn't point out that this question has been more or less asked already, but quite obtusely, here.

推荐答案

Xcode提供的标准llvm工具链似乎不支持从优化器获取调试信息.但是,如果滚动自己的llvm并使用它,则应该能够按照上面建议的方式传递标志.这是我使用的工作流程:

The standard llvm toolchain provided by Xcode doesn't seem to support getting debug info from the optimizer. However, if you roll your own llvm and use that, you should be able to pass flags as mishr suggested above. Here's the workflow I used:

1.使用自制软件,安装llvm

brew tap homebrew/versions
brew install llvm33 --with-clang --with-asan

这应该安装完整且相对最新的llvm工具链.它已链接到/usr/local/bin/*-3.3(即clang++-3.3).实际的磁盘位置可通过brew info llvm33-可能是/usr/local/Cellar/llvm33/3.3/bin.

This should install the full and relatively current llvm toolchain. It's linked into /usr/local/bin/*-3.3 (i.e. clang++-3.3). The actual on-disk location is available via brew info llvm33 - probably /usr/local/Cellar/llvm33/3.3/bin.

2.使用自制llvm和标志构建您要优化的单个文件

如果您使用Xcode内置,则可以轻松地复制粘贴构建参数,并使用clang ++-3.3代替Xcode自己的clang.

If you've built in Xcode, you can easily copy-paste the build parameters, and use your clang++-3.3 instead of Xcode’s own clang.

附加-mllvm -debug-only=loop-vectorize将为您提供自动矢量化报告.注意:这可能不适用于任何远程复杂的构建,例如如果您拥有PCH,但是它是调整单个cpp文件以确保其正确矢量化的一种简单方法.

Appending -mllvm -debug-only=loop-vectorize will get you the auto-vectorization report. Note: this will likely NOT work with any remotely complex build, e.g. if you've got PCH's, but is a simple way to tweak a single cpp file to make sure it's vectorizing correctly.

3.从新的llvm创建编译器插件

我能够通过以下方式使用自制llvm构建我的整个项目:

I was able to build my entire project with homebrew llvm by:

  1. 使用此Xcode编译器插件:
  1. Grabbing this Xcode compiler plugin: http://trac.seqan.de/browser/trunk/util/xcode/Clang%20LLVM%20MacPorts.xcplugin.zip?order=name
  2. Modifying the clang-related paths to point to my homebrew llvm and clang bin names (by appending '-3.3')
  3. Placing it in /Library/Application Support/Developer/5.0/Xcode/Plug-ins/

重新启动Xcode应该在可用编译器列表中显示此插件.此时,-mllvm -debug-only=loop-vectorize标志将显示自动矢量化报告.

Relaunching Xcode should show this plugin in the list of available compilers. At this point, the -mllvm -debug-only=loop-vectorize flag will show the auto-vectorization report.

我不知道为什么这在Apple版本中没有显示.

更新:在当前(8.x)版本的Xcode中公开.唯一需要做的就是启用一个或多个loop-vectorize标志.

UPDATE: This is exposed in current (8.x) versions of Xcode. The only thing required is to enable one or more of the loop-vectorize flags.

这篇关于有没有办法显示LLVM在哪里进行自动矢量化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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