Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

Ilaya Bharathi
Hi team, 

I'm looking for Instructions to install libraries for multithreading purposes on Octave 5.2.0 on the Windows 10 operating system.

After some research, I found BLAS and LAPACK libraries would help to implement multithreading. Unfortunately, I wasn't able to find the proper instructions to configure the libraries I need. 

Kindly provide me the instructions to configure the libraries. let me know if you need any other information from my side.

Best regards
Ilaya bharathi


Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

Ian McCallion
On Friday, 25 September 2020, Ilaya Bharathi <[hidden email]> wrote:
Hi team, 

I'm looking for Instructions to install libraries for multithreading purposes on Octave 5.2.0 on the Windows 10 operating system.

After some research, I found BLAS and LAPACK libraries would help to implement multithreading. Unfortunately, I wasn't able to find the proper instructions to configure the libraries I need.

The openblas library is included with your octave installation and configured for use (assuming you used the installation exe program rather than the zip file). 

This means if you have a program such as:
   a = rand(1, 1000000);
   b = a*a;

then Octave will automatically use openBLAS to do the calculations. By default openblas uses all processor threads. You can configure the number of threads using the environment variable OPENBLAS_NUM_THREADS.

Cheers Ian


Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

nrjank
Administrator
On Fri, Sep 25, 2020 at 10:59 AM Ian McCallion <[hidden email]> wrote:
On Friday, 25 September 2020, Ilaya Bharathi <[hidden email]> wrote:

The openblas library is included with your octave installation and configured for use (assuming you used the installation exe program rather than the zip file). 


I think I remember seeing a BLAS selection option the last time I ran the installer. For zip package users, the readme.html has the following statement:

"During the installation a default BLAS library was selected. The installer contains two BLAS implementations, the NetLib reference BLAS and OpenBLAS.

The choice of library may be changed after installation by copying either librefblas.dll or libopenblas.dll to the file libblas.dll in the bin folder of the Octave installation."




Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

Ilaya Bharathi
Hi Nicholas,

Thanks for your email.

Is it an openblas library which enables the multithreading is inbuilt with octave ?  

If so, please clarify which dll file(librefblas.dll or libopenblas.dll ) needs to be pasted where. If this is not the case, let me know what to do for the multithreading to work.

finally, after implementing the multithreading feature. how to check it whether it's implemented or not ? 

Many thanks 
Ilaya bharathi


On Fri, Sep 25, 2020 at 8:37 PM Nicholas Jankowski <[hidden email]> wrote:
On Fri, Sep 25, 2020 at 10:59 AM Ian McCallion <[hidden email]> wrote:
On Friday, 25 September 2020, Ilaya Bharathi <[hidden email]> wrote:

The openblas library is included with your octave installation and configured for use (assuming you used the installation exe program rather than the zip file). 


I think I remember seeing a BLAS selection option the last time I ran the installer. For zip package users, the readme.html has the following statement:

"During the installation a default BLAS library was selected. The installer contains two BLAS implementations, the NetLib reference BLAS and OpenBLAS.

The choice of library may be changed after installation by copying either librefblas.dll or libopenblas.dll to the file libblas.dll in the bin folder of the Octave installation."




Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

nrjank
Administrator
On Mon, Sep 28, 2020 at 1:46 PM Ilaya Bharathi <[hidden email]> wrote:

Is it an openblas library which enables the multithreading is inbuilt with octave ?  

I haven't done this myself, just reading the information and this thread from Ian that seems to be the case.

 
If so, please clarify which dll file(librefblas.dll or libopenblas.dll ) needs to be pasted where. If this is not the case, let me know what to do for the multithreading to work.

based on the file names, I would assume the librefblas.dll is the  NetLib reference BLAS and  libopenblas.dll is the OpenBLAS that Ian mentioned.

 
finally, after implementing the multithreading feature. how to check it whether it's implemented or not ? 

again, I would try something like what Ian mentioned:


>This means if you have a program such as:
>   a = rand(1, 1000000);
>   b = a*a;
>
>then Octave will automatically use openBLAS to do the calculations. By default openblas uses all processor threads. You can configure the number of threads using the environment >variable OPENBLAS_NUM_THREADS.



Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

Ian McCallion
On Mon, 28 Sep 2020 at 19:34, Nicholas Jankowski <[hidden email]> wrote:

>
> On Mon, Sep 28, 2020 at 1:46 PM Ilaya Bharathi <[hidden email]> wrote:
>>
>>
>> Is it an openblas library which enables the multithreading is inbuilt with octave ?
>>
> I haven't done this myself, just reading the information and this thread from Ian that seems to be the case.
>
>>
>> If so, please clarify which dll file(librefblas.dll or libopenblas.dll ) needs to be pasted where. If this is not the case, let me know what to do for the multithreading to work.
>>
> based on the file names, I would assume the librefblas.dll is the  NetLib reference BLAS and  libopenblas.dll is the OpenBLAS that Ian mentioned.

That's right, but the default is openblas, so you won't have to do any
dll copying. openblas is much faster than the reference blas.
>>
>> finally, after implementing the multithreading feature. how to check it whether it's implemented or not ?
>
> again, I would try something like what Ian mentioned:
>
> >This means if you have a program such as:
> >   a = rand(1, 1000000);
> >   b = a*a;

Yes, except of course it should be
b=a.*a:

And you should probably set
a= rand(1,100000000);
to see any significant CPU time.

> >then Octave will automatically use openBLAS to do the calculations. By default openblas uses all processor threads. You can configure the number of threads using the environment >variable OPENBLAS_NUM_THREADS.

Cheers... Ian


Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

Ilaya Bharathi
In reply to this post by Ian McCallion
Hi Ian,

Thanks for your reply. 
I use the zip file rather than the executable file for octave. Maybe I need to try the Octave exe file for the multithreading purpose as you suggested.
As far as I understand, I'm gonna proceed with the following. Kindly advise if I need to make any changes.

  • Downloading Octave 5.2.0-64 bit executable from the official GNU Octave website(https://www.gnu.org/software/octave/download.html#ms-windows) for Win 10
  • Installing the same and checking with the default OPENBLAS library.
  • Assigning the value for the environment variable  OPENBLAS_NUM_THREADS = "the number of processors we need to utilize"
Thanks for your time and for the information provided.
Have a great day.

best regards
Ilaya bharathi


On Fri, Sep 25, 2020 at 8:29 PM Ian McCallion <[hidden email]> wrote:
On Friday, 25 September 2020, Ilaya Bharathi <[hidden email]> wrote:
Hi team, 

I'm looking for Instructions to install libraries for multithreading purposes on Octave 5.2.0 on the Windows 10 operating system.

After some research, I found BLAS and LAPACK libraries would help to implement multithreading. Unfortunately, I wasn't able to find the proper instructions to configure the libraries I need.

The openblas library is included with your octave installation and configured for use (assuming you used the installation exe program rather than the zip file). 

This means if you have a program such as:
   a = rand(1, 1000000);
   b = a*a;

then Octave will automatically use openBLAS to do the calculations. By default openblas uses all processor threads. You can configure the number of threads using the environment variable OPENBLAS_NUM_THREADS.

Cheers Ian


Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

nrjank
Administrator
On Tue, Sep 29, 2020, 7:30 AM Ilaya Bharathi <[hidden email]> wrote:
Hi Ian,

Thanks for your reply. 
I use the zip file rather than the executable file for octave. Maybe I need to try the Octave exe file for the multithreading purpose as you suggested.

I use the zip package as we'll. As far as i understand it, the same procedure should work with either exe or zip installer.



Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

Ian McCallion
In reply to this post by Ilaya Bharathi


On Tuesday, 29 September 2020, Ilaya Bharathi <[hidden email]> wrote:
Hi Ian,

Thanks for your reply. 
I use the zip file rather than the executable file for octave. Maybe I need to try the Octave exe file for the multithreading purpose as you suggested.
As far as I understand, I'm gonna proceed with the following. Kindly advise if I need to make any changes.

  • Downloading Octave 5.2.0-64 bit executable from the official GNU Octave website(https://www.gnu.org/software/octave/download.html#ms-windows) for Win 10
  • Installing the same and checking with the default OPENBLAS library.
  • Assigning the value for the environment variable  OPENBLAS_NUM_THREADS = "the number of processors we need to utilize"

The second step is not necessary. Otherwise yes.

Ian


Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

nrjank
Administrator
  • Downloading Octave 5.2.0-64 bit executable from the official GNU Octave website(https://www.gnu.org/software/octave/download.html#ms-windows) for Win 10
  • Installing the same and checking with the default OPENBLAS library.
  • Assigning the value for the environment variable  OPENBLAS_NUM_THREADS = "the number of processors we need to utilize"

The second step is not necessary. Otherwise yes.

Ian

 Do you mean the installing or assigning step?  In my default config zip install, OPENBLAS_NUM_THREADS was empty.  I set it to different values from 1-4 since I have a 4 core machine, and didn't notice any real difference running that test routine you posted.  i extended the 1e8 to 2e8 and 1e9 to get meaningful runtimes, but there seemed to be no difference changing the value of that option.  in all cases multiple cores were taxed on execution.  It's a managed machine so I don't have Process Explorer to actually verify the thread count, so maybe other things are happening that I'm not noticing.


Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

Ilaya Bharathi
Hi Nicholas,

Do you have the variable OPENBLAS_NUM_THREADS by default with the zip installation?
Also, are there any codes to test the implementation?

Many thanks 
Ilaya bharathi


On Tue, Sep 29, 2020 at 7:30 PM Nicholas Jankowski <[hidden email]> wrote:
  • Downloading Octave 5.2.0-64 bit executable from the official GNU Octave website(https://www.gnu.org/software/octave/download.html#ms-windows) for Win 10
  • Installing the same and checking with the default OPENBLAS library.
  • Assigning the value for the environment variable  OPENBLAS_NUM_THREADS = "the number of processors we need to utilize"

The second step is not necessary. Otherwise yes.

Ian

 Do you mean the installing or assigning step?  In my default config zip install, OPENBLAS_NUM_THREADS was empty.  I set it to different values from 1-4 since I have a 4 core machine, and didn't notice any real difference running that test routine you posted.  i extended the 1e8 to 2e8 and 1e9 to get meaningful runtimes, but there seemed to be no difference changing the value of that option.  in all cases multiple cores were taxed on execution.  It's a managed machine so I don't have Process Explorer to actually verify the thread count, so maybe other things are happening that I'm not noticing.


Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

nrjank
Administrator
On Tue, Sep 29, 2020 at 11:38 AM Ilaya Bharathi <[hidden email]> wrote:
Hi Nicholas,

Do you have the variable OPENBLAS_NUM_THREADS by default with the zip installation?
Also, are there any codes to test the implementation?


for the latter, I do not know. not my area of expertise.

in a default configuration, getenv("OPENBLAS_NUM_THREADS") returns empty, so it appears the variable is not set.  i do not know if this is expected. 
 


Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

Dmitri A. Sergatskov


On Tue, Sep 29, 2020 at 11:42 AM Nicholas Jankowski <[hidden email]> wrote:
On Tue, Sep 29, 2020 at 11:38 AM Ilaya Bharathi <[hidden email]> wrote:
Hi Nicholas,

Do you have the variable OPENBLAS_NUM_THREADS by default with the zip installation?
Also, are there any codes to test the implementation?


for the latter, I do not know. not my area of expertise.

in a default configuration, getenv("OPENBLAS_NUM_THREADS") returns empty, so it appears the variable is not set.  i do not know if this is expected. 
 


Openblas can be compiled as single-threaded library, or a multithreaded library with either pthread or omp interface.
A long time ago somebody told me that I should use omp interface in a multithreaded program (like octave).
With OMP interface you need to use OMP_NUM_THREADS variable, OPENBLAS_NUM_THREADS is ignored.
I also noticed that at least on linux you need to setup this variable before starting octave; setting it from withing octave
does not work. Here is some benchmarks on i7-2600K (Fedora linux):

[dima@i7 gcc_def]$ OMP_NUM_THREADS=1 LD_PRELOAD=/usr/lib64/libopenblaso.so ./run-octave -q -f
octave:1> a=randn(4000); tic; inv(a)*a; toc
Elapsed time is 10.6499 seconds.
octave:2>
[dima@i7 gcc_def]$ OMP_NUM_THREADS=2 LD_PRELOAD=/usr/lib64/libopenblaso.so ./run-octave -q -f
octave:1> a=randn(4000); tic; inv(a)*a; toc
Elapsed time is 5.75883 seconds.
octave:2>
[dima@i7 gcc_def]$ OMP_NUM_THREADS=4 LD_PRELOAD=/usr/lib64/libopenblaso.so ./run-octave -q -f
octave:1> a=randn(4000); tic; inv(a)*a; toc
Elapsed time is 3.8937 seconds.
octave:2>
[dima@i7 gcc_def]$ OMP_NUM_THREADS=6 LD_PRELOAD=/usr/lib64/libopenblaso.so ./run-octave -q -f
octave:1> a=randn(4000); tic; inv(a)*a; toc
Elapsed time is 4.884 seconds.
octave:2>
[dima@i7 gcc_def]$ OMP_NUM_THREADS=8 LD_PRELOAD=/usr/lib64/libopenblaso.so ./run-octave -q -f
octave:1> a=randn(4000); tic; inv(a)*a; toc
Elapsed time is 6.45016 seconds.
octave:2>
[dima@i7 gcc_def]$ LD_PRELOAD=/usr/lib64/libopenblaso.so ./run-octave -q -f
octave:1> a=randn(4000); tic; inv(a)*a; toc
Elapsed time is 7.12494 seconds.
octave:2> a=randn(4000); tic; inv(a)*a; toc
Elapsed time is 7.05646 seconds.

I could not figure out how openblas is compiled for the win version of octave, it could be that it is just a single-threaded library.

Sincerely,
Dmitri.
--

 


Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

mmuetzel
Am 29. September 2020 um 18:33 Uhr schrieb "Dmitri A. Sergatskov":
> I could not figure out how openblas is compiled for the win version of octave, it could be that it is just a single-threaded library.

OpenBLAS is build by MXE Octave with "USE_THREAD=1". I guess that means that it is multi-threaded.

Markus



Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

Ian McCallion
In reply to this post by nrjank


On Tuesday, 29 September 2020, Nicholas Jankowski <[hidden email]> wrote:
  • Downloading Octave 5.2.0-64 bit executable from the official GNU Octave website(https://www.gnu.org/software/octave/download.html#ms-windows) for Win 10
  • Installing the same and checking with the default OPENBLAS library.
  • Assigning the value for the environment variable  OPENBLAS_NUM_THREADS = "the number of processors we need to utilize"

The second step is not necessary. Otherwise yes.

Ian

 Do you mean the installing or assigning step?  

My apologies. I was away from my desk any failed to give the question my full attention.

Install ( of course), but the default installation does result in libopenblas.dll being copied to libblass.dll so that "checking with the default OPENBLAS library" is not necessary.

In my default config zip install, OPENBLAS_NUM_THREADS was empty.  I set it to different values from 1-4 since I have a 4 core machine, and didn't notice any real difference running that test routine you posted.  i extended the 1e8 to 2e8 and 1e9 to get meaningful runtimes, but there seemed to be no difference changing the value of that option.  in all cases multiple cores were taxed on execution.  It's a managed machine so I don't have Process Explorer to actually verify the thread count, so maybe other things are happening that I'm not noticing.

I have the same result. I have task manager and whatever the value of  OPENBLAS_NUM_THREADS the execution time is the same and the cpu utilisation peaks at the same level so it would appear the environment variable is being ignored. I will investigate further as my system uses this, succesfully I believe!

Cheers Ian



 


Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

nrjank
Administrator
On Tue, Sep 29, 2020 at 12:54 PM Ian McCallion <[hidden email]> wrote:
  • I have the same result. I have task manager and whatever the value of  OPENBLAS_NUM_THREADS the execution time is the same and the cpu utilisation peaks at the same level so it would appear the environment variable is being ignored. I will investigate further as my system uses this, succesfully I believe!

 
seems Process Explorer is the windows tool of choice to verify if there is actually any difference, since of course windows doesn't come with that basic ability out of the box.
https://superuser.com/questions/462969/how-can-i-view-the-active-threads-of-a-running-program


Reply | Threaded
Open this post in threaded view
|

Re: Instructions for Installing BLAS and LAPACK library on Octave 5.2.0

Ian McCallion
In reply to this post by Ian McCallion
On Tue, 29 Sep 2020 at 17:54, Ian McCallion <[hidden email]> wrote:

>
>
>
> On Tuesday, 29 September 2020, Nicholas Jankowski <[hidden email]> wrote:
>>>>
>>>> Downloading Octave 5.2.0-64 bit executable from the official GNU Octave website(https://www.gnu.org/software/octave/download.html#ms-windows) for Win 10
>>>> Installing the same and checking with the default OPENBLAS library.
>>>> Assigning the value for the environment variable  OPENBLAS_NUM_THREADS = "the number of processors we need to utilize"
>>>
>>>
>>> The second step is not necessary. Otherwise yes.
>>>
>>> Ian
>>
>>
>>  Do you mean the installing or assigning step?
>>
> My apologies. I was away from my desk any failed to give the question my full attention.
>
> Install ( of course), but the default installation does result in libopenblas.dll being copied to libblass.dll so that "checking with the default OPENBLAS library" is not necessary.
>
>> In my default config zip install, OPENBLAS_NUM_THREADS was empty.  I set it to different values from 1-4 since I have a 4 core machine, and didn't notice any real difference running that test routine you posted.  i extended the 1e8 to 2e8 and 1e9 to get meaningful runtimes, but there seemed to be no difference changing the value of that option.  in all cases multiple cores were taxed on execution.  It's a managed machine so I don't have Process Explorer to actually verify the thread count, so maybe other things are happening that I'm not noticing.
>
>
> I have the same result. I have task manager and whatever the value of  OPENBLAS_NUM_THREADS the execution time is the same and the cpu utilisation peaks at the same level so it would appear the environment variable is being ignored. I will investigate further as my system uses this, succesfully I believe!

Progress. It all comes flooding back to me now! You must set
OPENBLAS_NUM_THREADS before launching Octave, which is of course a
real pain and cannot surely be justified as you might actually want to
change the number of threads used. I Imagine the DLL is loaded at
Octave startup and the value of OPENBLAS_NUM_THREADS is read at that
time.

If you don't set OPENBLAS_NUM_THREADS the default is to use enough
threads to consume most the CPU fully, and on my system I get

  >> tic; a=rand(10000); b=a*a;toc
  Elapsed time is 13.0891 seconds.

setting OPENBLAS_NUM_THREADS=1 and then calling Octave:
   >> tic; a=rand(10000); b=a*a;toc
   Elapsed time is 42.447 seconds.

One way to set OPENBLAS_NUM_THREADS which avoid leaving the Octave
environment is:

  >> setenv('OPENBLAS_NUM_THREADS','1')
  >> system C:/Octave/Octave-5.2.0/octave.vbs

This launches a second copy of Octave with the first as parent hence
inheriting the environment variables.

Cheers... Ian