Skip to content

Commit

Permalink
Merge pull request #9062 from cms-sw/140x-eigen-flags
Browse files Browse the repository at this point in the history
[14.0.X] Using consistent Eigen alignment settings
  • Loading branch information
smuzaffar authored Mar 13, 2024
2 parents 8b7f4e3 + d7a4d12 commit 29f2742
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmssw-vectorization.file
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
%define vectorized_packages zlib fastjet tensorflow-sources tensorflow OpenBLAS rivet gbl
%define vectorized_packages zlib fastjet tensorflow-sources tensorflow OpenBLAS rivet gbl lwtnn opencv pytorch
%{expand:%(for t in %{vectorized_packages} ; do echo Requires: $t; for v in %{package_vectorization}; do echo Requires: ${t}_${v}; done; done)}
13 changes: 7 additions & 6 deletions gbl.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@
## INCLUDE cpp-standard
%define tag 59c2d99ea96bc739321fd251096504c91467be24
Source: git+https://gitlab.desy.de/claus.kleinwort/general-broken-lines.git?obj=main/%{tag}&export=%{n}-%{realversion}&output=/%{n}-%{realversion}.tgz
Source99: scram-tools.file/tools/eigen/env

BuildRequires: cmake
Requires: eigen

%prep
%setup -q -n %{n}-%{realversion}
##Remove these line when new version of gbl is released
grep -q 'CMAKE_CXX_STANDARD *11' cpp/CMakeLists.txt
sed -i -e 's|CMAKE_CXX_STANDARD *11|CMAKE_CXX_STANDARD %{cms_cxx_standard}|' cpp/CMakeLists.txt

%build
rm -rf build
mkdir build
cd build
source %{_sourcedir}/env

cmake ../cpp \
-DCMAKE_INSTALL_PREFIX=%{i} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DEIGEN3_INCLUDE_DIR=${EIGEN_ROOT}/include/eigen3 \
-DSUPPORT_ROOT=False \
%ifarch x86_64
-DCMAKE_CXX_FLAGS="-DEIGEN_MAX_ALIGN_BYTES=64 -msse3"
%else
-DCMAKE_CXX_FLAGS="-DEIGEN_MAX_ALIGN_BYTES=64"
%endif
%ifarch x86_64
-DCMAKE_CXX_FLAGS="$CMS_EIGEN_CXX_FLAGS -msse3"
%else
-DCMAKE_CXX_FLAGS="$CMS_EIGEN_CXX_FLAGS"
%endif

make %{makeprocesses}

Expand Down
11 changes: 9 additions & 2 deletions lwtnn.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
### RPM external lwtnn 2.13
### RPM external lwtnn 2.14.1
## INCLUDE cpp-standard

Source: https://github.com/lwtnn/lwtnn/archive/v%{realversion}.tar.gz
Source99: scram-tools.file/tools/eigen/env

BuildRequires: ninja cmake
Requires: eigen boost

Expand All @@ -13,11 +15,16 @@ Requires: eigen boost
rm -rf ../build
mkdir ../build
cd ../build
source %{_sourcedir}/env

cmake ../%{n}-%{realversion} \
-G Ninja \
-DCMAKE_CXX_COMPILER="g++" \
-DCMAKE_CXX_FLAGS="-fPIC" \
%ifarch x86_64
-DCMAKE_CXX_FLAGS="-fPIC $CMS_EIGEN_CXX_FLAGS -msse3" \
%else
-DCMAKE_CXX_FLAGS="-fPIC $CMS_EIGEN_CXX_FLAGS" \
%endif
-DCMAKE_INSTALL_PREFIX:PATH="%{i}" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILTIN_BOOST=OFF \
Expand Down
8 changes: 8 additions & 0 deletions opencv.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
%define github_user opencv

Source0: git+https://github.com/%{github_user}/opencv.git?obj=%{branch}/%{tag}&export=%{n}-%{realversion}&output=/%{n}-%{realversion}-%{tag}.tgz
Source99: scram-tools.file/tools/eigen/env

BuildRequires: cmake ninja
Requires: python3 py3-numpy libpng libjpeg-turbo libtiff zlib eigen OpenBLAS

Expand All @@ -16,6 +18,7 @@ Requires: python3 py3-numpy libpng libjpeg-turbo libtiff zlib eigen OpenBLAS
rm -rf ../build
mkdir ../build
cd ../build
source %{_sourcedir}/env

cmake ../%{n}-%{realversion} \
-GNinja \
Expand All @@ -30,6 +33,11 @@ cmake ../%{n}-%{realversion} \
-DPYTHON3_INCLUDE_DIR:PATH="${PYTHON3_ROOT}/include/python%{cms_python3_major_minor_version}" \
-DPYTHON3_LIBRARY:FILEPATH="${PYTHON3_ROOT}/lib/libpython%{cms_python3_major_minor_version}.so" \
-DCMAKE_BUILD_TYPE=Release \
%ifarch x86_64
-DCMAKE_CXX_FLAGS="$CMS_EIGEN_CXX_FLAGS -msse3" \
%else
-DCMAKE_CXX_FLAGS="$CMS_EIGEN_CXX_FLAGS" \
%endif
-DCMAKE_PREFIX_PATH="${LIBPNG_ROOT};${LIBTIFF_ROOT};${LIBJPEG_TURBO_ROOT};${ZLIB_ROOT};${PYTHON3_ROOT};${PY2_NUMPY_ROOT};${PY3_NUMPY_ROOT};${EIGEN_ROOT};${OPENBLAS_ROOT}"

ninja -v %{makeprocesses}
Expand Down
7 changes: 7 additions & 0 deletions pytorch.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Source: git+https://github.com/pytorch/pytorch.git?obj=%{branch}/%{tag}&export=%{n}-%{realversion}&submodules=1&output=/%{n}-%{realversion}.tgz
Source1: FindEigen3.cmake
Source2: FindFMT.cmake
Source99: scram-tools.file/tools/eigen/env
Patch0: pytorch-ignore-different-cuda-include-dir
Patch1: pytorch-missing-braces
Patch2: pytorch-system-fmt
Expand All @@ -25,6 +26,7 @@ Requires: cuda cudnn OpenBLAS zlib protobuf fmt py3-pybind11
%build
cp %{_sourcedir}/FindEigen3.cmake %{_sourcedir}/FindFMT.cmake cmake/Modules/
rm -rf ../build && mkdir ../build && cd ../build
source %{_sourcedir}/env

USE_CUDA=OFF
%if "%{cmsos}" != "slc7_aarch64"
Expand Down Expand Up @@ -74,6 +76,11 @@ cmake ../%{n}-%{realversion} \
-DUSE_SYSTEM_FXDIV=ON \
-DUSE_SYSTEM_PYBIND11=ON \
-DUSE_SYSTEM_BENCHMARK=ON \
%ifarch x86_64
-DCMAKE_CXX_FLAGS="$CMS_EIGEN_CXX_FLAGS -msse3" \
%else
-DCMAKE_CXX_FLAGS="$CMS_EIGEN_CXX_FLAGS" \
%endif
-DCMAKE_PREFIX_PATH="%{cmake_prefix_path}" \
-DPYTHON_EXECUTABLE=${PYTHON3_ROOT}/bin/python3

Expand Down
3 changes: 1 addition & 2 deletions scram-tools.file/tools/eigen/eigen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<environment name="INCLUDE" default="$EIGEN_BASE/include/eigen3"/>
</client>
<runtime name="ROOT_INCLUDE_PATH" value="$INCLUDE" type="path"/>
<flags CPPDEFINES="EIGEN_DONT_PARALLELIZE"/>
<flags CPPDEFINES="EIGEN_MAX_ALIGN_BYTES=64"/>
<flags CXXFLAGS="@CMS_EIGEN_CXX_FLAGS@"/>
<flags CUDA_FLAGS="--diag-suppress 20014"/>
</tool>
1 change: 1 addition & 0 deletions scram-tools.file/tools/eigen/env.file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export CMS_EIGEN_CXX_FLAGS="-DEIGEN_DONT_PARALLELIZE -DEIGEN_MAX_ALIGN_BYTES=64"
2 changes: 2 additions & 0 deletions scram-tools.file/tools/eigen/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash -e
source ${SCRAM_TOOL_SOURCE_DIR}/env.file
5 changes: 5 additions & 0 deletions scram-tools.file/tools/lwtnn/vectorized.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<tool name="lwtnn_@TOOL_VECTORIZATION@" version="@TOOL_VERSION@">
<client>
<environment name="@TOOL_VECTORIZATION_KEY@_LIBDIR" default="@TOOL_ROOT@/lib"/>
</client>
</tool>
5 changes: 5 additions & 0 deletions scram-tools.file/tools/opencv/vectorized.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<tool name="opencv_@TOOL_VECTORIZATION@" version="@TOOL_VERSION@">
<client>
<environment name="@TOOL_VECTORIZATION_KEY@_LIBDIR" default="@TOOL_ROOT@/lib"/>
</client>
</tool>
5 changes: 5 additions & 0 deletions scram-tools.file/tools/pytorch/vectorized.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<tool name="pytorch_@TOOL_VECTORIZATION@" version="@TOOL_VERSION@">
<client>
<environment name="@TOOL_VECTORIZATION_KEY@_LIBDIR" default="@TOOL_ROOT@/lib"/>
</client>
</tool>
3 changes: 3 additions & 0 deletions vectorization/cmsdist_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"OpenBLAS",
"rivet",
"gbl",
"lwtnn",
"opencv",
"pytorch",
]
VALID_TARGETS = {
"nehalem": "-march=nehalem",
Expand Down

0 comments on commit 29f2742

Please sign in to comment.