Skip to content

Conversation

jblomer
Copy link
Contributor

@jblomer jblomer commented Sep 22, 2025

Allow for std::atomic --> T (or compatible) automatic conversion and vice versa.

@jblomer jblomer self-assigned this Sep 22, 2025
@jblomer jblomer force-pushed the ntuple-evolution-atomic branch from 9ce4dd5 to ac97cad Compare September 22, 2025 14:48
Copy link

github-actions bot commented Sep 22, 2025

Test Results

     5 files       5 suites   1d 1h 42m 54s ⏱️
 3 667 tests  3 662 ✅ 4 💤 1 ❌
17 598 runs  17 596 ✅ 0 💤 2 ❌

For more details on these failures, see this check.

Results for commit e44c16a.

♻️ This comment has been updated with latest results.

Copy link
Member

@hahnjo hahnjo left a comment

Choose a reason for hiding this comment

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

In principle, the changes look neat and small. I'm wondering about the error case: When reconciling an RAtomicField with something on-disk that is not std::atomic, we unconditionally delegate to the item field. Is that maybe confusing for the error message? (I don't have an immediate idea how to do it better)

@jblomer jblomer force-pushed the ntuple-evolution-atomic branch from ef0feec to 1aec090 Compare October 6, 2025 14:08
@jblomer jblomer requested a review from bellenot as a code owner October 6, 2025 14:08
@jblomer jblomer requested review from hahnjo and silverweed October 6, 2025 14:08
@@ -37,7 +37,7 @@ ROOT_GENERATE_DICTIONARY(RNTupleDescriptorDict ${CMAKE_CURRENT_SOURCE_DIR}/RNTup
DEPENDENCIES RIO)

ROOT_ADD_GTEST(ntuple_endian ntuple_endian.cxx LIBRARIES ROOTNTuple)
ROOT_ADD_GTEST(ntuple_evolution_type ntuple_evolution_type.cxx LIBRARIES ROOTNTuple)
ROOT_ADD_GTEST(ntuple_evolution_type ntuple_evolution_type.cxx LIBRARIES ROOTNTuple atomic)
Copy link
Member

Choose a reason for hiding this comment

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

Should this use ROOT_ATOMIC_LIBS? Not sure...

Copy link
Contributor Author

@jblomer jblomer Oct 6, 2025

Choose a reason for hiding this comment

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

I think it shouldn't. ROOT_ATOMIC_LIBS contains atomic when it is needed even for the normally lock-free cases, AFAICS.

Copy link
Member

Choose a reason for hiding this comment

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

That is not my reading. It seems to be literally that ROOT_ATOMIC_LIBS is the result of a test that checks whether std::atomic linking require an 'atomic' library or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On my machine (arch), ROOT_ATOMIC_LIBS is empty. If I use is_lock_free(), I need -latomic. For std::atomic<int> etc. I don't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But there is obviously an issue on EL platforms. I'm confused. Perhaps the check for ROOT_ATOMIC_LIBS is incomplete/buggy for arch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now, my suggestion is to merge the PR without testing std::atomic<MyClass> and to add that later once we figured out the linking issue.

Copy link
Member

Choose a reason for hiding this comment

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

That is fine as long as we keep track either by opening the next/new PR 'right away' or opening an issue.

if (fieldDesc.GetTypeName().rfind("std::atomic<", 0) == 0) {
EnsureMatchingOnDiskField(fieldDesc, kDiffTypeName).ThrowOnError();
} else {
fSubfields[0]->SetOnDiskId(GetOnDiskId());
Copy link
Member

Choose a reason for hiding this comment

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

I am missing (not seeing) the part of the code that make sure that the non-atomic value is compatible with the in memory type. For example:

auto v10 = reader->GetView<CustomAtomicNotLockFree>("atomicInt");

in the new test should still throw.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new test already tests that reader->GetView<std::atomic<std::byte>>("atomicInt") throws.

The RFieldBase::ConnectPageSource() method is recursive. Checking of the inner type is done when it comes to calling the method on the subfield.

Copy link
Member

Choose a reason for hiding this comment

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

The new test already tests that reader->GetView<std::atomicstd::byte>("atomicInt") throws.

Is that exercising the branch on line 1101 or 1103?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, the existing line tests something different. I added reader->GetView<CustomAtomicNotLockFree>("atomicInt") (which throws as expected).

@jblomer jblomer force-pushed the ntuple-evolution-atomic branch 3 times, most recently from 7023151 to e44c16a Compare October 7, 2025 20:13
Allow for std::atomic<T> --> T (or compatible) automatic conversion and
vice versa.
@jblomer jblomer force-pushed the ntuple-evolution-atomic branch from e44c16a to f75eb4b Compare October 9, 2025 14:13
@jblomer jblomer requested review from pcanal and hahnjo October 9, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants