Skip to content

Test case fail only with optimized build #4

@BerengerBerthoul

Description

@BerengerBerthoul

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions