Skip to content

Distribution issue: solve_order prevents other fields from being swizzled #242

@cshafer-tt

Description

@cshafer-tt

Capturing more distribution issues from #240 here.

Scaling up a bit and I'm still seeing distribution issues (unrelated to solve order, that seems to work perfectly now). Can you take a look at this one as well? Let me know if you would rather I file another issue instead.

For this one, I have added a third variable that is basically just an enable/disable that is explicitly disallowed for some formats. I have the constraint below:

  @vsc.constraint
  def c_feature_enable(self):
    with vsc.if_then(self.output_format == FormatType.Float16):
      self.feature_enable == 0

For some reason, this constraint impacts the distribution when output_format is not Float16. I would expect all other formats to have a ~50/50 distribution, but there is significant bias towards disable. Here are the results with and without the above constraint enabled:

With:

feature_enable:
  0: 8895
  1: 1105

Without:

feature_enable:
  0: 5070
  1: 4930

I have attached the updated file.

pyvsc_test.py

Originally posted by @cshafer-tt in #240

@cshafer-tt Yeah, you should probably start a new issue for this.

Looking at the current randomizing method it looks like only the fields listed in the solve_order actually get swizzled.
What you're seeing is two variables getting randomized, and the third one is getting whatever the SMT solver came up with, no randomization. So it could very well be the same value each time if that's what the solver goes to.

if rs.rand_order_l is not None:
# Perform an ordered randomization
if self.debug > 0: print(" following solve-order constraints")
for ro_l in rs.rand_order_l:
swizzled_field |= self.swizzle_field_l(ro_l, rs, bound_m, btor)
else:
if self.debug > 0: print(" following random field order")
swizzled_field |= self.swizzle_field_l(rs.rand_fields(), rs, bound_m, btor)

Plus it looks like there's a max of 4 fields that get randomized/swizzled. I think that's there for performance reasons.

max_swizzle = 4
# Select up to `max_swizzle` fields to swizzle
for i in range(max_swizzle):

If you explicitly include self.feature_enable in the solve_order to then it will get swizzled.

vsc.solve_order(self.output_format, [self.input_format, self.feature_enable])

With that modified solve_order:

With:
feature_enable:
  0: 534
  1: 466

Without:
feature_enable:
  1: 511
  0: 489

Feel free to copy this info into a new issue.
Edit: Oh, there's even a "Reference this in a new issue" button!

Originally posted by @alwilson in #240

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