0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd::simd: Add all() template w/ efficient word specializations.

This commit is contained in:
Jason Volk 2020-09-28 00:02:45 -07:00
parent 38a52f76d5
commit 9cee52fff0
2 changed files with 117 additions and 0 deletions

116
include/ircd/simd/all.h Normal file
View file

@ -0,0 +1,116 @@
// 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 all
// 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_ALL_H
namespace ircd::simd
{
/// Convenience wrapper around lateral<std::bit_and>()[0] with the most
/// efficient lane type conversions made.
template<class T>
bool all(const T) noexcept = delete;
}
template<>
inline bool
ircd::simd::all(const u64x8 a)
noexcept
{
return lateral<std::bit_and>(a)[0] == -1UL;
}
template<>
inline bool
ircd::simd::all(const u64x4 a)
noexcept
{
return lateral<std::bit_and>(a)[0] == -1UL;
}
template<>
inline bool
ircd::simd::all(const u64x2 a)
noexcept
{
return lateral<std::bit_and>(a)[0] == -1UL;
}
template<>
inline bool
ircd::simd::all(const u32x16 a)
noexcept
{
return all(u64x8(a));
}
template<>
inline bool
ircd::simd::all(const u32x8 a)
noexcept
{
return all(u64x4(a));
}
template<>
inline bool
ircd::simd::all(const u32x4 a)
noexcept
{
return all(u64x2(a));
}
template<>
inline bool
ircd::simd::all(const u16x32 a)
noexcept
{
return all(u64x8(a));
}
template<>
inline bool
ircd::simd::all(const u16x16 a)
noexcept
{
return all(u64x4(a));
}
template<>
inline bool
ircd::simd::all(const u16x8 a)
noexcept
{
return all(u64x2(a));
}
template<>
inline bool
ircd::simd::all(const u8x64 a)
noexcept
{
return all(u64x8(a));
}
template<>
inline bool
ircd::simd::all(const u8x32 a)
noexcept
{
return all(u64x4(a));
}
template<>
inline bool
ircd::simd::all(const u8x16 a)
noexcept
{
return all(u64x2(a));
}

View file

@ -31,6 +31,7 @@
#include "tzcnt.h"
#include "lateral.h"
#include "any.h"
#include "all.h"
#include "stream.h"
#include "print.h"