From bd2e49e3aeaef5f655f9cda1c04ebd72d0ecdb3a Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Wed, 3 Mar 2021 11:01:47 -0600 Subject: [PATCH] Move QMC_CLINE to CMake. --- CMakeLists.txt | 2 ++ src/Platforms/CPU/SIMD/aligned_allocator.hpp | 10 +++++- src/Platforms/CPU/SIMD/alignment.config.h | 37 -------------------- src/Platforms/CUDA/CUDAallocator.hpp | 1 - src/config.h.cmake.in | 3 ++ 5 files changed, 14 insertions(+), 39 deletions(-) delete mode 100644 src/Platforms/CPU/SIMD/alignment.config.h diff --git a/CMakeLists.txt b/CMakeLists.txt index eebc5204e1..d20aab97b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,6 +144,8 @@ SET(OHMMS_DIM 3 CACHE STRING "Select physical dimension") SET(OHMMS_INDEXTYPE int) MESSAGE(STATUS "defining the float point precision") SET(OHMMS_PRECISION_FULL double) +set(QMC_CLINE 32 CACHE STRING "Cache/SIMD alignment in bytes") + IF(QMC_CUDA) SET(QMC_MIXED_PRECISION 1 CACHE BOOL "Enable/disable mixed precision") SET(OHMMS_PRECISION double) diff --git a/src/Platforms/CPU/SIMD/aligned_allocator.hpp b/src/Platforms/CPU/SIMD/aligned_allocator.hpp index f992cd0e87..e1d60a21f3 100644 --- a/src/Platforms/CPU/SIMD/aligned_allocator.hpp +++ b/src/Platforms/CPU/SIMD/aligned_allocator.hpp @@ -16,9 +16,17 @@ #include #include -#include "alignment.config.h" +#include "config.h" #include "Mallocator.hpp" +#if defined(__INTEL_COMPILER) + #define ASSUME_ALIGNED(x) __assume_aligned(x,QMC_CLINE) +#elif defined(__GNUC__) && !defined(__ibmxl__) + #define ASSUME_ALIGNED(x) (x) = (__typeof__(x)) __builtin_assume_aligned(x,QMC_CLINE) +#else + #define ASSUME_ALIGNED(x) +#endif + namespace qmcplusplus { template diff --git a/src/Platforms/CPU/SIMD/alignment.config.h b/src/Platforms/CPU/SIMD/alignment.config.h deleted file mode 100644 index 578df2230e..0000000000 --- a/src/Platforms/CPU/SIMD/alignment.config.h +++ /dev/null @@ -1,37 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////// -// This file is distributed under the University of Illinois/NCSA Open Source License. -// See LICENSE file in top directory for details. -// -// Copyright (c) 2020 QMCPACK developers. -// -// File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory -// -// File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory -////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef ALIGNMENT_CONFIG_H -#define ALIGNMENT_CONFIG_H - -#if defined(__INTEL_COMPILER) - #if defined(__AVX512F__) - #define QMC_CLINE 64 - #define ASSUME_ALIGNED(x) __assume_aligned(x,64) - #else - #define QMC_CLINE 32 - #define ASSUME_ALIGNED(x) __assume_aligned(x,32) - #endif -#elif defined(__GNUC__) && !defined(__ibmxl__) - #if defined(__AVX512F__) - #define QMC_CLINE 64 - #define ASSUME_ALIGNED(x) (x) = (__typeof__(x)) __builtin_assume_aligned(x,64) - #else - #define QMC_CLINE 32 - #define ASSUME_ALIGNED(x) (x) = (__typeof__(x)) __builtin_assume_aligned(x,32) - #endif -#else - #define QMC_CLINE 32 - #define ASSUME_ALIGNED(x) -#endif - -#endif diff --git a/src/Platforms/CUDA/CUDAallocator.hpp b/src/Platforms/CUDA/CUDAallocator.hpp index a31c8c3d38..cbb334e776 100644 --- a/src/Platforms/CUDA/CUDAallocator.hpp +++ b/src/Platforms/CUDA/CUDAallocator.hpp @@ -27,7 +27,6 @@ #include "cudaError.h" #include "allocator_traits.hpp" #include "CUDAfill.hpp" -#include "CPU/SIMD/alignment.config.h" namespace qmcplusplus { diff --git a/src/config.h.cmake.in b/src/config.h.cmake.in index 21f7cb13d6..09f75944c5 100644 --- a/src/config.h.cmake.in +++ b/src/config.h.cmake.in @@ -68,6 +68,9 @@ /* Define the full precision: double, long double */ #cmakedefine OHMMS_PRECISION_FULL @OHMMS_PRECISION_FULL@ +/* Define Cache/SIMD alignment in bytes */ +#cmakedefine QMC_CLINE @QMC_CLINE@ + /* Define to 1 if precision is mixed, only for the CPU code */ #cmakedefine MIXED_PRECISION @MIXED_PRECISION@