Exemplo n.º 1
0
    def _visit_Call(self, stmt):

        args = []
        if stmt.args:
            args += self._visit(stmt.args)
        if stmt.keywords:
            args += self._visit(stmt.keywords)

        if len(args) == 0:
            args = ()

        func = self._visit(stmt.func)

        if isinstance(func, Symbol):
            f_name = func.name
            if str(f_name) == "print":
                func = PythonPrint(PythonTuple(*args))
            else:
                func = Function(f_name)(*args)
        elif isinstance(func, DottedName):
            f_name = func.name[-1]
            func_attr = Function(f_name)(*args)
            func = DottedName(*func.name[:-1], func_attr)
        else:
            raise NotImplementedError(' Unknown function type {}'.format(str(type(func))))

        return func
Exemplo n.º 2
0
    def _treat_import_source(self, source, level):
        source = '.' * level + str(source)
        if source.count('.') == 0:
            source = Symbol(source)
        else:
            source = DottedName(*source.split('.'))

        return get_default_path(source)
Exemplo n.º 3
0
def get_default_path(name):
    """this function takes a an import name
      and returns the path full bash of the library
      if the library is in stdlib"""
    name_ = name
    if isinstance(name, (DottedName, Symbol)):
        name_ = str(name)
    if name_ in pyccel_external_lib.keys():
        name = pyccel_external_lib[name_].split('.')
        if len(name) > 1:
            return DottedName(*name)
        else:
            return name[0]
    return name
Exemplo n.º 4
0
    def expr(self):

        if len(self.dotted_name)>1:
            name = DottedName(*self.dotted_name)
        else:
            name = str(self.dotted_name[0])

        args = []
        for i in self.args:
            if isinstance(i, MacroArg):
                args.append(i.expr)
            else:
                raise TypeError('argument must be of type MacroArg')


        if len(self.master_name)==1:
            master_name = str(self.master_name[0])
        else:
            raise NotImplementedError('TODO')

        master_args = []
        for i in self.master_args:
            if isinstance(i, MacroStmt):
                master_args.append(i.expr)
            else:
                master_args.append(Symbol(str(i)))


        results = self.results
        if (results is None):
            results = []


        if len(args + master_args + results) == 0:
            return MacroVariable(name, master_name)

        if not isinstance(name, str):
            #we treat the other all the names except the last one  as arguments
            # so that we always have a name of type str
            args = list(name.name[:-1]) + list(args)
            name = name.name[-1]
        return MacroFunction(name, args, master_name, master_args, results=results)
Exemplo n.º 5
0
    def _print_FunctionDef(self, expr):
        name = self._print(expr.name)
        body = self._print(expr.body)
        body = self._indent_codestring(body)
        args = ', '.join(self._print(i) for i in expr.arguments)

        imports = '\n'.join(self._print(i) for i in expr.imports)
        imports = self._indent_codestring(imports)
        code = ('def {name}({args}):\n'
                '\n{imports}\n{body}\n').format(name=name, args=args,imports=imports, body=body)

        decorators = expr.decorators

        if decorators:
            for n,f in decorators.items():
                if n in pyccel_decorators:
                    self._additional_imports.add(Import(DottedName('pyccel.decorators'), n))
                # TODO - All decorators must be stored in a list
                if not isinstance(f, list):
                    f = [f]
                dec = ''
                for func in f:
                    args = func.args
                    if args:
                        args = ', '.join("{}".format(self._print(i)) for i in args)
                        dec += '@{name}({args})\n'.format(name=n, args=args)

                    else:
                        dec += '@{name}\n'.format(name=n)

                code = '{dec}{code}'.format(dec=dec, code=code)
        headers = expr.headers
        if headers:
            headers = self._print(headers)
            code = '{header}\n{code}'.format(header=header, code=code)

        return code
Exemplo n.º 6
0
def get_for_clauses(expr):
    # ...
    def _format_str(a):
        if isinstance(a, str):
            return a.strip('\'')
        else:
            return a
    # ...

    # ...
    d_attributs = {}
    d_args      = {}
    # ...

    # ... we first create a dictionary of attributs
    if isinstance(expr, Variable):
        if expr.cls_base:
            d_attributs = expr.cls_base.attributs_as_dict
    elif isinstance(expr, ConstructorCall):
        attrs = expr.attributs
        for i in attrs:
            d_attributs[str(i).replace('self.', '')] = i
    # ...

    # ...
    if not d_attributs:
        raise ValueError('Can not find attributs')
    # ...

    # ...
    if isinstance(expr, Variable):
        cls_base = expr.cls_base

        if not cls_base:
            return None, None

        if not(('openmp' in cls_base.options) and ('iterable' in cls_base.options)):
            return None, None
    elif isinstance(expr, ConstructorCall):
        # arguments[0] is 'self'
        # TODO must be improved in syntax, so that a['value'] is a sympy object
        for a in expr.arguments[1:]:
            if isinstance(a, dict):
                # we add '_' tp be conform with the private variables convention
                d_args['_{0}'.format(a['key'])] = a['value']
    else:
        return None, None
    # ...

    # ... get initial values for all attributs
    #     TODO do we keep 'self' hard coded?
    d = {}
    for k,v in d_attributs.items():
        i = DottedName('self', k)
        d[k] = get_initial_value(expr, i)
    # ...

    # ... update the dictionary with the class parameters
    for k,v in d_args.items():
        d[k] = d_args[k]
    # ...

    # ... initial values for clauses
    nowait       = None

    collapse     = None
    private      = None
    firstprivate = None
    lastprivate  = None
    reduction    = None
    schedule     = None
    ordered      = None
    linear       = None
    # ...

    # ... nowait
    nowait = d['_nowait']
    # ...

    # ... collapse
    if not(d['_collapse'] is None):
        if not isinstance(d['_collapse'], Nil):
            ls = [d['_collapse']]
            collapse = OMP_Collapse(*ls)
    # ...

    # ... private
    if not(d['_private'] is None):
        if not isinstance(d['_private'], Nil):
            ls = d['_private']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            private = OMP_Private(*ls)
    # ...

    # ... firstprivate
    if not(d['_firstprivate'] is None):
        if not isinstance(d['_firstprivate'], Nil):
            ls = d['_firstprivate']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            firstprivate = OMP_FirstPrivate(*ls)
    # ...

    # ... lastprivate
    if not(d['_lastprivate'] is None):
        if not isinstance(d['_lastprivate'], Nil):
            ls = d['_lastprivate']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            lastprivate = OMP_LastPrivate(*ls)
    # ...

    # ... reduction
    if not(d['_reduction'] is None):
        if not isinstance(d['_reduction'], Nil):
            ls = d['_reduction']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            reduction = OMP_Reduction(*ls)
    # ...

    # ... schedule
    if not(d['_schedule'] is None):
        if not isinstance(d['_schedule'], Nil):
            ls = d['_schedule']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls[0] = _format_str(ls[0])
            schedule = OMP_Schedule(*ls)
    # ...

    # ... ordered
    if not(d['_ordered'] is None):
        if not isinstance(d['_ordered'], Nil):
            ls = d['_ordered']

            args = []
            if isinstance(ls, (int, sp_Integer)):
                args.append(ls)

            ordered = OMP_Ordered(*args)
    # ...

    # ... linear
    if not(d['_linear'] is None):
        if not isinstance(d['_linear'], Nil):
            # we need to convert Tuple to list here
            ls = list(d['_linear'])

            if len(ls) < 2:
                raise ValueError('Expecting at least 2 entries, '
                                 'given {0}'.format(len(ls)))

            variables = [a.strip('\'') for a in ls[0:-1]]
            ls[0:-1]  = variables

            linear = OMP_Linear(*ls)
    # ...

    # ...
    clauses = (private, firstprivate, lastprivate,
               reduction, schedule,
               ordered, collapse, linear)
    clauses = [i for i in clauses if not(i is None)]
    clauses = Tuple(*clauses)
    # ...

    # ...
    info = {}
    info['nowait'] = nowait
    # ...

    return info, clauses
Exemplo n.º 7
0
def get_with_clauses(expr):
    # ...
    def _format_str(a):
        if isinstance(a, str):
            return a.strip('\'')
        else:
            return a
    # ...

    # ...
    d_attributs = {}
    d_args      = {}
    # ...

    # ... we first create a dictionary of attributs
    if isinstance(expr, Variable):
        if expr.cls_base:
            d_attributs = expr.cls_base.attributs_as_dict

    elif isinstance(expr, ConstructorCall):
        attrs = expr.attributs
        for i in attrs:
            d_attributs[str(i).replace('self.', '')] = i
    # ...

    # ...
    if not d_attributs:
        raise ValueError('Can not find attributs')
    # ...

    # ...
    if isinstance(expr, Variable):
        cls_base = expr.cls_base

        if not cls_base:
            return None

        if not(('openmp' in cls_base.options) and ('with' in cls_base.options)):
            return None
    elif isinstance(expr, ConstructorCall):
        # arguments[0] is 'self'
        # TODO must be improved in syntax, so that a['value'] is a sympy object
        for a in expr.arguments[1:]:
            if isinstance(a, dict):
                # we add '_' tp be conform with the private variables convention
                d_args['_{0}'.format(a['key'])] = a['value']
    else:
        return None
    # ...

    # ... get initial values for all attributs
    #     TODO do we keep 'self' hard coded?
    d = {}
    for k,v in d_attributs.items():
        i = DottedName('self', k)
        d[k] = get_initial_value(expr, i)
    # ...

    # ... update the dictionary with the class parameters
    for k,v in d_args.items():
        d[k] = d_args[k]
    # ...

    # ... initial values for clauses
    private      = None
    firstprivate = None
    shared       = None
    reduction    = None
    copyin       = None
    default      = None
    proc_bind    = None
    num_threads  = None
    if_test      = None
    # ...

    # ... private
    if not(d['_private'] is None):
        if not isinstance(d['_private'], Nil):
            ls = d['_private']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            private = OMP_Private(*ls)
    # ...

    # ... firstprivate
    if not(d['_firstprivate'] is None):
        if not isinstance(d['_firstprivate'], Nil):
            ls = d['_firstprivate']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            firstprivate = OMP_FirstPrivate(*ls)
    # ...

    # ... shared
    if not(d['_shared'] is None):
        if not isinstance(d['_shared'], Nil):
            ls = d['_shared']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            shared = OMP_Shared(*ls)
    # ...

    # ... reduction
    if not(d['_reduction'] is None):
        if not isinstance(d['_reduction'], Nil):
            ls = d['_reduction']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            reduction = OMP_Reduction(*ls)
    # ...

    # ... copyin
    if not(d['_copyin'] is None):
        if not isinstance(d['_copyin'], Nil):
            ls = d['_copyin']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            copyin = OMP_Copyin(*ls)
    # ...

    # ... default
    if not(d['_default'] is None):
        if not isinstance(d['_default'], Nil):
            ls = d['_default']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls[0] = _format_str(ls[0])
            default = OMP_Default(*ls)
    # ...

    # ... proc_bind
    if not(d['_proc_bind'] is None):
        if not isinstance(d['_proc_bind'], Nil):
            ls = d['_proc_bind']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls[0] = _format_str(ls[0])
            proc_bind = OMP_ProcBind(*ls)
    # ...

    # ... num_threads
    #     TODO improve this to take any int expression for arg.
    #     see OpenMP specifications for num_threads clause
    if not(d['_num_threads'] is None):
        if not isinstance(d['_num_threads'], Nil):
            arg = d['_num_threads']
            ls = [arg]
            num_threads = OMP_NumThread(*ls)
    # ...

    # ... if_test
    #     TODO improve this to take any boolean expression for arg.
    #     see OpenMP specifications for if_test clause
    if not(d['_if_test'] is None):
        if not isinstance(d['_if_test'], Nil):
            arg = d['_if_test']
            ls = [arg]
            if_test = OMP_If(*ls)
    # ...

    # ...
    clauses = (private, firstprivate, shared,
               reduction, default, copyin,
               proc_bind, num_threads, if_test)
    clauses = [i for i in clauses if not(i is None)]
    clauses = Tuple(*clauses)
    # ...

    return clauses
Exemplo n.º 8
0
def get_for_clauses(expr):
    # ...
    def _format_str(a):
        if isinstance(a, str):
            return a.strip('\'')
        else:
            return a

    # ...

    # ...
    d_attributs = {}
    d_args = {}
    # ...

    # ... we first create a dictionary of attributs
    if isinstance(expr, Variable):
        if expr.cls_base:
            d_attributs = expr.cls_base.attributs_as_dict
    elif isinstance(expr, ConstructorCall):
        attrs = expr.attributs
        for i in attrs:
            d_attributs[str(i).replace('self.', '')] = i
    # ...

    # ...
    if not d_attributs:
        raise ValueError('Can not find attributs')
    # ...

    # ...
    if isinstance(expr, Variable):
        cls_base = expr.cls_base

        if not cls_base:
            return None, None

        if not (('openacc' in cls_base.options) and
                ('iterable' in cls_base.options)):
            return None, None
    elif isinstance(expr, ConstructorCall):
        # arguments[0] is 'self'
        # TODO must be improved in syntax, so that a['value'] is a sympy object
        for a in expr.arguments[1:]:
            if isinstance(a, dict):
                # we add '_' tp be conform with the private variables convention
                d_args['_{0}'.format(a['key'])] = a['value']
    else:
        return None, None
    # ...

    # ... get initial values for all attributs
    #     TODO do we keep 'self' hard coded?
    d = {}
    for k, v in d_attributs.items():
        i = DottedName('self', k)
        d[k] = get_initial_value(expr, i)
    # ...

    # ... update the dictionary with the class parameters
    for k, v in d_args.items():
        d[k] = d_args[k]
    # ...

    # ... initial values for clauses
    _collapse = None
    _gang = None
    _worker = None
    _vector = None
    _seq = None
    _auto = None
    _tile = None
    _device_type = None
    _independent = None
    _private = None
    _reduction = None
    # ...

    # ... auto
    if not (d['_auto'] is None):
        if not isinstance(d['_auto'], Nil):
            _auto = ACC_Auto()
    # ...

    # ... collapse
    if not (d['_collapse'] is None):
        if not isinstance(d['_collapse'], Nil):
            ls = [d['_collapse']]
            _collapse = ACC_Collapse(*ls)
    # ...

    # ... device_type
    if not (d['_device_type'] is None):
        if not isinstance(d['_device_type'], Nil):
            ls = d['_device_type']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _device_type = ACC_DeviceType(*ls)
    # ...

    # ... gang
    if not (d['_gang'] is None):
        if not isinstance(d['_gang'], Nil):
            ls = d['_gang']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _gang = ACC_Gang(*ls)
    # ...

    # ... independent
    if not (d['_independent'] is None):
        if not isinstance(d['_independent'], Nil):
            _independent = ACC_Independent()
    # ...

    # ... private
    if not (d['_private'] is None):
        if not isinstance(d['_private'], Nil):
            ls = d['_private']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _private = ACC_Private(*ls)
    # ...

    # ... reduction
    if not (d['_reduction'] is None):
        if not isinstance(d['_reduction'], Nil):
            ls = d['_reduction']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _reduction = ACC_Reduction(*ls)
    # ...

    # ... seq
    if not (d['_seq'] is None):
        if not isinstance(d['_seq'], Nil):
            _seq = ACC_Seq()
    # ...

    # ... tile
    if not (d['_tile'] is None):
        if not isinstance(d['_tile'], Nil):
            ls = d['_tile']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _tile = ACC_Tile(*ls)
    # ...

    # ... vector
    if not (d['_vector'] is None):
        if not isinstance(d['_vector'], Nil):
            ls = d['_vector']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _vector = ACC_Vector(*ls)
    # ...

    # ... worker
    if not (d['_worker'] is None):
        if not isinstance(d['_worker'], Nil):
            ls = d['_worker']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _worker = ACC_Worker(*ls)
    # ...

    # ...
    clauses = (_collapse, _gang, _worker, _vector, _seq, _auto, _tile,
               _device_type, _independent, _private, _reduction)

    clauses = [i for i in clauses if not (i is None)]
    clauses = Tuple(*clauses)
    # ...

    return clauses
Exemplo n.º 9
0
def get_with_clauses(expr):
    # ...
    def _format_str(a):
        if isinstance(a, str):
            return a.strip('\'')
        else:
            return a

    # ...

    # ...
    d_attributs = {}
    d_args = {}
    # ...

    # ... we first create a dictionary of attributs
    if isinstance(expr, Variable):
        if expr.cls_base:
            d_attributs = expr.cls_base.attributs_as_dict
    elif isinstance(expr, ConstructorCall):
        attrs = expr.attributs
        for i in attrs:
            d_attributs[str(i).replace('self.', '')] = i
    # ...

    # ...
    if not d_attributs:
        raise ValueError('Can not find attributs')
    # ...

    # ...
    if isinstance(expr, Variable):
        cls_base = expr.cls_base

        if not cls_base:
            return None

        if not (('openacc' in cls_base.options) and
                ('with' in cls_base.options)):
            return None
    elif isinstance(expr, ConstructorCall):
        # arguments[0] is 'self'
        # TODO must be improved in syntax, so that a['value'] is a sympy object
        for a in expr.arguments[1:]:
            if isinstance(a, dict):
                # we add '_' tp be conform with the private variables convention
                d_args['_{0}'.format(a['key'])] = a['value']
    else:
        return None
    # ...

    # ... get initial values for all attributs
    #     TODO do we keep 'self' hard coded?
    d = {}
    for k, v in d_attributs.items():
        i = DottedName('self', k)
        d[k] = get_initial_value(expr, i)
    # ...

    # ... update the dictionary with the class parameters
    for k, v in d_args.items():
        d[k] = d_args[k]
    # ...

    # ... initial values for clauses
    _async = None
    _wait = None
    _num_gangs = None
    _num_workers = None
    _vector_length = None
    _device_type = None
    _if = None
    _reduction = None
    _copy = None
    _copyin = None
    _copyout = None
    _create = None
    _present = None
    _deviceptr = None
    _private = None
    _firstprivate = None
    _default = None
    # ...

    # ... async
    if not (d['_async'] is None):
        if not isinstance(d['_async'], Nil):
            ls = d['_async']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _async = ACC_Async(*ls)
    # ...

    # ... copy
    if not (d['_copy'] is None):
        if not isinstance(d['_copy'], Nil):
            ls = d['_copy']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _copy = ACC_Copy(*ls)
    # ...

    # ... copyin
    if not (d['_copyin'] is None):
        if not isinstance(d['_copyin'], Nil):
            ls = d['_copyin']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _copyin = ACC_Copyin(*ls)
    # ...

    # ... copyout
    if not (d['_copyout'] is None):
        if not isinstance(d['_copyout'], Nil):
            ls = d['_copyout']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _copyout = ACC_Copyout(*ls)
    # ...

    # ... create
    if not (d['_create'] is None):
        if not isinstance(d['_create'], Nil):
            ls = d['_create']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _create = ACC_Copyin(*ls)
    # ...

    # ... default
    if not (d['_default'] is None):
        if not isinstance(d['_default'], Nil):
            ls = d['_default']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls[0] = _format_str(ls[0])
            _default = ACC_Default(*ls)
    # ...

    # ... deviceptr
    if not (d['_deviceptr'] is None):
        if not isinstance(d['_deviceptr'], Nil):
            ls = d['_deviceptr']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _deviceptr = ACC_DevicePtr(*ls)
    # ...

    # ... devicetype
    if not (d['_device_type'] is None):
        if not isinstance(d['_device_type'], Nil):
            ls = d['_device_type']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _device_type = ACC_DeviceType(*ls)
    # ...

    # ... firstprivate
    if not (d['_firstprivate'] is None):
        if not isinstance(d['_firstprivate'], Nil):
            ls = d['_firstprivate']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _firstprivate = ACC_FirstPrivate(*ls)
    # ...

    # ... if
    #     TODO improve this to take any boolean expression for arg.
    #     see OpenACC specifications
    if not (d['_if'] is None):
        if not isinstance(d['_if'], Nil):
            arg = d['_if']
            ls = [arg]
            _if = ACC_If(*ls)
    # ...

    # ... num_gangs
    #     TODO improve this to take any int expression for arg.
    #     see OpenACC specifications
    if not (d['_num_gangs'] is None):
        if not isinstance(d['_num_gangs'], Nil):
            arg = d['_num_gangs']
            ls = [arg]
            _num_gangs = ACC_NumGangs(*ls)
    # ...

    # ... num_workers
    #     TODO improve this to take any int expression for arg.
    #     see OpenACC specifications
    if not (d['_num_workers'] is None):
        if not isinstance(d['_num_workers'], Nil):
            arg = d['_num_workers']
            ls = [arg]
            _num_workers = ACC_NumWorkers(*ls)
    # ...

    # ... present
    if not (d['_present'] is None):
        if not isinstance(d['_present'], Nil):
            ls = d['_present']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _present = ACC_Present(*ls)
    # ...

    # ... private
    if not (d['_private'] is None):
        if not isinstance(d['_private'], Nil):
            ls = d['_private']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _private = ACC_Private(*ls)
    # ...

    # ... reduction
    if not (d['_reduction'] is None):
        if not isinstance(d['_reduction'], Nil):
            ls = d['_reduction']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _reduction = ACC_Reduction(*ls)
    # ...

    # ... vector_length
    if not (d['_vector_length'] is None):
        if not isinstance(d['_vector_length'], Nil):
            arg = d['_vector_length']
            ls = [arg]
            _vector_length = ACC_VectorLength(*ls)
    # ...

    # ... wait
    if not (d['_wait'] is None):
        if not isinstance(d['_wait'], Nil):
            ls = d['_wait']
            if not isinstance(ls, (list, tuple, Tuple)):
                ls = [ls]

            ls = [_format_str(a) for a in ls]
            _wait = ACC_Wait(*ls)
    # ...

    # ...
    clauses = (_async, _wait, _num_gangs, _num_workers, _vector_length,
               _device_type, _if, _reduction, _copy, _copyin, _copyout,
               _create, _present, _deviceptr, _private, _firstprivate,
               _default)

    clauses = [i for i in clauses if not (i is None)]
    clauses = Tuple(*clauses)
    # ...

    return clauses
Exemplo n.º 10
0
 def _visit_Attribute(self, stmt):
     val  = self._visit(stmt.value)
     attr = Symbol(stmt.attr)
     return DottedName(val, attr)