Skip to content

Conversation

@openroad-ci
Copy link
Collaborator

Fixes #9062

Problem

Bazel //test/orfs/mock-array:MockArray_8x8_flat_cts_openroad_test suffers from intermittent failure.

Root-cause

1. Cause of intermittent failure

Non-determinism (ND) described and resolved in parallaxsw/OpenSTA#359

  • Pointer-based ordered map caused the ND issue.
  • Once the PR is merged and OR uses the latest STA, this intermittent failure will be resolved.

2. Inappropriate test case setup in test/orfs/mock-array/power.tcl

Test case sequence

  1. Report power based on VCD dump (total_power_1)
  2. Dump the computed activity in an user activity file (Same value as the VCD flow)
  3. Read the user activity file and report power again based on the user activity (total_power_2)
  4. Checker 1: total_power_1 != total_power_2
  • If the user activity loading fails, the switching activity values based on VCD flow will not be overwritten by the user activity annotation and total_power_1 == total_power_2. Checker 1 is intended to catch such failure.
  1. Checker 2: abs(total_power_1 - total_power_2) < 1e-3
  • If there is a large error, something is wrong in the user activity flow.

So the test case expects a slight error b/w total_power_1 and total_power_2.
But this is not a robust test because the two total_power numbers are basically computed from the same set of float numbers.
The slight difference comes from the float-accumulation error because the float-accumulation sequences are different b/w VCD flow and user-activity flow.

Because of the ND-issue,

  • Sometimes (~70%), total_power_1 and total_power_2 are slightly different --> TEST PASS
  • Otherwise (~30%), total_power_1 and total_power_2 are exactly the same --> TEST FAIL

Solution

Once parallaxsw/OpenSTA#359 is merged, the intermittent failure will be gone.

But more robust test is to modify the test case in order to produce slightly different power numbers b/w VCD and user-activity flows.

If we intentionally distort a few of the activity factors (for the first three pins) in user-activity file, VCD and user-activity flows will use different sets of float numbers to accumulate and total_power_1 != total_power_2 will be satisfied always.
This is more robust test and the test case will not suffer from the ND issue.

…kArray_8x8_flat_cts_openroad_test to avoid non-determinism issue

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an intermittent test failure by introducing a deliberate distortion in the test data. The change modifies the power.tcl test script to alter the duty cycle for a few pins, ensuring a predictable difference in power calculations and making the test more robust. My review identified a minor discrepancy between the intended logic (modifying three pins) and the implementation (modifying four pins), and I've provided a suggestion to correct it.


# Fixed duty to 0.55 for the first three pins to give a slight distortion
# to see the slightly different power numbers b/w VCD and user activity flows.
if { $vcd_pin_count <= 3 } {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The condition $vcd_pin_count <= 3 will modify the duty cycle for the first four pins (when vcd_pin_count is 0, 1, 2, and 3). However, the comment on line 38 and the pull request description state that only the first three pins should be modified. To align with the intended logic, the condition should be changed to $vcd_pin_count < 3.

  if { $vcd_pin_count < 3 } {

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

clang-tidy review says "All clean, LGTM! 👍"

@jhkim-pii
Copy link
Contributor

jhkim-pii commented Jan 9, 2026

Once user activity file is read, the total power is recomputed and std::map<const Instance*, PowerResult> instance_powers_; is filled with different PowerResult objects w/ different pointer addresses (but the same float numbers).
--> float accumulation sequence changes
--> Slightly different total power for each run (ND issue).

My fix will produce different PowerResult numbers b/w VCD and user activity flows. So the test will pass always regardless of the ND issue.

@jhkim-pii
Copy link
Contributor

FWIW,

Before the ND issue fix (by parallaxsw/OpenSTA#359)

  • Total power numbers change in each run.
#1
Total power from VCD: 0.23302288353443146
Total power from user activity: 0.23302286863327026

#2
Total power from VCD: 0.23302291333675385
Total power from user activity: 0.23302288353443146

#3
Total power from VCD: 0.23302264511585236
Total power from user activity: 0.23302267491817474

After the ND issue fix

  • The same total power numbers in each run.
#1
Total power from VCD: 0.23309363424777985
Total power from user activity: 0.2330935150384903

#2
Total power from VCD: 0.23309363424777985
Total power from user activity: 0.2330935150384903

#3
Total power from VCD: 0.23309363424777985
Total power from user activity: 0.2330935150384903

@jhkim-pii jhkim-pii requested a review from maliberty January 9, 2026 16:06
@jhkim-pii
Copy link
Contributor

@oharboe FYI

@oharboe
Copy link
Collaborator

oharboe commented Jan 9, 2026

Thanks for curating and coming up with arobust plan for this use case.

@maliberty
Copy link
Member

@oharboe I thought the goal of this check was to compare sta computed activities to vcd ones not vcd to itself. Is that intentional?

@oharboe
Copy link
Collaborator

oharboe commented Jan 9, 2026

The goal is to run through the flow to check that all.pins are annotated simulation works, etc. A demonstration and basic smoke test of the use case.

I intended to check that default pin activations power and vcd power was different.

If I get around to it, I would switch to generating .saif and using read_saif

@maliberty
Copy link
Member

@jhkim-pii could you change the test to "I intended to check that default pin activations power and vcd power was different." rather than " distort a few of the activity factors "

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@jhkim-pii
Copy link
Contributor

If we intentionally distort a few of the activity factors (for the first three pins) in user-activity file, VCD and user-activity flows will use different sets of float numbers to accumulate and total_power_1 != total_power_2 will be satisfied always.

@jhkim-pii could you change the test to "I intended to check that default pin activations power and vcd power was different." rather than " distort a few of the activity factors "

Unfortunately, I cannot edit the PR description above because the author is openroad-ci. If you have the edit permission, you can do it.

I updated the comment in test/orfs/mock-array/power.tcl.

@maliberty
Copy link
Member

I don't see a change from distortion to the intended approach.

@jhkim-pii
Copy link
Contributor

jhkim-pii commented Jan 10, 2026

Oh, I misunderstood before.

I reduced the duty and activity values by a factor or 10, and added read back checks for the annotated activity values.

…k the annotated activity values

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty
Copy link
Member

I mean if you don't read a vcd then sta will estimate activities and the corresponding power. That should be the first value. Then read the vcd and compute the power as the second value. Those should never match without any trickery.

@oharboe
Copy link
Collaborator

oharboe commented Jan 10, 2026

I mean if you don't read a vcd then sta will estimate activities and the corresponding power. That should be the first value. Then read the vcd and compute the power as the second value. Those should never match without any trickery.

Yes, this was my plan with this test

- Removed the tricky 10x activity scale down.
- Added estimated power report before reading VCD.
- Refactored for better readability.

Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
@jhkim-pii
Copy link
Contributor

  • Removed the tricky 10x activity scale down.
  • Reported the estimated power before reading VCD.
  • Refactored power.tcl for better readability.
  • Changed file name from load_power.tcl to load_mock_array.tcl.

@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@@ -57,6 +57,3 @@ for { set x 0 } { $x < $::env(ARRAY_COLS) } { incr x } {
check_log_for_warning log.txt
}
}

set vcd_file $::env(VCD_STIMULI)
log_cmd read_vcd -scope TOP/MockArray $vcd_file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Removed the read_vcd command.
  • load_power.tcl name does not look good. So renamed it, and the renaming caused more changes in other files.

@maliberty maliberty merged commit 17710f5 into The-OpenROAD-Project:master Jan 15, 2026
13 checks passed
@maliberty maliberty deleted the secure-fix-test-orfs-mock-array branch January 15, 2026 00:38
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

Successfully merging this pull request may close these issues.

mock-array is unstable

4 participants