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

[Lang] Adds @.atomic and a few implementations #410

Merged
merged 6 commits into from
Oct 25, 2020
Merged

Conversation

dmed256
Copy link
Member

@dmed256 dmed256 commented Oct 25, 2020

Description

Adds @atomic for atomic support

Serial and OpenMP modes should be able to do any @atomic operation.

  • Serial: Doesn't need any implementation
  • OpenMP: Leverages #pragma omp atomic and #pragma omp critical

For the GPU modes, we have some basic implementations done. Here base types includes int, float, and double. The rest should be coming out soon!

Mode (int) -- (int) ++ (base types) += (base types) -= Atomic blocks
CUDA ✔️ ✔️ ✔️ ✔️ -
HIP ✔️ ✔️ ✔️ ✔️ -
OpenCL - - - - -
Metal - - - - -

Examples

Checkout the reduction example (04_reduction) where we showcase using @shared and @atomic for two ways to do reductions.

Basic atomic expressions

@atomic i += 1;
@atomic ++i;

Atomic regions

@atomic {
  i += 1;
  i += 1;
}

@codecov
Copy link

codecov bot commented Oct 25, 2020

Codecov Report

Merging #410 into main will decrease coverage by 0.03%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #410      +/-   ##
==========================================
- Coverage   76.34%   76.30%   -0.04%     
==========================================
  Files         240      241       +1     
  Lines       18425    18545     +120     
==========================================
+ Hits        14066    14151      +85     
- Misses       4359     4394      +35     
Impacted Files Coverage Δ
src/lang/expr/expr.cpp 49.49% <0.00%> (-2.09%) ⬇️
src/lang/expr/exprNode.cpp 76.92% <ø> (ø)
src/lang/modes/cuda.cpp 66.34% <15.00%> (-32.10%) ⬇️
src/lang/builtins/attributes/atomic.cpp 96.15% <96.15%> (ø)
src/lang/builtins/attributes/tile.cpp 92.61% <100.00%> (ø)
src/lang/modes/openmp.cpp 89.58% <100.00%> (+8.10%) ⬆️
src/lang/parser.cpp 86.56% <100.00%> (+0.01%) ⬆️
src/lang/specialMacros.cpp 59.48% <0.00%> (ø)
src/tools/sys.cpp 65.31% <0.00%> (+0.16%) ⬆️
... and 2 more

@dmed256 dmed256 changed the title [Lang] Adds @.atomic [Lang] Adds @.atomic and a few implementations Oct 25, 2020
@dmed256 dmed256 merged commit b82fbdd into main Oct 25, 2020
@dmed256 dmed256 deleted the lang/add-atomics branch October 25, 2020 02:59
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.

1 participant