Advanced Octave A60 — Resource policies and parallelism

by Giux GX-TXT, octave-en, scripts-en 1 min read

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

  1. How many blocks are processed in the test?
  2. The for cycle shown performs blocks in parallel?
  3. Why read the policy before choosing the worker number?

Worked solution

  1. Ten.
  2. No: they are executed in sequence.
  3. To respect the limits of the actual environment and use only permitted operations.

Download the Module 10 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *