Lapack and Xcode

Hello,

Does anyone know how to use Lapack framework with Xcode v2.2 from a simple C++ application project?

DO I need to include the accelerate framework with the vecLib frame work in the project?
What header should I include in my main file?
Once the framework are included, do I need to specify the path, or does Xcode manage it automatically ?

I also got confused with the version of the Lapack library. The original one is on Fortan, but I have read that there is a c++ version of Lapack.

Which one is included in the developer tools ?

Sincerely
Jc

Re: Lapack and Xcode

Hi JC,

Including LAPACK in Xcode is easy. Since it's part of the Accelerate framework the only thing you need to include is the Accelerate framework and add in the Accelerate header. To include the Accelerate framework:

1) In the Groups and Files pane right click on External Frameworks and Libraries and choos Add > Existing Frameworks. Navigate to /System/Library/Frameworks and click on the Accelerate.framework folder.
2) Click Add and then in the next window click Add again.

To include the header:

1) In the file you will be calling LAPACK routines from (or from a main/central header file) add the line:

#include <Accelerate/Accelerate.h>

Note that for ANY framework the top level header is always the basename of the framework (e.g. Accelerate) plus the basename of the framework plus .h (e.g. Accelerate.h).

Hope that helps,

Dave

The response below is

The response below is correct. I just thought I would add that accessing vecLib directly is deprecated. We keep it around for pre-MacOS X.3 apps. You should be using -framework Accelerate at link time and #include {less than sign}Accelerate/Accelerate.h{greater than sign} to use the headers.

Our LAPACK is callable from C/C++/ObjC/ObjC++ and fortran

http://developer.apple.com/hardware/ve/vector_libraries.html

thanks and one more question

Hi again,

Thank you for your answers. It works fine now

I have a last question:

The lapack library in the framework can be called from C or C++ but is basically a FORTRAN library.

What about lapack++ v2.5 that I have seen on http://sourceforge.net/. It seems that this library is directly developped in C++. Did anyone try to use it on Mac OS ?

thanks
jc

It is difficult to

It is difficult to anticipate your motivations for wanting a C++ library.

Most of the time, when I read requests for a C or FORTRAN library to have C++ interfaces, it is usually because the requester wants the degree of syntactic sugar he is accustomed to in the rest of his C++ application. Probably due to my own perverse tendencies to write mostly in C and occasionally in assembly -- these are the most useful when writing actual high performance code -- it is difficult for me to fully empathize with such a requirement. Largely it seems to me, such attempts are simply trading inherent quality for cosmetic beauty, a cosmetic beauty that your users will never see.

In any case, if you are looking for syntactic sugar, a cursory glance at lapack++ suggests it will not disappoint. With apologies to the developers of lapack++, who certainly know more about this product than I do, I don't see much meat here. In my book, that would include vector code, intelligent cache blocking, etc. The library, to it's credit, does appear to call through to the standard LAPACK/BLAS rather than trying to do the heavy lifting itself.

There is a place for C++ in HPC, as products like MacSTL and Blitz++ demonstrate. Unfortunately, I don't see much evidence of that sort of effort here.

Regardless of motivation, you should be able to use the C interfaces to the LAPACK in Accelerate.framework just like any other C programming interface that you are using without any trouble. Apple has wrapped the declarations with extern "C" {} to make sure the linkage is usable from C++. Just call them normally. The routines are all in the clapack.h header in Accelerate.framework.

may I

Hi iollman,

may I ask the name of your book?

Hello again, My main

Hello again,

My main motivations for wanting the C++ library were portability of the code to other OS and simplicity. But as I am not an expert I might be wrong.

I would define myself more as a physicist than a programmer. So I always try to get a good compromise between the time I need to program a code and the time I effectively use it for my research.

I will follow your advice and see I can make it work well this way.

Thanks
jc

LAPACK resources

I've convinced myself that it will be worth my time to learn to use LAPACK, but I'm having trouble finding good resources to help me along the way. The apple developer site still seems to focus strongly on the deprecated AltiVec libraries. The netlib.org resources also give a rather trial-by-fire introduction for a person who would rather work in C rather than Fortran. Perhaps I have become spoiled by the great wealth of novice resources for high performance 3D graphics, but there must be something out there other than netlib function definitions and a few Fortran example codes. From what I can tell, the Performance Tutorial on this site will be exactly what I need. Until the tutorial is finished where might I want to look?
Thanks to all,
JM

Re: LAPACK resources

Hi Justin,

Indeed these are things I'm hoping to cover in the performance tutorial. Unfortunately with the holidays/MacWorld etc... it's been slower to get published. I actually have most of the tutorial examples, it's a matter of writing it up. I will expedite this.

Can you provide a bit more information on what specifically you are trying to accomplish? Perhaps I can whip up something quickly to get you started. For example, are you just not sure how to use the performance libraries, which functions to use for a certain task?

Thanks,

Dave

Re: Re: LAPACK resources

Dave,

I'm making an interactive tool that plots molecular spectra in an unusual 3D form. I've solved the graphics with OpenGL and OpenGLSL. To find to spectra to plot I need to do fast diagonalizations of fairly large matrices (100sx100s). Ideally I would actually block diagonalize, but any diagonalization will work. After that I'll need to do a number of matrix multiplications (both inner products and outer products) to get symmetry information for each energy. Since I'm not using extremely large matrices I could simply use scalar numerical recipes, but as I extend things to higher order I'll need more speed to keep things interactive.

My questions about the Accelerate framework are mostly about what data types to use and how to make sure I'm making the correct function calls (passing pointers or variables). That is, what data types must I use for vector processing, must I malloc the space for them, and how do I pass this matrix or vector to an Accelerate function? I've found some help in Apple's vMathLib example, but one short example isn't usually enough for me to figure things out.

Thanks for all the work you do on this site. I've saved tons of time here already.
Justin

LAPACK needs

I'm making a sort of 3D molecular spectra plotting program. All of the OpenGL and GL Shading Language work is done, but the matrix diagonalizations that pick the energy levels are done using scalar "numerical recipes" style C algorithms. These diagonalize sparse matrixes around 60x60 elements in size. This all works fine, but I now need to deal with much larger systems that are also more dense. I could use the algorithms I already have, but I would like my application to be fast enough to be interactive. This all seems to point me into using Accelerate Frameworks.

My confusion is about what data types to use and how to make function calls. I'm unclear when I need to use LAPACK specific types (and how to define them / allocate memory for them) so that things aren't accidentally processed by scalar operations. I'm also unclear on what consequences come with calling Fortran functions from C. When do I pass the pointer vs. the variable itself.

Again, I don't think I'm going to be pushing the boundaries of computing with this project, but I find it to be a good excuse to learn how to do simple diagonalizations, matrix dot products and outer products using LAPACK.

Thanks for all your help. This site has already saved me loads of time.
Justin

While we're on the subject of LAPACK and BLAS

One of the things I miss in the otherwise excellent Accelerate framework is support for sparse linear algebra, preferable a Sparse BLAS implementation like the one found in MKL.

I know Apple don't discuss future plans and releases, but do you think this is something that is totally outside the scope of Apples Accelerate framework, or is it something that would be interesting given enough time and resources?

Re: While we're on the subject of LAPACK and BLAS

I think this is something that would fit perfectly well into Accelerate. If you have specific details of what you'd like to see implemented, source code snippets or URLs/PDFs that describe in detail what you'd like, MacResearch can help file feature requests. If you'd like to work on something like this (in terms of getting a feature request in) you can post information here, or feel free to contact me via email: sdg0919 AT gmail dot com .

Regards,

Dave

PETSc

Slightly off-topic, but has someone here succesfully compiled and run PETSc on an intel-based Apple machine?

New to MAC a recent Win+ LINUX convert quest for LAPACK, FORTRAN

Hello everyone I am new to the community where previously I used Windows as an operating system and LINUX as a programming environment. I use FORTRAN 77,90,95 to do my computations so I have lots of questions.

1. I have downloaded a free g77 and gfortran compiler for intel based MACS but the path is set to /usr/local/bin where my path is /usr/bin:sw/bin. I want to know is there a way to set the path permanently in the bash shell I have tried export $PATH:/usr/local/bin and the like but nothing seems to work. I have tried to change the etc/profile but its permissions are for root and it is only a read only file I have tried chown and chmod but my permissions are denied. I am able to set the path temporarily but I need permanent. Any suggestions. Also I am a bit of a novice at UNIX/LINUX commands I know just enough to stumble around in it.

2. I use LAPACK and BLAS extensively in my work. Is there support for the intel MAC OS X10.4. In the LAPACK makefile there isn't any support for 10.4 intel machines.

Your responses and patience is extremely appreciated.

ARW

Re: New to MAC a recent Win+ LINUX convert quest for LAPACK, FOR

I'm a tcsh user myself, but I think for bash you would create a file called .profile (or maybe .bashrc, I can't remember) in your home directory and add the line:

export PATH=${PATH}:/usr/local/bin

You can type that at the command line as well and it will add it to your path.

For part two, LAPACK is included in the Accelerate framework. See:

http://www.macresearch.org/tutorial_mixed_c_and_fortran_and_some_lapack

Near the bottom is a description of how to use Accelerate. Note that the entries are to standard LAPACK, so any code you write will be portable, you'll just need to use a different library on other systems.

Let us know if you have more questions,

Dave