I’m sort of a newbie to C coding but I’ve written a Matlab program for simulating neural networks and I wish to translate it to C code because our supercomputer cluster won’t allow running more than a few Matlab simulations at once. To that end, I’ve found GotoBLAS to take care of the matrix math.
Unfortunately I’m not sure how to use it as I don’t have a lot of experience in C and using external libraries. I’m assuming that ‘dgemm’ is a function in GotoBLAS from reading the BLAS guide pdf. I’ve been able to successfully compile GotoBLAS, but when I do:
gcc -o outputprog main.c -Wall -L -lgoto2.a
I get the messages:
undefined reference to 'dgemm'
As I understand it, I should be including some .h file (or maybe not) from GotoBLAS but I’m not sure which one (or if this is right at all).
Any help with this would be appreciated. Let me know if more information is needed.
Ok I was able to find the answer on the GotoBLAS mailing list https://lists.tacc.utexas.edu/mailman/listinfo/gotoblas (which is not listed on the website as far as I can see). Here’s a quick step by step on using GotoBLAS2 with C and GCC compiler.
Build GotoBLAS2 libraries (.so and .a), there’s good documentation on that included with the libraries so I won’t post it here. Include BOTH of these files in the libs directory of your choice as set by -L. I was only including one because I thought they were just different versions of the same library which was not correct.
Also link to
-lgfortranas well if you wish to compile with gcc.-lpthreadmight also be useful, although I’m not sure, I’ve seen examples with it but it compiles without. Your gcc should look something like this:gcc -Wall -o outprog -L./GotoLIBSDIR -lgoto2 -lgfortran -lpthread(maybe) main.cFinally, call
function_()instead offunction(), so for example,dgemm_()when using gfortran to compile the fortran interfaces.Alternatively to the fortran interface the cblas interface can be used as
cblas_dgemm(). You still need to link to-lgfortranfor this as otherwise linking tolibgoto2.sowill fail, and you need to link to that file to be able to usecblas_dgemm()correctly.There doesn’t appear to be any need to include any of the .h files or anything else.
Hopefully someone else will find this useful. Thanks for all the help!