Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
atomicadd_bug_nvhpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jayesh Badwaik
Playground
atomicadd_bug_nvhpc
Commits
91a231a2
Unverified
Commit
91a231a2
authored
May 15, 2023
by
Jayesh Badwaik
Browse files
Options
Downloads
Patches
Plain Diff
+ initial commit
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.cu
+35
-0
35 additions, 0 deletions
main.cu
readme.md
+8
-0
8 additions, 0 deletions
readme.md
reproduce.sh
+22
-0
22 additions, 0 deletions
reproduce.sh
with
65 additions
and
0 deletions
main.cu
0 → 100644
+
35
−
0
View file @
91a231a2
#include
<thrust/device_vector.h>
#include
<thrust/host_vector.h>
#include
<iostream>
template
<
class
It1
>
__global__
void
async_pluseq_impl
(
int
size
,
It1
lhs
)
{
int
i
=
blockIdx
.
x
*
blockDim
.
x
+
threadIdx
.
x
;
int
*
asd
=
lhs
;
if
(
i
<
size
){
int
rhs
=
3
;
atomicAdd
(
&
asd
[
i
],
rhs
);
}
}
int
main
(){
thrust
::
device_vector
<
int
>
v
=
std
::
vector
<
int
>
({
1
,
2
,
3
});
int
size
=
v
.
size
();
int
gridSize
=
(
size
+
255
)
/
256
;
int
blockSize
=
256
;
async_pluseq_impl
<<<
gridSize
,
blockSize
>>>
(
size
,
thrust
::
raw_pointer_cast
(
v
.
data
()));
thrust
::
host_vector
<
int
>
vv
(
v
.
begin
(),
v
.
end
());
for
(
auto
e
:
vv
)
std
::
cout
<<
e
<<
std
::
endl
;
return
0
;
}
This diff is collapsed.
Click to expand it.
readme.md
0 → 100644
+
8
−
0
View file @
91a231a2
# atomicAdd is not working on nvc++
The example takes an array [1,2,3] and atomically adds 3 to every element.
The correct output is 4,5,6. However, due to a misconfiguration, there is a bug
in the computation. The bug comes from NVHPC being configured against native CUDA 11.7 instead of
CUDA 12.
To reproduce the bug, run
`./reproduce`
on any JSC A100 machine.
This diff is collapsed.
Click to expand it.
reproduce.sh
0 → 100644
+
22
−
0
View file @
91a231a2
#!/bin/bash
NVCPPRC
=
$HOME
/.mynvc++rc
if
[
-f
$NVCPPRC
]
;
then
cp
$NVCPPRC
$NVCPPRC
.bak
fi
module load NVHPC/23.1
module load CUDA/11.7
makelocalrc
-x
$NVHPC
/Linux_x86_64/23.1/compilers/bin/
-d
.
cp
localrc ~/.mynvc++rc
nvc++ main.cu
&&
./a.out
module load CUDA/.12.0
makelocalrc
-x
$NVHPC
/Linux_x86_64/23.1/compilers/bin/
-d
.
cp
localrc ~/.mynvc++rc
nvc++ main.cu
&&
./a.out
if
[
-f
$NVCPPRC
.bak
]
;
then
mv
$NVCPPRC
.bak
$NVCPPRC
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment