From 2fb1fa1697309cad26ab7d472db4f8bfa617e0b4 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 27 Dec 2018 00:46:44 +0100 Subject: [PATCH 1/1] python: First working example --- docs/source/img/lang_cpp.png | Bin 0 -> 801 bytes docs/source/img/lang_python.png | Bin 0 -> 822 bytes examples/python/CMakeLists.txt | 10 ++++++ examples/python/exec-basic/exec-basic.py | 39 +++++++++++++++++++++ examples/python/exec-basic/exec-basic.tesh | 6 ++++ examples/s4u/README.rst | 15 ++++++-- src/bindings/python/simgrid_python.cpp | 4 ++- tools/cmake/DefinePackages.cmake | 3 ++ 8 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 docs/source/img/lang_cpp.png create mode 100644 docs/source/img/lang_python.png create mode 100644 examples/python/CMakeLists.txt create mode 100644 examples/python/exec-basic/exec-basic.py create mode 100644 examples/python/exec-basic/exec-basic.tesh diff --git a/docs/source/img/lang_cpp.png b/docs/source/img/lang_cpp.png new file mode 100644 index 0000000000000000000000000000000000000000..ad7a89a01594193a6573de9a69dd9c3a2ee58a40 GIT binary patch literal 801 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRp!3-o*pRS7lQY`6?zK#qG8~eHcB(ehe3dtTp zz6=aiY77hwEes65fI|Ni|y zcI#dFvg>zWer?-uCw11P_g{X^-Tx?U_NBS|9=-eW>(`%uThG1BnSZ5h>GjDw?r%Bw z^4Fig-J9=Tc<`}k@%fPclQP+>86xLAc>Qhhp(n3DeGi{_fGKKj=G@B}b1pTmy&#yf zc=C=1iw-^U?mQxtvQ#O5<oVoQZt$)jzo6lZ-`tH@Xl`(RTU)z4sut_qJ6CS_%$mH3<6gn-o zd&kCOH~;;OkH}(R`2PlBM(%Rc z*+4<|5>H=O_D4L@Ol+>{`2p-J?ZCo91`t(KO4Sz%wI6I;r`(VfgQU!TT5GyPh9cJ zO($)Ipsl6roC_hp&!|jg*tqZZ)!rvF6%v`kv{E11%oS8IVbebS)Ad~tNBEOQrsv_V zg|S-GPt99#=gz&iu2UC=P5<=o;l=36EQa%EpK-_Czvo%A<;}Nux3>NLsro^8=@#qQ z121o^`nTY^{0d8%UXJ6FS6W&Ap6hM?`RJMI_eHLI{#n;_Z2l>qC$l||k^hp6(eB)@ zz(mBLTH+c}l9E`GYL#4+3Zxi}3=A!F4UKe-%tH(etqjbpOw6@G41-HwFG-?k$jwj5 zOsmALVeyKrr9cgmARB`7(@M${i&7cN%ggmL^RkPR6AM!H@{7`Ezq647Dq`?-^>bP0 Hl+XkKt#NK% literal 0 HcmV?d00001 diff --git a/docs/source/img/lang_python.png b/docs/source/img/lang_python.png new file mode 100644 index 0000000000000000000000000000000000000000..585bc0d340be26a7b6c5b20d4a3d624036f1993e GIT binary patch literal 822 zcmV-61Ihe}P)Px#2XskIMF-mq6buF`DqZ}s0008rNkl`U1%I-6o#Lj*|gh2ZZ=w!29YY% zAFzc|3nCh$Ev7%K2x1Ce6}&6$Rm3(RiYTI#=vDNxRut@oTB{3fEh(u|*I0w~qA?~Z zhOnkPvu<{F=KG!byx5(h^uXbKe7x^D?|TjaL$7`A*z@KY;g(-=R8CBN3HSgNckK~Z zc;Ukzzi$Wi;dW5xr(>4@@Z9pKbJw;zV5bl8>|1Buz}CkHR%X7f`upBJ?>fy@tW~=f zPj>ub+-flOYE63W>!qxz|%58%LF46Qfsgxss>kg4|ysq0XvFDCUk=O=?ljfY=2*L z5EYCdqY-2Xu+dXVENdShJ=wpma}X8wtOk%ufUp2;05-U#O4#+^ps;;@7-#@X9w30G z=`?;p1sKtp12phE5Z~HE9{bSY(i$@rvGqlS5eD^RI8p$jfk4nl`CgHTlw{T3$TC#^k37vAKHBEsk5jM zY>a1=E!CSrN47! z1o#sOd-m*Y4SI_11nvU*fj%GuBA^be0x}2x3*RcdlZIv|jsO4v07*qoM6N<$f` [Tremblay:privileged:(2) 0.001500] [python/INFO] Done. +> [Tremblay:executor:(1) 0.002000] [python/INFO] Done. diff --git a/examples/s4u/README.rst b/examples/s4u/README.rst index b1b996da8b..e730f217b9 100644 --- a/examples/s4u/README.rst +++ b/examples/s4u/README.rst @@ -16,8 +16,8 @@ SimGrid comes with an extensive set of examples, documented on this page. Most of them only demonstrate one single feature, with some larger examplars listed below. -Each of these examples can be found in a subdirectory under -examples/s4u in the archive. It contains the source code (also listed +The C++ examples can be found under examples/s4u while python examples +are in examples/python. Each such directory contains the source code (also listed from this page), and the so-called tesh file containing how to call the binary obtained by compiling this example and also the expected output. Tesh files are used to turn each of our examples into an @@ -151,7 +151,8 @@ Executions on the CPU the actor until a given amount of flops gets computed on its simulated host. Some executions can be given an higher priority so that they get more resources. - |br| `examples/s4u/exec-basic/s4u-exec-basic.cpp `_ + |br| |cpp| `examples/s4u/exec-basic/s4u-exec-basic.cpp `_ + |br| |py| `examples/python/exec-basic/exec-basic.py `_ - **Asynchronous execution:** You can start asynchronous executions, just like you would fire @@ -340,3 +341,11 @@ Distributed Hash Tables (DHT) .. |br| raw:: html
+ +.. |cpp| image:: /img/lang_cpp.png + :align: middle + :width: 12 + +.. |py| image:: /img/lang_python.png + :align: middle + :width: 12 diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index aace9c9162..4a9fd8759e 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -23,7 +23,7 @@ using simgrid::s4u::ActorPtr; using simgrid::s4u::Engine; using simgrid::s4u::Host; -XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_python, "S4U python"); +XBT_LOG_NEW_DEFAULT_CATEGORY(python, "python"); PYBIND11_DECLARE_HOLDER_TYPE(T, boost::intrusive_ptr); @@ -52,6 +52,8 @@ PYBIND11_MODULE(simgrid, m) /* this_actor namespace */ m.def("execute", py::overload_cast(&simgrid::s4u::this_actor::execute), "Block the actor, computing the given amount of flops"); + m.def("execute", py::overload_cast(&simgrid::s4u::this_actor::execute), + "Block the actor, computing the given amount of flops at the given priority"); m.def("yield_", &simgrid::s4u::this_actor::yield, "Yield the actor"); /* Class Engine */ diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index e05bf0f41f..39c8d01b25 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -905,6 +905,8 @@ set(DOC_SOURCES docs/source/img/extlink.png docs/source/img/extlink.svg docs/source/img/graphical-toc.svg + source/img/lang_cpp.png + source/img/lang_python.png docs/source/img/smpi_simgrid_alltoall_pair_16.png docs/source/img/smpi_simgrid_alltoall_ring_16.png docs/source/img/zone_hierarchy.png @@ -1008,6 +1010,7 @@ set(CMAKEFILES_TXT examples/java/CMakeLists.txt examples/msg/CMakeLists.txt examples/msg/mc/CMakeLists.txt + examples/python/CMakeLists.txt examples/s4u/CMakeLists.txt examples/simdag/CMakeLists.txt examples/smpi/CMakeLists.txt -- 2.20.1