Browse Source

starpupy/examples: return 77 when no worker is available

Nathalie Furmento 4 years ago
parent
commit
5ff7c0f805

+ 8 - 3
starpupy/examples/starpu_py.py

@@ -1,6 +1,6 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
-# Copyright (C) 2020       Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
+# Copyright (C) 2020-2021  Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
 #
 # StarPU is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as published by
@@ -50,7 +50,7 @@ def func2():
 	return 12
 
 ###############################################################################
- 
+
 #function has 2 int inputs and 1 int output
 def multi(a,b):
 	print ("Example 5:")
@@ -142,7 +142,12 @@ async def main():
     res8 = await fut8
     print("The result of function sqrt is:", res8)
 
-asyncio.run(main())
+try:
+        asyncio.run(main())
+except starpupy.error as e:
+        print("No worker to execute the job")
+        starpupy.shutdown()
+        exit(77)
 
 starpupy.shutdown()
 #starpu.task_wait_for_all()

+ 7 - 2
starpupy/examples/starpu_py_np.py

@@ -1,6 +1,6 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
-# Copyright (C) 2020       Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
+# Copyright (C) 2020-2021  Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
 #
 # StarPU is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as published by
@@ -35,6 +35,11 @@ async def main():
     print("The return array is", t)
     #print("The result type is", type(res8))
 
-asyncio.run(main())
+try:
+        asyncio.run(main())
+except starpupy.error as e:
+        print("No worker to execute the job")
+        starpupy.shutdown()
+        exit(77)
 
 starpupy.shutdown()

+ 14 - 6
starpupy/examples/starpu_py_parallel.py

@@ -1,6 +1,6 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
-# Copyright (C) 2020       Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
+# Copyright (C) 2020-2021  Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
 #
 # StarPU is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as published by
@@ -136,9 +136,13 @@ for arg in sys.argv[1:]:
 for x in listX:
 	for X in range(x, x*10, x):
 		#print("X=",X)
-		starpu.joblib.Parallel(mode="normal", n_jobs=-1, perfmodel="log_list")(starpu.joblib.delayed(log10)(i+1)for i in range(X))
-		A=np.arange(1,X+1,1)
-		starpu.joblib.Parallel(mode="normal", n_jobs=-1, perfmodel="log_arr")(starpu.joblib.delayed(log10_arr)(A))
+		try :
+			starpu.joblib.Parallel(mode="normal", n_jobs=-1, perfmodel="log_list")(starpu.joblib.delayed(log10)(i+1)for i in range(X))
+			A=np.arange(1,X+1,1)
+			starpu.joblib.Parallel(mode="normal", n_jobs=-1, perfmodel="log_arr")(starpu.joblib.delayed(log10_arr)(A))
+		except starpupy.error as e:
+			print("No worker to execute the job")
+			exit(77)
 
 print("************************")
 print("parallel Normal version:")
@@ -335,7 +339,11 @@ async def main():
 	res10=await fut10
 	#print(res9)
 
-asyncio.run(main())
+try:
+        asyncio.run(main())
+except starpupy.error as e:
+        starpupy.shutdown()
+        exit(77)
 
 starpu.perfmodel_plot(perfmodel="sqrt",view=displayPlot)
 starpu.perfmodel_plot(perfmodel="multi",view=displayPlot)
@@ -349,4 +357,4 @@ starpu.perfmodel_plot(perfmodel="func",view=displayPlot)
 starpu.perfmodel_plot(perfmodel="log_list",view=displayPlot)
 starpu.perfmodel_plot(perfmodel="log_arr",view=displayPlot)
 
-starpupy.shutdown()
+starpupy.shutdown()