Skip to content

Specific targets#3206

Merged
tgamblin merged 4 commits intodevelopfrom
specific-targets
Sep 20, 2019
Merged

Specific targets#3206
tgamblin merged 4 commits intodevelopfrom
specific-targets

Conversation

@becker33
Copy link
Copy Markdown
Member

@becker33 becker33 commented Feb 21, 2017

Resolves #2379

Allow spack to detect target at a finer granularity.

Moves toward using the granularity of the -march option for the gnu compiler toolchain.

Modifications to be done to add the feature
  • Add support for detecting specific architectures (complete for Intel, IBM and AMD chips, not done for ARM yet).
  • Create a mechanism for comparisons among architectures. This will be a partial ordering.
  • Automatically add optimization flags for the proper target through the compiler wrappers.
  • Ensure that defaults from packages.yaml allow for setting a generic target at any scope.
  • Ensure that moving to a new architecture family will still use platform.machine() and avoid failures due to the architecture not being present in the list of known ones
  • Ensure that targets saved in compilers.yaml are just representing an arch family - not micro-architectures. The rationale is that if a compiler can emit code for x86_64 it can also emit specialized code for any x86_64 micro-architecture it knows about. The benefits are that:
    1. The number of entries in compilers.yaml is not exploding due to over-specialization.
    2. This will be backward compatible with what we are already doing, and won't require user intervention on upgrade
  • Make the features, etc. of the specialized architecture part of the hash. For generic architectures, like x86_64 continue to use a string for backward compatibility.
  • Document the extended support for micro-architectures
  • Sync module docstrings as they contain outdated information
  • Add a schema for targets.json
  • Modify concretization algorithm to take into account compiler constraints if available, see Specific targets #3206 (comment)
Tests to be added to the suite
  • Ensure that high-end machines with custom build / detection logic (Cray, BG/Q) still work properly
  • Test that defaults in packages.yaml can set the target at any scope
  • Test the semantic of llnl.util.cpu.MicroArchitecture, including partial ordering
  • Ensure that we don't dump unicode to yaml configuration even in Python 2
  • Test that we are injecting the right compiler flags for relevant pairs of target / compiler
  • Test that target names don't contain dashes
  • Test that spack find works properly (was broken by 43d5e97 but not caught by unit tests)
  • Test micro-architecture detection for common targets

@mamelara

This comment has been minimized.

@becker33
Copy link
Copy Markdown
Member Author

@scheibelp this is the architecture PR we were discussing. It still needs a bunch of work, especially for ARM architectures.

@becker33
Copy link
Copy Markdown
Member Author

@mamelara yes this branch is in active development.

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Jun 27, 2019

@tgamblin @becker33 The last commit adds micro-architecture information to the spec YAML file and tries to maintain backward compatibility. For instance zlib concretized for broadwell would look like:

spec:
- zlib:
    version: 1.2.11
    arch:
      platform: linux
      platform_os: ubuntu18.04
      target:
        name: broadwell
        vendor: GenuineIntel
        features:
        - adx
        - aes
        - avx
        - avx2
        - bmi1
        - bmi2
        - f16c
        - fma
        - mmx
        - movbe
        - pclmulqdq
        - popcnt
        - rdrand
        - rdseed
        - sse
        - sse2
        - sse4_1
        - sse4_2
        - ssse3
        generation: 0
        parents:
        - haswell
    compiler:
      name: gcc
      version: 9.0.1
    namespace: builtin
    parameters:
      optimize: true
      pic: true
      shared: true
      cflags: []
      cppflags: []
      cxxflags: []
      fflags: []
      ldflags: []
      ldlibs: []
    hash: os3djb57dqdzhaqsl2n7iefz3gwombyi

while for x86_64 would be instead:

spec:
- zlib:
    version: 1.2.11
    arch:
      platform: linux
      platform_os: ubuntu18.04
      target: x86_64
    compiler:
      name: gcc
      version: 9.0.1
    namespace: builtin
    parameters:
      optimize: true
      pic: true
      shared: true
      cflags: []
      cppflags: []
      cxxflags: []
      fflags: []
      ldflags: []
      ldlibs: []
    hash: tn4qvs7g6r45dipq6kvg4ggs6rts3m7s

@tgamblin tgamblin self-requested a review June 27, 2019 18:03
@alalazo
Copy link
Copy Markdown
Member

alalazo commented Jun 29, 2019

The last commit introduces checks on the compiler to ensure it can optimize for the requested architecture:

$ spack spec hdf5 target=icelake %[email protected]
Input spec
--------------------------------
hdf5%[email protected] arch=linux-None-icelake

Concretized
--------------------------------
==> Error: cannot produce optimized binary for micro-architecture "icelake" with [email protected] [supported compiler versions are 8:]

At the moment Spack errors out if the required target is not supported and we have info on the compiler in the JSON file. An alternative behavior would be to just print a warning and don't pass any optimization flag (my personal preference goes on the current behavior).

If we don't have information on the compiler Spack will proceed and avoid using any optimization flag, for instance:

$ spack spec hdf5 target=icelake %clang
Input spec
--------------------------------
hdf5%clang arch=linux-None-icelake

Concretized
--------------------------------
[email protected]%[email protected]~cxx~debug~fortran~hl+mpi+pic+shared~szip~threadsafe arch=linux-ubuntu18.04-icelake
    ^[email protected]%[email protected]~cuda+cxx_exceptions fabrics=none ~java~legacylaunchers~memchecker~pmi schedulers=none ~sqlite3~thread_multiple+vt arch=linux-ubuntu18.04-icelake
        ^[email protected]%[email protected]~cairo~cuda~gl+libxml2~nvml+pci+shared arch=linux-ubuntu18.04-icelake
            ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake
                ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake
                    ^[email protected]%[email protected] patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,c0a408fbffb7255fcc75e26bd8edab116fc81d216bfd18b473668b7739a4158e,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 +sigsegv arch=linux-ubuntu18.04-icelake
                        ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake
                ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake
                ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake
            ^[email protected]%[email protected]~python arch=linux-ubuntu18.04-icelake
                ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake
                ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake
                ^[email protected]%[email protected]+optimize+pic+shared arch=linux-ubuntu18.04-icelake
            ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake
                ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake
                    ^[email protected]%[email protected]+cpanm patches=0eac10ed90aeb0459ad8851f88081d439a4e41978e586ec743069e8b059370ac +shared+threads arch=linux-ubuntu18.04-icelake
                        ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake
                            ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake
                                ^[email protected]%[email protected]~symlinks~termlib arch=linux-ubuntu18.04-icelake
                ^[email protected]%[email protected] arch=linux-ubuntu18.04-icelake

will concretize but won't use any march flag because we don't have (yet) any information concerning clang in the JSON file.

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Jul 1, 2019

@alalazo:

At the moment Spack errors out if the required target is not supported and we have info on the compiler in the JSON file. An alternative behavior would be to just print a warning and don't pass any optimization flag (my personal preference goes on the current behavior).

I agree with the current behavior -- if we say the binary is for icelake, it should really mean we tried to optimize for icelake. I think the error message above should print out something about what targets are supported by the selected compilers -- e.g., it might say something like "most recent supported architecture is skylake_avx512", or list the possible options (indicating which is the most recent).

This probably also means that when the target isn't specified, Spack should scale it back to somethign that's good for the selected compiler. e.g., if you say spack install foo %[email protected] and you're on a cascadelake machine, I think the concretizer should set target to skylake_avx512. What do you think?

Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@becker33 @alalazo: I did an initial pass over this. It looks like it's coming along well but I have some requests and I figure I better get started early.

@alalazo: can you address these or should we get @becker33 to?

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Jul 21, 2019

@alalazo @becker33: high level comment: we should allow the default target to be overridden somehow, I guess in packages.yaml, so that people can prefer to build everything with some generic architecture (i.e., x86_64) if they so choose. I know @gartung and the Fermilab folks need this for heterogeneous clusters. @gartung should probably take a look at where this PR is going.

@gartung
Copy link
Copy Markdown
Member

gartung commented Jul 22, 2019

I can only comment that we have to compile to the lower common instruction set between AMD and Intel server chips. I believe this is K2(?)

@becker33
Copy link
Copy Markdown
Member Author

@tgamblin This PR already does allow the default target to be overriden in packages.yaml.

@gartung I think the target is x86-64, unless you happen to know that a particular AMD chip has no instructions that aren't also available on Intel chips.

@alalazo alalazo force-pushed the specific-targets branch from 3c89366 to fed4916 Compare July 23, 2019 11:25
@alalazo alalazo force-pushed the specific-targets branch 2 times, most recently from 60b064f to 28b2d96 Compare August 11, 2019 13:30
@alalazo alalazo added the feature A feature is missing in Spack label Aug 12, 2019
sethrj added a commit to sethrj/spack that referenced this pull request Sep 26, 2019
Since spack#3206, 'spec.architecture.target' returned the microarchitecture
target rather than the architecture family. This causes QT 4 to fail to
build because it's expecting something like 'x86_64' rather than
'broadwell'.

See spack#12914

Erorr message:
```
==> [2019-09-26-09:37:33.834286] './configure' '-prefix' '/rnsdhpc/code/spack/opt/spack/clang/qt/aguusfi' '-v' '-opensource' '-no-opengl' '-release' '-confirm-license' '-optimized-qmake' '-no-pch' '-no-freetype' '-no-openssl' '-no-sql-db2' '-no-sql-ibase' '-no-sql-oci' '-no-sql-tds' '-no-sql-mysql' '-no-sql-odbc' '-no-sql-psql' '-no-sql-sqlite' '-no-sql-sqlite2' '-shared' '-no-openvg' '-no-nis' '-nomake' 'examples' '-nomake' 'tools' '-no-dbus' '-no-framework' '-fast' '-no-declarative-debug' '-no-gtkstyle' '-no-webkit' '-no-phonon' '-arch' 'broadwell' '-nomake' 'demos' '-cocoa' '-platform' 'unsupported/macx-clang-libc++' '-sdk' '/var/folders/gy/mrg1ffts2h945qj9k29s1l1dvvmbqb/T/s3j/spack-stage/xcode-select/clang/10.0.1-apple/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk'
Determining system architecture... (Darwin:18.7.0:x86_64)
    'macosx' is supported
System architecture: 'macosx'
Unknown architecture: "broadwell". Supported architectures: x86[i386] ppc x86_64 ppc64 arm armv6 armv7
```
sethrj added a commit to sethrj/spack that referenced this pull request Sep 26, 2019
Since spack#3206, 'spec.architecture.target' returned the microarchitecture
target rather than the architecture family. This causes QT 4 to fail to
build because it's expecting something like 'x86_64' rather than
'broadwell'.

See spack#12914

Erorr message:
```
==> [2019-09-26-09:37:33.834286] './configure' '-prefix' '/rnsdhpc/code/spack/opt/spack/clang/qt/aguusfi' '-v' '-opensource' '-no-opengl' '-release' '-confirm-license' '-optimized-qmake' '-no-pch' '-no-freetype' '-no-openssl' '-no-sql-db2' '-no-sql-ibase' '-no-sql-oci' '-no-sql-tds' '-no-sql-mysql' '-no-sql-odbc' '-no-sql-psql' '-no-sql-sqlite' '-no-sql-sqlite2' '-shared' '-no-openvg' '-no-nis' '-nomake' 'examples' '-nomake' 'tools' '-no-dbus' '-no-framework' '-fast' '-no-declarative-debug' '-no-gtkstyle' '-no-webkit' '-no-phonon' '-arch' 'broadwell' '-nomake' 'demos' '-cocoa' '-platform' 'unsupported/macx-clang-libc++' '-sdk' '/var/folders/gy/mrg1ffts2h945qj9k29s1l1dvvmbqb/T/s3j/spack-stage/xcode-select/clang/10.0.1-apple/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk'
Determining system architecture... (Darwin:18.7.0:x86_64)
    'macosx' is supported
System architecture: 'macosx'
Unknown architecture: "broadwell". Supported architectures: x86[i386] ppc x86_64 ppc64 arm armv6 armv7
```
alalazo added a commit to alalazo/spack that referenced this pull request Oct 9, 2019
fixes spack#13073

Since spack#3206 was merged bootstrapping environment-modules was using
the architecture of the current host or the best match supported
by the default compiler. The former case is an issue since shell
integration was looking for a spec targeted at the host
microarchitecture.

This commit fixes the problem by:

1. Bootstrapping an en modules targeted at generic architectures
2. Looking for generic targets in shell integration scripts
alalazo added a commit to alalazo/spack that referenced this pull request Oct 10, 2019
fixes spack#13005

This commit fixes an issue with the name of the root directory for
module file hierarchies. Since spack#3206 the root folder was named after
the microarchitecture used for the spec, which is too specific and
not backward compatible for lmod hierarchies. Here we compute the
root folder name using the target family instead of the target name
itself and we add target information in the 'whatis' portion of the
module file.
@tgamblin tgamblin deleted the specific-targets branch October 13, 2019 00:16
tgamblin pushed a commit that referenced this pull request Oct 15, 2019
#13121)

fixes #13005

This commit fixes an issue with the name of the root directory for
module file hierarchies. Since #3206 the root folder was named after
the microarchitecture used for the spec, which is too specific and
not backward compatible for lmod hierarchies. Here we compute the
root folder name using the target family instead of the target name
itself and we add target information in the 'whatis' portion of the
module file.
tgamblin pushed a commit that referenced this pull request Oct 21, 2019
…13105)

fixes #13073

Since #3206 was merged bootstrapping environment-modules was using the architecture of the current host or the best match supported by the default compiler. The former case is an issue since shell integration was looking for a spec targeted at the host microarchitecture.

1. Bootstrap an env modules targeted at generic architectures
2. Look for generic targets in shell integration scripts
3. Add a new entry in Travis to test shell integration
jrmadsen pushed a commit to jrmadsen/spack that referenced this pull request Oct 30, 2019
spack#13121)

fixes spack#13005

This commit fixes an issue with the name of the root directory for
module file hierarchies. Since spack#3206 the root folder was named after
the microarchitecture used for the spec, which is too specific and
not backward compatible for lmod hierarchies. Here we compute the
root folder name using the target family instead of the target name
itself and we add target information in the 'whatis' portion of the
module file.
jrmadsen pushed a commit to jrmadsen/spack that referenced this pull request Oct 30, 2019
…pack#13105)

fixes spack#13073

Since spack#3206 was merged bootstrapping environment-modules was using the architecture of the current host or the best match supported by the default compiler. The former case is an issue since shell integration was looking for a spec targeted at the host microarchitecture.

1. Bootstrap an env modules targeted at generic architectures
2. Look for generic targets in shell integration scripts
3. Add a new entry in Travis to test shell integration
@haampie haampie added the hash-change things that will change a lot of hashes label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A feature is missing in Spack hash-change things that will change a lot of hashes impact-high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compute-Specific Architecture Chains

10 participants