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

CTG tests are not reproducible #566

Open
trdthg opened this issue Nov 21, 2024 · 4 comments
Open

CTG tests are not reproducible #566

trdthg opened this issue Nov 21, 2024 · 4 comments

Comments

@trdthg
Copy link
Contributor

trdthg commented Nov 21, 2024

After some testing, I found that the tests ctg (without -r option) generated each time is different. This is completely different from what I expected. I also had another person try it, and the results were also different.

I think Tim have already found this issue a few month ago: riscv-software-src/riscv-ctg#115

I'm trying to fix this, but simply appending a line random.seed(10) after all import random statements does not solve the problem. I will check it again.

Update: The reason is the use of set in the code, and I am replacing them with ordered_set


if you don't know what -r option does:

-r, --randomize Randomize Outputs.

If randomization is enabled we use the MinConflictsSolver solver to find solutions.

if self.random:
problem = Problem(MinConflictsSolver())
else:
problem = Problem()

I haven't tested the behavior of MinConflictsSolver, which will use random inside

Originally posted by @trdthg in #565 (comment)


Update: In summary, two steps are needed to solve the problem here

@trdthg trdthg changed the title I thought this is strange too. CTG tests are not reproducible Nov 21, 2024
@trdthg
Copy link
Contributor Author

trdthg commented Nov 26, 2024

But I don't know how to handle random, according to the following code, it seems intentional, or it is necessary because we need to choose one from various solutions

# Randomly choose an instruction
instr = random.choice(instrs_sol)
isa_set += (self.OP_TEMPLATE[instr]['isa'])

However, I think we can set the random seed as a parameter, which ensures reproducibility while also allowing for some randomness

@allenjbaum
Copy link
Collaborator

allenjbaum commented Nov 26, 2024 via email

@trdthg
Copy link
Contributor Author

trdthg commented Nov 26, 2024

I roughly understand what you mean; ctg only generates new test cases for points that have not yet been covered. I will give it a try

I highly recommend adding an option to filter the instruction set, as it would make debugging much simpler, and I will send a PR later, I've already add a --filter=<PATH> for riscof riscv-software-src/riscof#127

@allenjbaum
Copy link
Collaborator

If you are generating tests for a specific extension, you can add a filter,
Riscof generates a test list default, so you could filter it, but there is also an option to skip generating the test list and just test using an existing test list, which probably does what you want.

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

2 participants