We've started experiencing some heisenbugs in our benchmarks that use <random> 
to generate input data randomly. It's been a bit painful to get a trace, as 
that seems to perturb things enough such that the bug won't trigger. Based on 
what we know, however, we suspect that the below unimplemented instructions 
should be manipulating some FP registers (e.g., ST). The FP registers do not 
seem to be initialized in initCPU(), and therefore we hypothesize that in some 
cases, for example when the values happen to be 0, the denominator has a value 
that can cause the div 0 fault.

The fault is always preceded by this sequence of unimplemented instruction 
warnings, then finally the simulation fails with the following error on a div 
instruction:

warn: instruction 'fsubrp' unimplemented
warn: instruction 'fxam' unimplemented
warn: instruction 'fcomp' unimplemented
warn: instruction 'fyl2xp1' unimplemented
warn: instruction 'fdivrp' unimplemented
warn: instruction 'fistp' unimplemented
panic: fault (Divide-Error) detected @ PC (0x400fad=>0x400fb1).(1=>2)

This can be reproduced on master (fairly reliably) with the following 
microbenchmark:

scons -jN -sQ ./build/X86/gem5.opt
./build/X86/gem5.opt configs/example/se.py -c /path/to/benchmark/binary

Build the following with g++ 5.4.0, flags are -std=c++11.

#include <array>
#include <iostream>
#include <random>

using namespace std;

constexpr int VEC_ELEMS = 64;

struct Point2D
{
    float x;
    float y;
};

int main(int argc, char *argv[])
{
    uniform_real_distribution<float> rng_dist(-1.0, 1.0);
    cout << "here" << endl;

    mt19937 rng;
    array<Point2D, VEC_ELEMS> vec;

    for (int i = 0; i < VEC_ELEMS; ++i) {
        vec[i].x = rng_dist(rng);
        vec[i].y = rng_dist(rng);

        cout << "vec[" << i << "].x = " << vec[i].x << endl;
        cout << "vec[" << i << "].y = " << vec[i].y << endl;
    }
    Return 0;
}
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to