Skip to content

Add hipObjGetVersion(), and take the docs version from CMake - #251

Merged
derobins merged 1 commit into
developfrom
derobins/api_call
Oct 17, 2026
Merged

derobins merged 1 commit into
developfrom
derobins/api_call

Conversation

@derobins

Copy link
Copy Markdown
Collaborator

Add hipObjGetVersion(), which returns the running library's major, minor, and patch version as numbers, like hipFile's hipFileGetVersion(). A NULL argument skips that part, and it doesn't need hipObjInit(). A program can compare the numbers with the HIPOBJ_VERSION_* macros to check that the library it loaded can be used with the header it was compiled with, without parsing hipObjGetVersionString()'s text.

The new get-version example shows how. It prints both versions and exits with status 1 if they're incompatible. It's installed with the other examples, and it needs no GPU, so ctest runs it as hipobj-example-get-version. The tests check the values against the header, every combination of NULL arguments, agreement with hipObjGetVersionString(), calls before, during, and after initialization, and calls from a callback and from many threads.

Other versioning changes:

  • HIPOBJ_LIBRARY_VERSION is no longer a cache variable. A cache entry is written only on the first configure, so a version bump didn't reach an existing build directory: the soname, packages, and docs kept the old version while the header had the new one.
  • docs/conf.py takes its version from CMake (@PROJECT_VERSION@) instead of a hardcoded copy.
  • Comments in CMakeLists.txt say that the version must match the header's macros, which hipobj-install checks, and that the soname has only the major version, so minor and patch releases must not break the ABI, except while the major version is 0.

Add hipObjGetVersion(), which returns the running library's major, minor,
and patch version as numbers, like hipFile's hipFileGetVersion(). A NULL
argument skips that part, and it doesn't need hipObjInit(). A program can
compare the numbers with the HIPOBJ_VERSION_* macros to check that the
library it loaded can be used with the header it was compiled with,
without parsing hipObjGetVersionString()'s text.

The new get-version example shows how. It prints both versions and exits
with status 1 if they're incompatible. It's installed with the other
examples, and it needs no GPU, so ctest runs it as
hipobj-example-get-version. The tests check the values against the
header, every combination of NULL arguments, agreement with
hipObjGetVersionString(), calls before, during, and after
initialization, and calls from a callback and from many threads.

Other versioning changes:

- HIPOBJ_LIBRARY_VERSION is no longer a cache variable. A cache entry is
  written only on the first configure, so a version bump didn't reach an
  existing build directory: the soname, packages, and docs kept the old
  version while the header had the new one.
- docs/conf.py takes its version from CMake (@PROJECT_VERSION@) instead
  of a hardcoded copy.
- Comments in CMakeLists.txt say that the version must match the
  header's macros, which hipobj-install checks, and that the soname has
  only the major version, so minor and patch releases must not break the
  ABI, except while the major version is 0.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor
Security scan found no critical or high findings on lines changed by this pull request

View the security scan run for complete reports.

“New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

Static review found only a minor changelog omission and no blocking correctness issues; builds and tests were not run.

1 open issue
What changed in this PR

Adds numeric runtime version queries to hipObject and keeps build and documentation versions synchronized.

Changes:

  • Adds hipObjGetVersion() with nullable outputs and no initialization requirement.
  • Adds a compatibility-check example and API/concurrency tests.
  • Removes cached library versioning and derives the documentation version from CMake.
File Description
test/​unit/​test-thread-safety.cpp Tests concurrent and callback version queries.
test/​unit/​test-api-args.cpp Tests values, null arguments, and initialization independence.
test/​install/​run-package-test.cmake Checks example packaging.
test/​install/​run-install-test.cmake Clarifies why installed examples aren't run.
src/​hipobj.cpp Implements numeric version queries.
include/​hipobj.h Declares and documents the API.
examples/​README.md Documents the compatibility example.
examples/​get-version.cpp Demonstrates runtime compatibility checks.
examples/​CMakeLists.txt Builds and registers the example test.
examples/​CMakeLists.install.cmake Builds the installed example as C++11.
docs/​conf.py Uses CMake's project version.
docs/​architecture.rst Lists the new initialization-independent API.
CMakeLists.txt Removes version caching and explains ABI expectations.
cmake/​HIPOBJInstall.cmake Installs the new example source.
cmake/​HIPOBJDocumentation.cmake Updates the configuration comment.
CHANGELOG.md Announces the API and example.

Review effort: Balanced

Comment thread CHANGELOG.md
@derobins
derobins merged commit 359edd8 into develop Oct 17, 2026
37 checks passed
@derobins
derobins deleted the derobins/api_call branch October 17, 2026 22:02
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.

2 participants