<commit_before>#ifndef _TBLIS_CONFIG_BUILDER_HPP_
#define _TBLIS_CONFIG_BUILDER_HPP_

#include "configs.hpp"

#include "src/external/stl_ext/include/type_traits.hpp"

#define TBLIS_PASTE(x,y) x##y
#define TBLIS_HAS_COMMA_HELPER(_0,_1,_2,...) _2
#define TBLIS_HAS_COMMA(...) TBLIS_HAS_COMMA_HELPER(__VA_ARGS__,1,0)
#define TBLIS_COMMA_IF_EMPTY() ,
#define _TBLIS_COMMA_IF_EMPTY() ,
#define TBLIS_IS_EMPTY(x) TBLIS_HAS_COMMA(TBLIS_PASTE(x,TBLIS_COMMA_IF_EMPTY)())
#define TBLIS_GET_VALUE_OR_DEFAULT_CASE_0(value,default) value
#define TBLIS_GET_VALUE_OR_DEFAULT_CASE_1(value,default) default
#define TBLIS_GET_VALUE_OR_DEFAULT_CASE(value,default,case) \
    TBLIS_PASTE(TBLIS_GET_VALUE_OR_DEFAULT_CASE_,case)(value,default)
#define TBLIS_GET_VALUE_OR_DEFAULT(value,default) \
    TBLIS_GET_VALUE_OR_DEFAULT_CASE(value,default,TBLIS_IS_EMPTY(value))

#define TBLIS_BEGIN_CONFIG(cfg) \
extern config cfg##_config_instance; \
struct cfg##_config : config_template<cfg##_config> \
{ \
    typedef cfg##_config this_config; \
 \
    static constexpr const char* name = #cfg; \
 \
    static const config& instance() \
    { \
        return cfg##_config_instance; \
    } \

#define TBLIS_END_CONFIG };

#define TBLIS_CONFIG_INSTANTIATE(cfg) \
config cfg##_config_instance = config(cfg##_config());

#define TBLIS_CONFIG_REGISTER_BLOCKSIZE(name, S,D,C,Z, SE,DE,CE,ZE, SD,DD,CD,ZD) \
    template <typename T> struct name : register_blocksize<T, \
        TBLIS_GET_VALUE_OR_DEFAULT(S,SD), \
        TBLIS_GET_VALUE_OR_DEFAULT(D,DD), \
        TBLIS_GET_VALUE_OR_DEFAULT(C,CD), \
        TBLIS_GET_VALUE_OR_DEFAULT(Z,ZD), \
        TBLIS_GET_VALUE_OR_DEFAULT(SE,TBLIS_GET_VALUE_OR_DEFAULT(S,SD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(DE,TBLIS_GET_VALUE_OR_DEFAULT(D,DD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(CE,TBLIS_GET_VALUE_OR_DEFAULT(C,CD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(ZE,TBLIS_GET_VALUE_OR_DEFAULT(Z,ZD))> {};

#define TBLIS_CONFIG_CACHE_BLOCKSIZE(name, RB, S,D,C,Z, SM,DM,CM,ZM, SD,DD,CD,ZD) \
    template <typename T> struct name : cache_blocksize<T, RB<T>, \
        TBLIS_GET_VALUE_OR_DEFAULT(S,SD), \
        TBLIS_GET_VALUE_OR_DEFAULT(D,DD), \
        TBLIS_GET_VALUE_OR_DEFAULT(C,CD), \
        TBLIS_GET_VALUE_OR_DEFAULT(Z,ZD), \
        TBLIS_GET_VALUE_OR_DEFAULT(SM,TBLIS_GET_VALUE_OR_DEFAULT(S,SD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(DM,TBLIS_GET_VALUE_OR_DEFAULT(D,DD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(CM,TBLIS_GET_VALUE_OR_DEFAULT(C,CD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(ZM,TBLIS_GET_VALUE_OR_DEFAULT(Z,ZD))> {};

#define TBLIS_CONFIG_TRANS_MR(S,D,C,Z) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(trans_mr, S,D,C,Z, S,D,C,Z, 8,4,4,4)
#define TBLIS_CONFIG_TRANS_NR(S,D,C,Z) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(trans_nr, S,D,C,Z, S,D,C,Z, 4,4,4,2)

#define TBLIS_CONFIG_GEMM_MR(S,D,C,Z) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_mr, S,D,C,Z, S,D,C,Z, 8,4,4,2)
#define TBLIS_CONFIG_GEMM_NR(S,D,C,Z) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_nr, S,D,C,Z, S,D,C,Z, 4,4,2,2)
#define TBLIS_CONFIG_GEMM_KR(S,D,C,Z) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_kr, S,D,C,Z, S,D,C,Z, 4,2,2,1)

#define TBLIS_CONFIG_GEMM_MR_EXTENT(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_mr, S,D,C,Z, SE,DE,CE,ZE, 8,4,4,2)
#define TBLIS_CONFIG_GEMM_NR_EXTENT(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_nr, S,D,C,Z, SE,DE,CE,ZE, 4,4,2,2)
#define TBLIS_CONFIG_GEMM_KR_EXTENT(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_kr, S,D,C,Z, SE,DE,CE,ZE, 4,2,2,1)

#define TBLIS_CONFIG_GEMM_MC(S,D,C,Z) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_mc, gemm_mr, S,D,C,Z, S,D,C,Z,  512,  256,  256,  128)
#define TBLIS_CONFIG_GEMM_NC(S,D,C,Z) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_nc, gemm_nr, S,D,C,Z, S,D,C,Z, 4096, 4096, 4096, 4096)
#define TBLIS_CONFIG_GEMM_KC(S,D,C,Z) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_kc, gemm_kr, S,D,C,Z, S,D,C,Z,  256,  256,  256,  256)

#define TBLIS_CONFIG_GEMM_MC_MAX(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_mc, gemm_mr, S,D,C,Z, SE,DE,CE,ZE,  512,  256,  256,  128)
#define TBLIS_CONFIG_GEMM_NC_MAX(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_nc, gemm_nr, S,D,C,Z, SE,DE,CE,ZE, 4096, 4096, 4096, 4096)
#define TBLIS_CONFIG_GEMM_KC_MAX(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_kc, gemm_kr, S,D,C,Z, SE,DE,CE,ZE,  256,  256,  256,  256)

#define TBLIS_CONFIG_PARAMETER(name, type, S,D,C,Z, SD,DD,CD,ZD) \
    template <typename T> struct name : static_value<T, type, \
        TBLIS_GET_VALUE_OR_DEFAULT(S,SD), \
        TBLIS_GET_VALUE_OR_DEFAULT(D,DD), \
        TBLIS_GET_VALUE_OR_DEFAULT(C,CD), \
        TBLIS_GET_VALUE_OR_DEFAULT(Z,ZD)> {};

#define TBLIS_CONFIG_TRANS_ROW_MAJOR(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(trans_row_major, bool, S,D,C,Z, false,false,false,false)
#define TBLIS_CONFIG_GEMM_ROW_MAJOR(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(gemm_row_major, bool, S,D,C,Z, false,false,false,false)

#define TBLIS_CONFIG_M_THREAD_RATIO(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(m_thread_ratio, bool, S,D,C,Z, 2,2,2,2)
#define TBLIS_CONFIG_N_THREAD_RATIO(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(n_thread_ratio, bool, S,D,C,Z, 1,1,1,1)
#define TBLIS_CONFIG_MR_MAX_THREAD(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(mr_max_thread, bool, S,D,C,Z, 1,1,1,1)
#define TBLIS_CONFIG_NR_MAX_THREAD(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(nr_max_thread, bool, S,D,C,Z, 3,3,3,3)

#define TBLIS_CONFIG_UKR(name, type, S,D,C,Z, def_ker) \
    template <typename T> struct name : static_microkernel<T, \
        type<   float>, TBLIS_GET_VALUE_OR_DEFAULT(S,def_ker<   float>), \
        type<  double>, TBLIS_GET_VALUE_OR_DEFAULT(D,def_ker<  double>), \
        type<scomplex>, TBLIS_GET_VALUE_OR_DEFAULT(C,def_ker<scomplex>), \
        type<dcomplex>, TBLIS_GET_VALUE_OR_DEFAULT(Z,def_ker<dcomplex>)> {};

#define TBLIS_CONFIG_UKR2(config, name, type, S,D,C,Z, def_ker) \
    template <typename T> struct name : static_microkernel<T, \
        type<   float>, TBLIS_GET_VALUE_OR_DEFAULT(S,(def_ker<config,   float>)), \
        type<  double>, TBLIS_GET_VALUE_OR_DEFAULT(D,(def_ker<config,  double>)), \
        type<scomplex>, TBLIS_GET_VALUE_OR_DEFAULT(C,(def_ker<config,scomplex>)), \
        type<dcomplex>, TBLIS_GET_VALUE_OR_DEFAULT(Z,(def_ker<config,dcomplex>))> {};<commit_msg>Fix bone-headed casting problem.<commit_after>#ifndef _TBLIS_CONFIG_BUILDER_HPP_
#define _TBLIS_CONFIG_BUILDER_HPP_

#include "configs.hpp"

#include "src/external/stl_ext/include/type_traits.hpp"

#define TBLIS_PASTE(x,y) x##y
#define TBLIS_HAS_COMMA_HELPER(_0,_1,_2,...) _2
#define TBLIS_HAS_COMMA(...) TBLIS_HAS_COMMA_HELPER(__VA_ARGS__,1,0)
#define TBLIS_COMMA_IF_EMPTY() ,
#define _TBLIS_COMMA_IF_EMPTY() ,
#define TBLIS_IS_EMPTY(x) TBLIS_HAS_COMMA(TBLIS_PASTE(x,TBLIS_COMMA_IF_EMPTY)())
#define TBLIS_GET_VALUE_OR_DEFAULT_CASE_0(value,default) value
#define TBLIS_GET_VALUE_OR_DEFAULT_CASE_1(value,default) default
#define TBLIS_GET_VALUE_OR_DEFAULT_CASE(value,default,case) \
    TBLIS_PASTE(TBLIS_GET_VALUE_OR_DEFAULT_CASE_,case)(value,default)
#define TBLIS_GET_VALUE_OR_DEFAULT(value,default) \
    TBLIS_GET_VALUE_OR_DEFAULT_CASE(value,default,TBLIS_IS_EMPTY(value))

#define TBLIS_BEGIN_CONFIG(cfg) \
extern config cfg##_config_instance; \
struct cfg##_config : config_template<cfg##_config> \
{ \
    typedef cfg##_config this_config; \
 \
    static constexpr const char* name = #cfg; \
 \
    static const config& instance() \
    { \
        return cfg##_config_instance; \
    } \

#define TBLIS_END_CONFIG };

#define TBLIS_CONFIG_INSTANTIATE(cfg) \
config cfg##_config_instance = config(cfg##_config());

#define TBLIS_CONFIG_REGISTER_BLOCKSIZE(name, S,D,C,Z, SE,DE,CE,ZE, SD,DD,CD,ZD) \
    template <typename T> struct name : register_blocksize<T, \
        TBLIS_GET_VALUE_OR_DEFAULT(S,SD), \
        TBLIS_GET_VALUE_OR_DEFAULT(D,DD), \
        TBLIS_GET_VALUE_OR_DEFAULT(C,CD), \
        TBLIS_GET_VALUE_OR_DEFAULT(Z,ZD), \
        TBLIS_GET_VALUE_OR_DEFAULT(SE,TBLIS_GET_VALUE_OR_DEFAULT(S,SD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(DE,TBLIS_GET_VALUE_OR_DEFAULT(D,DD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(CE,TBLIS_GET_VALUE_OR_DEFAULT(C,CD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(ZE,TBLIS_GET_VALUE_OR_DEFAULT(Z,ZD))> {};

#define TBLIS_CONFIG_CACHE_BLOCKSIZE(name, RB, S,D,C,Z, SM,DM,CM,ZM, SD,DD,CD,ZD) \
    template <typename T> struct name : cache_blocksize<T, RB<T>, \
        TBLIS_GET_VALUE_OR_DEFAULT(S,SD), \
        TBLIS_GET_VALUE_OR_DEFAULT(D,DD), \
        TBLIS_GET_VALUE_OR_DEFAULT(C,CD), \
        TBLIS_GET_VALUE_OR_DEFAULT(Z,ZD), \
        TBLIS_GET_VALUE_OR_DEFAULT(SM,TBLIS_GET_VALUE_OR_DEFAULT(S,SD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(DM,TBLIS_GET_VALUE_OR_DEFAULT(D,DD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(CM,TBLIS_GET_VALUE_OR_DEFAULT(C,CD)), \
        TBLIS_GET_VALUE_OR_DEFAULT(ZM,TBLIS_GET_VALUE_OR_DEFAULT(Z,ZD))> {};

#define TBLIS_CONFIG_TRANS_MR(S,D,C,Z) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(trans_mr, S,D,C,Z, S,D,C,Z, 8,4,4,4)
#define TBLIS_CONFIG_TRANS_NR(S,D,C,Z) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(trans_nr, S,D,C,Z, S,D,C,Z, 4,4,4,2)

#define TBLIS_CONFIG_GEMM_MR(S,D,C,Z) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_mr, S,D,C,Z, S,D,C,Z, 8,4,4,2)
#define TBLIS_CONFIG_GEMM_NR(S,D,C,Z) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_nr, S,D,C,Z, S,D,C,Z, 4,4,2,2)
#define TBLIS_CONFIG_GEMM_KR(S,D,C,Z) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_kr, S,D,C,Z, S,D,C,Z, 4,2,2,1)

#define TBLIS_CONFIG_GEMM_MR_EXTENT(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_mr, S,D,C,Z, SE,DE,CE,ZE, 8,4,4,2)
#define TBLIS_CONFIG_GEMM_NR_EXTENT(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_nr, S,D,C,Z, SE,DE,CE,ZE, 4,4,2,2)
#define TBLIS_CONFIG_GEMM_KR_EXTENT(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_REGISTER_BLOCKSIZE(gemm_kr, S,D,C,Z, SE,DE,CE,ZE, 4,2,2,1)

#define TBLIS_CONFIG_GEMM_MC(S,D,C,Z) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_mc, gemm_mr, S,D,C,Z, S,D,C,Z,  512,  256,  256,  128)
#define TBLIS_CONFIG_GEMM_NC(S,D,C,Z) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_nc, gemm_nr, S,D,C,Z, S,D,C,Z, 4096, 4096, 4096, 4096)
#define TBLIS_CONFIG_GEMM_KC(S,D,C,Z) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_kc, gemm_kr, S,D,C,Z, S,D,C,Z,  256,  256,  256,  256)

#define TBLIS_CONFIG_GEMM_MC_MAX(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_mc, gemm_mr, S,D,C,Z, SE,DE,CE,ZE,  512,  256,  256,  128)
#define TBLIS_CONFIG_GEMM_NC_MAX(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_nc, gemm_nr, S,D,C,Z, SE,DE,CE,ZE, 4096, 4096, 4096, 4096)
#define TBLIS_CONFIG_GEMM_KC_MAX(S,D,C,Z, SE,DE,CE,ZE) \
    TBLIS_CONFIG_CACHE_BLOCKSIZE(gemm_kc, gemm_kr, S,D,C,Z, SE,DE,CE,ZE,  256,  256,  256,  256)

#define TBLIS_CONFIG_PARAMETER(name, type, S,D,C,Z, SD,DD,CD,ZD) \
    template <typename T> struct name : static_value<T, type, \
        TBLIS_GET_VALUE_OR_DEFAULT(S,SD), \
        TBLIS_GET_VALUE_OR_DEFAULT(D,DD), \
        TBLIS_GET_VALUE_OR_DEFAULT(C,CD), \
        TBLIS_GET_VALUE_OR_DEFAULT(Z,ZD)> {};

#define TBLIS_CONFIG_TRANS_ROW_MAJOR(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(trans_row_major, bool, S,D,C,Z, false,false,false,false)
#define TBLIS_CONFIG_GEMM_ROW_MAJOR(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(gemm_row_major, bool, S,D,C,Z, false,false,false,false)

#define TBLIS_CONFIG_M_THREAD_RATIO(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(m_thread_ratio, unsigned, S,D,C,Z, 2,2,2,2)
#define TBLIS_CONFIG_N_THREAD_RATIO(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(n_thread_ratio, unsigned, S,D,C,Z, 1,1,1,1)
#define TBLIS_CONFIG_MR_MAX_THREAD(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(mr_max_thread, unsigned, S,D,C,Z, 1,1,1,1)
#define TBLIS_CONFIG_NR_MAX_THREAD(S,D,C,Z) \
    TBLIS_CONFIG_PARAMETER(nr_max_thread, unsigned, S,D,C,Z, 3,3,3,3)

#define TBLIS_CONFIG_UKR(name, type, S,D,C,Z, def_ker) \
    template <typename T> struct name : static_microkernel<T, \
        type<   float>, TBLIS_GET_VALUE_OR_DEFAULT(S,def_ker<   float>), \
        type<  double>, TBLIS_GET_VALUE_OR_DEFAULT(D,def_ker<  double>), \
        type<scomplex>, TBLIS_GET_VALUE_OR_DEFAULT(C,def_ker<scomplex>), \
        type<dcomplex>, TBLIS_GET_VALUE_OR_DEFAULT(Z,def_ker<dcomplex>)> {};

#define TBLIS_CONFIG_UKR2(config, name, type, S,D,C,Z, def_ker) \
    template <typename T> struct name : static_microkernel<T, \
        type<   float>, TBLIS_GET_VALUE_OR_DEFAULT(S,(def_ker<config,   float>)), \
        type<  double>, TBLIS_GET_VALUE_OR_DEFAULT(D,(def_ker<config,  double>)), \
        type<scomplex>, TBLIS_GET_VALUE_OR_DEFAULT(C,(def_ker<config,scomplex>)), \
        type<dcomplex>, TBLIS_GET_VALUE_OR_DEFAULT(Z,(def_ker<config,dcomplex>))> {};
{'fraction_non_alphanumeric': 0.14349988160075774, 'fraction_numerical': 0.021627594916725865, 'mean_word_length': 6.0703125, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 59, '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': '100660', 'n_tokens_mistral': 6070, 'n_tokens_neox': 5969, 'n_words': 641}