TMP: Be more DRY

This commit is contained in:
Rohit Goswami 2024-03-17 02:22:36 +00:00 committed by Mateusz Sokół
parent e9a3897174
commit c76e7c6b95
1 changed files with 58 additions and 35 deletions

View File

@ -5,7 +5,7 @@ _rk = ['s', 'd']
_ck = ['c', 'z'] _ck = ['c', 'z']
_std_dk = _rk + _ck # Standard precisions _std_dk = _rk + _ck # Standard precisions
# TODO: Actually test and set this # TODO: Actually test and set this
if fma3 if true
fma3_flag = '-mfma' fma3_flag = '-mfma'
endif endif
# TODO: This is currently following x86_64 generic for src and dir, but it needs # TODO: This is currently following x86_64 generic for src and dir, but it needs
@ -16,7 +16,7 @@ endif
# undef --> -Uwhatever # undef --> -Uwhatever
# def --> -Dwhatever # def --> -Dwhatever
# addl --> passed AS IS # addl --> passed AS IS
kops_array = [ base_kops = [
# Level 1 BLAS # Level 1 BLAS
{ {
'base': 'rot', 'base': 'rot',
@ -25,14 +25,11 @@ kops_array = [
's' : { 's' : {
'dir': 'arm', 'dir': 'arm',
'kernel': 'rot.c', 'kernel': 'rot.c',
'undef': ['COMPLEX', 'DOUBLE'],
'addl': [fma3_flag], 'addl': [fma3_flag],
}, },
'd' : { 'd' : {
'dir': 'arm', 'dir': 'arm',
'kernel': 'rot.c', 'kernel': 'rot.c',
'undef': ['COMPLEX'],
'def': ['DOUBLE'],
'addl': [fma3_flag], 'addl': [fma3_flag],
}, },
'q' : { 'q' : {
@ -41,6 +38,8 @@ kops_array = [
'undef': ['COMPLEX'], 'undef': ['COMPLEX'],
'def': ['DXDOUBLE'], 'def': ['DXDOUBLE'],
}, },
# TODO: rot is nonstandard in this instance, taking cs zd xq
# The others (scal, swap) take c z x
'cs' : { 'cs' : {
'dir': 'arm', 'dir': 'arm',
'kernel': 'zrot.c', 'kernel': 'zrot.c',
@ -59,40 +58,64 @@ kops_array = [
}, },
}, },
}, },
{'symb': 'swap', # {'symb': 'swap',
'src': {'real': 'swap', 'cmplx': 'zswap', 'ext': '.c'}, # 'src': {'real': 'swap', 'cmplx': 'zswap', 'ext': '.c'},
'dir': 'arm', 'precs': _std_dk }, # 'dir': 'arm', 'precs': _std_dk },
{'symb': 'scal', # {'symb': 'scal',
'src': {'real': 'scal', 'cmplx': 'zscal', 'ext': '.c'}, # 'src': {'real': 'scal', 'cmplx': 'zscal', 'ext': '.c'},
'dir': 'arm', 'precs': _std_dk }, # 'dir': 'arm', 'precs': _std_dk },
{'symb': 'copy', # {'symb': 'copy',
'src': {'real': 'copy', 'cmplx': 'zcopy', 'ext': '.c'}, # 'src': {'real': 'copy', 'cmplx': 'zcopy', 'ext': '.c'},
'dir': 'arm', 'precs': _std_dk }, # 'dir': 'arm', 'precs': _std_dk },
{'symb': 'axpy', # {'symb': 'axpy',
'src': {'real': 'axpy', 'cmplx': 'zaxpy', 'ext': '.c'}, # 'src': {'real': 'axpy', 'cmplx': 'zaxpy', 'ext': '.c'},
'dir': 'arm', 'precs': _std_dk }, # 'dir': 'arm', 'precs': _std_dk },
{'symb': 'dot', # {'symb': 'dot',
'src': {'real': 'dot', 'cmplx': 'zdot', 'ext': '.c'}, # 'src': {'real': 'dot', 'cmplx': 'zdot', 'ext': '.c'},
'dir': 'arm', 'precs': _std_dk }, # 'dir': 'arm', 'precs': _std_dk },
] ]
kernel_confs = [] kernel_confs = []
foreach root : blas1_roots foreach _kop : base_kops
fname = root + '.S' foreach pkey, pval : _kop['precs']
defs = [] kcfg = {
foreach prec : real_kinds 'name': pkey + _kop['base'] + '_k',
name = prec + fname + '_k' # TODO: This should probably be in files() after this is ready
kernel_confs += {'defs': defs, 'name': name, 'src': fname} # dictionaries with files can't be printed with message
'src': pval['dir'] + '/' + pval['kernel'],
}
if pval.has_key('addl')
kcfg += {'addl': pval['addl']}
endif
if 's' == pkey
kcfg += {'undef': ['COMPLEX', 'DOUBLE']}
endif
if 'd' == pkey
kcfg += {
'undef': ['COMPLEX'],
'def': ['DOUBLE'],
}
endif
message(kcfg)
endforeach endforeach
endforeach endforeach
_static_libs = [] # foreach root : blas1_roots
foreach conf: kernel_confs # fname = root + '.S'
_static_libs += static_library( # defs = []
conf['name'], # foreach prec : real_kinds
conf['src'], # name = prec + fname + '_k'
include_directories: _inc, # kernel_confs += {'defs': defs, 'name': name, 'src': fname}
c_args: conf['defs'], # endforeach
) # endforeach
endforeach
# _static_libs = []
# foreach conf: kernel_confs
# _static_libs += static_library(
# conf['name'],
# conf['src'],
# include_directories: _inc,
# c_args: conf['defs'],
# )
# endforeach