Skip to content

Commit

Permalink
Merge pull request #187 from jcelerier/emscripten
Browse files Browse the repository at this point in the history
Enable the library to build against WebAssembly SIMD support
  • Loading branch information
dancazarin authored Feb 13, 2024
2 parents 68b99bb + 5c16acb commit 31166bd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/kfr/cident.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
extern char* gets(char* __s);
#endif

#if defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__x86_64__)
#if defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__x86_64__) || defined(__wasm)
#define CMT_ARCH_X86 1
#elif defined(__arm__) || defined(__arm64__) || defined(_M_ARM) || defined(__aarch64__)
#define CMT_ARCH_ARM 1
#endif

#ifdef CMT_ARCH_X86
#if defined(_M_X64) || defined(__x86_64__)
#if defined(_M_X64) || defined(__x86_64__) || defined(__wasm64)
#define CMT_ARCH_X64 1
#define CMT_ARCH_BITNESS_NAME "64-bit"
#else
Expand Down
30 changes: 28 additions & 2 deletions include/kfr/runtime/cpuid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,34 @@

namespace kfr
{
#ifdef CMT_ARCH_X86

#if defined(__wasm)
namespace internal_generic
{
template <size_t = 0>
cpu_t detect_cpu()
{
#if defined(__AVX512F__)
return cpu_t::avx512;
#elif defined(__AVX2__)
return cpu_t::avx2;
#elif defined(__AVX__)
return cpu_t::avx1;
#elif defined(__SSE42__)
return cpu_t::sse42;
#elif defined(__SSE41__)
return cpu_t::sse41;
#elif defined(__SSSE3__)
return cpu_t::ssse3;
#elif defined(__SSE3__)
return cpu_t::sse3;
#elif defined(__SSE2__)
return cpu_t::sse2;
#else
return cpu_t::lowest;
#endif
}
}
#elif defined(CMT_ARCH_X86)
struct cpu_features
{
u32 max;
Expand Down

0 comments on commit 31166bd

Please sign in to comment.