Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ed255f5
Add guidance for claude-code
robtaylor Nov 23, 2025
53c9cd0
CI: No need to run on push to all branches
robtaylor Nov 23, 2025
5b6f3e1
CI: Explictly name runner images
robtaylor Nov 23, 2025
e99c4dd
CI: Cache brew packages
robtaylor Nov 23, 2025
54d21f6
CI: No need to install mingw on macos
robtaylor Nov 23, 2025
5557811
CI: Cache cargo build
robtaylor Nov 23, 2025
c883033
Fix order-dependency in small-signal analysis from IndexSet::remove d…
robtaylor Nov 23, 2025
945cbf5
CI: Enable integration tests
robtaylor Nov 23, 2025
51dc5d9
Fix non-deterministic compilation causing random CI test failures
robtaylor Nov 24, 2025
7dcdec1
Update snapshots
robtaylor Nov 25, 2025
c5f0fc1
Executing cargo +nightly fmt
Kreijstal Jul 21, 2025
d2023c4
Deleting LLVM
Kreijstal Jul 21, 2025
173581d
Adding LLVM18
Kreijstal Jan 10, 2025
800340f
Allow compilation using msys2 toolchain
Kreijstal Nov 1, 2024
0afc220
Creating CI
adrienluitot Nov 30, 2024
a68f9a6
change i8 -> c_char
adrienluitot Dec 2, 2024
8b0f902
Fix: null deref check
Kreijstal Apr 27, 2025
17f1e3a
Update sccache action
Kreijstal Apr 27, 2025
dabb5ed
Change salsa
Kreijstal Jul 21, 2025
f900add
change versions
Kreijstal Jul 21, 2025
9eb13be
compiling under rv64
Kreijstal Jul 22, 2025
51e646d
Linking under Windows now works.
arpadbuermen Sep 16, 2025
ce3cc1e
Ignore .exp files in sources.
arpadbuermen Sep 16, 2025
acc8952
Updated Readme.
arpadbuermen Sep 16, 2025
cb08e73
Fixed formatting so that cargo fmt does not complain.
arpadbuermen Sep 19, 2025
a471d99
Exposed natures, disciplines, and their attributes.
arpadbuermen Oct 9, 2025
6cecfc2
Fixed machete and fmt warnings.
arpadbuermen Oct 9, 2025
139f2da
Added into_raw() for Idx<T>.
arpadbuermen Oct 10, 2025
18ec060
Simplified code that exposes natures and disciplines.
arpadbuermen Oct 10, 2025
f42329e
Exposed node disciplines.
arpadbuermen Oct 10, 2025
8b104f8
Updated Readme.
arpadbuermen Oct 10, 2025
4a78c4c
Exposed unknown/residual natures and units.
arpadbuermen Oct 14, 2025
81ff7a1
Fix LLVM 18 compatibility on macOS ARM64
robtaylor Nov 23, 2025
093c95f
CI: Update for LLVM 18 and enable integration tests
robtaylor Nov 23, 2025
a2367ab
Remove architecture-specific values from OSDI integration test snapshots
robtaylor Nov 23, 2025
1e2cf60
Fix ld64.lld linking on macOS for LLVM 18
robtaylor Nov 23, 2025
a3d2ada
Fix ARM64 SIGSEGV: correct snprintf varargs calling convention
robtaylor Nov 23, 2025
2240264
Merge pull request #16 from robtaylor/better-ci
arpadbuermen Nov 27, 2025
84a6458
Fix most compiler warnings
robtaylor Nov 23, 2025
8ece652
Fix order-dependency in small-signal analysis from IndexSet::remove d…
robtaylor Nov 23, 2025
550cb15
Fix linking of built objects on macos
robtaylor Nov 28, 2025
263a453
CI: Use architecture in cache keys
robtaylor Nov 28, 2025
ad2d1ca
Merge branch 'better-ci' into merge-macos
robtaylor Nov 28, 2025
350fb7d
Merge branches 'fix-compiler-warnings', 'determinism', 'macos-fixes' …
robtaylor Nov 28, 2025
3617c19
Add --allow-analog-in-cond flag for non-standard Verilog-A models
robtaylor Nov 23, 2025
ca84621
Add support for hierarchical module instantiation syntax
robtaylor Dec 1, 2025
c521c8d
Fix crash when compiling models with BoundStep outputs
robtaylor Dec 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 91 additions & 13 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ name: Rust CI
on:
push:
branches:
- '**'
- master
- main
- llvm18
pull_request:
branches:
- '**'
Expand All @@ -26,17 +28,21 @@ jobs:
- name: Setup sccache
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
uses: mozilla-actions/sccache-action@v0.0.9

- name: Configure sccache
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV

- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install cargo-machete
run: cargo install cargo-machete

- name: Run cargo machete
run: cargo machete

Expand All @@ -45,19 +51,37 @@ jobs:
needs: [format, machete]
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
targets: x86_64-pc-windows-gnu

- name: Setup sccache
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
uses: mozilla-actions/sccache-action@v0.0.9

- name: Configure sccache
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV

- name: "Cache cargo"
id: cache-cargo
uses: "actions/cache@v4"
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
save-always: true
key: ${{ runner.os }}-${{runner.arch}}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{runner.arch}}-cargo-

- name: Install LLVM 18 and Windows cross-compilation tools
run: |
wget https://apt.llvm.org/llvm.sh
Expand All @@ -74,28 +98,36 @@ jobs:
# Verify installation
which llvm-lib
llvm-lib --version

- name: Set LLVM environment variables
run: |
echo "LLVM_SYS_181_PREFIX=/usr/lib/llvm-18" >> $GITHUB_ENV
echo "CLANG_PATH=/usr/lib/llvm-18/bin/clang" >> $GITHUB_ENV
echo "PATH=/usr/lib/llvm-18/bin:$PATH" >> $GITHUB_ENV
echo "RUST_BACKTRACE=1" >> $GITHUB_ENV

- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential

- name: Build
run: cargo build --release

- name: Show sccache stats
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
shell: bash
run: ${SCCACHE_PATH} --show-stats
# someone has to fix the errors
# - name: Run Clippy
# run: cargo clippy -- -D warnings

- name: Run tests
run: cargo test --release

- name: Run integration tests
run: cargo test --release --test integration

msys2-build-test:
strategy:
fail-fast: false
Expand Down Expand Up @@ -129,26 +161,44 @@ jobs:
mkdir -p .cargo
echo '[net]' > .cargo/config.toml
echo 'git-fetch-with-cli = true' >> .cargo/config.toml

- name: Cache sccache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/sccache
key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-${{runner.arch}}-sccache-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-sccache-
${{ runner.os }}-${{runner.arch}}-sccache-

- name: Locate and configure sccache
shell: msys2 {0}
run: |
# export SCCACHE_PATH=$(which sccache)
# echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=${SCCACHE_PATH}" >> $GITHUB_ENV

- name: "Cache cargo"
id: cache-cargo
uses: "actions/cache@v4"
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
save-always: true
key: ${{ runner.os }}-${{runner.arch}}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{runner.arch}}-cargo-

- name: Run cargo
shell: msys2 {0}
run: cargo build --release
#- name: Show sccache stats
# if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
# shell: msys2 {0}
# run: $SCCACHE_PATH --show-stats

- name: Run tests
shell: msys2 {0}
run: cargo test --release
Expand All @@ -158,28 +208,56 @@ jobs:
fail-fast: false
matrix:
include:
- arch: arm64
macos: 13
- arch: x86_64
macos: 13
runs-on: macos-${{ matrix.macos }}
# Intel
- image: macos-15-intel
# ARM64
- image: macos-15
- image: macos-14

runs-on: ${{ matrix.image }}
needs: [format, machete]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pkg-config with Homebrew
- name: Install dependencies with Homebrew
uses: tecolicom/actions-use-homebrew-tools@v1
with:
tools: pkg-config sccache llvm@18
cache: yes

- name: Set LLVM environment variables
run: |
brew install pkg-config mingw-w64 sccache llvm
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
echo "$(brew --prefix llvm@18)/bin" >> $GITHUB_PATH
echo "LLVM_SYS_181_PREFIX=$(brew --prefix llvm@18)" >> $GITHUB_ENV
echo "RUST_BACKTRACE=1" >> $GITHUB_ENV
echo "RUN_DEV_TESTS=1" >> $GITHUB_ENV

- name: sccache setup
run: |
# echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=$(which sccache)" >> $GITHUB_ENV


- name: "Cache cargo"
id: cache-cargo
uses: "actions/cache@v4"
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
save-always: true
key: ${{ runner.os }}-${{runner.arch}}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{runner.arch}}}-cargo-

- name: Build
run: cargo build --release

- name: Run tests
run: cargo test --release

- name: Run integration tests
run: cargo test --release --test integration

174 changes: 174 additions & 0 deletions ARCH_SPECIFIC_VALUES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# Architecture-Specific Values in OSDI Snapshots

## Problem

Multiple values in the OSDI descriptor snapshots are architecture-dependent because they represent memory offsets and sizes calculated by LLVM using platform-specific ABI rules.

## Architecture-Dependent Values

### 1. `instance size` ✓ CONFIRMED
**Line**: `instance size 1864`

**Source**: `openvaf/osdi/src/metadata.rs:376`
```rust
let instance_size =
LLVMABISizeOfType(*target_data, NonNull::from(inst_data.ty).as_ptr()) as u32;
```

**Why**: LLVM calculates struct size including padding based on platform ABI alignment rules.

**Example differences**:
- BSIM3: 4512 (x86-64) vs 4568 (ARM64) = +56 bytes
- amplifier: 224 (x86-64) vs 240 (ARM64) = +16 bytes

---

### 2. `residual` offset values ✓ CONFIRMED
**Line**: `residual 256 264 4294967295 4294967295`

The four numbers are:
1. resist_residual_off
2. react_residual_off
3. resist_limit_rhs_off
4. react_limit_rhs_off

**Source**: `openvaf/osdi/src/inst_data.rs:472-489`
```rust
pub fn residual_off(..., target_data: &LLVMTargetDataRef) -> Option<u32> {
let off = unsafe {
LLVMOffsetOfElement(*target_data, NonNull::from(self.ty).as_ptr(), elem)
} as u32;
Some(off)
}
```

**Why**: Offsets into the instance data struct depend on field alignment.

**Example differences** (diode.va):
- Node A resist: 248 (old) → 256 (new)
- Node A react: 256 (old) → 264 (new)

---

### 3. `react_ptr` values ✓ CONFIRMED
**Line**: `jacobian (A, A) JacobianFlags(...) react_ptr = 120`

**Source**: `openvaf/osdi/src/metadata.rs:265-267`
```rust
let mut jacobian_ptr_react_offset = unsafe {
LLVMOffsetOfElement(*target_data, NonNull::from(inst_data.ty).as_ptr(), JACOBIAN_PTR_REACT)
} as u32;
```

**Why**: Offset to the reactive jacobian pointer array in the instance struct.

**Note**: Often `4294967295` (u32::MAX) meaning "not present", but when present, the value is arch-specific.

---

### 4. `model size` ⚠️ TO VERIFY
**Line**: `model size 120`

**Source**: `openvaf/osdi/src/metadata.rs:378`
```rust
let model_size =
LLVMABISizeOfType(*target_data, NonNull::from(model_data.ty).as_ptr()) as u32;
```

**Status**: Similar to instance_size, this is likely arch-specific. Need to verify if it changes.

---

## Non-Architecture-Specific Values

These values **should be** the same across platforms:

- Parameter names, types, descriptions
- Node names, units, is_flow flags
- Number of terminals, parameters, states
- Jacobian flags (which entries are const, have react, etc.)
- Nature and discipline information
- runits strings (units of flow/potential)

## Solutions

### Option 1: Remove All Arch-Specific Values from Snapshots ✅ RECOMMENDED

**Implementation**:
1. Comment out or skip these in Debug formatter:
- `instance size`
- `model size`
- `residual` offset numbers (but keep the field itself as marker)
- `react_ptr` values (but keep the field)

2. Replace with markers:
```
node "A" units = "V", runits = "A"
residual <arch-specific offsets>
jacobian (A, A) JacobianFlags(...) react_ptr = <arch-specific>
instance size <arch-specific>
model size <arch-specific>
```

**Pros**:
- Clean, platform-agnostic snapshots
- Still test the important structural information
- Easy to maintain

**Cons**:
- Lose some regression detection for layout changes
- Can't detect if offsets become corrupted

---

### Option 2: Test Field Count/Types Instead of Offsets

Instead of testing exact offsets, verify:
- Number of fields is correct
- Field types are correct
- Field order is correct

This would require a different test approach entirely.

---

### Option 3: Normalize to Field Index

Instead of printing byte offsets, print field indices:
```
residual field=12 field=13 field=MAX field=MAX
```

This would be arch-independent but still verify structure.

**Pros**:
- Still verifies layout without being arch-specific
- Detects field ordering changes

**Cons**:
- Requires code changes to track field indices
- Less directly readable

---

## Recommended Action

**Go with Option 1**: Remove arch-specific numeric values from snapshots.

Modified output would look like:
```
node "A" units = "V", runits = "A"
residual
jacobian (A, A) JacobianFlags(JACOBIAN_ENTRY_RESIST | JACOBIAN_ENTRY_REACT)
...
0 states
has bound_step false
```

We remove:
- The four residual offset numbers
- The `react_ptr = XXX` values
- The `instance size XXX` line
- The `model size XXX` line

This preserves all the semantically important information while being platform-independent.
Loading
Loading