Skip to content
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
78 changes: 78 additions & 0 deletions .agents/docs/2026-10-20-add-xsimd-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Add xsimd 14.3.0 as compat.xsimd

## Source and shape

- Upstream: <https://github.com/xtensor-stack/xsimd>.
- Version: `14.3.0`, the newest stable tag observed with
`git ls-remote --tags --refs`.
- License: BSD-3-Clause.
- Shape: Form B, header-only. Upstream's CMake INTERFACE target exposes
`include/`, where consumers find `<xsimd/xsimd.hpp>`. The package therefore
uses `include_dirs = { "*/include" }` and a trivial anchor C TU to provide a
buildable `xsimd` lib target.
- No features: xsimd has no optional compilable library component. The
optional `xtl::xcomplex` integration is an external dependency plus the
consumer's `XSIMD_ENABLE_XTL_COMPLEX` define, which a sources-only feature
cannot express.

Upstream requires C++14. The descriptor compiles its own anchor as C++; the
consumer test uses the workspace default C++23 mode and a direct smoke test
also verifies that the public header compiles in C++14 mode.

## Download and mirror

- GLOBAL:
`https://github.com/xtensor-stack/xsimd/archive/refs/tags/14.3.0.tar.gz`
- SHA-256:
`b3d50e7a73fbf4642ceef30131c93414901d69eee41c2a5302db650b03e2c792`
- The archive was downloaded twice and compared byte-for-byte; both copies had
the same digest.
- No verified `mcpp-res/xsimd` release is available, so the descriptor uses the
upstream plain-string URL fallback rather than inventing a CN resource.

## Automatic updates

The package meets the automatic-update criteria: it has GitHub numeric tags,
stable archive URLs, identical resources on all declared platforms, and future
versions do not require a build-recipe change. `extensions.autoupdate` uses the
unprefixed `${version}` tag spelling and the GitHub tag-archive URL template.
The initial URL and SHA-256 live once in the `versions` table and all three
platforms reference that entry.

## Test member

`tests/examples/xsimd/` is registered in the root workspace. It asserts:

- the selected default architecture is supported and available;
- runtime architecture discovery contains the default architecture;
- unaligned load, batch addition and unaligned store preserve every lane;
- batch square root and horizontal reduction return the expected scalar.

Every assertion affects the process exit status (`return ok ? 0 : 1`).

## Verification

- Pinned mcpp `2026.10.1.2`:
`mcpp xpkg parse --all-os pkgs/c/compat.xsimd.lua` reports `parse OK` for
linux, macosx, and windows.
- Pinned cold GCC run:
`mcpp test -p xsimd --cache off` reports
`test result ok. 1 passed; 0 failed`, running
`xsimd OK width=4 arch=sse2`.
- Pinned cold LLVM run:
`mcpp test -p xsimd --toolchain llvm@22.1.8 --cache off` reports the same
successful test with Clang.
- The public header and test compile and run directly under both C++14 and
C++23 (GCC 16.2.1), covering xsimd's documented language floor.
- Full relevant lint passed: Lua syntax, mirror URL policy, package identity,
reserved namespaces, cross-package references, platform parity, and
duplicate versions. All 255 descriptors parse with the pinned mcpp.
- The pinned updater's 11 repository tests pass. Its declaration coverage audit
reports `All 83 GitHub-direct descriptors declared; all existing versions
unchanged`, including `compat:xsimd`.
- `xpkgindex_update inspect --package compat:xsimd` accepts the declaration and
reports the three platform URLs plus the automatic-update template.
- `xpkgindex_update check --package compat:xsimd` reports
`status = "up-to-date"`, current version `14.3.0`, discovery by upstream
tags. An earlier attempt hit the unauthenticated GitHub API rate limit; the
check passed after the documented reset window.
1 change: 1 addition & 0 deletions mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ members = [
"tests/examples/websocket-features",
"tests/examples/websocket-tls",
"tests/examples/tray",
"tests/examples/xsimd",
"tests/examples/xxhash",
"tests/examples/yaml-cpp",
"tests/examples/yaml-cpp-v080",
Expand Down
68 changes: 68 additions & 0 deletions pkgs/c/compat.xsimd.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
local versions = {
["14.3.0"] = {
url = "https://github.com/xtensor-stack/xsimd/archive/refs/tags/14.3.0.tar.gz",
sha256 = "b3d50e7a73fbf4642ceef30131c93414901d69eee41c2a5302db650b03e2c792",
},
}

-- Form B inline descriptor for xsimd — C++ wrappers over SIMD intrinsics.
--
-- HEADER-ONLY: upstream's CMake target exposes exactly `include/`, where
-- consumers find `<xsimd/xsimd.hpp>`. Tests, examples, benchmarks and docs
-- stay outside the include path. A trivial anchor TU gives mcpp a buildable
-- `xsimd` lib target, following compat.gtl / compat.safeint.
--
-- LANGUAGE FLOOR: xsimd requires C++14 (`target_compile_features` says
-- `cxx_std_14`). The package's own anchor is compiled as C++; consumers may
-- use any C++14-or-newer language mode supported by their toolchain.
--
-- No features: xsimd is header-only and has no optional compilable library
-- component. Its optional `xtl::xcomplex` integration is controlled by the
-- consumer's XSIMD_ENABLE_XTL_COMPLEX define and an external xtl dependency,
-- so a sources-only feature cannot represent it and is deliberately omitted.
--
-- No verified mcpp-res mirror is available, so the upstream URL is a plain
-- string rather than a fabricated GLOBAL/CN resource table.
package = {
spec = "1",
namespace = "compat",
name = "xsimd",
description = "C++ wrappers for SIMD intrinsics with runtime architecture selection (header-only)",
licenses = {"BSD-3-Clause"},
repo = "https://github.com/xtensor-stack/xsimd",
type = "package",

extensions = {
autoupdate = {
tag = "${version}",
url = "https://github.com/xtensor-stack/xsimd/archive/refs/tags/${tag}.tar.gz",
},
},

xpm = {
linux = {
["14.3.0"] = versions["14.3.0"],
},
macosx = {
["14.3.0"] = versions["14.3.0"],
},
windows = {
["14.3.0"] = versions["14.3.0"],
},
},

mcpp = {
language = "c++23",
import_std = false,
c_standard = "c11",
include_dirs = { "*/include" },
generated_files = {
["mcpp_generated/xsimd_anchor.c"] = [==[
int mcpp_compat_xsimd_headers_anchor(void) { return 0; }
]==],
},
sources = { "mcpp_generated/xsimd_anchor.c" },
targets = { ["xsimd"] = { kind = "lib" } },
deps = { },
},
}
8 changes: 8 additions & 0 deletions tests/examples/xsimd/mcpp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# xsimd test project: exercise the default architecture selected from the
# consumer's compiler flags, plus load/store and useful batch operations.
[package]
name = "xsimd-tests"
version = "0.1.0"

[dependencies.compat]
xsimd = "14.3.0"
55 changes: 55 additions & 0 deletions tests/examples/xsimd/tests/xsimd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// compat.xsimd — assert architecture discovery, unaligned load/store, batch
// arithmetic, math functions and horizontal reduction through the public API.
#include <xsimd/xsimd.hpp>

#include <array>
#include <cmath>
#include <cstddef>
#include <cstdio>

int main() {
using batch_type = xsimd::batch<float>;
constexpr std::size_t width = batch_type::size;

std::array<float, width> left{};
std::array<float, width> right{};
std::array<float, width> sum{};
for (std::size_t i = 0; i < width; ++i) {
left[i] = static_cast<float>(i + 1);
right[i] = static_cast<float>(2 * i + 2);
}

bool ok = true;
auto check = [&](bool condition, const char* what) {
if (!condition) {
std::printf("FAIL: %s\n", what);
ok = false;
}
};

check(xsimd::default_arch::supported(),
"default architecture is supported by the compiler");
check(xsimd::default_arch::available(),
"default architecture is available on this CPU");
check(xsimd::available_architectures().has(xsimd::default_arch{}),
"runtime discovery includes the default architecture");

auto lhs = xsimd::load_unaligned(left.data());
auto rhs = xsimd::load_unaligned(right.data());
xsimd::store_unaligned(sum.data(), lhs + rhs);
for (std::size_t i = 0; i < width; ++i) {
check(sum[i] == left[i] + right[i],
"unaligned load, batch addition and store");
}

auto square_roots = xsimd::sqrt(lhs * lhs);
const float expected = static_cast<float>(width * (width + 1) / 2);
check(std::fabs(xsimd::reduce_add(square_roots) - expected) < 0.001f,
"batch math and horizontal reduction");

if (ok) {
std::printf("xsimd OK width=%zu arch=%s\n",
width, xsimd::default_arch::name());
}
return ok ? 0 : 1;
}
Loading