Multithreading with octave and perform installation on cluster

I have been investigating and looking for a way to perform multithreading using octave, I have set the variables both in windows and in linux, but I have not been able to find a substantial difference unlike using MATLAB, I have used the variables both environment and setting of this on the octave console

  • setenv OMP_NUM_THREADS

  • Using too nproc (all)


  • setenv USE_OPENMP

In various forums, most of them talk about how to perform multithreading with octave, however in the tests that I did I cannot see a substantial difference in the reduction of the time when increasing the threads. I am using version 5.0.2 of your portal which already has OPENBLAS integrated. We use MATLAB in the company, however we are exploring the use of OCTAVE, I hope you can support me, if it is possible to perform multithreading, or failing that, know if it is feasible to implement it in a cluster and make use of the GPU processors, and thus send the user works towards the cluster. If so, could you tell me if there is documentation in this regard to help me with the implementation.

Thanks so much.

Best Regards.

To give a satisfying answer, what code is it that you want to perform multi-threaded? Octave-code involving lots of linear algebra (matrix-vector multiplication) and vectorized code? Hoping for Octave-code scripts with many for loops and scalar computations to magically run faster is not possible.

Octave, like Matlab, strongly relies on the underlying math libraries to work with multiple processor cores. In case of linear algebra tasks, Octave mostly uses (Open)BLAS functions and a simple backslash operation x = A \ b can be performed on as many cores as the used (Open)BLAS library permits. For me it worked with 28 cpu cores (56 threads). OpenBLAS is controlled by the environment variables you gave a try, but is limited during the build time of OpenBLAS (depends on which OpenBLAS you are using, from the Linux Distribution most likely). Setting those environment variables should happen before starting Octave, e.g. from your shell

OMP_NUM_THREADS=2 ./octave

When you run nproc() what do you see, what do you expect so see?

So far Octave has nothing comparable to the advanced “MATLAB Parallel Server” or “Parallel Computing Toolbox”. Parallelization can be achieved by adapting your code to existing Octave packages. For example:

  • parallel - parcellfun and pararrayfun executable over multiple cores or machines
  • mpi - lower level MPI functions
  • ocl - OpenCL data type (GPU)

Thank you very much for the quick answer.

1.- Thinking about the possibility that whatever the code was for matrix calculation and worked in octave by users, it would be possible to think that just by increasing the number of threads in OMP_NUM_THREADS, this particularity of octave would help users to perform Does it work much faster or would it basically depend on your ability to create scripts with functions that would optimize their response time?

If that were the case, would it be possible for you to provide me with some examples with which to demonstrate to my colleagues the usefulness of using this parameter as an environment variable and to demonstrate what you assert in your previous email, would it be possible?

2.- On the other hand, they could provide me with information, how to implement this functionality in Octave, to support it to my superiors and to be able to carry out tests at the cluster level, and start a process and an implementation oriented to this solution, and thus guide users towards the use of an octave cluster that helps your job processing needs and does not depend solely on the resources that a server or a stand-alone windows machine can provide.

* parallel - parcellfun and pararayfun executable over multiple cores or machines

My system CPU is a AMD Ryzen 7 with 8 CPU cores.

I find that Python 3.8.6 Tensorflow can use up to 6 CPU cores (CPU usage is at a maximum 75%).

How do I configure Octave to use 6 cores? My OS is Windows 10 64 bit, Octave 5.2.0 64 bit.

Thanks for your attentions. :upside_down_face: