Advanced Octave A60 — Resource policies and parallelism
Advanced GNU Octave with GX-TXT · Module 10
Splitting a work in blocks helps to control memory and advancement. The subdivision, however, does not imply that the blocks are executed in parallel: the policy of the Session and the contract of the service must be respected.
Objectives and prerequisites
We repeat the events of A59 and the numerical statistics of the course. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0. Import blocchi.m, register it and run it in the Runner.
Consult policy
PARALLEL_EXECUTION_API_v1/api_info describes the service and resources reads the policy allowed. In the test configuration are a default worker and a maximum; the recommended number of internal threads is one. Politics can be different on another installation.
Determined calculation of blocks
The program divides the numbers from 1 to 10,000 in ten sequential blocks of 1,000 values, sums the partials and calculates the average. Then compare the result with NUMERIC_API_v1/statistics: in the test both the averages are 5000,5 and the printed difference is zero.
This example does not start parallel workers. It shows how to design blocks and control recombination before using, where available, a public operation that manages parallel execution. Do not directly invoke process builders or controls reserved to the host by the Bridge. In real calculations, even the sum order in mobile comma can affect small numerical differences.
Exercise
- How many blocks are processed in the test?
- The
forcycle shown performs blocks in parallel? - Why read the policy before choosing the worker number?
Worked solution
- Ten.
- No: they are executed in sequence.
- To respect the limits of the actual environment and use only permitted operations.
Other steps of this project
- Advanced Octave A75 — Dynamical systems in phase space
- Advanced Octave A81 — Geography of the waves and a 3D surface
- Advanced Octave A82 — Age, sex and demographic inequalities
- Advanced Octave A83 — All-cause mortality, certified COVID deaths and surveillance
- Advanced Octave A84 — A reproducible public account
- Advanced Octave A73 — Optimization landscapes and 3D trajectories