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

Add microarch-level packages #24306

Merged
merged 25 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions recipes/x86_64_level/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2023, conda-forge
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of staged-recipes nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104 changes: 104 additions & 0 deletions recipes/x86_64_level/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# This file is auto-generated by recipe/gen.py
microarchitecture:
- x86_64
- nocona
- core2
- k10
- x86_64_v2
- nehalem
- westmere
- sandybridge
- ivybridge
- bulldozer
- piledriver
- steamroller
- x86_64_v3
- haswell
- broadwell
- skylake
- mic_knl
- cannonlake
- excavator
- zen
- zen2
- zen3
mbargull marked this conversation as resolved.
Show resolved Hide resolved
- x86_64_v4
- skylake_avx512
- cascadelake
- icelake
- zen4
- ppc64le
- power8le
- power9le
- power10le

level:
- 1
- 1
- 1
- 1
- 2
- 2
- 2
- 2
- 2
- 2
- 2
- 2
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- 3
- 4
- 4
- 4
- 4
- 4
- 8
- 8
- 9
- 10

family:
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- x86_64
- ppc64le
- ppc64le
- ppc64le
- ppc64le

zip_keys:
- - microarchitecture
- level
- family
47 changes: 47 additions & 0 deletions recipes/x86_64_level/gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import archspec.cpu

archs = archspec.cpu.TARGETS

levels = {}

name_mapping = {
"x86_64": 1,
"x86_64_v2": 2,
"x86_64_v3": 3,
"x86_64_v4": 4,

"ppc64le": 8,
"power8le": 8,
"power9le": 9,
"power10le": 10,
}

for arch_name, arch in archs.items():
if arch.family.name not in ("x86_64", "ppc64le"):
continue
levels[(arch_name, arch.family.name)] = max(
1,
name_mapping.get(arch_name, 0),
*(name_mapping.get(parent.name, 0) for parent in (arch.ancestors or ()))
)

levels = {arch: level for arch, level in sorted(
levels.items(), key=lambda kv: kv[1])}

print(f"# This file is auto-generated by recipe/gen.py with archspec={archspec.__version__}")
print("microarchitecture:")
for arch, _ in levels.keys():
print(f"- {arch}")
print()
print("level:")
for level in levels.values():
print(f"- {level}")
print()
print("family:")
for _, family in levels.keys():
print(f"- {family}")
print("""
zip_keys:
- - microarchitecture
- level
- family""")
17 changes: 17 additions & 0 deletions recipes/x86_64_level/install_scripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
mkdir -p "${PREFIX}"/etc/conda/{de,}activate.d/

if [[ "${family}" == "x86_64" ]]; then
if [[ "${level}" == "1" ]]; then
flag="-march=x86-64"
else
flag="-march=x86-64-v${level}"
fi
elif [[ "${family}" == "ppc64le" ]]; then
flag="-mcpu=${level}"
fi

cat << EOF > "${PREFIX}/etc/conda/activate.d/~activate-${family}-level.sh"
export CXXFLAGS="\${CXXFLAGS} ${flag}"
export CFLAGS="\${CFLAGS} ${flag}"
export CPPFLAGS="\${CPPFLAGS} ${flag}"
EOF
82 changes: 82 additions & 0 deletions recipes/x86_64_level/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{% set number = 0 %}

package:
isuruf marked this conversation as resolved.
Show resolved Hide resolved
name: microarch-level-split
version: {{ level }}

build:
number: {{ number }}
string: {{ number }}_{{ microarchitecture }}
noarch: generic

isuruf marked this conversation as resolved.
Show resolved Hide resolved
outputs:
- name: _{{ family }}-microarch-level
build:
number: {{ number }}
string: {{ number }}_{{ microarchitecture }}
noarch: generic
run_exports:
strong:
- _{{ family }}-microarch-level >={{ level }}
mbargull marked this conversation as resolved.
Show resolved Hide resolved
requirements:
run:
- __archspec 1={{ microarchitecture }}

about:
home: https://github.com/conda-forge/microarch-level-feedstock
summary: 'Meta package to build conda recipes with microarchitecture levels'
description: |
The meta-package _{{ family }}-microarch-level enforces the microarchitecture in the
user system.

Note that a user would need the archspec conda package installed
in the base environment where conda/mamba is run from.
isuruf marked this conversation as resolved.
Show resolved Hide resolved

See {{ family }}-microarch-level for using this in conda recipes
license: BSD-3-Clause
license_file: LICENSE.txt

- name: {{ family }}-microarch-level
script: install_scripts.sh
build:
number: {{ number }}
string: {{ number }}_{{ microarchitecture }}
noarch: generic
run_exports:
strong:
- _{{ family }}-microarch-level >={{ level }}
requirements:
run:
- __unix
isuruf marked this conversation as resolved.
Show resolved Hide resolved
about:
home: https://github.com/conda-forge/microarch-level-feedstock
summary: 'Meta package to build conda recipes with microarchitecture levels'
description: |
Use the meta-package {{ family }}-microarch-level in requirements/build in conda
recipes to set up the compiler flags and set up the virtual package
requirements in the run requirements.

When building packages on CI, level=4 will not be guaranteed, so
you can only use level<=3 to build.

The run_exports only has a lower bound and therefore a level=2
build can be installed on a level=3 user system. A tighter bound
is not added because we want to be able to test both level=2 and
level=3 on a CI machine with level=3.
Therefore in order to prioritise the highest level, use the build
number to prioritise the level.

Only supported on Linux and macOS.
license: BSD-3-Clause
license_file: LICENSE.txt

about:
home: https://github.com/conda-forge/microarch-level-feedstock
summary: 'Meta package to build conda recipes with microarchitecture levels'
license: BSD-3-Clause
license_file: LICENSE.txt

extra:
feedstock-name: microarch-level
recipe-maintainers:
- isuruf