コード例 #1
0
 def function(self, meta, precision):
     data = Variable('data_p', 'const void *')
     back = Variable('back_p', 'void *')
     meta = NS(precision=precision, **meta.__dict__)
     return Function(name=self.name,
                     arguments=ArgumentList(data, back),
                     meta=meta)
コード例 #2
0
 def add(name, scheme, pool=None):
     functions.append(
         Function(name=name,
                  arguments=ArgumentList(data, back),
                  meta=NS(length=length,
                          precision=precision,
                          scheme=scheme,
                          pool=pool)))
コード例 #3
0
 def add(name, scheme, pool=None):
     use3Steps = {'sp': 'true', 'dp': 'true'}
     if length == 81:
         use3Steps['dp'] = 'false'
     elif length == 200:
         use3Steps['sp'] = use3Steps['dp'] = 'false'
     functions.append(
         Function(name=name,
                  arguments=ArgumentList(data, back),
                  meta=NS(length=length,
                          precision=precision,
                          scheme=scheme,
                          use_3steps_large_twd=use3Steps,
                          pool=pool)))
コード例 #4
0
def generate_cpu_function_pool(functions):
    """Generate function to populate the kernel function pool."""

    function_map_single = Map('function_map_single')
    function_map_double = Map('function_map_double')
    function_map_single_2d = Map('function_map_single_2D')
    function_map_double_2d = Map('function_map_double_2D')
    function_map_single_transpose_tile_aligned = Map(
        'function_map_single_transpose_tile_aligned')
    function_map_double_transpose_tile_aligned = Map(
        'function_map_double_transpose_tile_aligned')
    function_map_single_transpose_diagonal = Map(
        'function_map_single_transpose_diagonal')
    function_map_double_transpose_diagonal = Map(
        'function_map_double_transpose_diagonal')

    pool_map = {
        ('sp', None): function_map_single,
        ('dp', None): function_map_double,
        ('sp', '2D'): function_map_single_2d,
        ('dp', '2D'): function_map_double_2d,
        ('sp', 'tile_aligned'): function_map_single_transpose_tile_aligned,
        ('dp', 'tile_aligned'): function_map_double_transpose_tile_aligned,
        ('sp', 'transpose_diagonal'): function_map_single_transpose_diagonal,
        ('dp', 'transpose_diagonal'): function_map_double_transpose_diagonal,
    }

    populate = StatementList()
    for f in functions:
        length, precision, scheme, pool = f.meta.length, f.meta.precision, f.meta.scheme, f.meta.pool
        if isinstance(length, (int, str)):
            key = Call(name='std::make_pair',
                       arguments=ArgumentList(length, scheme)).inline()
        else:
            key = Call(name='std::make_tuple',
                       arguments=ArgumentList(length[0], length[1],
                                              scheme)).inline()
        populate += pool_map[precision, pool].emplace(key, FFTKernel(f))

    return StatementList(
        Include('<iostream>'), Include('"../include/function_pool.h"'),
        StatementList(*[f.prototype() for f in functions]),
        Function(name='function_pool::function_pool',
                 value=False,
                 arguments=ArgumentList(),
                 body=populate))
コード例 #5
0
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
INCLUDES_H = ('<stddef.h>   /* ptrdiff_t */',)
INCLUDES_C = ('<stddef.h>         /* ptrdiff_t */',
              '<string.h>         /* strlen() */',
              '"internal/fmtc.h"  /* cutils_fmtc_repr */',
              '"internal/fcmp.h"  /* cutils_fcmp_compare */')

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
_RETURN_DEF = 'return {ORIGINAL}({ARGUMENTS});'



#------------------------------------------------------------------------------#
new_ = Function('new', 'bool', ('{MAINTYPE}**', 'd'),
                               ('size_t',       'c'),
                               ('{SUBTYPE}*',   'a'))
new_.wrapping = 'return {ORIGINAL}(d,sizeof({SUBTYPE}),c,a);'
new_.defaults = {'_default2': ('a', 'return {WRAPPED}(d,sizeof({SUBTYPE}),c,NULL);'),
                 '_default1': ('c', 'a', 'return {WRAPPED}(d,sizeof({SUBTYPE}),0,NULL);')}
new_.original = 4
new_.original_defaults = {'_default2': 2,
                          '_default3': 3}

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
del_ = Function('del', 'void', ('{MAINTYPE}*', 'd'))
del_.pointing = '{ORIGINAL}'
del_.original = 1

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
data_ = Function('data', '{SUBTYPE}*', ('{MAINTYPE}*', 'd'),
コード例 #6
0
ファイル: static_hash_map.py プロジェクト: matt-hayden/cutils
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
SUPPORTS = (('iterator', 'SHMIterator'),)

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
INCLUDES_H = ('<stddef.h>   /* size_t */',)
INCLUDES_C = ('<stddef.h>         /* size_t, ptrdiff_t */',
              '<string.h>         /* memcmp() */',
              '"internal/fcmp.h"  /* cutils_fcmp_compare */')

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
_RETURN_DEF = 'return {ORIGINAL}({ARGUMENTS});'



#------------------------------------------------------------------------------#
new_ = Function('new', 'bool', ('{MAINTYPE}**', 'h'),
                               ('size_t',       'c'))
new_.wrapping = _RETURN_DEF
new_.original = 2

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
del_ = Function('del', 'void', ('{MAINTYPE}*', 'h'))
del_.pointing = '{ORIGINAL}'
del_.original = 1

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
add_ = Function('add', 'bool', ('{MAINTYPE}*',      'h'),
                               Function('f', 'bool', ('const void*', 'p1'),
                                                     ('const void*', 'p2'),
                                                     ('size_t',      's')),
                               ('const {SUBTYPE_1}*', 'k'),
                               ('const {SUBTYPE_2}*', 'v'))
コード例 #7
0
######################################################################## INFO ##

# Import cutils modules
from generator import methods, Function

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
NAME = 'Tester'
PREFIX = 'cutils_cutt'

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
_RETURN_DEF = ''



#------------------------------------------------------------------------------#
new_ = Function('new', 'void', ('{MAINTYPE}**', 't'),
                               ('size_t',      'c'))
new_.wrapping = _RETURN_DEF

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
del_ = Function('del', 'void', ('{MAINTYPE}*', 't'))
del_.wrapping = _RETURN_DEF



#------------------------------------------------------------------------------#
def generate(folder, macros_dict):
    methods(base_name=NAME,
            module_prefix=PREFIX,
            macros_dict=macros_dict,
            functions=(new_, del_))
コード例 #8
0
PREFIX = 'cutils_cshm'

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
SUPPORTS = (('iterator', 'SHMIterator'), )

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
INCLUDES_H = ('<stddef.h>   /* size_t */', )
INCLUDES_C = ('<stddef.h>         /* size_t, ptrdiff_t */',
              '<string.h>         /* memcmp() */',
              '"internal/fcmp.h"  /* cutils_fcmp_compare */')

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
_RETURN_DEF = 'return {ORIGINAL}({ARGUMENTS});'

#------------------------------------------------------------------------------#
new_ = Function('new', 'bool', ('{MAINTYPE}**', 'h'), ('size_t', 'c'))
new_.wrapping = _RETURN_DEF
new_.original = 2

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
del_ = Function('del', 'void', ('{MAINTYPE}*', 'h'))
del_.pointing = '{ORIGINAL}'
del_.original = 1

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
add_ = Function(
    'add', 'bool', ('{MAINTYPE}*', 'h'),
    Function('f', 'bool', ('const void*', 'p1'), ('const void*', 'p2'),
             ('size_t', 's')), ('const {SUBTYPE_1}*', 'k'),
    ('const {SUBTYPE_2}*', 'v'))
add_.wrapping = 'return {ORIGINAL}(h,f,sizeof({SUBTYPE_1}),sizeof({SUBTYPE_2}),k,v);'
コード例 #9
0
ファイル: shell.py プロジェクト: VladasZ/shell
from generator import Function

aldir = '~/dev/shell'
args = '$@'

Function.generate([
    ('r', 'mkdir $@'),
    ('py', 'sudo python3 $@'),
    ('_py', 'python3 ' + aldir + '/helper.py $@'),
    ('res', 'py ' + aldir + '/shell.py;. ' + aldir + '/shell.sh'),
    ('subll', 'subl .'),
    ('dev', 'cd  ~/dev'),
    ('sand', 'cd ~/dev/sand'),
    ('cdal', 'cd ' + aldir),
    ('al', 'cdal\n subll'),
    ('op', 'xdg-open .'),
    ('getbuild', '_py cleanclone vladasz/build'),
    ('build', 'py build.py')

    ##projects
    ,
    ('cdengine', 'cd ~/dev/projects/testengine'),
    ('bengine', 'cdengine;cd build;sudo make;cd ..'),
    ('rengine', 'cdengine;cd build/source/Engine/bin/; ./Engine; cdengine'),
    ('engine', 'bengine;rengine')
])
コード例 #10
0
INCLUDES_H = ('<stdio.h>    /* FILE */',
              '<stddef.h>   /* ptrdiff_t */')
INCLUDES_C = ('<stddef.h>         /* ptrdiff_t */',
              '<string.h>         /* strlen() */',
              '"internal/fmtc.h"  /* cutils_fmtc_repr */',
              '"internal/fcmp.h"  /* cutils_fcmp_compare */')

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
_RETURN_DEF = 'return {ORIGINAL}({ARGUMENTS});'
_RETURN_EXT = 'return {ORIGINAL}(l,i,sizeof({SUBTYPE}),c,a);'



#------------------------------------------------------------------------------#
new_ = Function('new', 'bool', ('{MAINTYPE}**', 'l'),
                               ('size_t',       'c'),
                               ('{SUBTYPE}*',   'a'))
new_.wrapping = 'return {ORIGINAL}(l,sizeof({SUBTYPE}),c,a);'
new_.defaults = {'_default1': ('c', 'a', 'return {WRAPPED}(l,sizeof({SUBTYPE}),0,NULL);')}
new_.original = 4
new_.original_defaults = {'_default1': 1}

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
del_ = Function('del', 'void', ('{MAINTYPE}*', 'l'))
del_.pointing = '{ORIGINAL}'
del_.original = 1

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
len_ = Function('len', 'size_t', ('{MAINTYPE}*', 'l'))
len_.pointing = '{ORIGINAL}'
len_.original = 1