<commit_before>! Copyright (C) 2009 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: system kernel memoize math math.order math.parser
namespaces alien.c-types alien.syntax combinators locals init io
compiler compiler.units accessors ;
IN: cpu.x86.features

<PRIVATE

FUNCTION: int sse_version ( ) ;

FUNCTION: longlong read_timestamp_counter ( ) ;

PRIVATE>

: sse-version ( -- n )
    sse_version
    "sse-version" get string>number [ min ] when* ; foldable

: sse? ( -- ? ) sse-version 10 >= ; foldable
: sse2? ( -- ? ) sse-version 20 >= ; foldable
: sse3? ( -- ? ) sse-version 30 >= ; foldable
: ssse3? ( -- ? ) sse-version 33 >= ; foldable
: sse4.1? ( -- ? ) sse-version 41 >= ; foldable
: sse4.2? ( -- ? ) sse-version 42 >= ; foldable

: sse-string ( version -- string )
    {
        { 00 [ "no SSE" ] }
        { 10 [ "SSE1" ] }
        { 20 [ "SSE2" ] }
        { 30 [ "SSE3" ] }
        { 33 [ "SSSE3" ] }
        { 41 [ "SSE4.1" ] }
        { 42 [ "SSE4.2" ] }
    } case ;

HOOK: instruction-count cpu ( -- n )

M: x86 instruction-count read_timestamp_counter ;

: count-instructions ( quot -- n )
    instruction-count [ call ] dip instruction-count swap - ; inline
<commit_msg>cpu.x86.features: don't fold away sse-version, instead memoize it and recompute on startup<commit_after>! Copyright (C) 2009 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: system kernel memoize math math.order math.parser
namespaces alien.c-types alien.syntax combinators locals init io
compiler compiler.units accessors ;
IN: cpu.x86.features

<PRIVATE

FUNCTION: int sse_version ( ) ;

FUNCTION: longlong read_timestamp_counter ( ) ;

PRIVATE>

MEMO: sse-version ( -- n )
    sse_version
    "sse-version" get string>number [ min ] when* ;

[ \ sse-version reset-memoized ] "cpu.x86.features" add-init-hook

: sse? ( -- ? ) sse-version 10 >= ;
: sse2? ( -- ? ) sse-version 20 >= ;
: sse3? ( -- ? ) sse-version 30 >= ;
: ssse3? ( -- ? ) sse-version 33 >= ;
: sse4.1? ( -- ? ) sse-version 41 >= ;
: sse4.2? ( -- ? ) sse-version 42 >= ;

: sse-string ( version -- string )
    {
        { 00 [ "no SSE" ] }
        { 10 [ "SSE1" ] }
        { 20 [ "SSE2" ] }
        { 30 [ "SSE3" ] }
        { 33 [ "SSSE3" ] }
        { 41 [ "SSE4.1" ] }
        { 42 [ "SSE4.2" ] }
    } case ;

HOOK: instruction-count cpu ( -- n )

M: x86 instruction-count read_timestamp_counter ;

: count-instructions ( quot -- n )
    instruction-count [ call ] dip instruction-count swap - ; inline

{'fraction_non_alphanumeric': 0.16116195781933942, 'fraction_numerical': 0.04058893752487067, 'mean_word_length': 2.4771784232365146, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4923616', 'n_tokens_mistral': 987, 'n_tokens_neox': 917, 'n_words': 221}