带有AVX2支持进行编译并运行 [英] Compile with AVX2 support and run

查看:147
本文介绍了带有AVX2支持进行编译并运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的库,我想用AVX2支持对其进行编译(但我的处理器仅支持AVX).该库还具有内部运行时检查,以检查处理器是否支持AVX2.像这样:

I have a very big library and I want to compile it with AVX2 support (but my processor supports inly AVX). This library also has internal runtime checks whether a processor support AVX2 or not. Something like this:

#if __AVX2__
if (support_avx2)
{
    // vectorized code
}
#endif
// simple C++ code

我能够在具有AVX2支持的情况下编译该库,但是当我运行测试时,我就已经开始了:

I was able to compile the library with AVX2 support, but when I run tests I have got at the very beginning:

Illegal instruction: 4

有什么想法吗? 目的是使用所有可用的优化和功能来编译库,并在运行时对其进行检查.

Any ideas? The goal is to compile the library with all available optimisations and features and check them in runtime.

p.s.我正在使用OSX

p.s. I'm working on OSX

推荐答案

没有简单的方法在只有AVX(例如Sandy Bridge/Ivy Bridge)的CPU上运行AVX2代码.您可以使用英特尔的SDE 来运行以下代码测试目的(至少对于命令行可执行文件而言,这实际上工作得很好),但是获得Haswell Mac进行开发和测试可能会更容易.

There is no easy way to run AVX2 code on a CPU that only has AVX (e.g. Sandy Bridge/Ivy Bridge). You could use Intel's SDE to run the code for test purposes (this actually works pretty well, for command-line executables at least), but it might just be easier to get a Haswell Mac for development and testing.

这篇关于带有AVX2支持进行编译并运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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