Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid compiling for AVX2 instructions on older hardware. #485

Merged
merged 3 commits into from
Sep 26, 2018

Conversation

KineticTheory
Copy link
Collaborator

@KineticTheory KineticTheory commented Sep 26, 2018

Background

  • The compile option /arch:AVX2 was always enabled for Visual Studio, but pre-Haswell hardware does not support AVX2. While the compiler could still create code, it would fail to run properly. To avoid this, we add a platform check for AVX2 capabilities -- actually the check already existed in config/query_fma.cc but it needed a small change to narrow the check to AVX2 only.

Description of changes

  • Modify query_fma.cc to take command line arguments -f and -a, which limit the check to fma-availability or avx2-availablity only. This code will return 1 if those features are found.
  • Update platform_checks.cmake to compile and run query_fma.cc and then set the build variables HAVE_HARDWARE_AVX2 and HAVE_HARDWARE_FMA. These values are saved to ds++/config.h and are also available when the build system parses windows-cl.cmake so that appropriate code paths can be taken.
  • Also:
    • Fix a comment block in drel.f90.
    • Fix a typo in appveyor.yml that prevented output from failing tests from being printed.

Status

+ The compile option `/arch:AVX2` was always enabled for Visual Studio, but
  pre-Haswell hardware does not support AVX2.  While the compiler could still
  create code, it would fail to run properly. To avoid this, we add a
  platform check for AVX2 capabilities -- actually the check already existed
  in `config/query_fma.cc` but it needed a small change to narrow the check
  to AVX2 -nly.
+ Modify `query_fma.cc` to take command line arguments `-f` and `-a`, which
  limit the check to fma-availability or avx2-availablity only. This code
  will return `1` if those features are found.
+ Update `platform_checks.cmake` to compile and run `query_fma.cc` and then
  set the build variables `HAVE_HARDWARE_AVX2` and `HAVE_HARDWARE_FMA`.
  These values are saved to `ds++/config.h` and are also available when
  the build system parses `windows-cl.cmake` so that appropriate code
  paths can be taken.
+ Also:
  + Fix a comment block in `drel.f90`.
  + Fix a typo in `appveyor.yml` that prevented output from failing tests
    from being printed.
@codecov
Copy link

codecov bot commented Sep 26, 2018

Codecov Report

Merging #485 into develop will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           develop    #485   +/-   ##
=======================================
  Coverage     91.9%   91.9%           
=======================================
  Files          375     375           
  Lines        17528   17528           
=======================================
  Hits         16124   16124           
  Misses        1404    1404

@KineticTheory KineticTheory changed the title Avoid compiling for AVX2 instructions on older hardware. WIP: Avoid compiling for AVX2 instructions on older hardware. Sep 26, 2018
@KineticTheory
Copy link
Collaborator Author

Compile fails on Cray. Looking into it.

+ `query_fma.cc` has a special ifdef block for `__INTEL_COMPILER`.  I forgot to
  update the function signature inside this block. Fixed.
+ Also add an alias to the bashrc files to help developers remember that they
  need the salloc option `--gres=craynetwork:0` to enable running ctest with the
  `-j` option.
@alexrlongne alexrlongne changed the title WIP: Avoid compiling for AVX2 instructions on older hardware. Avoid compiling for AVX2 instructions on older hardware. Sep 26, 2018
@alexrlongne
Copy link
Contributor

Looks good, I'm removing the WIP tag and merging after talking with @KineticTheory .

@alexrlongne alexrlongne merged commit 76584f6 into lanl:develop Sep 26, 2018
@KineticTheory KineticTheory deleted the query_avx2 branch September 26, 2018 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants