- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在用 C++ 实现一个简单的 SIMD 包装器。为了使其跨平台,我使用 CMake 通过 Visual Studio 设置项目
我添加了/Arch:AVX2,但 Visual Studio 无法识别 __AVX2__
宏。
首先,我的 CMake。
cmake_minimum_required(VERSION 3.12.2)
set(INCLUDEDIR "include/Maths")
set(SOURCEDIR "src")
set(HEADER_FILES
${INCLUDEDIR}/export.h
${INCLUDEDIR}/SIMDWrapper/Config/SIMDConfig.h)
set(SOURCE_FILES
${SOURCEDIR}/Application.cpp)
add_library(Maths SHARED ${SOURCE_FILES} ${HEADER_FILES})
target_link_libraries(Maths PUBLIC Core)
target_include_directories(Maths PUBLIC "include")
target_compile_options(Maths PRIVATE $<$<BOOL:${MSVC}>:/arch:AVX2>)
target_compile_definitions(Maths PRIVATE MATHS_EXPORT)
还有我的头文件(来自 Agner Fog 的 VectorClass instrset.h
):
#pragma once
#if (defined(_M_AMD64) || defined(_M_X64) || defined(__amd64)) && !
defined(__x86_64__)
#define __x86_64__ 1
#endif
#ifndef SIMD_INSTR_SET
#if defined (__AVX2__)
#define SIMD_INSTR_SET 8
#elif defined ( __AVX__ )
#define SIMD_INSTR_SET 7
#elif defined ( __SSE4_2__ )
#define SIMD_INSTR_SET 6
#elif defined ( __SSE4_1__ )
#define SIMD_INSTR_SET 5
#elif defined ( __SSSE3__ )
#define SIMD_INSTR_SET 4
#elif defined ( __SSE3__ )
#define SIMD_INSTR_SET 3
#elif defined ( __SSE2__ ) || defined ( __x86_64__ )
#define SIMD_INSTR_SET 2 //this is where the color has changed
#elif defined ( __SSE__ )
#define SIMD_INSTR_SET 1
#elif defined ( _M_IX86_FP )
#define SIMD_INSTR_SET _M_IX86_FP
#else
#define SIMD_INSTR_SET 0
#endif // instruction set defines
#endif // SIMD_INSTR_SET
我就是这样做的。__x86_64__
已定义,我的 CPU 是 i5 Skylake,因此它应该支持 AVX2。
我检查了是否从项目配置属性中启用了 Advanced Vector Extensions 2 选项,并且它已启用。
是否需要从 CMake 或 Visual Studio 更改/添加某些内容以使 AVX2 宏可识别?
最佳答案
可以通过三种方式为您的目标启用编译选项/arch:AVX2
(如果您的编译器支持)。
要么使用生成器表达式
target_compile_options(Maths PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/arch:AVX2>)
或者通过在 if
子句中设置编译选项
if(MSVC)
target_compile_options(Maths PRIVATE /arch:AVX2)
endif()
或者通过使用 add_definition
调用将定义添加到在此命令之后在脚本中创建的所有目标
if(MSVC)
add_definition(/arch:AVX2)
endif()
如果不是绝对必要,我尽量避免使用生成器表达式,因为它们不会提高 CMake 脚本文件的可读性,而且有时很难正确处理。
关于c++ - Visual Studio 无法识别 __AVX2__ 或 __AVX__,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54114287/
设置.py CELERY_BROKER_URL = 'redis://localhost:6379' CELERY_RESULT_BACKEND = 'redis://localhost:6379'
在 thymeleaf 中, [__${roleStat.index}__] 部分在做什么? 我知道这是数组索引,但是 __ 是做什么用的? 最佳答案 This doc说(第 26 页): Prepr
我正在使用以下时间选择器,它给出了 --:-- 有什么方法可以转换默认值 --:--至 __:__来自时间域? 最佳答案 在 Chromium 中,您可以使用 ::-webkit-datetime-
随着我正在从事的项目变得越来越大,我已经厌倦了编写全面的日志消息,需要找出问题所在和出处。 因此,如果我可以将该信息自动合并到消息中,将非常有用。对于C++,我们有方便的__FILE__,__LINE
我有以下代码: #ifdef __SYM_TRACE__ #define SYM_TRACE( L, F ) { SETTRACE_LEVEL(L); tracefunc F; } #define
假设我创建了一个这样的自定义异常类: class MyError(Exception): def __init__(self, msg): pass raise MyError
让我们假设以下代码: char* c = __FILE__; c是否存在于堆栈或堆中? (作为后续措施-我可以将c传递给另一个线程进行处理,还是需要在其他地方存储数据?)。 谢谢你。 最佳答案 c是指
我的 Activity 中有一个 EditText,用户必须以我想要的格式在其中输入日期,例如 ____/__/__。有没有办法像某些编程语言的掩码文本框一样在Android的EditText中显示这
我试图区分 while 循环的不同编写方式。 我专门为一个扑克游戏写这篇文章,我在其中区分不同的手牌类型。在编写我的 is_pair 函数时,我首先说 pair = False。我发现继续循环的唯一方
是否有遵循 ____ 模式的方法?并作为别名工作,而不是 __send__ ? 最佳答案 很容易找到与您的模式匹配的方法名称列表: ObjectSpace.each_object(Module).fl
我正在尝试创建一个循环遍历列表的脚本。 我需要查看能力标识符的有限列表 (400)(例如 124、129 等 - 普通整数) 然后我有一本字典,记录每个用户拥有的能力。键是用户名,每个键的值是整数列表
这个问题已经有答案了: __proto__ VS. prototype in JavaScript (34 个回答) 已关闭 8 年前。 我没有正确地理解这一点。我看到了一个与之相关的问题,但无法从中
我正在尝试使用 chartjs 制作图表用于显示民意调查投票的所有统计数据。这是针对有 12 个月的特定年份。 例如, 你是程序员吗? 是 没有 我想在图表中显示 - 用户给一年中的 12 个月投了多
几个月前我刚开始学习 Python,我正在尝试了解不同 __get*__ 方法之间的区别: __get__ __getattr__ __getattribute__ __getitem___ 以及它们
我有一个充满ActiveX控件的工作表。我知道他们在工作表上有错误,所以这是我实现的用于重置控件并保持其行为受控的功能。 问题在于,错误处理程序无法捕获由于尝试访问ListBox的auto-size属
我正在将可以在Linux上完美运行的代码移植到Windows visual c++。 我在Linux中有以下代码: struct exif_desc { uint16_t tag;
RegEx 一直让我感到困惑。 我有这样一个字符串: IDE\DiskDJ205GA20_____________________________A3VS____\5&1003ca0&0&0.0.
这个问题已经有答案了: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘int’ (8 个回答) C Forma
我试图在 Intellij IDEA 中查看一个大文件,但遇到错误:“文件太大:30.1 MB,显示第一个 2.56 MB 的只读预览”。 我看过这个问题的一些以前的答案,包括: IntelliJ c
我正在尝试学习用于跨平台 GUI 开发的 wxwidgets,但是我遇到了一个问题。 当尝试使用 mingW32 构建 wxwidgets 时,我遇到了错误。我安装了带有代码块 16.1 的 minG
我是一名优秀的程序员,十分优秀!