<commit_before>! Copyright (C) 2010 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.accessors alien.c-types arrays
byte-arrays combinators combinators.smart continuations destructors
fry io.encodings.ascii io.encodings.string kernel libc locals macros
math math.order multiline opencl.ffi prettyprint sequences
specialized-arrays typed variants namespaces ;
IN: opencl
SPECIALIZED-ARRAYS: void* char size_t ;

<PRIVATE
ERROR: cl-error err ;

: cl-success ( err -- )
    dup CL_SUCCESS = [ drop ] [ cl-error ] if ; inline

: cl-not-null ( err -- )
    dup f = [ cl-error ] [ drop ] if ; inline

MACRO: info ( info-quot lift-quot -- quot )
    [ dup ] dip '[ 2dup 0 f 0 <size_t> _ '[ _ call cl-success ] keep
       *size_t dup <byte-array> _ '[ f _ call cl-success ] keep
       _ call ] ;
   
MACRO: 2info ( info-quot lift-quot -- quot )
    [ dup ] dip '[ 3dup 0 f 0 <size_t> _ '[ _ call cl-success ] keep
       *size_t dup <byte-array> _ '[ f _ call cl-success ] keep
       _ call ] ;
   
: info-bool ( handle name quot -- ? )<commit_msg>Replace info and 2info macros with simple inline words.<commit_after>! Copyright (C) 2010 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.c-types arrays byte-arrays combinators
combinators.smart destructors io.encodings.ascii io.encodings.string
kernel libc locals math namespaces opencl.ffi sequences shuffle
specialized-arrays variants ;
IN: opencl
SPECIALIZED-ARRAYS: void* char size_t ;

<PRIVATE
ERROR: cl-error err ;

: cl-success ( err -- )
    dup CL_SUCCESS = [ drop ] [ cl-error ] if ; inline

: cl-not-null ( err -- )
    dup f = [ cl-error ] [ drop ] if ; inline
 
: info-data-size ( handle name info-quot -- size_t )
    [ 0 f 0 <size_t> ] dip [ call cl-success ] 2keep drop *size_t ; inline

: info-data-bytes ( handle name info-quot size -- bytes )
    swap [ dup <byte-array> f ] dip [ call cl-success ] 3keep 2drop ; inline

: info ( handle name info-quot lift-quot -- value )
    [ 3dup info-data-size info-data-bytes ] dip call ; inline

: 2info-data-size ( handle1 handle2 name info-quot -- size_t )
    [ 0 f 0 <size_t> ] dip [ call cl-success ] 2keep drop *size_t ; inline

: 2info-data-bytes ( handle1 handle2 name info-quot size -- bytes )
    swap [ dup <byte-array> f ] dip [ call cl-success ] 3keep 2drop ; inline

: 2info ( handle1 handle2 name info_quot lift_quot -- value )
    [ 4dup 2info-data-size 2info-data-bytes ] dip call ; inline
    
: info-bool ( handle name quot -- ? )
{'fraction_non_alphanumeric': 0.11595911949685535, 'fraction_numerical': 0.015330188679245283, 'mean_word_length': 2.9952904238618525, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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': '4708286', 'n_tokens_mistral': 883, 'n_tokens_neox': 835, 'n_words': 274}