Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the Atomic Sum of Different Types #13078

Closed
wants to merge 2 commits into from

Conversation

matekelemen
Copy link
Contributor

@matekelemen matekelemen commented Jan 31, 2025

AtomicAdd used the same template parameter for both the left and right hand side operands. This PR templates the two operands separately, allowing the left hand side operand's update with a different type.

float target = 0;
double update = 1;
AtomicAdd(target, update);

A use case would be assembly when the local space uses double precision floats while the global space is in single precision.

@reviewers can you please take a close look? I don't think this would be an issue, but I've been wrong about OpenMP before ...

@matekelemen matekelemen added Kratos Core C++ Parallel-SMP Shared memory parallelism with OpenMP or C++ Threads labels Jan 31, 2025
@matekelemen matekelemen self-assigned this Jan 31, 2025
@matekelemen matekelemen requested a review from a team as a code owner January 31, 2025 11:58
matekelemen

This comment was marked as off-topic.

loumalouomega
loumalouomega previously approved these changes Jan 31, 2025
@philbucher
Copy link
Member

I feel like it would be cleaner to solve this "client side"

float target = 0;
double update = 1;
AtomicAdd(target, static_case<float>(update));

@matekelemen
Copy link
Contributor Author

I feel like it would be cleaner to solve this "client side"

float target = 0;
double update = 1;
AtomicAdd(target, static_case<float>(update));

Rust infected you, hasn't it

@matekelemen matekelemen deleted the core/atomic-add-heterogenous-types branch January 31, 2025 13:30
@philbucher
Copy link
Member

I didn't want to write it but yes, it has

It just wont let you do ambiguous stuff, for better or worse...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ Kratos Core Parallel-SMP Shared memory parallelism with OpenMP or C++ Threads
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants