Crafter.Math/project.cpp

67 lines
2.6 KiB
C++
Raw Normal View History

2026-04-29 19:01:52 +02:00
import std;
import Crafter.Build;
namespace fs = std::filesystem;
using namespace Crafter;
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
constexpr std::array<std::string_view, 8> mathInterfaces = {
"interfaces/Crafter.Math-Basic",
"interfaces/Crafter.Math",
"interfaces/Crafter.Math-Common",
"interfaces/Crafter.Math-Vector",
"interfaces/Crafter.Math-Intersection",
"interfaces/Crafter.Math-MatrixRowMajor",
"interfaces/Crafter.Math-VectorF16",
"interfaces/Crafter.Math-VectorF32",
};
Configuration cfg;
cfg.path = "./";
cfg.name = "Crafter.Math";
cfg.outputName = "Crafter.Math";
cfg.type = ConfigurationType::LibraryStatic;
2026-04-29 20:16:46 +02:00
ApplyStandardArgs(cfg, args);
2026-04-29 19:01:52 +02:00
{
std::array<fs::path, 8> ifaces;
std::ranges::copy(mathInterfaces, ifaces.begin());
std::array<fs::path, 0> impls = {};
cfg.GetInterfacesAndImplementations(ifaces, impls);
}
2026-05-18 20:33:47 +02:00
auto addTest = [&](std::string_view testName, std::string march, std::string mtune, std::string target = {}) {
2026-04-29 19:01:52 +02:00
Test t;
t.config.path = "./";
2026-05-18 18:03:20 +02:00
t.config.name = std::format("{}-{}", testName, march);
2026-04-29 19:01:52 +02:00
t.config.outputName = t.config.name;
2026-05-18 20:33:47 +02:00
t.config.target = target.empty() ? cfg.target : target;
2026-04-29 19:01:52 +02:00
t.config.type = ConfigurationType::Executable;
t.config.march = march;
t.config.mtune = mtune;
t.config.debug = cfg.debug;
std::array<fs::path, 8> ifaces;
std::ranges::copy(mathInterfaces, ifaces.begin());
2026-05-18 18:03:20 +02:00
std::array<fs::path, 1> impls = { fs::path{std::format("tests/{}", testName)} };
2026-04-29 19:01:52 +02:00
t.config.GetInterfacesAndImplementations(ifaces, impls);
cfg.tests.push_back(std::move(t));
};
2026-05-18 20:33:47 +02:00
const std::string_view target = cfg.target;
const bool isX86 = target.starts_with("x86_64") || target.starts_with("i686");
const bool isRiscv = target.starts_with("riscv");
2026-05-18 18:03:20 +02:00
for (std::string_view name : { "Vector", "Intersection", "Matrix" }) {
2026-05-18 20:33:47 +02:00
if (isX86) {
addTest(name, "sapphirerapids", "native");
addTest(name, "x86-64-v4", "generic");
addTest(name, "x86-64-v3", "generic");
}
if (isRiscv) {
// RISC-V tiers, mirroring the x86 selector: register width is
// picked from the guaranteed VLEN encoded in the march's Zvl*
// suffix. rv64gcv → ZVL128B (matches the RVA23 baseline).
addTest(name, "rv64gcv_zvl512b", "generic");
addTest(name, "rv64gcv_zvl256b", "generic");
addTest(name, "rv64gcv", "generic");
}
2026-05-18 18:03:20 +02:00
}
2026-04-29 19:01:52 +02:00
return cfg;
}