Browse Source

starpupy: add an example, using decorator to wrap a function with input

HE Kun 4 years ago
parent
commit
ceb204c221
1 changed files with 14 additions and 1 deletions
  1. 14 1
      starpupy/tests/starpu_py.py

+ 14 - 1
starpupy/tests/starpu_py.py

@@ -49,7 +49,7 @@ asyncio.run(func1_wait())
 def func1_deco():
 	#time.sleep(1)
 	print ("Example 3:")
-	print ("This is a function wrapped by the decorator function")
+	print ("This is a function no input no output wrapped by the decorator function")
 
 #apply starpu.delayed(func1_deco())
 func1_deco()
@@ -116,4 +116,17 @@ asyncio.run(sub_wait())
 
 ###############################################################################
 
+#using decorator wrap the function with input
+@starpu.delayed
+def add_deco(a,b,c):
+	#time.sleep(1)
+	print ("Example 8:")
+	print ("This is a function with input wrapped by the decorator function:")
+	print ("The result of function is:", a, "+", b, "+", c, "=", a+b+c)
+
+#apply starpu.delayed(add_deco)
+add_deco(1,2,3)
+
+###############################################################################
+
 starpu.task_wait_for_all()