ermig1979 / Simd

C++ image processing and machine learning library with using of SIMD: SSE, AVX, AVX-512, AMX for x86/x64, VMX(Altivec) and VSX(Power7) for PowerPC, NEON for ARM.
http://ermig1979.github.io/Simd
MIT License
2.03k stars 406 forks source link

Clang build issues #174

Closed ArsMasiuk closed 2 years ago

ArsMasiuk commented 2 years ago

There are following issues reported by clang-msvc under Windows (64 bit):

In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.8.103\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.8.103\Simd/SimdMath.h:29: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.8.103\Simd/SimdConst.h(94,36): error: excess elements in vector initializer const __m128i K_INV_ZERO = SIMD_MM_SET1_EPI8(0xFF); ^~~~~~~ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.8.103\Simd/SimdInit.h(104,40): note: expanded from macro 'SIMD_MM_SET1_EPI8' {SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), \ ^~~~~~~ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.8.103\Simd/SimdInit.h(38,25): note: expanded from macro 'SIMD_AS_CHAR'

define SIMD_AS_CHAR(a) char(a)

                    ^~~~~~~

and also these:

..\CSimdImageResolutionReductorComp.cpp(141,15): error: always_inline function '_mm_mullo_epi32' requires target feature 'sse4.1', but would be inlined into function 'Calc4PixelValue' that is compiled without support for 'sse4.1' m128i r2 = _mm_mullo_epi32(_mm_and_si128(loaded2, mask), c5); ^ ..\CSimdImageResolutionReductorComp.cpp(142,15): error: always_inline function '_mm_mullo_epi32' requires target feature 'sse4.1', but would be inlined into function 'Calc4PixelValue' that is compiled without support for 'sse4.1' m128i r3 = _mm_mullo_epi32(_mm_and_si128(loaded3, mask), c10); ^ ..\CSimdImageResolutionReductorComp.cpp(143,15): error: always_inline function '_mm_mullo_epi32' requires target feature 'sse4.1', but would be inlined into function 'Calc4PixelValue' that is compiled without support for 'sse4.1' m128i r4 = _mm_mullo_epi32(_mm_and_si128(loaded4, mask), c10); ^ ..\CSimdImageResolutionReductorComp.cpp(144,15): error: always_inline function '_mm_mullo_epi32' requires target feature 'sse4.1', but would be inlined into function 'Calc4PixelValue' that is compiled without support for 'sse4.1' m128i r5 = _mm_mullo_epi32(_mm_and_si128(loaded5, mask), c5); ^

MSVC, Intel, GCC and MinGW are fine with this, although. What could be the reason and it is possible to fix it for Clang?

ermig1979 commented 2 years ago

Hello! As I can see this bug report is linked with previous your report (https://github.com/ermig1979/Simd/issues/166). You were used the same Simd vesion in both cases. I made some fixes and they were included in release: (https://github.com/ermig1979/Simd/releases/tag/v4.9.104). Could you check are my changes fix this bug?

ArsMasiuk commented 2 years ago

Thank you, I'll check ASAP

ArsMasiuk commented 2 years ago

unfortunately, the bug is yet here:

In file included from ..\CSimdRgbToGrayProcessorComp.cpp:20: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMath.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h:28: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdInit.h(99,2): error: This platform is unsupported!

error This platform is unsupported!

^ In file included from ..\CSimdRgbToGrayProcessorComp.cpp:20: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMath.h:29: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(93,32): error: use of undeclared identifier 'SIMD_AS_CHAR' const __m128i K_ZERO = SIMD_MM_SET1_EPI8(0); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdInit.h(108,6): note: expanded from macro 'SIMD_MM_SET1_EPI8' {SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), \ ^ In file included from ..\CSimdRgbToGrayProcessorComp.cpp:20: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMath.h:29: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(93,32): error: use of undeclared identifier 'SIMD_AS_CHAR' C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdInit.h(108,23): note: expanded from macro 'SIMD_MM_SET1_EPI8' {SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), \ ^ In file included from ..\CSimdRgbToGrayProcessorComp.cpp:20: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMath.h:29: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(93,32): error: use of undeclared identifier 'SIMD_AS_CHAR' C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdInit.h(108,40): note: expanded from macro 'SIMD_MM_SET1_EPI8' {SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), \ ^

ermig1979 commented 2 years ago

OK. I will try to fixed it.

ermig1979 commented 2 years ago

I did some fixes: https://github.com/ermig1979/Simd/archive/refs/heads/master.zip Could you check?

ArsMasiuk commented 2 years ago

I've took the fixes, but still see the following:

In file included from ..\CSimdRgbToGrayProcessorComp.cpp:20: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMath.h:29: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(93,32): error: use of undeclared identifier 'SIMD_AS_CHAR' const __m128i K_ZERO = SIMD_MM_SET1_EPI8(0); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdInit.h(108,6): note: expanded from macro 'SIMD_MM_SET1_EPI8' {SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), \ ^ In file included from ..\CSimdRgbToGrayProcessorComp.cpp:20: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMath.h:29: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(93,32): error: use of undeclared identifier 'SIMD_AS_CHAR' C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdInit.h(108,23): note: expanded from macro 'SIMD_MM_SET1_EPI8' {SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), \ ^ In file included from ..\CSimdRgbToGrayProcessorComp.cpp:20: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMath.h:29: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(93,32): error: use of undeclared identifier 'SIMD_AS_CHAR' C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdInit.h(108,40): note: expanded from macro 'SIMD_MM_SET1_EPI8' {SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), \ ^ In file included from ..\CSimdRgbToGrayProcessorComp.cpp:20: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMath.h:29: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(93,32): error: use of undeclared identifier 'SIMD_AS_CHAR' C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdInit.h(108,57): note: expanded from macro 'SIMD_MM_SET1_EPI8' {SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), \ ^ In file included from ..\CSimdRgbToGrayProcessorComp.cpp:20: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMath.h:29: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(93,32): error: use of undeclared identifier 'SIMD_AS_CHAR' C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdInit.h(109,5): note: expanded from macro 'SIMD_MM_SET1_EPI8' SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), \ ^ In file included from ..\CSimdRgbToGrayProcessorComp.cpp:20: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMath.h:29: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(93,32): error: use of undeclared identifier 'SIMD_AS_CHAR' C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdInit.h(109,22): note: expanded from macro 'SIMD_MM_SET1_EPI8' SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), SIMD_AS_CHAR(a), \ ^

ermig1979 commented 2 years ago

Could you check again - I added some fixes?

ArsMasiuk commented 2 years ago

well, now I see something different:

In file included from ..\CSimdRgbToGrayProcessorComp.cpp:20: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMemory.h:29: In file included from C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdMath.h:29: C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(198,33): error: use of undeclared identifier 'm256' const size_t F = sizeof(__m256) / sizeof(float); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(215,33): error: use of undeclared identifier 'm256i' const size_t A = sizeof(m256i); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(221,15): error: unknown type name 'm256i' const m256i K_ZERO = SIMD_MM256_SET1_EPI8(0); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(222,15): error: unknown type name 'm256i' const m256i K_INV_ZERO = SIMD_MM256_SET1_EPI8(0xFF); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(224,15): error: unknown type name 'm256i' const m256i K8_01 = SIMD_MM256_SET1_EPI8(0x01); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(225,15): error: unknown type name 'm256i' const m256i K8_02 = SIMD_MM256_SET1_EPI8(0x02); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(226,15): error: unknown type name 'm256i' const m256i K8_03 = SIMD_MM256_SET1_EPI8(0x03); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(227,15): error: unknown type name 'm256i' const m256i K8_04 = SIMD_MM256_SET1_EPI8(0x04); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(228,15): error: unknown type name 'm256i' const m256i K8_07 = SIMD_MM256_SET1_EPI8(0x07); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(229,15): error: unknown type name 'm256i' const m256i K8_08 = SIMD_MM256_SET1_EPI8(0x08); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(230,15): error: unknown type name 'm256i' const m256i K8_10 = SIMD_MM256_SET1_EPI8(0x10); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(231,15): error: unknown type name 'm256i' const m256i K8_20 = SIMD_MM256_SET1_EPI8(0x20); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(232,15): error: unknown type name 'm256i' const m256i K8_40 = SIMD_MM256_SET1_EPI8(0x40); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(233,15): error: unknown type name 'm256i' const m256i K8_80 = SIMD_MM256_SET1_EPI8(0x80); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(235,15): error: unknown type name 'm256i' const m256i K8_01_FF = SIMD_MM256_SET2_EPI8(0x01, 0xFF); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(237,15): error: unknown type name 'm256i' const m256i K16_0001 = SIMD_MM256_SET1_EPI16(0x0001); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(238,15): error: unknown type name 'm256i' const m256i K16_0002 = SIMD_MM256_SET1_EPI16(0x0002); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(239,15): error: unknown type name 'm256i' const __m256i K16_0003 = SIMD_MM256_SET1_EPI16(0x0003); ^ C:\Work\Test\End.Expert.V2.LLVM\Code\ExtLibs_Include\simd-4.9.104\Simd/SimdConst.h(240,15): error: unknown type name 'm256i' const m256i K16_0004 = SIMD_MM256_SET1_EPI16(0x0004); ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated.

ArsMasiuk commented 2 years ago

It looks like AVX includes are not loaded. Should I maybe disable AVX support in the SimdConfig.h?

ermig1979 commented 2 years ago

Why do your file CSimdRgbToGrayProcessorComp.cpp includes SimdMemory.h ? This is internal file of SimdLibrary. You can include in your project only SimdLib.h (or C++ header files like Simd*.hpp).

ArsMasiuk commented 2 years ago

ok, seems I've finally got it... one thing I had to do is to disable SSE3 support in my code. and second, add -msse4.2 instead of -msse4 to the compiler flags. thank you for your help and for the great lib :)

ArsMasiuk commented 2 years ago

Why do your file CSimdRgbToGrayProcessorComp.cpp includes SimdMemory.h ? This is internal file of SimdLibrary. You can include in your project only SimdLib.h (or C++ header files like Simd*.hpp).

Thats because I needed to use some defines like K16_00FF etc which are not visible by default.

ermig1979 commented 2 years ago

There is simpler way:

__m128i K16_00FF = _mm_set1_epi16(0x00FF);
ArsMasiuk commented 2 years ago

There is simpler way:

__m128i K16_00FF = _mm_set1_epi16(0x00FF);

I'll try, thanks!