Skip to content

Add tests for CPU features#1287

Open
AntoinePrv wants to merge 5 commits intoxtensor-stack:masterfrom
AntoinePrv:cpu-test
Open

Add tests for CPU features#1287
AntoinePrv wants to merge 5 commits intoxtensor-stack:masterfrom
AntoinePrv:cpu-test

Conversation

@AntoinePrv
Copy link
Copy Markdown
Contributor

  • Add cpu_feature test
  • Add run CPU tests in CI

- name: Test
run: |
# Set CPU feature test expectations
# Assuming the runner always has AVX (independent of compilation option)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can theoritically check that through grep -E '\<avx\>' /proc/cpuinfo

run: cmake --build _build
- name: Set CPU feature test expectations
run: |
echo "XSIMD_TEST_CPU_ASSUME_SSE4_2=0" >> "$GITHUB_ENV"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't that be easy to just not set it instead of setting it to zero?


#include "xsimd/xsimd.hpp"

#define CHECK_IMPLICATION(a, b) CHECK_UNARY(!(a) || (b))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow that reminds me of my old logic lessons ^^!

xsimd::x86_cpu_features cpu;

// SSE implication chain
CHECK_IMPLICATION(cpu.sse4_2(), cpu.sse4_1());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that make sense to use this to also check the is_base_of type relationship?

void check_env_flag(const char* env_var, const char* feature_name, bool actual)
{
const char* val = std::getenv(env_var);
if (val)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if (const char* val = ...)

const char* val = std::getenv(env_var);
if (val)
{
// Doctest struggles with string litteras and const char *
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO(c++20): use std::format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants