BLAS, LAPACK和ATLAS之间的关系是什么

时间:2020-12-09 04:08:40

I don't understand how BLAS, LAPACK and ATLAS are related and how I should use them together! I have been looking through all of their manuals and I have a general idea of BLAS and LAPACK and how to use them with the very few examples I find, but I can't find any actual examples using ATLAS to see how it is related with these two.

我不明白BLAS, LAPACK和ATLAS是怎么联系在一起的,我应该如何一起使用它们!我查阅了他们所有的手册,我对BLAS和LAPACK有一个大致的概念,以及如何在我找到的少数例子中使用它们,但是我找不到任何使用ATLAS的实际示例来了解它们与这两个例子之间的关系。

I am trying to do some low level work on matrixes and my primary language is C. First I wanted to use GSL, but it says that if you want the best preformance you should use BLAS and ATLAS. Is there any good webpage giving some nice examples of how to use these (in C) all together? In other words I am looking for a tutorial on using these three (or any subset of them!). In short I am confused!

我正在做一些关于矩阵的低级工作,我的主要语言是c。首先我想使用GSL,但是它说如果你想要最好的性能,你应该使用BLAS和ATLAS。是否有好的网页提供了如何使用这些(在C中)的好例子?换句话说,我正在寻找使用这三种方法的教程(或者它们的任何子集!)总之,我很困惑!

4 个解决方案

#1


115  

BLAS is a collection of low-level matrix and vector arithmetic operations (“multiply a vector by a scalar”, “multiply two matrices and add to a third matrix”, etc ...).

BLAS是一个低级矩阵和向量算术运算的集合(“将一个向量乘以一个标量”、“将两个矩阵相乘并将其相加”等等)。

LAPACK is a collection of higher-level linear algebra operations. Things like matrix factorizations (LU, LLt, QR, SVD, Schur, etc) that are used to do things like “find the eigenvalues of a matrix”, or “find the singular values of a matrix”, or “solve a linear system”. LAPACK is built on top of the BLAS; many users of LAPACK only use the LAPACK interfaces and never need to be aware of the BLAS at all. LAPACK is generally compiled separately from the BLAS, and can use whatever highly-optimized BLAS implementation you have available.

LAPACK是高级线性代数运算的集合。像矩阵分解(LU, LLt, QR, SVD, Schur,等等)这些被用来做诸如“找到一个矩阵的特征值”,“找到一个矩阵的奇异值”,或者“解一个线性系统”。LAPACK位于BLAS的顶部;许多LAPACK用户只使用LAPACK接口,根本不需要知道BLAS。LAPACK通常与BLAS分开编译,并且可以使用任何高度优化的BLAS实现。

ATLAS is a portable reasonably good implementation of the BLAS interfaces, that also implements a few of the most commonly used LAPACK operations.

ATLAS是一个相当好的BLAS接口的可移植实现,它还实现了一些最常用的LAPACK操作。

What “you should use” depends somewhat on details of what you’re trying to do and what platform you’re using. You won't go too far wrong with “use ATLAS + LAPACK”, however.

“您应该使用什么”在某种程度上取决于您正在尝试做什么以及您正在使用的平台的细节。不过,“使用ATLAS + LAPACK”不会有太大的错误。

#2


25  

While ago, when I started doing some linear algebra in C, it came to me as a surprise to see there are so few tutorials for BLAS, LAPACK and other fundamental APIs, despite the fact that they are somehow the cornerstones of many other libraries. For that reason I started collecting all the examples/tutorials I could find all over the internet for BLAS, CBLAS, LAPACK, CLAPACK, LAPACKE, ATLAS, OpenBLAS ... in this Github repo.

当我开始在C中做一些线性代数时,我惊讶地发现,BLAS、LAPACK和其他基础api的教程太少了,尽管它们是许多其他库的基石。由于这个原因,我开始收集所有的例子/教程,我可以在网上找到的BLAS, CBLAS, LAPACK, CLAPACK, LAPACKE, ATLAS, OpenBLAS…Github回购。

Well, I should warn you that as a mechanical engineer I have little experience in managing such a repo or github. It will first seem as a complete mess to you guys. However if you manage to get over the messy structure you will find all kind of examples and instructions which might be a help. I have tried the most to be sure they compile and the ones which do not compile I have mentioned. I have modified many of them to be compilable with GNU compilers (gcc, g++ and gfortran). I have made MakeFiles which you can read to learn how you can call individual Fortran/FORTRAN routines in a C or C++ program. I have also put some installations instructions for mac and linux (sorry windows guys!). I have also made some bash .sh files for automatic compilation of some of these libraries.

好吧,我得提醒你,作为一名机械工程师,我在管理这样一个repo或github方面几乎没有经验。这首先会让你们觉得一团糟。然而,如果你设法克服混乱的结构,你会找到各种各样的例子和说明,这可能是一个帮助。我已经尽力确保它们是编译的,以及我提到的那些不编译的。我已经修改了其中许多代码,使它们可以使用GNU编译器(gcc、g++和gfortran)进行编译。我已经制作了makefile,您可以阅读它以了解如何在C或c++程序中调用单个Fortran/ Fortran例程。我还为mac和linux安装了一些说明(不好意思是windows的家伙们!)我还制作了一些bash .sh文件,用于自动编译这些库中的一些。

But going to your other question: BLAS and LAPACK are rather APIs not specific SDKs. They are just a list of specifications or language extensions rather than an implementations or libraries. With that said, there are original implementations by Netlib in FORTRAN 77, which most people refer to (confusingly!) when talking about BLAS and LAPACK. So if you see a lot of strange things when using these APIs is because you were actually calling FORTRAN routines in C rather than C libraries and functions. ATLAS and OpenBLAS are some of the best implementations of BLAS and LACPACK as far as I know. They conform to the original API, even though, to my knowledge they are implemented on C/C++ from scratch (not sure!). There are GPGPU implementations of the APIs suing OpenCL: CLBlast, clBLAS, clMAGMA and ViennaCL to mention some. There are also vendor specific implementations optimized for specific hardware or platform, which I strongly discourage anybody to use them.

但是回到你的另一个问题:BLAS和LAPACK更像是api而不是特定的SDKs。它们只是一个规范或语言扩展的列表,而不是一个实现或库。话虽如此,在FORTRAN 77中有Netlib的原始实现,这是大多数人在讨论BLAS和LAPACK时提到的(令人困惑的是!)如果你在使用这些api时看到很多奇怪的事情是因为你实际上是在C中调用FORTRAN例程而不是C库和函数。就我所知,ATLAS和OpenBLAS是BLAS和LACPACK的一些最佳实现。它们符合原始的API,尽管,据我所知,它们是用C/ c++来实现的(不确定!)使用OpenCL的api有GPGPU实现:CLBlast、clBLAS、cl岩浆和vienna。也有针对特定硬件或平台优化的特定供应商实现,我强烈反对任何人使用它们。

My recommendation to anyone who wants to learn using BLAS and LAPACK in C is to learn FORTRAN-C mixed programming first. The first chapter of the mentioned repo is dedicated to this matter and there I have collected many different examples.

对于任何想在C中学习使用BLAS和LAPACK的人,我的建议是首先学习FORTRAN-C混合编程。上面提到的repo的第一章专门讨论这个问题,我在那里收集了许多不同的例子。

#3


8  

I looked around and could only find these two webpages with some simple examples. I wish more people would add examples of codes to use these libraries.

我环顾四周,只能找到这两个网页,上面有一些简单的例子。我希望更多的人能添加代码示例来使用这些库。

http://www.seehuhn.de/pages/linear

http://www.seehuhn.de/pages/linear

http://www.lindonslog.com/programming/atlas-blas-lapack-linear-algebra-libraries/

http://www.lindonslog.com/programming/atlas-blas-lapack-linear-algebra-libraries/

#4


0  

As far as I'm aware, and after working through the ATLAS repository, it seems that it includes a re-implementation of BLAS in C. There's bit more to it than that but I hope it answers the question.

据我所知,在研究了ATLAS存储库之后,似乎它在c中包含了对BLAS的重新实现。

#1


115  

BLAS is a collection of low-level matrix and vector arithmetic operations (“multiply a vector by a scalar”, “multiply two matrices and add to a third matrix”, etc ...).

BLAS是一个低级矩阵和向量算术运算的集合(“将一个向量乘以一个标量”、“将两个矩阵相乘并将其相加”等等)。

LAPACK is a collection of higher-level linear algebra operations. Things like matrix factorizations (LU, LLt, QR, SVD, Schur, etc) that are used to do things like “find the eigenvalues of a matrix”, or “find the singular values of a matrix”, or “solve a linear system”. LAPACK is built on top of the BLAS; many users of LAPACK only use the LAPACK interfaces and never need to be aware of the BLAS at all. LAPACK is generally compiled separately from the BLAS, and can use whatever highly-optimized BLAS implementation you have available.

LAPACK是高级线性代数运算的集合。像矩阵分解(LU, LLt, QR, SVD, Schur,等等)这些被用来做诸如“找到一个矩阵的特征值”,“找到一个矩阵的奇异值”,或者“解一个线性系统”。LAPACK位于BLAS的顶部;许多LAPACK用户只使用LAPACK接口,根本不需要知道BLAS。LAPACK通常与BLAS分开编译,并且可以使用任何高度优化的BLAS实现。

ATLAS is a portable reasonably good implementation of the BLAS interfaces, that also implements a few of the most commonly used LAPACK operations.

ATLAS是一个相当好的BLAS接口的可移植实现,它还实现了一些最常用的LAPACK操作。

What “you should use” depends somewhat on details of what you’re trying to do and what platform you’re using. You won't go too far wrong with “use ATLAS + LAPACK”, however.

“您应该使用什么”在某种程度上取决于您正在尝试做什么以及您正在使用的平台的细节。不过,“使用ATLAS + LAPACK”不会有太大的错误。

#2


25  

While ago, when I started doing some linear algebra in C, it came to me as a surprise to see there are so few tutorials for BLAS, LAPACK and other fundamental APIs, despite the fact that they are somehow the cornerstones of many other libraries. For that reason I started collecting all the examples/tutorials I could find all over the internet for BLAS, CBLAS, LAPACK, CLAPACK, LAPACKE, ATLAS, OpenBLAS ... in this Github repo.

当我开始在C中做一些线性代数时,我惊讶地发现,BLAS、LAPACK和其他基础api的教程太少了,尽管它们是许多其他库的基石。由于这个原因,我开始收集所有的例子/教程,我可以在网上找到的BLAS, CBLAS, LAPACK, CLAPACK, LAPACKE, ATLAS, OpenBLAS…Github回购。

Well, I should warn you that as a mechanical engineer I have little experience in managing such a repo or github. It will first seem as a complete mess to you guys. However if you manage to get over the messy structure you will find all kind of examples and instructions which might be a help. I have tried the most to be sure they compile and the ones which do not compile I have mentioned. I have modified many of them to be compilable with GNU compilers (gcc, g++ and gfortran). I have made MakeFiles which you can read to learn how you can call individual Fortran/FORTRAN routines in a C or C++ program. I have also put some installations instructions for mac and linux (sorry windows guys!). I have also made some bash .sh files for automatic compilation of some of these libraries.

好吧,我得提醒你,作为一名机械工程师,我在管理这样一个repo或github方面几乎没有经验。这首先会让你们觉得一团糟。然而,如果你设法克服混乱的结构,你会找到各种各样的例子和说明,这可能是一个帮助。我已经尽力确保它们是编译的,以及我提到的那些不编译的。我已经修改了其中许多代码,使它们可以使用GNU编译器(gcc、g++和gfortran)进行编译。我已经制作了makefile,您可以阅读它以了解如何在C或c++程序中调用单个Fortran/ Fortran例程。我还为mac和linux安装了一些说明(不好意思是windows的家伙们!)我还制作了一些bash .sh文件,用于自动编译这些库中的一些。

But going to your other question: BLAS and LAPACK are rather APIs not specific SDKs. They are just a list of specifications or language extensions rather than an implementations or libraries. With that said, there are original implementations by Netlib in FORTRAN 77, which most people refer to (confusingly!) when talking about BLAS and LAPACK. So if you see a lot of strange things when using these APIs is because you were actually calling FORTRAN routines in C rather than C libraries and functions. ATLAS and OpenBLAS are some of the best implementations of BLAS and LACPACK as far as I know. They conform to the original API, even though, to my knowledge they are implemented on C/C++ from scratch (not sure!). There are GPGPU implementations of the APIs suing OpenCL: CLBlast, clBLAS, clMAGMA and ViennaCL to mention some. There are also vendor specific implementations optimized for specific hardware or platform, which I strongly discourage anybody to use them.

但是回到你的另一个问题:BLAS和LAPACK更像是api而不是特定的SDKs。它们只是一个规范或语言扩展的列表,而不是一个实现或库。话虽如此,在FORTRAN 77中有Netlib的原始实现,这是大多数人在讨论BLAS和LAPACK时提到的(令人困惑的是!)如果你在使用这些api时看到很多奇怪的事情是因为你实际上是在C中调用FORTRAN例程而不是C库和函数。就我所知,ATLAS和OpenBLAS是BLAS和LACPACK的一些最佳实现。它们符合原始的API,尽管,据我所知,它们是用C/ c++来实现的(不确定!)使用OpenCL的api有GPGPU实现:CLBlast、clBLAS、cl岩浆和vienna。也有针对特定硬件或平台优化的特定供应商实现,我强烈反对任何人使用它们。

My recommendation to anyone who wants to learn using BLAS and LAPACK in C is to learn FORTRAN-C mixed programming first. The first chapter of the mentioned repo is dedicated to this matter and there I have collected many different examples.

对于任何想在C中学习使用BLAS和LAPACK的人,我的建议是首先学习FORTRAN-C混合编程。上面提到的repo的第一章专门讨论这个问题,我在那里收集了许多不同的例子。

#3


8  

I looked around and could only find these two webpages with some simple examples. I wish more people would add examples of codes to use these libraries.

我环顾四周,只能找到这两个网页,上面有一些简单的例子。我希望更多的人能添加代码示例来使用这些库。

http://www.seehuhn.de/pages/linear

http://www.seehuhn.de/pages/linear

http://www.lindonslog.com/programming/atlas-blas-lapack-linear-algebra-libraries/

http://www.lindonslog.com/programming/atlas-blas-lapack-linear-algebra-libraries/

#4


0  

As far as I'm aware, and after working through the ATLAS repository, it seems that it includes a re-implementation of BLAS in C. There's bit more to it than that but I hope it answers the question.

据我所知,在研究了ATLAS存储库之后,似乎它在c中包含了对BLAS的重新实现。