Skip to content

Conversation

@cyb70289
Copy link
Contributor

@cyb70289 cyb70289 commented Sep 14, 2021

MSVC does not define __SSEn__ macros. Currently, we have to specify /arch:AVXn for an SSE only binary.

Fix #561

@cyb70289
Copy link
Contributor Author

@serge-sans-paille @JohanMabille
I don't have windows dev env for a local test. Would you try if this PR is okay? Thanks.

@serge-sans-paille
Copy link
Contributor

I'm puzzled: I activated SSE2 testing here: #563 but it doesn't show any error

@cyb70289
Copy link
Contributor Author

Reproduced this error with below trivial code.

#include <xsimd/xsimd.hpp>

int main(void) {
  xsimd::batch<int8_t, xsimd::sse4_2> batch;
  return 0;
}

Tested on windows-10, visual studio community 2019,
command: cl -I include /arch:SSE2 test.cpp, same error without /arch. OK if /arch:AVX.

Logs:

λ cl -I include /arch:SSE2 test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28612 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

cl : Command line warning D9002 : ignoring unknown option '/arch:SSE2'
test.cpp
C:\tools\cmder\xsimd\include\xsimd\memory\xsimd_aligned_allocator.hpp(40): error C2039: 'alignment': is not a member of 'xsimd::unavailable'
C:\tools\cmder\xsimd\include\xsimd\types\../config/xsimd_arch.hpp(57): note: see declaration of 'xsimd::unavailable'
C:\tools\cmder\xsimd\include\xsimd\memory\xsimd_aligned_allocator.hpp(40): error C3861: 'alignment': identifier not found
C:\tools\cmder\xsimd\include\xsimd\types\../memory/xsimd_alignment.hpp(46): error C2976: 'xsimd::aligned_allocator': too few template arguments
C:\tools\cmder\xsimd\include\xsimd\memory\xsimd_aligned_allocator.hpp(42): note: see declaration of 'xsimd::aligned_allocator'
C:\tools\cmder\xsimd\include\xsimd\types\../memory/xsimd_alignment.hpp(46): error C2975: 'Align': invalid template argument for 'xsimd::aligned_allocator', expected compile-time constant expression
C:\tools\cmder\xsimd\include\xsimd\memory\xsimd_aligned_allocator.hpp(40): note: see declaration of 'Align'
C:\tools\cmder\xsimd\include\xsimd\types\./xsimd_batch.hpp(23): error C2504: 'xsimd::types::simd_register<T,A>': base class undefined
        with
        [
            T=int8_t,
            A=xsimd::sse4_2
        ]
test.cpp(4): note: see reference to class template instantiation 'xsimd::batch<int8_t,xsimd::sse4_2>' being compiled
C:\tools\cmder\xsimd\include\xsimd\types\./xsimd_batch.hpp(25): error C2027: use of undefined type 'xsimd::types::simd_register<T,A>'
        with
        [
            T=int8_t,
            A=xsimd::sse4_2
        ]
C:\tools\cmder\xsimd\include\xsimd\types\./xsimd_batch.hpp(23): note: see declaration of 'xsimd::types::simd_register<T,A>'
        with
        [
            T=int8_t,
            A=xsimd::sse4_2
        ]
C:\tools\cmder\xsimd\include\xsimd\types\./xsimd_batch.hpp(29): error C2027: use of undefined type 'xsimd::types::simd_register<T,A>'
        with
        [
            T=int8_t,
            A=xsimd::sse4_2
        ]
C:\tools\cmder\xsimd\include\xsimd\types\./xsimd_batch.hpp(23): note: see declaration of 'xsimd::types::simd_register<T,A>'
        with
        [
            T=int8_t,
            A=xsimd::sse4_2
        ]
C:\tools\cmder\xsimd\include\xsimd\types\./xsimd_batch.hpp(29): error C2061: syntax error: identifier 'register_type'
C:\tools\cmder\xsimd\include\xsimd\types\./xsimd_batch.hpp(37): error C2061: syntax error: identifier 'register_type'
C:\tools\cmder\xsimd\include\xsimd\types\./xsimd_batch.hpp(37): error C2535: 'xsimd::batch<int8_t,xsimd::sse4_2>::batch(void)': member function already defined or declared
C:\tools\cmder\xsimd\include\xsimd\types\./xsimd_batch.hpp(33): note: see declaration of 'xsimd::batch<int8_t,xsimd::sse4_2>::batch'

@cyb70289 cyb70289 marked this pull request as draft September 14, 2021 11:40
MSVC does not define __SSEn__ macros. Currently, we have to specify
/arch:AVXn for an SSE only binary.
Comment on lines +213 to +215
// NB: MSVC does not define __SSEn__
#define XSIMD_WITH_SSE4_2 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit rude to always enable SSE4_2 for MSVC.
Per my understanding, 64bit MSVC supports at least SSE2, (/arch:SSE2 is actually an invalid option), and looks there's no way to detect SSE3/4 at compiler time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously this change causes windows-clang ci job failures.
Comments welcomed.

@cyb70289 cyb70289 marked this pull request as ready for review September 14, 2021 11:56
@cyb70289 cyb70289 marked this pull request as draft September 14, 2021 11:59
@cyb70289
Copy link
Contributor Author

I'm puzzled: I activated SSE2 testing here: #563 but it doesn't show any error

Not familiar with appveyor environment. Just blind guess. From the SSE job log, looks it's still running AVX2 tests?
https://ci.appveyor.com/project/xtensor-stack/xsimd/builds/40755892/job/yn99tj388o4g2ku3#L736

@cyb70289
Copy link
Contributor Author

Close this PR. Will be fixed by #563.

@cyb70289 cyb70289 closed this Sep 19, 2021
@cyb70289 cyb70289 deleted the msvc-sse branch September 26, 2021 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SSE] xsimd sse code failed to build with msvc

2 participants