How to detect different MAGMA flavors at compile time?

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)
Post Reply
matteosecli
Posts: 2
Joined: Mon Oct 07, 2019 8:57 am

How to detect different MAGMA flavors at compile time?

Post by matteosecli » Mon Oct 07, 2019 10:53 am

Hello, I'm working to integrate MAGMA on my program (written in C++); I mainly have to use magma_zgeev().

I'm new to the library, but to my understanding magma_zgeev() takes different arguments based on the flavor: i.e. MAGMA's version sort of maps into the LAPACK prototype while clMAGMA's version takes an additional queue argument before the last argument. There are differences in function prototypes even between MAGMA v1 and MAGMA v2, e.g. magma_queue_create() takes two arguments in MAGMA v2 and clMAGMA but it takes only one argument in MAGMA v1.

My idea is to differentiate these cases at compile time via macros, e.g. define some macro MAGMA_FLAVOR_CLMAGMA if the user is compiling the code with clMAGMA, MAGMA_FLAVOR_MAGMA if he's compiling with regular MAGMA, etc. for other flavors; this would in principle enable my program to run on different machines with possibly different hardware and different MAGMA versions. I definitely don't want to do this differentiation at runtime.

I'm therefore looking for some flavor-specific MAGMA macro(s) that would allow me to make this distinction; for example, I can distinguish MAGMA v2 from clMAGMA by looking for the magma_queue_create_from_cuda macro, but in this way I cannot distinguish MAGMA v2 from MAGMA v1. Is there any safer / more stable way to do it?

mgates3
Posts: 902
Joined: Fri Jan 06, 2012 2:13 pm

Re: How to detect different MAGMA flavors at compile time?

Post by mgates3 » Mon Oct 07, 2019 2:01 pm

MAGMA 1.0 is quite old, so I personally wouldn't bother. If you insist, there are MAGMA_VERSION_MAJOR, _MINOR, and _MICRO macros. See include/magma_types.h.

clMAGMA is not actively maintained — even AMD's clBLAS is a couple years old at this point. clMAGMA uses HAVE_clAmdBlas or HAVE_clBLAS macros, while cuda MAGMA uses HAVE_CUBLAS.

-mark

matteosecli
Posts: 2
Joined: Mon Oct 07, 2019 8:57 am

Re: How to detect different MAGMA flavors at compile time?

Post by matteosecli » Mon Oct 07, 2019 4:31 pm

Thank you, I think I'll go with the HAVE_CUBLAS / HAVE_clBLAS / HAVE_MIC solution! :)

Post Reply