Container System 0.1.0
High-performance C++20 type-safe container framework with SIMD-accelerated serialization
Loading...
Searching...
No Matches
kcenon::container::simd::simd_support Class Reference

Utility to check SIMD support at runtime. More...

#include <simd_processor.h>

Collaboration diagram for kcenon::container::simd::simd_support:
Collaboration graph

Static Public Member Functions

static bool has_sse2 ()
 
static bool has_sse42 ()
 
static bool has_avx2 ()
 
static bool has_avx512f ()
 
static bool has_avx512dq ()
 
static bool has_avx512bw ()
 
static bool has_avx512vl ()
 
static bool has_neon ()
 
static simd_level get_best_simd_level ()
 Get the best available SIMD instruction set level.
 
static std::string get_simd_info ()
 Get a string describing available SIMD features.
 
static size_t get_optimal_width ()
 Get the optimal SIMD width for current platform.
 

Detailed Description

Utility to check SIMD support at runtime.

Definition at line 247 of file simd_processor.h.

Member Function Documentation

◆ get_best_simd_level()

◆ get_optimal_width()

static size_t kcenon::container::simd::simd_support::get_optimal_width ( )
inlinestatic

Get the optimal SIMD width for current platform.

Definition at line 272 of file simd_processor.h.

272 {
273 #if defined(HAS_AVX512)
274 return 16;
275 #elif defined(HAS_AVX2)
276 return 8;
277 #elif defined(HAS_SSE42) || defined(HAS_SSE2) || defined(HAS_ARM_NEON)
278 return 4;
279 #else
280 return 1;
281 #endif
282 }

Referenced by get_simd_info().

Here is the caller graph for this function:

◆ get_simd_info()

std::string kcenon::container::simd::simd_support::get_simd_info ( )
static

Get a string describing available SIMD features.

Definition at line 642 of file simd_processor.cpp.

643 {
644 std::string info = "SIMD Support: ";
645
646 #if defined(HAS_AVX512)
647 info += "AVX-512 ";
648 #elif defined(HAS_AVX2)
649 info += "AVX2 ";
650 #elif defined(HAS_SSE42)
651 info += "SSE4.2 ";
652 #elif defined(HAS_SSE2)
653 info += "SSE2 ";
654 #elif defined(HAS_ARM_NEON)
655 info += "NEON ";
656 #else
657 info += "None ";
658 #endif
659
660 // Add runtime detection info
661 info += "(Compile-time), Runtime: ";
662 if (has_avx512f()) {
663 info += "AVX-512F ";
664 if (has_avx512dq()) info += "AVX-512DQ ";
665 if (has_avx512bw()) info += "AVX-512BW ";
666 if (has_avx512vl()) info += "AVX-512VL ";
667 } else if (has_avx2()) {
668 info += "AVX2 ";
669 } else if (has_sse42()) {
670 info += "SSE4.2 ";
671 } else if (has_sse2()) {
672 info += "SSE2 ";
673 } else if (has_neon()) {
674 info += "NEON ";
675 } else {
676 info += "None ";
677 }
678
679 info += "(Width: " + std::to_string(get_optimal_width()) + ")";
680 return info;
681 }
static size_t get_optimal_width()
Get the optimal SIMD width for current platform.

References get_optimal_width(), has_avx2(), has_avx512bw(), has_avx512dq(), has_avx512f(), has_avx512vl(), has_neon(), has_sse2(), and has_sse42().

Here is the call graph for this function:

◆ has_avx2()

bool kcenon::container::simd::simd_support::has_avx2 ( )
static

Definition at line 556 of file simd_processor.cpp.

557 {
558 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
559 #if defined(__GNUC__) || defined(__clang__)
560 unsigned int eax, ebx, ecx, edx;
561 if (__get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx)) {
562 return (ebx & (1 << 5)) != 0; // AVX2 bit
563 }
564 #endif
565 #endif
566 return false;
567 }

Referenced by get_best_simd_level(), and get_simd_info().

Here is the caller graph for this function:

◆ has_avx512bw()

bool kcenon::container::simd::simd_support::has_avx512bw ( )
static

Definition at line 595 of file simd_processor.cpp.

596 {
597 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
598 #if defined(__GNUC__) || defined(__clang__)
599 unsigned int eax, ebx, ecx, edx;
600 if (__get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx)) {
601 return (ebx & (1 << 30)) != 0; // AVX-512BW bit
602 }
603 #endif
604 #endif
605 return false;
606 }

Referenced by get_simd_info().

Here is the caller graph for this function:

◆ has_avx512dq()

bool kcenon::container::simd::simd_support::has_avx512dq ( )
static

Definition at line 582 of file simd_processor.cpp.

583 {
584 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
585 #if defined(__GNUC__) || defined(__clang__)
586 unsigned int eax, ebx, ecx, edx;
587 if (__get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx)) {
588 return (ebx & (1 << 17)) != 0; // AVX-512DQ bit
589 }
590 #endif
591 #endif
592 return false;
593 }

Referenced by get_simd_info().

Here is the caller graph for this function:

◆ has_avx512f()

bool kcenon::container::simd::simd_support::has_avx512f ( )
static

Definition at line 569 of file simd_processor.cpp.

570 {
571 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
572 #if defined(__GNUC__) || defined(__clang__)
573 unsigned int eax, ebx, ecx, edx;
574 if (__get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx)) {
575 return (ebx & (1 << 16)) != 0; // AVX-512F bit
576 }
577 #endif
578 #endif
579 return false;
580 }

Referenced by get_best_simd_level(), and get_simd_info().

Here is the caller graph for this function:

◆ has_avx512vl()

bool kcenon::container::simd::simd_support::has_avx512vl ( )
static

Definition at line 608 of file simd_processor.cpp.

609 {
610 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
611 #if defined(__GNUC__) || defined(__clang__)
612 unsigned int eax, ebx, ecx, edx;
613 if (__get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx)) {
614 return (ebx & (1 << 31)) != 0; // AVX-512VL bit
615 }
616 #endif
617 #endif
618 return false;
619 }

Referenced by get_simd_info().

Here is the caller graph for this function:

◆ has_neon()

bool kcenon::container::simd::simd_support::has_neon ( )
static

Definition at line 633 of file simd_processor.cpp.

634 {
635 #if defined(HAS_ARM_NEON)
636 return true;
637 #else
638 return false;
639 #endif
640 }

Referenced by get_simd_info().

Here is the caller graph for this function:

◆ has_sse2()

bool kcenon::container::simd::simd_support::has_sse2 ( )
static

Definition at line 530 of file simd_processor.cpp.

531 {
532 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
533 #if defined(__GNUC__) || defined(__clang__)
534 unsigned int eax, ebx, ecx, edx;
535 if (__get_cpuid(1, &eax, &ebx, &ecx, &edx)) {
536 return (edx & (1 << 26)) != 0; // SSE2 bit
537 }
538 #endif
539 #endif
540 return false;
541 }

Referenced by get_best_simd_level(), and get_simd_info().

Here is the caller graph for this function:

◆ has_sse42()

bool kcenon::container::simd::simd_support::has_sse42 ( )
static

Definition at line 543 of file simd_processor.cpp.

544 {
545 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
546 #if defined(__GNUC__) || defined(__clang__)
547 unsigned int eax, ebx, ecx, edx;
548 if (__get_cpuid(1, &eax, &ebx, &ecx, &edx)) {
549 return (ecx & (1 << 20)) != 0; // SSE4.2 bit
550 }
551 #endif
552 #endif
553 return false;
554 }

Referenced by get_best_simd_level(), and get_simd_info().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: