|
Ublas : |
Subject: Re: [ublas] Bindings: second C linkage of overloaded function 'cbdsqr_'
From: George Slavov (gpslavov_at_[hidden])
Date: 2011-04-12 20:33:52
On 4/11/2011 4:05 PM, Thomas Klimpel wrote:
> George Slavov wrote:
>> I have been able to use gotoblas in a separate project that directly
>> called the functions defined in clapack.h. However, when I try to
>> include the lapack header (I just include it but I haven't written any
>> code to use it) from the ublas bindings, I get trouble. The error is
>> c:\documents and settings\username\my
>> documents\libs\clapack\clapack.h(512) : error C2733: second C linkage
>> of
>> overloaded function 'cbdsqr_' not allowed
>> c:\documents and settings\username\my
>> documents\libs\clapack\clapack.h(509) : see declaration of 'cbdsqr_'
>>
>> There are 100 more of these of these functions that the compiler
>> complains about, after which it gives up. Unfortunately, MSVC isn't
>> telling me where this other different C declaration is.
> The solution is real simple: don't include "c:\documents and settings\username\my documents\libs\clapack\clapack.h" and don't define BOOST_NUMERIC_BINDINGS_LAPACK_CLAPACK. The numeric_bindings library already includes a header with its own "const correct" prototype declarations for the functions declared in clapack.h:
>
> #include<boost/numeric/bindings/lapack/detail/lapack.h>
>
> But now you protest that you don't include "c:\documents and settings\username\my documents\libs\clapack\clapack.h" explicitly? That's quite possible, because some files from the numeric_bindings library (getrf.hpp, getri.hpp, getrs.hpp, potrf.hpp, potri.hpp, potrs.hpp, trtri.hpp, gesv.hpp, posv.hpp) will include<boost/numeric/bindings/lapack/detail/clapack.h> if you define BOOST_NUMERIC_BINDINGS_LAPACK_CLAPACK. This file contains the lines
>
> extern "C" {
> #include<clapack.h>
> }
>
> The<clapack.h> file which is expected here is not the one from CLAPACK, but the one from the ATLAS library. And BOOST_NUMERIC_BINDINGS_LAPACK_CLAPACK is also just referring to this part of the ATLAS library, and has nothing to do with the CLAPACK library (besides the name).
>
>
> I know why the compiler complains when the<clapack.h> from CLAPACK and<boost/numeric/bindings/lapack/detail/lapack.h> are included in the same translation unit. They both declare prototypes for c-functions with the same name, but the types in the prototypes are not identical ("void*" instead of "complex*" for example). This makes the compiler think that these are overloads, but overloads or not allowed for functions with C linkage.
>
>
>> I guess we aren't talking about the same thing, but I've got to tell
>> you... I'm not surprised. The landscape of BLAS is incredibly
>> frustrating and oftentimes I can't make head or tail of instructions.
>>
>> I was under the impression that using the Fortran libraries on Windows
>> is a major pain because of the unavailability of Fortran compilers for
>> Windows that are free and interoperate with Visual Studio well.
> I can understand how this impression arises, but it isn't actually true. The recent gcc Fortran compilers are actually pretty interoperable with Visual Studio. I tested with<http://www.equation.com/servlet/equation.cmd?fa=fortran>, but the versions from the mingw distributable or from<http://tdm-gcc.tdragon.net/> will probably work just as well.
>
> That said, it's actually a good idea to start with CLAPACK, and only try this stuff later when you are eager and confident to try some experiments.
>
>
>> If you have the patience for it, I would appreciate it if you could
>> explain to me what ATLAS and LAPACK really are in relation to gotoblas
>> because now I'm completely confused.
> - BLAS is a library for which there exists different tuned implementations. Examples are the reference Fortran implementation, gotoblas and ATLAS.
> - LAPACK is a Fortran library making use of whichever BLAS library you will link it with in order to achieve high performance.
> - CLAPACK is the f2c'ed version of this Fortran library, also making use of whichever BLAS library you will link it with...
> - Both LAPACK and CLAPACK also come with a relatively slow reference implementation of the BLAS library, so if you don't like the extra effort, there is no need to link against an optimized BLAS library.
> - gotoblas is an optimized BLAS library.
> - The ATLAS library also provides an optimized BLAS library. It also provides an implementation of the official c-interface to BLAS (which is called cblas), and has implemented a very small subset of the LAPACK routines directly with a c-interface, which it calls clapack. ATLAS can be built in a way that LAPACK and clapack can be used at the same time, when linking against LAPACK. The official c-interface to LAPACK has been developed much later by Intel MKL developers and seems to be called LAPACKE.
> - The Intel MKL library and the AMD AMCL library provide both BLAS and LAPACK library implementations.
>
>
> It's actually not as complicated as it sounds.
>
>
> Regards,
> Thomas
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: gpslavov_at_[hidden]
I think I have actually made some progress in understanding. Let's see
if that's true.
So even if I haven't figured out what I'm going to link to yet, I should
at least be able to get MSVC to compile my own code and then just get
unresolved externals on the lapack routine I need. However, I seem to be
getting a compilation error.
I am not defining anything anymore and am including
<boost/numeric/bindings/lapack.hpp>. Including just the driver I need
gives me the same error though. The code I use is
namespace lapack = boost::numeric::bindings::lapack;
ublas::symmetric_matrix<double> m(2,2);
m(0,0) = 8.12; m(0,1) = 1.54;
m(1,1) = 1.12;
ublas::vector<double> b(2);
b(0) = 1.0;
b(1) = 1.0;
lapack::ppsv(m, b);
std::cout << "Solution to system: " << b << std::endl;
I get an error calling ppsv which looks like this:
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/detail/property_map.hpp(30):
error C2039: 'property_map' : is not a member of
'boost::numeric::bindings::detail::adaptor_access<T>'
with
[
T=boost::numeric::ublas::symmetric_matrix<double>
]
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/value_type.hpp(20) : see
reference to class template instantiation
'boost::numeric::bindings::detail::property_at<T,Key>' being compiled
with
[
T=boost::numeric::ublas::symmetric_matrix<double>,
Key=boost::numeric::bindings::tag::value_type
]
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/lapack/driver/ppsv.hpp(164)
: see reference to class template instantiation
'boost::numeric::bindings::value_type<T>' being compiled
with
[
T=boost::numeric::ublas::symmetric_matrix<double>
]
main.cpp(128) : see reference to function template
instantiation 'ptrdiff_t
boost::numeric::bindings::lapack::ppsv<boost::numeric::ublas::symmetric_matrix<T>,boost::numeric::ublas::vector<T>>(MatrixAP
&,MatrixB &)' being compiled
with
[
T=double,
MatrixAP=boost::numeric::ublas::symmetric_matrix<double>,
MatrixB=boost::numeric::ublas::vector<double>
]
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/detail/property_map.hpp(30):
error C2146: syntax error : missing ',' before identifier 'property_map'
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/detail/property_map.hpp(30):
error C2065: 'property_map' : undeclared identifier
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/detail/property_map.hpp(30):
error C2955: 'boost::mpl::at' : use of class template requires template
argument list
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/mpl/at.hpp(32) : see declaration of
'boost::mpl::at'
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/detail/property_map.hpp(30):
error C2039: 'type' : is not a member of 'boost::mpl::at'
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/mpl/at.hpp(32) : see declaration of
'boost::mpl::at'
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/detail/property_map.hpp(30):
error C2146: syntax error : missing ';' before identifier 'type'
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/detail/property_map.hpp(30):
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/detail/property_map.hpp(30):
error C2602:
'boost::numeric::bindings::detail::property_at<T,Key>::type' is not a
member of a base class of
'boost::numeric::bindings::detail::property_at<T,Key>'
with
[
T=boost::numeric::ublas::symmetric_matrix<double>,
Key=boost::numeric::bindings::tag::value_type
]
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/detail/property_map.hpp(30)
: see declaration of
'boost::numeric::bindings::detail::property_at<T,Key>::type'
with
[
T=boost::numeric::ublas::symmetric_matrix<double>,
Key=boost::numeric::bindings::tag::value_type
]
C:\Documents and Settings\Eeyore\My
Documents\libs\boost\boost/numeric/bindings/detail/property_map.hpp(30):
error C2868:
'boost::numeric::bindings::detail::property_at<T,Key>::type' : illegal
syntax for using-declaration; expected qualified-name
with
[
T=boost::numeric::ublas::symmetric_matrix<double>,
Key=boost::numeric::bindings::tag::value_type
]
Best regards,
George