ENH: Start adding L3 driver symbols

This commit is contained in:
Rohit Goswami 2024-05-13 00:11:23 +00:00 committed by Mateusz Sokół
parent ca8e18eda2
commit 2f17fd08b7
2 changed files with 320 additions and 33 deletions

274
driver/level3/meson.build Normal file
View File

@ -0,0 +1,274 @@
# Naming conventions can be read from here:
# https://click.rgoswami.me/intel_blas_names
# Ported in order from the Makefile
driver_kops = [
# { 'base': '?bgemm',
# 'sources': {
# 'gemm.c': {'mode': ['s'], 'srcs': ['level3.c'],
# 'exts': ['_nn', '_nt',
# '_tn', '_tt']},
# }
# },
{ 'base': '?gemm',
'sources': {
'gemm.c': {'mode': ['s', 'd',], #'q'],
'exts': ['_nn', '_nt',
'_tn', '_tt']},
}
},
{ 'base': '?gemm',
'sources': {
'gemm.c': {'mode': ['c', 'z',],# 'x'],
'srcs': ['level3.c'],
'exts': ['_nn', '_nt',
'_nr', '_nc',
'_tn', '_tt',
'_tr', '_tc',
'_rn', '_rt',
'_rr', '_rc',
'_cn', '_ct',
'_cr', '_cc']},
}
},
{ 'base': '?gemm_thread',
'sources': {
'gemm_thread_m.c': {'mode': [''],
'exts': ['_m']},
'gemm_thread_n.c': {'mode': [''],
'exts': ['_n']},
'gemm_thread_mn.c': {'mode': [''],
'exts': ['_mn']},
'gemm_thread_variable.c': {'mode': [''],
'exts': ['_variable']},
}
},
# { 'base': '?bgemm_thread',
# 'sources': {
# 'gemm.c': {'mode': ['s'], 'srcs': ['level3.c'],
# 'exts': ['_nn', '_nt',
# '_tn', '_tt']},
# }
# },
{ 'base': '?gemm_thread',
'sources': {
'gemm.c': {'mode': ['s', 'd'], #'q'],
'addl': ['-DTHREADED_LEVEL3'],
'exts': ['_nn', '_nt',
'_tn', '_tt']},
}
},
{ 'base': '?gemm_thread',
'sources': {
'gemm.c': {'mode': ['c', 'z'],# 'x'],
'addl': ['-DTHREADED_LEVEL3'],
'exts': ['_nn', '_nt',
'_nr', '_nc',
'_tn', '_tt',
'_tr', '_tc',
'_rn', '_rt',
'_rr', '_rc',
'_cn', '_ct',
'_cr', '_cc']},
}
},
{ 'base': '?trmm',
'sources': {
'trmm_L.c': {'mode': ['s', 'd'],# 'q'],
'exts': ['_LNUU', '_LNUN',
'_LNLU', '_LNLN',
'_LTUU', '_LTUN',
'_LTLU', '_LTLN']},
'trmm_R.c': {'mode': ['s', 'd'],# 'q'],
'exts': ['_RNUU', '_RNUN',
'_RNLU', '_RNLN',
'_RTUU', '_RTUN',
'_RTLU', '_RTLN']},
}
},
{ 'base': '?trmm',
'sources': {
'trmm_L.c': {'mode': ['c', 'z'],# 'x'],
'exts': ['_LNUU', '_LNUN',
'_LNLU', '_LNLN',
'_LTUU', '_LTUN',
'_LTLU', '_LTLN',
'_LRUU', '_LRUN',
'_LRLU', '_LRLN',
'_LCUU', '_LCUN',
'_LCLU', '_LCLN',
]},
'trmm_R.c': {'mode': ['c', 'z'],# 'x'],
'exts': ['_RNUU', '_RNUN',
'_RNLU', '_RNLN',
'_RTUU', '_RTUN',
'_RTLU', '_RTLN',
'_RRUU', '_RRUN',
'_RRLU', '_RRLN',
'_RCUU', '_RCUN',
'_RCLU', '_RCLN',
]},
}
},
{ 'base': '?symm',
'sources': {
'symm_k.c': {'mode': ['s', 'd', # 'q'],
'c', 'z'], # 'x'],
'exts': ['_LU', '_LL',
'_RU', '_RL']},
}
},
{ 'base': '?symm_thread',
'sources': {
'symm_k.c': {'mode': ['s', 'd', # 'q'],
'c', 'z'], # 'x'],
'addl': ['-DTHREADED_LEVEL3'],
'exts': ['_LU', '_LL',
'_RU', '_RL']},
}
},
{ 'base': '?syrk',
'sources': {
'symm_k.c': {'mode': ['s', 'd', # 'q'],
'c', 'z'], # 'x'],
'exts': ['_UN', '_UT',
'_LN', '_LT']},
}
},
]
# Initialize kernel configurations list
kernel_confs = []
# Iterate through each kernel operation
foreach _kop : driver_kops
base = _kop['base']
sources = _kop['sources']
# Generate the symbol flags
_ckop_args = []
if symb_defs.has_key(base)
symb_base = symb_defs[base]
if symb_base.has_key('def')
foreach _d : symb_base['def']
_ckop_args += ['-D' + _d]
endforeach
endif
if symb_base.has_key('undef')
foreach _u : symb_base['undef']
_ckop_args += ['-U' + _u]
endforeach
endif
endif
# Iterate through each source file and its details
foreach fname, details : sources
modes = details['mode']
exts = details['exts']
# Iterate through each mode
foreach mode : modes
# Generate the mapping for the type
__cargs = _cargs + _ckop_args
prec_mode = precision_mappings[mode]
# Add precision-specific definitions
if prec_mode.has_key('def')
foreach _d : prec_mode['def']
__cargs += ['-D' + _d]
endforeach
endif
if prec_mode.has_key('undef')
foreach _u : prec_mode['undef']
__cargs += ['-U' + _u]
endforeach
endif
# Iterate through each extension
foreach ext : exts
_ext_cargs = []
# Check ext_mappings first
if ext_mappings.has_key(ext)
extmap = ext_mappings[ext]
if extmap.has_key('def')
foreach _d : extmap['def']
_ext_cargs += ['-D' + _d]
endforeach
endif
if extmap.has_key('undef')
foreach _u : extmap['undef']
_ext_cargs += ['-U' + _u]
endforeach
endif
else
# Fallback to ext_mappings_l2
foreach ext_map : ext_mappings_l2
if ext_map['ext'] == ext and mode in ext_map['for']
if ext_map.has_key('def')
foreach _d : ext_map['def']
_ext_cargs += ['-D' + _d]
endforeach
endif
if ext_map.has_key('undef')
foreach _u : ext_map['undef']
_ext_cargs += ['-U' + _u]
endforeach
endif
break
endif
endforeach
endif
# Construct the final paths
src = [ fname ]
# if sources[fname].has_key('srcs')
# src += sources[fname]['srcs']
# endif
# Add additional flags if present
if sources[fname].has_key('addl')
_ext_cargs += sources[fname]['addl']
endif
# Generate the symbol name
sym_name = base.replace('?', mode) + ext
sym_underscored = f'@sym_name@_'
# Add standard flags for naming conventions
_ext_cargs += [
f'-DASMNAME=@sym_name@',
f'-DASMFNAME=@sym_underscored@',
f'-DNAME=@sym_underscored@',
f'-DCNAME=@sym_name@',
f'-DCHAR_NAME="@sym_underscored@"',
f'-DCHAR_CNAME="@sym_name@"',
]
# Append the current configuration
current_def = {
'c_args': __cargs + _ext_cargs,
'name': sym_name,
'src': src,
}
kernel_confs += [current_def]
endforeach
endforeach
endforeach
endforeach
# Create the static libraries from the configurations
_kern_libs = []
foreach conf : kernel_confs
message(conf['name'])
message(conf)
_kern_libs += [static_library(
conf['name'],
conf['src'],
include_directories: _inc,
c_args: conf['c_args'],
)]
endforeach
# Create the final kernel library
_l3_driver = static_library('l3_driver',
link_whole: _kern_libs)

View File

@ -300,6 +300,16 @@ ext_mappings = {
'_ct': {'def': ['CT']},
'_cr': {'def': ['CR']},
'_cc': {'def': ['CC']},
# Level 3 symbols
'_LU': {'def': ['NN'], 'undef': ['LOWER', 'RSIDE']},
'_LL': {'def': ['LOWER', 'NN'], 'undef': ['RSIDE']},
'_RU': {'def': ['RSIDE', 'NN'], 'undef': ['LOWER']},
'_RL': {'def': ['RSIDE', 'NN', 'LOWER']},
'_UN': {'undef': ['TRANS', 'LOWER']},
'_UT': {'def': ['TRANS'], 'undef': ['LOWER']},
# TODO(rg): Need to handle the key conflict here for syrk
'_LN': {'def': ['LOWER'], 'undef': ['TRANS']},
'_LT': {'def': ['TRANS', 'LOWER']},
}
ext_mappings_l2 = [
@ -347,41 +357,44 @@ ext_mappings_l3 = [
{'ext': '_RTLU', 'def': ['TRANSA', 'UNIT'], 'undef': ['UPPER'], 'for': ['s', 'd', 'q']},
{'ext': '_RTLN', 'def': ['TRANSA'], 'undef': ['UPPER', 'UNIT'], 'for': ['s', 'd']},
{'ext': '_LNUU', 'def': ['UPPER', 'UNIT'], 'undef': ['TRANSA', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LNUN', 'def': ['UPPER'], 'undef': ['TRANSA', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LNLU', 'def': ['UNIT'], 'undef': ['TRANSA', 'UPPER', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LNLN', 'def': [], 'undef': ['TRANSA', 'UPPER', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LTUU', 'def': ['TRANSA', 'UPPER', 'UNIT'], 'undef': ['CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LTUN', 'def': ['TRANSA', 'UPPER'], 'undef': ['UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LTLU', 'def': ['TRANSA', 'UNIT'], 'undef': ['UPPER', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LTLN', 'def': ['TRANSA'], 'undef': ['UPPER', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LRUU', 'def': ['UPPER', 'UNIT', 'CONJ'], 'undef': ['TRANSA'], 'for': ['c', 'z', 'x']},
{'ext': '_LRUN', 'def': ['UPPER', 'CONJ'], 'undef': ['TRANSA', 'UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_LRLU', 'def': ['UNIT', 'CONJ'], 'undef': ['TRANSA', 'UPPER'], 'for': ['c', 'z', 'x']},
{'ext': '_LRLN', 'def': ['CONJ'], 'undef': ['TRANSA', 'UPPER', 'UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_LCUU', 'def': ['TRANSA', 'UPPER', 'UNIT', 'CONJ'], 'undef': [], 'for': ['c', 'z', 'x']},
{'ext': '_LCUN', 'def': ['TRANSA', 'UPPER', 'CONJ'], 'undef': ['UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_LCLU', 'def': ['TRANSA', 'UNIT', 'CONJ'], 'undef': ['UPPER'], 'for': ['c', 'z', 'x']},
{'ext': '_LCLN', 'def': ['TRANSA', 'CONJ'], 'undef': ['UPPER', 'UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_RNUU', 'def': ['UPPER', 'UNIT'], 'undef': ['TRANSA', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RNUN', 'def': ['UPPER'], 'undef': ['TRANSA', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RNLU', 'def': ['UNIT'], 'undef': ['TRANSA', 'UPPER', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RNLN', 'def': [], 'undef': ['TRANSA', 'UPPER', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RTUU', 'def': ['TRANSA', 'UPPER', 'UNIT'], 'undef': ['CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RTUN', 'def': ['TRANSA', 'UPPER'], 'undef': ['UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RTLU', 'def': ['TRANSA', 'UNIT'], 'undef': ['UPPER', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RTLN', 'def': ['TRANSA'], 'undef': ['UPPER', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RRUU', 'def': ['UPPER', 'UNIT', 'CONJ'], 'undef': ['TRANSA'], 'for': ['c', 'z', 'x']},
{'ext': '_RRUN', 'def': ['UPPER', 'CONJ'], 'undef': ['TRANSA', 'UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_RRLU', 'def': ['UNIT', 'CONJ'], 'undef': ['TRANSA', 'UPPER'], 'for': ['c', 'z', 'x']},
{'ext': '_RRLN', 'def': ['CONJ'], 'undef': ['TRANSA', 'UPPER', 'UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_RCUU', 'def': ['TRANSA', 'UPPER', 'UNIT', 'CONJ'], 'undef': [], 'for': ['c', 'z', 'x']},
{'ext': '_RCUN', 'def': ['TRANSA', 'UPPER', 'CONJ'], 'undef': ['UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_RCLU', 'def': ['TRANSA', 'UNIT', 'CONJ'], 'undef': ['UPPER'], 'for': ['c', 'z', 'x']},
{'ext': '_RCLN', 'def': ['TRANSA', 'CONJ'], 'undef': ['UPPER', 'UNIT'], 'for': ['c', 'z', 'x']},
# For trmm
{'ext': '_LNUU', 'def': ['UPPER', 'UNIT'], 'undef': ['TRANSA', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LNUN', 'def': ['UPPER'], 'undef': ['TRANSA', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LNLU', 'def': ['UNIT'], 'undef': ['TRANSA', 'UPPER', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LNLN', 'def': [], 'undef': ['TRANSA', 'UPPER', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LTUU', 'def': ['TRANSA', 'UPPER', 'UNIT'], 'undef': ['CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LTUN', 'def': ['TRANSA', 'UPPER'], 'undef': ['UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LTLU', 'def': ['TRANSA', 'UNIT'], 'undef': ['UPPER', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LTLN', 'def': ['TRANSA'], 'undef': ['UPPER', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_LRUU', 'def': ['UPPER', 'UNIT', 'CONJ'], 'undef': ['TRANSA'], 'for': ['c', 'z', 'x']},
{'ext': '_LRUN', 'def': ['UPPER', 'CONJ'], 'undef': ['TRANSA', 'UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_LRLU', 'def': ['UNIT', 'CONJ'], 'undef': ['TRANSA', 'UPPER'], 'for': ['c', 'z', 'x']},
{'ext': '_LRLN', 'def': ['CONJ'], 'undef': ['TRANSA', 'UPPER', 'UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_LCUU', 'def': ['TRANSA', 'UPPER', 'UNIT', 'CONJ'], 'undef': [], 'for': ['c', 'z', 'x']},
{'ext': '_LCUN', 'def': ['TRANSA', 'UPPER', 'CONJ'], 'undef': ['UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_LCLU', 'def': ['TRANSA', 'UNIT', 'CONJ'], 'undef': ['UPPER'], 'for': ['c', 'z', 'x']},
{'ext': '_LCLN', 'def': ['TRANSA', 'CONJ'], 'undef': ['UPPER', 'UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_RNUU', 'def': ['UPPER', 'UNIT'], 'undef': ['TRANSA', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RNUN', 'def': ['UPPER'], 'undef': ['TRANSA', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RNLU', 'def': ['UNIT'], 'undef': ['TRANSA', 'UPPER', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RNLN', 'def': [], 'undef': ['TRANSA', 'UPPER', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RTUU', 'def': ['TRANSA', 'UPPER', 'UNIT'], 'undef': ['CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RTUN', 'def': ['TRANSA', 'UPPER'], 'undef': ['UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RTLU', 'def': ['TRANSA', 'UNIT'], 'undef': ['UPPER', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RTLN', 'def': ['TRANSA'], 'undef': ['UPPER', 'UNIT', 'CONJ'], 'for': ['c', 'z', 'x']},
{'ext': '_RRUU', 'def': ['UPPER', 'UNIT', 'CONJ'], 'undef': ['TRANSA'], 'for': ['c', 'z', 'x']},
{'ext': '_RRUN', 'def': ['UPPER', 'CONJ'], 'undef': ['TRANSA', 'UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_RRLU', 'def': ['UNIT', 'CONJ'], 'undef': ['TRANSA', 'UPPER'], 'for': ['c', 'z', 'x']},
{'ext': '_RRLN', 'def': ['CONJ'], 'undef': ['TRANSA', 'UPPER', 'UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_RCUU', 'def': ['TRANSA', 'UPPER', 'UNIT', 'CONJ'], 'undef': [], 'for': ['c', 'z', 'x']},
{'ext': '_RCUN', 'def': ['TRANSA', 'UPPER', 'CONJ'], 'undef': ['UNIT'], 'for': ['c', 'z', 'x']},
{'ext': '_RCLU', 'def': ['TRANSA', 'UNIT', 'CONJ'], 'undef': ['UPPER'], 'for': ['c', 'z', 'x']},
{'ext': '_RCLN', 'def': ['TRANSA', 'CONJ'], 'undef': ['UPPER', 'UNIT'], 'for': ['c', 'z', 'x']},
# symm
]
# cc -c -O2 -DSMALL_MATRIX_OPT -DMAX_STACK_ALLOC=2048 -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=12 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.26.dev\" -msse3 -mssse3 -msse4.1 -mavx -mavx2 -mavx2 -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME=strmm_RTUU -DASMFNAME=strmm_RTUU_ -DNAME=strmm_RTUU_ -DCNAME=strmm_RTUU -DCHAR_NAME=\"strmm_RTUU_\" -DCHAR_CNAME=\"strmm_RTUU\" -DNO_AFFINITY -I../.. -UDOUBLE -UCOMPLEX -UCOMPLEX -UDOUBLE -DTRANSA -DUPPER -DUNIT trmm_R.c -o strmm_RTUU.o
# cc -c -O2 -DSMALL_MATRIX_OPT -DMAX_STACK_ALLOC=2048 -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=12 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.26.dev\" -msse3 -mssse3 -msse4.1 -mavx -mavx2 -mavx2 -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME=strmm_RTUU -DASMFNAME=strmm_RTUU_ -DNAME=strmm_RTUU_ -DCNAME=strmm_RTUU -DCHAR_NAME=\"strmm_RTUU_\" -DCHAR_CNAME=\"strmm_RTUU\" -DNO_AFFINITY -I../.. -UDOUBLE -UCOMPLEX -UCOMPLEX -UDOUBLE -DTRANSA -DUPPER -DUNIT trmm_R.c -o strmm_RTUU.o
symb_defs = {
'?amax': {'def': ['USE_ABS'], 'undef': ['USE_MIN']},