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 9 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.
59 changes: 59 additions & 0 deletions recipes/x86_64_level/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
microarchitecture:
- x86_64
- x86_64_v2
- x86_64_v3
- x86_64_v4
isuruf marked this conversation as resolved.
Show resolved Hide resolved
- nocona
- core2
- nehalem
- westmere
- sandybridge
- ivybridge
- haswell
- broadwell
- skylake
- mic_knl
- skylake_avx512
- cannonlake
- cascadelake
- icelake
- k10
- bulldozer
- piledriver
- steamroller
- excavator
- zen
- zen2
- zen3
mbargull marked this conversation as resolved.
Show resolved Hide resolved

level:
- 1
- 1
- 2
- 3
- 1
- 1
- 2
- 2
- 2
- 2
- 3
- 3
- 3
- 3
- 4
- 3
- 4
- 4
- 1
- 2
- 2
- 2
- 3
- 3
- 3
- 3
h-vetinari marked this conversation as resolved.
Show resolved Hide resolved

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

archs = archspec.cpu.TARGETS

x86_64_levels = {}

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

for arch_name, arch in archs.items():
if arch.family.name != "x86_64":
continue
if arch.parents:
level = max(name_mapping.get(parent.name, 0) for parent in arch.ancestors)
else:
level = 1
x86_64_levels[arch_name] = level
isuruf marked this conversation as resolved.
Show resolved Hide resolved

print("microarchitecture:")
for arch in x86_64_levels.keys():
print(f"- {arch}")
print()
print("level:")
for level in x86_64_levels.values():
print(f"- {level}")
12 changes: 12 additions & 0 deletions recipes/x86_64_level/install_scripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mkdir -p "${PREFIX}"/etc/conda/{de,}activate.d/

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

echo 'export CXXFLAGS="${CXXFLAGS} '$flag'"' >> "${PREFIX}"/etc/conda/activate.d/~activate-x86-64-level.sh
beckermr marked this conversation as resolved.
Show resolved Hide resolved
echo 'export CFLAGS="${CFLAGS} '$flag'"' >> "${PREFIX}"/etc/conda/activate.d/~activate-x86-64-level.sh
echo 'export CPPFLAGS="${CPPFLAGS} '$flag'"' >> "${PREFIX}"/etc/conda/activate.d/~activate-x86-64-level.sh
chmod +x "${PREFIX}"/etc/conda/activate.d/~activate-x86-64-level.sh
isuruf marked this conversation as resolved.
Show resolved Hide resolved
66 changes: 66 additions & 0 deletions recipes/x86_64_level/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package:
isuruf marked this conversation as resolved.
Show resolved Hide resolved
name: x86_64-microarch-level-split
version: {{ level }}

build:
number: 0
isuruf marked this conversation as resolved.
Show resolved Hide resolved
string: 0_{{ microarchitecture }}
isuruf marked this conversation as resolved.
Show resolved Hide resolved
noarch: generic
run_exports:
strong:
- _x86_64-microarch-level >={{ level }}

isuruf marked this conversation as resolved.
Show resolved Hide resolved
outputs:
- name: _x86_64-microarch-level
requirements:
run:
- __archspec 1={{ microarchitecture }}

about:
home: https://github.com/conda-forge/_x86_64-microarch-level-feedstock
summary: 'Meta package to build conda recipes with x86_64 microarchitecture levels'
description: |
The meta-package _x86_64-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 x86_64-microarch-level for using this in conda recipes
license: BSD-3-Clause
license_file: LICENSE.txt

- name: x86_64-microarch-level
script: install_scripts.sh
requirements:
run:
- __unix
isuruf marked this conversation as resolved.
Show resolved Hide resolved
about:
home: https://github.com/conda-forge/_x86_64-microarch-level-feedstock
summary: 'Meta package to build conda recipes with x86_64 microarchitecture levels'
description: |
Use the meta-package x86_64-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.
license: BSD-3-Clause
license_file: LICENSE.txt

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

extra:
recipe-maintainers:
- isuruf