0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd::simd: Add constexpr feature support suite.

This commit is contained in:
Jason Volk 2020-10-10 05:09:45 -07:00
parent a015872df7
commit 019010336b
3 changed files with 111 additions and 54 deletions

View file

@ -11,6 +11,7 @@
#pragma once
#define HAVE_IRCD_SIMD_H
#include "support.h"
#include "type.h"
#include "unaligned.h"
#include "traits.h"

101
include/ircd/simd/support.h Normal file
View file

@ -0,0 +1,101 @@
// The Construct
//
// Copyright (C) The Construct Developers, Authors & Contributors
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#pragma once
#define HAVE_IRCD_SIMD_SUPPORT_H
//
// These values allow for `if constexpr` to be used for generating feature-
// specific code. This is preferred to using preprocessor statements.
//
namespace ircd::simd::support
{
constexpr bool sse2
{
#if defined(__SSE2__)
true
#else
false
#endif
};
constexpr bool sse3
{
#if defined(__SSE3__)
true
#else
false
#endif
};
constexpr bool ssse3
{
#if defined(__SSSE3__)
true
#else
false
#endif
};
constexpr bool sse4a
{
#if defined(__SSE4A__)
true
#else
false
#endif
};
constexpr bool sse4_1
{
#if defined(__SSE4_1__)
true
#else
false
#endif
};
constexpr bool sse4_2
{
#if defined(__SSE4_2__)
true
#else
false
#endif
};
constexpr bool avx
{
#if defined(__AVX__)
true
#else
false
#endif
};
constexpr bool avx2
{
#if defined(__AVX2__)
true
#else
false
#endif
};
constexpr bool avx512f
{
#if defined(__AVX512__)
true
#else
false
#endif
};
}

View file

@ -265,60 +265,15 @@ ircd::info::dump_cpu_info_x86()
});
}};
#if defined(__SSE2__)
append("sse2", hardware::x86::sse2, true);
#else
append("sse2", hardware::x86::sse2, false);
#endif
#if defined(__SSE3__)
append("sse3", hardware::x86::sse3, true);
#else
append("sse3", hardware::x86::sse3, false);
#endif
#if defined(__SSSE3__)
append("ssse3", hardware::x86::ssse3, true);
#else
append("ssse3", hardware::x86::ssse3, false);
#endif
#if defined(__SSE4A__)
append("sse4a", hardware::x86::sse4a, true);
#else
append("sse4a", hardware::x86::sse4a, false);
#endif
#if defined(__SSE4_1__)
append("sse4.1", hardware::x86::sse4_1, true);
#else
append("sse4.1", hardware::x86::sse4_1, false);
#endif
#if defined(__SSE4_2__)
append("sse4.2", hardware::x86::sse4_2, true);
#else
append("sse4.2", hardware::x86::sse4_2, false);
#endif
#if defined(__AVX__)
append("avx", hardware::x86::avx, true);
#else
append("avx", hardware::x86::avx, false);
#endif
#if defined(__AVX2__)
append("avx2", hardware::x86::avx2, true);
#else
append("avx2", hardware::x86::avx2, false);
#endif
#if defined(__AVX512F__)
append("avx512f", hardware::x86::avx512f, true);
#else
append("avx512f", hardware::x86::avx512f, false);
#endif
append("sse2", hardware::x86::sse2, simd::support::sse2);
append("sse3", hardware::x86::sse3, simd::support::sse3);
append("ssse3", hardware::x86::ssse3, simd::support::ssse3);
append("sse4a", hardware::x86::sse4a, simd::support::sse4a);
append("sse4.1", hardware::x86::sse4_1, simd::support::sse4_1);
append("sse4.2", hardware::x86::sse4_2, simd::support::sse4_2);
append("avx", hardware::x86::avx, simd::support::avx);
append("avx2", hardware::x86::avx2, simd::support::avx2);
append("avx512f", hardware::x86::avx512f, simd::support::avx512f);
append("constant_tsc", hardware::x86::tsc_constant, -1);
log::info