Page 1 of 1

Offloading Python functions to the Epiphany

PostPosted: Mon Oct 02, 2017 8:01 am
by polas
Hi,

I have released version 2 of ePython, the biggest new feature is the ability to seamlessly offload functions in any Python code to the Epiphany cores. For instance the following Python code running under any Python interpreter (such as CPython on the Parallella) will run on the host only.

Code: Select all
def addNumbers(a,b):
  print "Adding!"
  return a+b

print addNumbers(10,20)


To offload specific functions to the Epiphany just requires you decorate them with the offload directive. Still executed under any Python interpreter (such as python hello.py if the file is called hello.py)

Code: Select all
from epython import offload

@offload
def addNumbers(a,b):
  print "Adding!"
  return a+b

print addNumbers(10,20)


Now the function addNumbers will run on each Epiphany core which will print out Adding! to the screen, calculate the sum of two numbers provided and return this to the host which itself displays the values returned from each core in a list. There are also a whole heap of optional controls for more advanced offloading such as running kernels asynchronously, managing device resident data and running on a subset of cores. I have written a blog article which explains all of this in more detail https://www.parallella.org/2017/09/29/offloading-kernels-from-python-codes-onto-the-epiphany/ and also walks you through how to upgrade your existing version of ePython to this latest release.

Cheers,
Nick