473,624 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BLAS vs CBLAS in C++

hello --

i'm working on a C++ code that uses dgemm in a simple way, but i want
ports of my code to different machines to be easy.

further, i want to make compiling of my code easy for new users -- i
don't want them to compile more libraries than absolutely necessary
(compiling ATLAS or GotoBLAS is necessary).

i already have my code working with both BLAS and CBLAS interfaces,
but I have some questions.
1) can i expect cblas to be available on pretty much any machine i
want to use? because ATLAS packages CBLAS, it didn't occur to me that
CBLAS might be standard until now.

2) to use blas, I had to switch from using new [] to malloc, and
delete [] to free. why? once allocated, i didn't realize there was a
difference.
is it not possible to use new [] allocated arrays with fortran
libraries?

3) once your code can is programmed to use either, is linking directly
to BLAS preferable in any way to using CBLAS?

thanks!

amos.

Sep 3 '07 #1
6 11469
On 2007-09-04 01:12, ni*******@gmail .com wrote:
hello --

i'm working on a C++ code that uses dgemm in a simple way, but i want
ports of my code to different machines to be easy.

further, i want to make compiling of my code easy for new users -- i
don't want them to compile more libraries than absolutely necessary
(compiling ATLAS or GotoBLAS is necessary).

i already have my code working with both BLAS and CBLAS interfaces,
but I have some questions.
You might also be interested in uBlas from Boost, which would remove the
dependency on external libraries (do not know how the compare
performance wise). There is also Lapack++ which provide both BLAS and
LAPACK, once again, I make no guarantees of performance.
1) can i expect cblas to be available on pretty much any machine i
want to use? because ATLAS packages CBLAS, it didn't occur to me that
CBLAS might be standard until now.
I don't have it on any of my computers, however you might be able to
assume that those computers where your program will run will have it, or
perhaps you cannot.
2) to use blas, I had to switch from using new [] to malloc, and
delete [] to free. why? once allocated, i didn't realize there was a
difference.
is it not possible to use new [] allocated arrays with fortran
libraries?
There should not be any problem as long as BLAS does not try to free or
reallocate memory (memory allocated with new[] must be freed with
delete[], using free() will not work). Are you sure it does not work?
3) once your code can is programmed to use either, is linking directly
to BLAS preferable in any way to using CBLAS?
I seem to recall that CBLAS is BLAS converted to C, and I seem to recall
that there are certain features (or lack thereof) in Fortran that allows
for better optimisations in Fortran than C. So it probably depends on
how good your Fortran compiler is compared to your C compiler.

--
Erik Wikström
Sep 4 '07 #2
On Tue, 04 Sep 2007 11:15:59 +0000, Erik Wikström wrote:
On 2007-09-04 01:12, ni*******@gmail .com wrote:
>hello --

i'm working on a C++ code that uses dgemm in a simple way, but i want
ports of my code to different machines to be easy.
[...]
>3) once your code can is programmed to use either, is linking directly
to BLAS preferable in any way to using CBLAS?

I seem to recall that CBLAS is BLAS converted to C,
I think, rather, it's just a set of C wrappers for the (Fortran) BLAS
functions, so you should not see any performance difference at all.

[...]

--
Lionel B
Sep 4 '07 #3
i would expect that for large enough matrices, there would be no
performance difference between BLAS and CBLAS since the overhead of
calling libraries would be amortized.

however, if CBLAS is not available and my code relies on it, then a
user might be stuck having to compile it. and that is more work than i
want them to have to do.

basically, i put in the effort to program direct BLAS links, and I'm
trying to find excuses to convince myself that i didn't waste my
effort! :-)

amos.
On Sep 4, 5:25 am, Lionel B <m...@privacy.n etwrote:
On Tue, 04 Sep 2007 11:15:59 +0000, Erik Wikström wrote:
On 2007-09-04 01:12, nitroa...@gmail .com wrote:
hello --
i'm working on a C++ code that uses dgemm in a simple way, but i want
ports of my code to different machines to be easy.

[...]
3) once your code can is programmed to use either, is linking directly
to BLAS preferable in any way to using CBLAS?
I seem to recall that CBLAS is BLAS converted to C,

I think, rather, it's just a set of C wrappers for the (Fortran) BLAS
functions, so you should not see any performance difference at all.

[...]

--
Lionel B

Sep 4 '07 #4
>
There should not be any problem as long as BLAS does not try to free or
reallocate memory (memory allocated with new[] must be freed with
delete[], using free() will not work). Are you sure it does not work?
I've gone back to investigate this issue, and the problem has
disappeared. I can use either memory allocation/deallocation method
with no problem.

Sep 4 '07 #5
Hi,
i'm working on a C++ code that uses dgemm in a simple way, but i want
ports of my code to different machines to be easy.

further, i want to make compiling of my code easy for new users -- i
don't want them to compile more libraries than absolutely necessary
(compiling ATLAS or GotoBLAS is necessary).
I am currently also using BLAS and LAPACK in a c++ code, and I generally
want the same features like you. Being easily portable, disregarding of
the BLAS LAPACK library the person uses (original netlib BLAS and
LAPACK, GotoBLAS, Intel MKL, AMD CML, ...)

If you take a look at most of these libraries, they all contain the
FORTRAN versions with/without a c wrapper. CLAPACK and CBLAS on the
other hand, are fully f2c versions of the original FORTRAN code and need
F2Clibs to work.

This means that if you take a look at the symbols whit for example the
gnutool nm or objdump, you will notice that all the same symbols
(representing the functions) are there. For BLAS this means srotg_,
drotg_ scopy_, dcopy_, ... (notice the underscore at the end).

For this reason, I strongly suggest to use these symbols to call the
functions, and this according the rules of engagement when it comes to
calling FORTRAN from C(++). This makes sure that you don't have to
implement any different BLAS wrappers like there exist several and are
also included in the Intel and AMD versions.
2) to use BLAS, I had to switch from using new [] to malloc, and
delete [] to free. why? once allocated, i didn't realize there was a
difference.
is it not possible to use new [] allocated arrays with FORTRAN
libraries?
I had the same problem when I used the CBLAS version, and this is mainly
because you can not mix new, delete with malloc, free. When linking
CBLAS you also need to link the libF77.a and libI77.a from the F2CLIBS.
If you check out this code, you see they make use of the free and
malloc command there, and hence all new and delete operations will
conflict with this. You see this clearly with valgrind.
3) once your code can is programmed to use either, is linking directly
to BLAS preferable in any way to using CBLAS?
Hence as I stated above, I suggest linking to FORTRAN versions and not
C-wrapped or F2C versions of BLAS (i.e. CBLAS). A FORTRAN version is
more frequent available then a C converted version.

I hope this helped.

Regards
Klaas
Sep 5 '07 #6
yes, your discussion answered my questions.

i won't delete my CBLAS calls, but they'll be commented out.

thanks!
amos.

Sep 6 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2573
by: drife | last post by:
Hello, I need to calculate the eigenvectors and eigenvalues for a 3600 X 3600 covariance matrix. The LinearAlgebra package in Python is incredibly slow to perform the above calculations (about 1.5 hours). This in spite of the fact that I have installed Numeric with the full ATLAS and LAPACK libraries. Also note that my computer has dual Pentium IV (3.1 GHz) processors
1
1533
by: Edward C. Jones | last post by:
I have a PC with Debian sid installed. I install all my Python stuff in /usr/local. I just installed numarray 1.3.1. Blaslite and lapacklite were compiled. Did the installation process search for blas and lapack?
5
2327
by: querypk | last post by:
Did anyone try to install Scipy package on python2.4 linux version. I see only python2.3 version of scipy released. When I try to install I get an dependency warning saying scipy cannot find python2.3. Can someone point me to python2.4 version of scipy and help me install.
5
4011
by: NM | last post by:
Hi all I am trying to link C++ and Fortran.I am not very familiar with Fortran. I have been successful in linking C++ and fortran using g++ and ifc for simple program. So adding _ to at the end of fortran subroutine names when calling from C++ is working. Now I want to move to bigger program. I have a rather big Fortran code which compiles and links fine under ifc. Now I changed the program main in Fortran into a subroutine main_sub so...
1
3239
by: pervinder | last post by:
Hi, I am building a c++ executable which uses fortan math libs. blas, lapack etc. But when i build this on HP-UX, i get below linker errors while it build without anyissues on Sun and Linux platforms. dgetrs_ (first referenced in .../../output/HPUX_32/lib/acc352/dbg/libmtx.a(denseMatrix.o)) (code) dsytrs_ (first referenced in
13
5851
by: Havatcha | last post by:
Does anyone know of a decent (free/easy to use) C++ library for manipulating matrices and caculating eigenvalues, eigenvectors and so on? I intend to add some Principal Component Analysis functionality to some software. Any recommendations appreciated.
0
620
by: Darren L. Weber | last post by:
The following is a first attempt to almost create a shell script for installation of ATLAS and LAPACK. It does not work right now and it is specific to a particular platform. It is posted here to archive it and throw into the public domain, maybe others will find it useful. It is at least a documentation of some relevant notes on the procedure. Corrections and updates would be really appreciated. Alternatives to automate this process...
1
3447
by: Ken Dere | last post by:
I am trying to install numpy-0.9.8 prior to installing scipy (0.4.9) on a machine running Suse 10.0 with Python 2.4 I am able to get numpy installed to the point when I import it I can do the following: numpy.show_config() atlas_threads_info: NOT AVAILABLE
2
2993
by: aberte | last post by:
Hi, i'm learning how to use lapack library (in particular, Intel MKL). I wish to know how I have to format the my inputs. I'm calling lapack functions from c++ (zhetri, zhemm, zgemm, zhseqr, ztrevc). I declare the 3x3 matrix (in c++) in this way: complex MyMatrix; I intend MyMatrix, MyMatrix, MyMatrix
0
8238
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7164
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.