Skip to content

Commit

Permalink
Changes for Cray & Clang (AMReX-Codes#2941)
Browse files Browse the repository at this point in the history
* It seems that the new Cray compilers no longer define `_CRAYC`.  However it does define
  `__cray__`.

* For Clang based Cray compilers, use -O3 instead of -O2 for optimization.

* Clang's vectorization pragma is very aggressive.  For some codes, it makes ParallelFor
  with many if statements on CPU much slower than without vectorization.  Unfortunately,
  it does not have an ivdep pragma.  So we disable AMREX_PRAGMA for clang for safety.

* No longer need to use -Wno-pass-failed for Clang based compilers.
  • Loading branch information
WeiqunZhang committed Sep 7, 2022
1 parent 5b0c598 commit 6738470
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/hip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# ^
# /opt/rocm-4.1.1/hip/include/hip/hcc_detail/hip_runtime.h:176:9: note: macro 'select_impl_' defined here
# #define select_impl_(_1, _2, impl_, ...) impl_
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wno-deprecated-declarations -Wno-gnu-zero-variadic-macro-arguments -Wno-pass-failed"}
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wno-deprecated-declarations -Wno-gnu-zero-variadic-macro-arguments"}
steps:
- uses: actions/checkout@v2
- name: Dependencies
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
# ^
# /opt/rocm-4.1.1/hip/include/hip/hcc_detail/hip_runtime.h:176:9: note: macro 'select_impl_' defined here
# #define select_impl_(_1, _2, impl_, ...) impl_
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wno-deprecated-declarations -Wno-gnu-zero-variadic-macro-arguments -Wno-pass-failed"}
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wno-deprecated-declarations -Wno-gnu-zero-variadic-macro-arguments"}
steps:
- uses: actions/checkout@v2
- name: Dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
env:
# build universal binaries for M1 "Apple Silicon" and Intel CPUs
CMAKE_OSX_ARCHITECTURES: "arm64;x86_64"
CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wno-c++17-extensions -Wno-range-loop-analysis -Wno-pass-failed"
CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wno-c++17-extensions -Wno-range-loop-analysis"
# -Wno-range-loop-analysis: Apple clang has a bug in range-loop-analysis
steps:
- uses: actions/checkout@v2
Expand All @@ -39,7 +39,7 @@ jobs:
name: AppleClang@11.0 GFortran@9.3 [tests]
runs-on: macos-latest
env:
CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wno-c++17-extensions -Wno-range-loop-analysis -Wno-pass-failed"
CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wno-c++17-extensions -Wno-range-loop-analysis"
# -Wno-range-loop-analysis: Apple clang has a bug in range-loop-analysis
steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions Src/Base/AMReX_Extension.H
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#elif defined(__INTEL_COMPILER)
#define AMREX_PRAGMA_SIMD _Pragma("ivdep")

#elif defined(_CRAYC)
#elif defined(_CRAYC) || defined(__cray__)
#define AMREX_PRAGMA_SIMD _Pragma("ivdep")

#elif defined(__PGI)
Expand All @@ -73,7 +73,7 @@
#define AMREX_PRAGMA_SIMD _Pragma("ibm independent_loop")

#elif defined(__clang__)
#define AMREX_PRAGMA_SIMD _Pragma("clang loop vectorize(enable)")
#define AMREX_PRAGMA_SIMD

#elif defined(__GNUC__)
#define AMREX_PRAGMA_SIMD _Pragma("GCC ivdep")
Expand Down
18 changes: 9 additions & 9 deletions Tools/CMake/AMReXFlagsTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ target_compile_options( Flags_CXX
$<${_cxx_cray_dbg}:-O0>
$<${_cxx_cray_rwdbg}:>
$<${_cxx_cray_rel}:>
$<${_cxx_clang_dbg}:-O0 -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-pass-failed>
$<${_cxx_clang_rwdbg}:-Wno-pass-failed>
$<${_cxx_clang_rel}:-Wno-pass-failed>
$<${_cxx_appleclang_dbg}:-O0 -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-pass-failed>
$<${_cxx_appleclang_rwdbg}:-Wno-pass-failed>
$<${_cxx_appleclang_rel}:-Wno-pass-failed>
$<${_cxx_intelllvm_dbg}:-O0 -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-pass-failed>
$<${_cxx_intelllvm_rwdbg}:-Wno-pass-failed>
$<${_cxx_intelllvm_rel}:-Wno-pass-failed>
$<${_cxx_clang_dbg}:-O0 -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable>
$<${_cxx_clang_rwdbg}:>
$<${_cxx_clang_rel}:>
$<${_cxx_appleclang_dbg}:-O0 -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable>
$<${_cxx_appleclang_rwdbg}:>
$<${_cxx_appleclang_rel}:>
$<${_cxx_intelllvm_dbg}:-O0 -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable>
$<${_cxx_intelllvm_rwdbg}:>
$<${_cxx_intelllvm_rel}:>
)

#
Expand Down
2 changes: 1 addition & 1 deletion Tools/CMake/AMReXParallelBackends.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ if (AMReX_HIP)
# else there will be a runtime issue (cannot find
# missing gpu devices)
target_compile_options(amrex PUBLIC
$<$<COMPILE_LANGUAGE:CXX>:--amdgpu-target=${AMReX_AMD_ARCH_HIPCC} -Wno-pass-failed>)
$<$<COMPILE_LANGUAGE:CXX>:--amdgpu-target=${AMReX_AMD_ARCH_HIPCC}>)
endif()

target_compile_options(amrex PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-m64>)
Expand Down
2 changes: 1 addition & 1 deletion Tools/CMake/AMReXSYCL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ target_compile_features(SYCL INTERFACE cxx_std_17)
#
target_compile_options( SYCL
INTERFACE
$<${_cxx_dpcpp}:-Wno-error=sycl-strict -Wno-pass-failed -fsycl>
$<${_cxx_dpcpp}:-Wno-error=sycl-strict -fsycl>
$<${_cxx_dpcpp}:$<$<BOOL:${AMReX_DPCPP_SPLIT_KERNEL}>:-fsycl-device-code-split=per_kernel>>)

# temporary work-around for DPC++ beta08 bug
Expand Down
2 changes: 1 addition & 1 deletion Tools/GNUMake/comps/armclang.mak
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ifeq ($(WARN_ERROR),TRUE)
endif

# disable some warnings
CXXFLAGS += -Wno-pass-failed -Wno-c++17-extensions
CXXFLAGS += -Wno-c++17-extensions

########################################################################

Expand Down
10 changes: 5 additions & 5 deletions Tools/GNUMake/comps/cray.mak
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ else
# CCE <= 8. So we adjust some flags to achieve similar optimization. See
# this page:
# http://pubs.cray.com/content/S-5212/9.0/cray-compiling-environment-cce-release-overview/cce-900-software-enhancements
CXXFLAGS += -O2 -ffast-math #-fsave-loopmark -fsave-decompile
CFLAGS += -O2 -ffast-math #-fsave-loopmark -fsave-decompile
FFLAGS += -O2 -h list=a
F90FLAGS += -O2 -h list=a
CXXFLAGS += -O3 -ffast-math #-fsave-loopmark -fsave-decompile
CFLAGS += -O3 -ffast-math #-fsave-loopmark -fsave-decompile
FFLAGS += -O3 -h list=a
F90FLAGS += -O3 -h list=a
else
GENERIC_COMP_FLAGS += -h list=a

Expand Down Expand Up @@ -120,7 +120,7 @@ else
endif

ifeq ($(CRAY_IS_CLANG_BASED),TRUE)
CXXFLAGS += -Wno-pass-failed -Wno-c++17-extensions
CXXFLAGS += -Wno-c++17-extensions
endif

CXXFLAGS += $(GENERIC_COMP_FLAGS)
Expand Down
2 changes: 0 additions & 2 deletions Tools/GNUMake/comps/dpcpp.mak
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ else

endif

CXXFLAGS += -Wno-pass-failed # disable this warning

ifeq ($(WARN_ALL),TRUE)
warning_flags = -Wall -Wextra -Wno-sign-compare -Wunreachable-code -Wnull-dereference
warning_flags += -Wfloat-conversion -Wextra-semi
Expand Down
2 changes: 0 additions & 2 deletions Tools/GNUMake/comps/hip.mak
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ ifeq ($(HIP_COMPILER),clang)

endif

CXXFLAGS += -Wno-pass-failed # disable this warning

ifeq ($(WARN_ALL),TRUE)
warning_flags = -Wall -Wextra -Wunreachable-code -Wnull-dereference
warning_flags += -Wfloat-conversion -Wextra-semi
Expand Down
2 changes: 1 addition & 1 deletion Tools/GNUMake/comps/llvm.mak
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ifeq ($(WARN_ERROR),TRUE)
endif

# disable some warnings
CXXFLAGS += -Wno-pass-failed -Wno-c++17-extensions
CXXFLAGS += -Wno-c++17-extensions

########################################################################

Expand Down

0 comments on commit 6738470

Please sign in to comment.