You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current GetValuePtr routine is modestly under-specified with regards to the validity of the returned pointer, and what it means if a model does or doesn't return a pointer for a given variable.
I propose making the semantics more explicit through the use of variable sets. Specifically, variables in a set bmi:stable_pointers can be expected to yield pointers that are valid for the lifetime of the model, and variables in a set bmi:transient_pointers can be expected to yield pointers that are valid for immediate use, but may be invalidated by calls to any other BMI routine on that model.
The example I have in mind for transient pointers are variables backed by a dynamically resizable array or vector, which exist in at least a few models I'm aware of.
Transient pointers would still be useful in model coupling, calling auto ptr = modelA->GetValuePtr("foo"); modelB->SetValue("foo", ptr); and avoiding an intermediate buffer and copy in the driver.
I initially thought of this as a possible extension. It could still be, if we want to drop GetValuePtr() from the core BMI specification, and have one fewer thing for 'naive' model implementers to stub out with BMI_FAILURE returns or throws of "unimplemented" exceptions. In that case, I would tentatively propose to call the sets bmi:pointers:stable and bmi:pointers:transient, with the extension called bmi:pointers
PhilMiller
added
the
BMIv3
Prospective elements of a future major version 3 of the BMI specification.
label
Nov 4, 2025
PhilMiller
changed the title
BMIv3: Variable Pointers
Extension: Variable Pointers
Nov 4, 2025
In discussion with Austin, I concluded that GetValuePtr, however it persists, should be in an extension and not core BMI. Among other things, this potentially plays into core BMI being more fully compatible with Rust bindings that follow its strict semantics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BMIv3Prospective elements of a future major version 3 of the BMI specification.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current
GetValuePtrroutine is modestly under-specified with regards to the validity of the returned pointer, and what it means if a model does or doesn't return a pointer for a given variable.I propose making the semantics more explicit through the use of variable sets. Specifically, variables in a set
bmi:stable_pointerscan be expected to yield pointers that are valid for the lifetime of the model, and variables in a setbmi:transient_pointerscan be expected to yield pointers that are valid for immediate use, but may be invalidated by calls to any other BMI routine on that model.The example I have in mind for transient pointers are variables backed by a dynamically resizable array or vector, which exist in at least a few models I'm aware of.
Transient pointers would still be useful in model coupling, calling
auto ptr = modelA->GetValuePtr("foo"); modelB->SetValue("foo", ptr);and avoiding an intermediate buffer and copy in the driver.