Open liamsemeria opened 1 year ago
thanks!
this code is by @manasij7479 -- Manasij please look into it
Hi @liamsemeria, std::srand(0) is intentional.
We want a diverse set of deterministic inputs, and not random ones.
Random ones would make it difficult to test pruning success and failures.
Please send a fix for the rest of your points!
Ok cool PR is up for the other fixes I mentioned!
Currently the generated inputs for dataflow pruning looks something like this:
Inputs 0,1,-1, 2147483647, -2147483647 are "special inputs" and the remaining values are supposed to be random. Since by default only 10 inputs are tested for each candidate, random inputs are never used. The special inputs are generated twice because there are currently two implementations.
In Pruning.cpp line 761:
And right below it:
Commenting out either of these only adds the special inputs once which avoids testing the same input multiple times and makes room for random inputs. Random Inputs are generated In Pruning.cpp line 817:
The random inputs are never reseeded, but changing
std::srand(0);
tostd::srand(time(0));
makes random numbers work as intended. Also, when generating small inputs they have a range of 0 to I->Width. This leads to a lot of repeat values since MaxTries is 100 and you could only be generating values from 0 to 8 for example. Maybe replacingCache[I] = {llvm::APInt(I->Width, std::rand() % I->Width)};
with something likeCache[I] = {llvm::APInt(I->Width, std::rand() % (some value depending on width))};
would lead to less repeat values?I have fixes for these issues and can make a pull request. I just wanted to double check first since I didn't know which implementation of adding special inputs to remove since they both work. I also made the max amount of inputs to try user controllable which is part of a TODO on Pruning.cpp line 246. No changes were made to the range of random small inputs but I fixed the srand.