|
@@ -1,28 +1,59 @@
|
|
|
import starpu
|
|
|
import time
|
|
|
+import asyncio
|
|
|
|
|
|
+############################################################################
|
|
|
+#function no input no output print hello world
|
|
|
+def hello():
|
|
|
+ print ("Example 1:")
|
|
|
+ print ("Hello, world!")
|
|
|
+
|
|
|
+#submit function "hello"
|
|
|
+async def hello_wait():
|
|
|
+ fut = starpu.task_submit(hello)
|
|
|
+ await fut
|
|
|
+asyncio.run(hello_wait())
|
|
|
+
|
|
|
+#############################################################################
|
|
|
+
|
|
|
+#function no input no output
|
|
|
+def func1():
|
|
|
+ print ("Example 2:")
|
|
|
+ print ("This is a function no input no output")
|
|
|
+
|
|
|
+#submit function "func1"
|
|
|
+async def func1_wait():
|
|
|
+ fut1 = starpu.task_submit(func1)
|
|
|
+ await fut1
|
|
|
+asyncio.run(func1_wait())
|
|
|
+
|
|
|
+##############################################################################
|
|
|
+
|
|
|
+#using decorator wrap the function
|
|
|
@starpu.delayed
|
|
|
-def salut():
|
|
|
- time.sleep(1)
|
|
|
- print ("salut, le monde")
|
|
|
+def func1_deco():
|
|
|
+ #time.sleep(1)
|
|
|
+ print ("Example 3:")
|
|
|
+ print ("This is a function wrapped by the decorator function")
|
|
|
|
|
|
+#apply starpu.delayed(func1_deco())
|
|
|
+func1_deco()
|
|
|
|
|
|
-def hello():
|
|
|
- print ("print in python")
|
|
|
- print ("Hello, world!")
|
|
|
+##############################################################################
|
|
|
|
|
|
-starpu.pause()
|
|
|
+#function no input return a value
|
|
|
+def func2():
|
|
|
+ print ("Example 4:")
|
|
|
+ return 12
|
|
|
|
|
|
-print("begin to submit task in python")
|
|
|
-fut=starpu.task_submit(hello)
|
|
|
-salut()
|
|
|
-#starpu.task_submit(hello)
|
|
|
-#starpu.task_submit(hello)
|
|
|
-print("finish to submit task in python")
|
|
|
-starpu.resume()
|
|
|
+#submit function "func2"
|
|
|
+async def func2_wait():
|
|
|
+ fut2 = starpu.task_submit(func2)
|
|
|
+ res = await fut2
|
|
|
+ #print the result of function
|
|
|
+ print("This is a function no input and the return value is", res)
|
|
|
+asyncio.run(func2_wait())
|
|
|
|
|
|
-#print("begin to sleep")
|
|
|
-#time.sleep(1)
|
|
|
-#print("finish to sleep")
|
|
|
+###############################################################################
|
|
|
|
|
|
starpu.task_wait_for_all()
|