Skip to content

Commit 7856f95

Browse files
committed
Add python script to visualize results, updates on compilation
1 parent 650f47f commit 7856f95

4 files changed

Lines changed: 373 additions & 12 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,18 @@ endif()
2626
project(BasicSIMD)
2727

2828
set(CMAKE_CXX_STANDARD 11)
29-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
30-
29+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
30+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
31+
endif()
3132
add_library(BasicSIMD INTERFACE)
3233
target_include_directories(BasicSIMD INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
3334
target_sources(BasicSIMD INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/SIMD.h)
3435

35-
if(MSVC)
36+
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
3637
target_compile_options(BasicSIMD INTERFACE /arch:AVX2)
37-
else()
38-
target_compile_options(BasicSIMD INTERFACE -march=native -fno-strict-aliasing)
38+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
39+
# Save assembly output with very detailed annotations
40+
target_compile_options(BasicSIMD INTERFACE -march=native -fno-strict-aliasing -O3 -fno-tree-vectorize)
3941
endif()
4042

4143
# Tests

SIMD.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifdef _MSC_VER
22
#define _SIMD_INL_ __forceinline
3-
#else
4-
#define _SIMD_INL_ __attribute__((always_inline))
3+
#elif defined(__GNUC__) || defined(__clang__)
4+
#define _SIMD_INL_ __attribute__((always_inline)) inline
55
#endif
66
#include <immintrin.h>
77
#include <type_traits>
@@ -1384,31 +1384,31 @@ class Array
13841384
}
13851385

13861386
//Add + and - operators
1387-
friend void operator+=(Array& lhs, const Array& rhs)
1387+
_SIMD_INL_ friend void operator+=(Array& lhs, const Array& rhs)
13881388
{
13891389
for (unsigned int i = 0; i < Length; i++)
13901390
{
13911391
T::AddInplaceRaw(lhs.Data + i*T::ElementCount, rhs.Data + i*T::ElementCount);
13921392
}
13931393
}
13941394

1395-
friend void operator-=(Array& lhs, const Array& rhs)
1395+
_SIMD_INL_ friend void operator-=(Array& lhs, const Array& rhs)
13961396
{
13971397
for (unsigned int i = 0; i < Length; i++)
13981398
{
13991399
T::SubtractInplaceRaw(lhs.Data + i*T::ElementCount, rhs.Data + i*T::ElementCount);
14001400
}
14011401
}
14021402

1403-
friend void operator*=(Array& lhs, const Array& rhs)
1403+
_SIMD_INL_ friend void operator*=(Array& lhs, const Array& rhs)
14041404
{
14051405
for (unsigned int i = 0; i < Length; i++)
14061406
{
14071407
T::MultiplyInplaceRaw(lhs.Data + i*T::ElementCount, rhs.Data + i*T::ElementCount);
14081408
}
14091409
}
14101410

1411-
friend void operator/=(Array& lhs, const Array& rhs)
1411+
_SIMD_INL_ friend void operator/=(Array& lhs, const Array& rhs)
14121412
{
14131413
for (unsigned int i = 0; i < Length; i++)
14141414
{

0 commit comments

Comments
 (0)