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

dft: fix crossplatform inconsistencies #6509

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

donn
Copy link
Contributor

@donn donn commented Jan 12, 2025

  • dft::ScanArchitect: Use a stable sort for scan cells within buckets. Also added a debugPrint to preview the buckets.
    • This is necessary as otherwise two scan elements with identical bit widths and clock domains's order is undefined and a place for inconsistency between platforms.
  • dft::ClockDomain::getClockDomainId: Uses the FNV1a hash algorithm which unlike std::hash is not implementation-dependent and will return an identical hash across all platforms.
    • This is necessary as C++ maps sort not by in the insertion order, but by the key order, e.g., the hash's absolute value. Yep.
  • dft::GetClockDomainHashFn: Now simply uses getClockDomainId for the NoMix mode.
    • To avoid code duplication.
  • Updated DFT tets to reflect new sort ordinals.

DFT tests confirmed returning an identical result on both macOS and Linux on aarch64.

Resolves #6411

@donn donn force-pushed the dft_os_inconsistency branch from 80ed7ea to 68e0a69 Compare January 12, 2025 11:17
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/dft/src/clock_domain/ClockDomain.cpp Outdated Show resolved Hide resolved
@donn donn force-pushed the dft_os_inconsistency branch from bb912d2 to bfe369a Compare January 12, 2025 11:23
Copy link
Contributor

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

1 similar comment
Copy link
Contributor

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

src/dft/src/architect/ScanArchitect.cpp Outdated Show resolved Hide resolved
src/dft/src/clock_domain/ClockDomain.cpp Outdated Show resolved Hide resolved
src/dft/src/clock_domain/ClockDomain.cpp Show resolved Hide resolved
src/dft/test/scan_architect_clock_mix_sky130.tcl Outdated Show resolved Hide resolved
@donn donn force-pushed the dft_os_inconsistency branch 2 times, most recently from 2967e18 to 56edc63 Compare January 13, 2025 09:12
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/dft/src/clock_domain/ClockDomain.cpp Outdated Show resolved Hide resolved
src/dft/src/clock_domain/ClockDomain.cpp Outdated Show resolved Hide resolved
@donn donn force-pushed the dft_os_inconsistency branch from 756ab89 to df45145 Compare January 13, 2025 09:21
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/dft/src/clock_domain/ClockDomain.cpp Outdated Show resolved Hide resolved
* dft::ScanArchitect: Use a stable sort for scan cells within buckets. Also added a debugPrint to preview the buckets.
  * This is necessary as otherwise two scan elements with identical bit widths and clock domains's order is undefined and a place for inconsistency between platforms.
* dft::ClockDomain::getClockDomainId: Uses the FNV1a hash algorithm which unlike std::hash is not implementation-dependent and will return an identical hash across all platforms.
  * This is necessary as C++ maps sort not by in the insertion order, but by the key order, e.g., the hash's absolute value. Yep.
* dft::GetClockDomainHashFn: Now simply uses `getClockDomainId` for the NoMix mode.
  * To avoid code duplication.
* Updated DFT tets to reflect new sort ordinals.

---

DFT tests confirmed returning an identical result on both macOS and Linux on aarch64.

Signed-off-by: Mohamed Gaber <[email protected]>
@donn donn force-pushed the dft_os_inconsistency branch from df45145 to 1a20416 Compare January 13, 2025 10:01
@donn donn requested a review from maliberty January 13, 2025 10:02
@donn
Copy link
Contributor Author

donn commented Jan 13, 2025

@maliberty boost::hash_combine assumes you're using boost::hash which is implementation-dependent, and boost::hash_detail::hash_mix doesn't appear to be in the version of boost the CI builds with. I've just left it as an XOR.

Copy link
Contributor

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

@maliberty
Copy link
Member

std::hash is used throughout OR so I'm curious why only this one place needs fixing. This feels like either a deeper issue or a very small Band-Aid.

@donn
Copy link
Contributor Author

donn commented Jan 14, 2025

@maliberty ScanArchitect uses std::map, which will sort the clock domains, and thus the chains, by the absolute value of the hash.

@maliberty
Copy link
Member

@maliberty ScanArchitect uses std::map, which will sort the clock domains, and thus the chains, by the absolute value of the hash.

What map are you referring to? Your answer only potentially explains why this change is needed and doesn't address my more general question.

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.

dft::ScanArchitect not cross-OS deterministic?
2 participants