Skip to content

Intel prefixes#7469

Merged
scheibelp merged 221 commits intospack:developfrom
mgsternberg:intel-prefixes
Aug 30, 2018
Merged

Intel prefixes#7469
scheibelp merged 221 commits intospack:developfrom
mgsternberg:intel-prefixes

Conversation

@mgsternberg
Copy link
Copy Markdown
Contributor

I reworked class IntelPackage to overcome what was for me a major barrier to entry in adopting Spack that showed up when attempting to integrate an existing Intel tool chain on my HPC system.

There was a serious conceptual conflict for prefix between versions of Intel packages that were installed under Spack and those brought in via packages.yaml. I am not the only one to have stumbled over this, see e.g. https://groups.google.com/d/msg/spack/x28qlmqPAys/Ewx6220uAgAJ

This is an initial attempt at tackling the problem, having targeted MKL and Intel-MPI as proof-of-concept. I was able to build ABINIT and CP2K with those, the latter having a downright gluttonous list of dependencies. Other Intel packages should be possible to integrate.

The major affected files so far are:

  • .../build_systems/intel.py
  • .../intel-mkl/package.py
  • .../intel-mpi/package.py
  • .../intel-parallel-studio/package.py

A major goal was elimination of duplicate code. To this end, I pulled up foo_libs() and related methods into the IntelPackage class definition. The following methods should give a flavor of my approach:

def product_dir(self, product_dir_name, version_glob='_2???.*.*[0-9]',
                postfix_dir=''):
    '''Returns the version-specific directory of an Intel product release,
    holding the main product and possibly auxiliary files from other
    products.
    '''
…
def component_dir(self, component=None):
    '''Returns the directory of a product component, appropriate for
    presenting to users in environment variables like MKLROOT and
    I_MPI_ROOT, or the product dir itself (when the component not evident
    from the package name and wasn't specified).
    '''
…
def component_bin_dir(self, component=None, relative=False):
…
def component_lib_dir(self, component=None, relative=False):

The reorganization dramatically shortens .../intel-mkl/package.py, and allows to write, e.g.

def file_to_source(self):
    return join_path(self.component_bin_dir(), 'mklvars.sh')

Other changes are minor and showed up/were prompted by testing:

  • lib/spack/spack/environment.py
  • var/spack/repos/builtin/packages/libxc/package.py

Comments and suggestions on my approach are needed and welcome.

…m spack-native install and explain what happens for spack-external installs
@mgsternberg
Copy link
Copy Markdown
Contributor Author

@davydden @adamjstewart @tgamblin
I updated the doc in the present form and addressed the majority of @adamjstewart's review comments from last month. We touched on factoring out the docs, but this would leave this PR without any doc at all which I would think would be worse. Factoring out and re-distributing the docs elsewhere into the doc tree may well be tackled later.

I also left in the perhaps unexpecterd instructions for declaring a "stub" compilers.yaml entry prior to installing intel-parallel-studio. This is related to the otherwise still unresolved issue of unexpected package re-installs, which would be particularly troubling and annoying for that package and for new users, as discussed here before.

@mgsternberg
Copy link
Copy Markdown
Contributor Author

I added a doc section on how to properly link the MKL using the utilities from class llnl.util.filesystem. This overlaps with, extends, and links to the relevant Packaging Guide section.
Parts might in fact be migrated into the Packaging Guide at some point.

While large parts are not specific to the MKL, the issues came to the fore when MKL is used.

@mgsternberg
Copy link
Copy Markdown
Contributor Author

mgsternberg commented Aug 16, 2018

@mamelara
As mentioned in today's Telcon, here's the doc section on MKL linkage that I recently added. – Does that help?

@mamelara
Copy link
Copy Markdown
Member

mamelara commented Aug 16, 2018

So just to clarify, the intel mkl advisor recommends a link line looking like this:

 ${MKLROOT}/lib/intel64/libmkl_scalapack_ilp64.a -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a ${MKLROOT}/lib/intel64/libmkl_blacs_intelmpi_ilp64.a -Wl,--end-group -lpthread -lm -ldl

With the key part being this:

-Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a ${MKLROOT}/lib/intel64/libmkl_blacs_intelmpi_ilp64.a -Wl,--end-group 

So I was thinking that something like spec['blas'].ld_flags would return something like that if it is trying to link statically.

We've been running into the issue of getting undefined references since for whatever reason those libraries have circular dependencies on each other.

Obviously, I don't want to hold this PR back any longer and could add the change later if need be but I was wondering if this PR addressed that.

@mgsternberg
Copy link
Copy Markdown
Contributor Author

mgsternberg commented Aug 16, 2018

@mamelara Can you offer more specifics on the failure? Is it just undefined symbols or inability to link statically in general?

Some thoughts:

  1. static linkage did not come up as issue in this PR, except peripherally for TBB where Intel has published a note explaining the absence of a static TBB.

  2. The Intel packages that provide the MKL offer a +shared variant which is coded along the lines of find_libraries(..., shared=('+shared' in self.spec)). From that, spec['blas'].libs will duly return a list of .a files, though without the -Wl bracketing, and the spack codebase uses --start-group only in a test context, under lib/spack/spack/test/cc.py.

    I just realized that spec['blas'].libs.ld_flags as in the doc would in fact mask the distinction between .so and .a because it outputs -L<dir> -l<libname> ... strings.

  3. Spack-built executables do include the MKL paths in their -rpath settings. Assuming you have the Intel libs available on target nodes, doesn't that give you most of the same effect as -static without having to worry about LD_LIBRARY_PATH?

  4. All said, I recall a hackish ancient setup where one of the libs (scalapack or blacs) needed to be given again near the end of the link line. Spack at the moment doesn't do that.

@scheibelp
Copy link
Copy Markdown
Member

I would be happy to merge now (after merge conflicts are resolved): @davydden mentioned that this worked for him. And the documentation is great. @adamjstewart had some comments about refactoring but IMO those could be handled in another issue/PR. I also think @mamelara's concerns could be handled in a new issue/PR.

Were you looking for any additional user testing or feedback?

If so, if you resolve the conflicts in the next couple days. I could merge #7540 at which point I assume it would be easy to resolve conflicts which arise from that (since you mention your edits are a superset of that).

@adamjstewart
Copy link
Copy Markdown
Member

@adamjstewart had some comments about refactoring but IMO those could be handled in another issue/PR.

Agreed. The semester just started for me so I probably won't have time to review very many Spack PRs. If everyone can build their favorite packages with this branch them I'm fine with the merge.

@mgsternberg
Copy link
Copy Markdown
Contributor Author

@scheibelp
Good to hear! Yes, I'd be glad to hear from @mamelara, but you're right in handling that later.

Following up, I just saw the conflicts, and will review.

@davydden had a note on #9032, obviating an SPACK_COMPILER_EXTRA_RPATHS modification for MKL here. That's not merged yet, though, so I'll have to leave that RPATH part in.

@davydden
Copy link
Copy Markdown
Member

@davydden had a note on #9032, obviating an SPACK_COMPILER_EXTRA_RPATHS modification for MKL here. That's not merged yet, though, so I'll have to leave that RPATH part in.

I agree. I can always adopt #9032 after this PR is merged.

@mgsternberg
Copy link
Copy Markdown
Contributor Author

@scheibelp
Given the high-profile and thus potentially showstopping role of licensing for the Intel packages, merging #8991 alongside here should be helpful for new users.

Note that there was a strange Travis failure for Python-3.6. The raw log does not mention "intel" so I don't think the failure has to do with that PR itself.

@scheibelp scheibelp merged commit a86f22d into spack:develop Aug 30, 2018
@scheibelp
Copy link
Copy Markdown
Member

Thanks for this!

Note that there was a strange Travis failure for Python-3.6. The raw log does not mention "intel" so I don't think the failure has to do with that PR itself.

Agreed - the final message indicates that the build was stalled.

ptbremer pushed a commit to ptbremer/spack that referenced this pull request Aug 31, 2018
Consolidate prefix calculation logic for intel packages into the
IntelPackage class.

Add documentation on installing Intel packages with Spack an
(alternatively) adding them as external packages in Spack.
anderson2981 pushed a commit to anderson2981/spack that referenced this pull request Sep 7, 2018
Consolidate prefix calculation logic for intel packages into the
IntelPackage class.

Add documentation on installing Intel packages with Spack an
(alternatively) adding them as external packages in Spack.
ptbremer pushed a commit to ptbremer/spack that referenced this pull request Oct 12, 2018
Consolidate prefix calculation logic for intel packages into the
IntelPackage class.

Add documentation on installing Intel packages with Spack an
(alternatively) adding them as external packages in Spack.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.