Software Archive
Read-only legacy content

How to compile/install/use third party library

Ioannis_V_
Beginner
408 Views

Hello,

I am using compiler assisted offload in my application, explicitly specifying which computations should be transferred to the Xeon Phi. Things are working correctly, but now I got to the point where I need to use a third party library in the part of the application that is offloaded to the Phi. If it is of any use, the library under consideration is PRIMME (http://www.cs.wm.edu/~andreas/software, code and documentation found at https://github.com/primme/primme).

I am struggling to figure out how I should compile the library, where to install the produced files, how to compile my application and how to link it to the library. More specifically:

- How many compiled version of the library do I need? Should I compile the library for both, the host and the Phi? I would like to have it working like the Intel libraries, where code is executed on the host if a Phi is not detected on the system and no offload can be done.

- Do I need both, LP64 and ILP64? Are both static and dynamic libraries required? PRIMME currently only produces a static library, but it seems straightforward to modify the build procedure and add a dynamic version too.

- Depending on which compiled versions I need, where should these be installed? I assume it could be anywhere on the host, but where to put them on the Phi?

- How do I compile my application in order to link to the correct version of the library? It confuses me, since if a Phi is available on the system the Phi library should be used, otherwise the host library should be used. What happens if static linking is done? Shouldn't both be linked in, so as to be able to run the executable on any system?

- In case of a dynamic library, how does the system find which version of the library should be loaded?

- PRIMME uses internally BLAS and LAPACK routines and I would like to link with MKL to satisfy these dependencies. Anything more I need to do for this?

It would be great if there is any tutorial available about how to proceed with this. Unfortunately I couldn't find one. Hopefully I didn't miss anything.

Ioannis E. Venetis

0 Kudos
2 Replies
TimP
Honored Contributor III
408 Views

Too many questions all at once.  Many of them are answered in the Intel docs; you'll need to get used to google e.g. "compiler assisted offload site:software.intel.com" as the docs are fragmentary.

Compiler assisted offload refers to MKL performance library.  You can use only one of LP64 and ILP64. according to whether your integer parameters are 32- or 64-bit.  There is mechanism in "automatic offload" to look at individual BLAS function calls and figure out whether they are best run on coprocessor or host.

Offload mode takes care automatically of any necessary code transfers to coprocessor.  That's one of the few things I like about it.

 

0 Kudos
Ioannis_V_
Beginner
408 Views

Dear Tim,

Tim P. wrote:

Too many questions all at once.  Many of them are answered in the Intel docs; you'll need to get used to google e.g. "compiler assisted offload site:software.intel.com" as the docs are fragmentary.

Searching with Google is always the first thing :-) I am not a novice on such things. I am working for years on low-level stuff and I know well how to use a compiler, linker and other required tools to build a library and use it in an application. You can check my contributions on cross-compilation environments, where knowledge about such low-level procedures is necessary. But I got lost with Phi. And the problem is exactly the one you mention: the docs are fragmentary. And I cannot figure out how to connect the dots, because we are not talking about a single machine, but two machines in one: the host and the Phi.

Tim P. wrote:

Compiler assisted offload refers to MKL performance library.

You are right, but this is not obvious in the document where I read it (https://software.intel.com/en-us/node/528434). The way it is written it seems to refer to the general method of using the offload pragma. Only after your comment I realized that it was specifically about MKL.

Tim P. wrote:

Offload mode takes care automatically of any necessary code transfers to coprocessor.

I agree, but in order to transfer the executable code to the coprocessor, we need to have that code ;-) And my problem is how to create it and where to put it so that offload mode can afterwards take care automatically of any necessary code transfers.

So, essentially the questions are only two. What are the steps to compile a third party library for use with the offload pragma and what are the steps to link that library with my application so that it runs whether a Phi is present on a machine or not. All other questions are "sub-problems" of these issues.

I have also noticed in this forum that other people are trying to do similar things with third party libraries. I believe that as the Phi becomes more and more used, such cases will appear more often. Maybe Intel could write a single document describing what is necessary to be done in such cases?

Best regards,

Ioannis .E Venetis

0 Kudos
Reply