www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Help using lubeck on Windows

reply Arredondo <arm.plus gmail.com> writes:
Help using lubeck on Windows

I'd like to experiment with linear algebra in D, and it looks 
like lubeck is the way to do it right now. However, I'm having a 
hard time dealing with the CBLAS and LAPACK dependencies.

I downloaded the OpenBLAS binaries for Windows (libopenblas.dll), 
but I am cluless as to what to do with them. I can't find an 
example of how to link them/what commands to pass to dmd. Any 
help deeply appreciated.
Feb 23 2018
next sibling parent reply jmh530 <john.michael.hall gmail.com> writes:
On Friday, 23 February 2018 at 12:13:11 UTC, Arredondo wrote:
 Help using lubeck on Windows

 I'd like to experiment with linear algebra in D, and it looks 
 like lubeck is the way to do it right now. However, I'm having 
 a hard time dealing with the CBLAS and LAPACK dependencies.

 I downloaded the OpenBLAS binaries for Windows 
 (libopenblas.dll), but I am cluless as to what to do with them. 
 I can't find an example of how to link them/what commands to 
 pass to dmd. Any help deeply appreciated.
It is a rather frustrating experience on Windows. I've banged my head against my desk a few times trying to get it working. My suggestion is to get the Windows Subsystem for Linux set up. With Ubuntu, you can follow all of the Linux instructions and it is pretty easy. For trying to get it to work on Windows, first look at lubeck's dub.sdl, it depends on mir-blas and mir-lapack. So before you think about getting lubeck to work, you'll need to get those to work. Both of those depend on calling C libraries, you might refer to https://dlang.org/blog/2017/12/05/interfacing-d-with-c-getting-started/ mir-blas depends on the D package cblas, which has headers for blas. It uses blas/cblas as libs, so you'll need to link in a blas library to get it to work. mir-lapack depends on the D package lapack, which has headers for LAPACK. So again, I'm pretty sure you'll need to link in a lapack library to get it to work. The lapack downloads usually contain a blas, though it may not be the most optimized one. The annoying thing is that when you go to the download links for things like lapack for Windows http://icl.cs.utk.edu/lapack-for-windows/ the pre-built libraries require you to either have Visual Studio with Intel Compilers or MinGW and D's support with MinGW isn't all that great. So then what you'd need to do is use CMAKE to compile it with Visual Studio without Intel Compilers. This should work on DMD with -m32mscoff or -m64 and LDC. Also, make sure you link in the library correctly. Visual Studio's linker is different than DMD's when compiling 32bit code. I had given up and used WSL at this point rather than compile it myself with CMAKE. Less of a headache.
Feb 23 2018
parent reply Arredondo <arm.plus gmail.com> writes:
On Friday, 23 February 2018 at 16:56:13 UTC, jmh530 wrote:
 I had given up and used WSL at this point rather than compile 
 it myself with CMAKE. Less of a headache.
I don’t understand. Wouldn’t WSL produce Linux binaries? I need my project compiled as a Windows .exe, other parts of my development environment depend on that.
Feb 25 2018
parent reply jmh530 <john.michael.hall gmail.com> writes:
On Sunday, 25 February 2018 at 14:25:04 UTC, Arredondo wrote:
 On Friday, 23 February 2018 at 16:56:13 UTC, jmh530 wrote:
 I had given up and used WSL at this point rather than compile 
 it myself with CMAKE. Less of a headache.
I don’t understand. Wouldn’t WSL produce Linux binaries? I need my project compiled as a Windows .exe, other parts of my development environment depend on that.
Usually what I need is to do some calculation and print the results in the console or write them to a file, so it's fine for me. If you need an exe, then I guess WSL wouldn't be for you.
Feb 25 2018
parent reply Arredondo <arm.plus gmail.com> writes:
On Monday, 26 February 2018 at 05:15:48 UTC, jmh530 wrote:
 On Sunday, 25 February 2018 at 14:25:04 UTC, Arredondo wrote:
 On Friday, 23 February 2018 at 16:56:13 UTC, jmh530 wrote:
 I had given up and used WSL at this point rather than compile 
 it myself with CMAKE. Less of a headache.
I don’t understand. Wouldn’t WSL produce Linux binaries? I need my project compiled as a Windows .exe, other parts of my development environment depend on that.
Usually what I need is to do some calculation and print the results in the console or write them to a file, so it's fine for me. If you need an exe, then I guess WSL wouldn't be for you.
Okay, so I just finished configuring WSL. The way I want to use my app is having it read from stdin, do some calculations, and write to stdout, in an infinite cycle. I wanted to feed this to some higher level algorithms in Wolfram Mathematica, that's why I needed Windows binaries. But it turns out that I can feed the shell.exe program itself to Mathemtaica, and from there call my compiled-in-ubuntu app and do the same thing. So it looks like I could get away with using WSL after all. I am new to linux, so I could use some help, and you have clearly done this before. So far I've managed to install dmd and OpenBlas. I guess I should pass some commands to dmd so it knows where to look for the static blas and lapack libraries. Any suggestions? Thank you, Arredondo.
Feb 26 2018
parent reply jmh530 <john.michael.hall gmail.com> writes:
On Monday, 26 February 2018 at 17:12:51 UTC, Arredondo wrote:
 Okay, so I just finished configuring WSL. The way I want to use 
 my app is having it read from stdin, do some calculations, and 
 write to stdout, in an infinite cycle. I wanted to feed this to 
 some higher level algorithms in Wolfram Mathematica, that's why 
 I needed Windows binaries. But it turns out that I can feed the 
 shell.exe program itself to Mathemtaica, and from there call my 
 compiled-in-ubuntu app and do the same thing. So it looks like 
 I could get away with using WSL after all.

 I am new to linux, so I could use some help, and you have 
 clearly done this before. So far I've managed to install dmd 
 and OpenBlas. I guess I should pass some commands to dmd so it 
 knows where to look for the static blas and lapack libraries. 
 Any suggestions?

 Thank you,
 Arredondo.
I was using Ubuntu with WSL. For installing, I think I had done sudo apt update sudo apt upgrade sudo apt-get install libblas-dev liblapack-dev I think on Linux you can just put blas and lapack in the libs in your dub.json. I always just try to do some simple example first, usually just calling dmd/ldc directly. So long as I can translate it to a dub configuration that is equivalent, then I will switch over. You might look at some of the dub.jsons that are used in Lubeck and other mir projects for reference.
Feb 26 2018
parent reply Arredondo <arm.plus gmail.com> writes:
On Monday, 26 February 2018 at 17:40:05 UTC, jmh530 wrote:
 On Monday, 26 February 2018 at 17:12:51 UTC, Arredondo wrote:
 Okay, so I just finished configuring WSL. The way I want to 
 use my app is having it read from stdin, do some calculations, 
 and write to stdout, in an infinite cycle. I wanted to feed 
 this to some higher level algorithms in Wolfram Mathematica, 
 that's why I needed Windows binaries. But it turns out that I 
 can feed the shell.exe program itself to Mathemtaica, and from 
 there call my compiled-in-ubuntu app and do the same thing. So 
 it looks like I could get away with using WSL after all.

 I am new to linux, so I could use some help, and you have 
 clearly done this before. So far I've managed to install dmd 
 and OpenBlas. I guess I should pass some commands to dmd so it 
 knows where to look for the static blas and lapack libraries. 
 Any suggestions?

 Thank you,
 Arredondo.
I was using Ubuntu with WSL. For installing, I think I had done sudo apt update sudo apt upgrade sudo apt-get install libblas-dev liblapack-dev I think on Linux you can just put blas and lapack in the libs in your dub.json. I always just try to do some simple example first, usually just calling dmd/ldc directly. So long as I can translate it to a dub configuration that is equivalent, then I will switch over. You might look at some of the dub.jsons that are used in Lubeck and other mir projects for reference.
This worked. Thank you jmh530! I feel like at this moment, lubeck should be clearly marked "not Windows ready", as not everybody will have the inclination/patience to deal with incompatible object file formats or the Windows subsystem for Linux. I wonder if compiling OpenBlas from source using DMC would solve this. I also wonder if the resulting binaries would be as fast. Arredondo
Feb 26 2018
parent jmh530 <john.michael.hall gmail.com> writes:
On Monday, 26 February 2018 at 19:02:36 UTC, Arredondo wrote:
 This worked. Thank you jmh530!

 I feel like at this moment, lubeck should be clearly marked 
 "not Windows ready", as not everybody will have the 
 inclination/patience to deal with incompatible object file 
 formats or the Windows subsystem for Linux.

 I wonder if compiling OpenBlas from source using DMC would 
 solve this. I also wonder if the resulting binaries would be as 
 fast.

 Arredondo
The people who created lubeck are aware that there is scope for improvement in the documentation. If you compile OpenBlas from source with DMC, then it will not work with LDC, which would have the best performance, or DMD with 64bit binaries. To get it to work with LDC (or 64bit DMD), you'd need to compile it with Visual Studio. https://github.com/xianyi/OpenBLAS/wiki/How-to-use-OpenBLAS-in-Microsoft-Visual-Studio
Feb 26 2018
prev sibling parent reply Ilya Yaroshenko <ilyayaroshenko gmail.com> writes:
On Friday, 23 February 2018 at 12:13:11 UTC, Arredondo wrote:
 Help using lubeck on Windows

 I'd like to experiment with linear algebra in D, and it looks 
 like lubeck is the way to do it right now. However, I'm having 
 a hard time dealing with the CBLAS and LAPACK dependencies.

 I downloaded the OpenBLAS binaries for Windows 
 (libopenblas.dll), but I am cluless as to what to do with them. 
 I can't find an example of how to link them/what commands to 
 pass to dmd. Any help deeply appreciated.
openblas.net contains precompiled openblas library for Windows. It may not be optimised well for exactly your CPU but it is fast enought to start. Put the library files into your prodject and add openblas library to your project dub configuration. A .dll files are dinamic, you need also a .lib /.a to link with. OpenBLAS contains both cblas and lapack api by default. We defenetely need to add an example for Windows Best Ilya
Feb 23 2018
parent reply Arredondo <arm.plus gmail.com> writes:
On Friday, 23 February 2018 at 18:29:09 UTC, Ilya Yaroshenko 
wrote:
 openblas.net contains precompiled openblas library for Windows. 
 It may not be optimised well for exactly your CPU but it is 
 fast enought to start. Put the library files into your prodject 
 and add openblas library to your project dub configuration. A 
 .dll files are dinamic, you need also a .lib /.a to link with.

 OpenBLAS contains both cblas and lapack api by default.

 We defenetely need to add an example for Windows

 Best
 Ilya
It is not working my friend. I've been at this for nearly two full days now. All the .lib/.a files I have tried for BLAS and LAPACK just fail to link, including those from openblas.net. rdmd insists on: Error 42: Symbol Undefined _cblas_dgemm Error 42: Symbol Undefined _cblas_dger Error: linker exited with status 2 Am I missing something? Thank you.
Feb 25 2018
next sibling parent FrankLike <1150015857 qq.com> writes:
On Sunday, 25 February 2018 at 14:26:24 UTC, Arredondo wrote:
 On Friday, 23 February 2018 at 18:29:09 UTC, Ilya Yaroshenko 
 wrote:
 full days now. All the .lib/.a files I have tried for BLAS and
to do: dmd -L .\openblas.lib put the lib file in your code path.
 Error 42: Symbol Undefined _cblas_dgemm
 Error 42: Symbol Undefined _cblas_dger
 Error: linker exited with status 2
Feb 25 2018
prev sibling parent reply 9il <ilyayaroshenko gmail.com> writes:
On Sunday, 25 February 2018 at 14:26:24 UTC, Arredondo wrote:
 On Friday, 23 February 2018 at 18:29:09 UTC, Ilya Yaroshenko 
 wrote:
 openblas.net contains precompiled openblas library for 
 Windows. It may not be optimised well for exactly your CPU but 
 it is fast enought to start. Put the library files into your 
 prodject and add openblas library to your project dub 
 configuration. A .dll files are dinamic, you need also a .lib 
 /.a to link with.

 OpenBLAS contains both cblas and lapack api by default.

 We defenetely need to add an example for Windows

 Best
 Ilya
It is not working my friend. I've been at this for nearly two full days now. All the .lib/.a files I have tried for BLAS and LAPACK just fail to link, including those from openblas.net. rdmd insists on: Error 42: Symbol Undefined _cblas_dgemm Error 42: Symbol Undefined _cblas_dger Error: linker exited with status 2 Am I missing something? Thank you.
CBLAS. Lubeck uses its API. Intel MKL do have it. Just pick required libs (there multiple variants plus core and thread libs).
Jul 03 2018
parent 9il <ilyayaroshenko gmail.com> writes:
On Wednesday, 4 July 2018 at 00:23:36 UTC, 9il wrote:
 On Sunday, 25 February 2018 at 14:26:24 UTC, Arredondo wrote:
 On Friday, 23 February 2018 at 18:29:09 UTC, Ilya Yaroshenko 
 wrote:
 [...]
It is not working my friend. I've been at this for nearly two full days now. All the .lib/.a files I have tried for BLAS and LAPACK just fail to link, including those from openblas.net. rdmd insists on: Error 42: Symbol Undefined _cblas_dgemm Error 42: Symbol Undefined _cblas_dger Error: linker exited with status 2 Am I missing something? Thank you.
CBLAS. Lubeck uses its API. Intel MKL do have it. Just pick required libs (there multiple variants plus core and thread libs).
Openblas also has cblas api, but it may need explicitly included into the project. See its command line config param.
Jul 03 2018