Skip to content

Generic atomic operation#2005

Merged
adayton1 merged 43 commits into
developfrom
feature/atomic_op
Jun 3, 2026
Merged

Generic atomic operation#2005
adayton1 merged 43 commits into
developfrom
feature/atomic_op

Conversation

@adayton1

@adayton1 adayton1 commented Mar 16, 2026

Copy link
Copy Markdown
Member

Summary

  • This PR is a feature
  • It does the following:
    • Adds a generic atomic operation at the request of myself

Use case:

  • Computing a signed distance field, and need to do the atomic comparison based on the absolute value but update with the signed value.
  • I think I've also seen the need for an atomic multiply in an application.

Design discussion points:

  • atomicGeneric seemed like a less overloaded name than atomicOperation (which would confuse vendors)
  • To keep the interface and implementation simple, no short-circuiting or custom comparison functions were added in this merge request. They could be added in a future merge request.

Comment thread include/RAJA/policy/desul/atomic.hpp Outdated
Comment thread include/RAJA/policy/desul/atomic.hpp Outdated
Comment thread include/RAJA/policy/desul/atomic.hpp Outdated
Comment thread include/RAJA/policy/desul/atomic.hpp Outdated
@adayton1 adayton1 changed the title Draft: Generic atomic operation Generic atomic operation May 29, 2026
@adayton1 adayton1 requested review from a team, MrBurmark and johnbowen42 May 29, 2026 00:38
Comment thread include/RAJA/util/TypeConvert.hpp
Comment thread include/RAJA/policy/cuda/atomic.hpp Outdated
Comment thread include/RAJA/policy/desul/atomic.hpp Outdated
Comment thread include/RAJA/policy/atomic_builtin.hpp
@adayton1 adayton1 requested a review from rhornung67 June 1, 2026 16:23

@johnbowen42 johnbowen42 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.

I have two nits: one where we could replace a static_assert with concepts, one where extra performance could be gained with an early exit condition inside the generic loop. However I think this is fine as is and don't want to block

Comment thread include/RAJA/util/TypeConvert.hpp
old = desul::atomic_compare_exchange(acc, expected, operation(expected),
raja_default_desul_order {},
raja_default_desul_scope {});
} while (!RAJA::util::bit_equal(old, expected));

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.

we might get a small performance hit here whenever we perform an operation like <=, where early exit is possible upon equality

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, that's likely. I was thinking we could add an overload with short-circuiting in a future PR.

@adayton1 adayton1 merged commit 2b575f1 into develop Jun 3, 2026
21 checks passed
@adayton1 adayton1 deleted the feature/atomic_op branch June 3, 2026 18:56
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.

4 participants