Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
host(x, y)
"""
name = 'host'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]
def _sympystr(self, printer):
sstr = printer.doprint
args = ', '.join('{0}'.format(sstr(i)) for i in self.variables)
return 'host({})'.format(args)
class ACC_If(ACC):
"""
Examples
>>> from pyccel.parallel.openacc import ACC_If
>>> ACC_If(True)
if (True)
"""
name = 'if'
def __new__(cls, *args, **options):
test = args[0]
return Basic.__new__(cls, test)
@property
def test(self):
return self._args[0]
ACC_Copyin,
ACC_Copyout,
ACC_Create,
ACC_Present,
ACC_DevicePtr,
ACC_Private,
ACC_FirstPrivate,
ACC_Default)
for clause in clauses:
if not isinstance(clause, _valid_clauses):
raise TypeError('Wrong clause for ACC_Parallel')
return ParallelBlock.__new__(cls, clauses, variables, body)
class ACC_For(ForIterator, ACC):
"""
ACC Loop construct statement.
Examples
"""
_prefix = '#pragma'
name = 'do'
def __new__(cls, loop, clauses):
if not iterable(clauses):
raise TypeError('Expecting an iterable for clauses')
_valid_clauses = (ACC_Collapse,
ACC_Gang,
ACC_Worker,
ACC_Vector,
'given {0}'.format(len(args)))
n = args[0]
return Basic.__new__(cls, n)
@property
def n_worker(self):
return self._args[0]
def _sympystr(self, printer):
sstr = printer.doprint
n_worker = '{0}'.format(sstr(self.n_worker))
return 'num_workers({0})'.format(n_worker)
class ACC_Present(ACC):
"""
Examples
>>> from pyccel.parallel.openacc import ACC_Present
>>> ACC_Present('x', 'y')
present(x, y)
"""
name = 'present'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]
self(x, y)
"""
name = 'self'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]
def _sympystr(self, printer):
sstr = printer.doprint
args = ', '.join('{0}'.format(sstr(i)) for i in self.variables)
return 'self({})'.format(args)
class ACC_Seq(ACC):
"""
Examples
>>> from pyccel.parallel.openacc import ACC_Seq
>>> ACC_Seq()
seq
"""
name = 'seq'
def _sympystr(self, printer):
return 'seq'
class ACC_Tile(ACC):
"""
copyout(x, y)
"""
name = 'copyout'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]
def _sympystr(self, printer):
sstr = printer.doprint
args = ', '.join('{0}'.format(sstr(i)) for i in self.variables)
return 'copyout({})'.format(args)
class ACC_Create(ACC):
"""
Examples
>>> from pyccel.parallel.openacc import ACC_Create
>>> ACC_Create('x', 'y')
create(x, y)
"""
name = 'create'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]
use_device(x, y)
"""
name = 'use_device'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]
def _sympystr(self, printer):
sstr = printer.doprint
args = ', '.join('{0}'.format(sstr(i)) for i in self.variables)
return 'use_device({})'.format(args)
class ACC_Vector(ACC):
"""
Examples
>>> from pyccel.parallel.openacc import ACC_Vector
>>> ACC_Vector('x', 'y')
vector(x, y)
"""
name = 'vector'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]
'given {0}'.format(len(args)))
n = args[0]
return Basic.__new__(cls, n)
@property
def n_loops(self):
return self._args[0]
def _sympystr(self, printer):
sstr = printer.doprint
n_loops = '{0}'.format(sstr(self.n_loops))
return 'collapse({0})'.format(n_loops)
class ACC_Copy(ACC):
"""
Examples
>>> from pyccel.parallel.openacc import ACC_Copy
>>> ACC_Copy('x', 'y')
copy(x, y)
"""
name = 'copy'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]
vector(x, y)
"""
name = 'vector'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]
def _sympystr(self, printer):
sstr = printer.doprint
args = ', '.join('{0}'.format(sstr(i)) for i in self.variables)
return 'vector({})'.format(args)
class ACC_VectorLength(ACC):
"""
Examples
>>> from pyccel.parallel.openacc import ACC_VectorLength
>>> ACC_VectorLength(2)
vector_length(2)
"""
name = 'vector_length'
def __new__(cls, *args, **options):
if not(len(args) == 1):
raise ValueError('Expecting 1 entry, '
'given {0}'.format(len(args)))
n = args[0]
return Basic.__new__(cls, n)
firstprivate(x, y)
"""
name = 'firstprivate'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]
def _sympystr(self, printer):
sstr = printer.doprint
args = ', '.join('{0}'.format(sstr(i)) for i in self.variables)
return 'firstprivate({})'.format(args)
class ACC_Gang(ACC):
"""
Examples
>>> from pyccel.parallel.openacc import ACC_Gang
>>> ACC_Gang('x', 'y')
gang(x, y)
"""
name = 'gang'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]
def target(self):
return self.loop.target
@property
def iterable(self):
return self.loop.iterable
@property
def body(self):
return self.loop.body
#################################################
#################################################
# Clauses
#################################################
class ACC_Async(ACC):
"""
Examples
>>> from pyccel.parallel.openacc import ACC_Async
>>> ACC_Async('x', 'y')
async(x, y)
"""
name = 'async'
def __new__(cls, *args, **options):
return Basic.__new__(cls, args)
@property
def variables(self):
return self._args[0]