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