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

Test case fail only with optimized build #4

Open
BerengerBerthoul opened this issue Sep 6, 2024 · 0 comments
Open

Test case fail only with optimized build #4

BerengerBerthoul opened this issue Sep 6, 2024 · 0 comments

Comments

@BerengerBerthoul
Copy link
Member

The test case update_ids_in_range_after_permutation__non_involutive fails with specific compilation options :

CXXFLAGS="-O3 -g -DNDEBUG -ftree-vectorize -ftree-loop-vectorize -fvect-cost-model=unlimited -ftree-loop-optimize -march=native -fopenmp-simd -mtune=intel -mprefer-vector-width=512"
CMAKE_BUILD_TYPE: Release

With CPU type : Sapphire rapids (Intel(R) Xeon(R) Platinum 8468)

Note that it does not fail on AMD Zen3 with similar compiler options.

Simplifying the test to narrow it down, we get :

TEST_CASE("narrowing the problem") {
  int* permutation = new int[3];
  permutation[0] = 2; 
  permutation[1] = 0; 
  permutation[2] = 1; 

  std::vector<int> ids = {-1, 0,2,1};
  //std::vector<int> ids(4);
  //ids[0] = -1;
  //ids[1] =  0;
  //ids[2] =  2;
  //ids[3] =  1;

  for (int i=0; i<4; ++i) {
    if ( ids[i] >= 0 ) {
      ids[i] = permutation[ids[i]];
    }
  }

  CHECK( ids[0] == -1 );
  CHECK( ids[1] ==  2 ); // Fail: returns 0
  CHECK( ids[2] ==  1 );
  CHECK( ids[3] ==  0 );
}

If the vector is initialized with an initializer list, the test fails. However, with an element-based initialization (such as with the commented lines), it works...

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

No branches or pull requests

1 participant