Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pub
pi
Commits
64e3c3be
Commit
64e3c3be
authored
Oct 24, 2021
by
Neil Gershenfeld
Browse files
CUDA error check
parent
b08534ce
Pipeline
#16404
passed with stage
in 2 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CUDA/cudapi.cu
View file @
64e3c3be
...
...
@@ -28,16 +28,25 @@ void reduce(double *arr) {
uint64_t
len
=
npts
>>
1
;
while
(
1
)
{
reduce_sum
<<<
blocks
,
threads
>>>
(
arr
,
len
);
cudaCheck
(
"reduce"
);
len
=
len
>>
1
;
if
(
len
==
0
)
return
;
}
}
void
cudaCheck
(
string
msg
)
{
cudaError
err
;
err
=
cudaGetLastError
();
if
(
cudaSuccess
!=
err
)
cerr
<<
msg
<<
": "
<<
cudaGetErrorString
(
err
)
<<
endl
;
}
int
main
(
void
)
{
double
harr
[
1
],
*
darr
;
cudaMalloc
(
&
darr
,
npts
*
sizeof
(
double
));
cudaCheck
(
"cudaMalloc"
);
auto
tstart
=
std
::
chrono
::
high_resolution_clock
::
now
();
init
<<<
blocks
,
threads
>>>
(
darr
,
nloop
);
cudaCheck
(
"init"
);
reduce
(
darr
);
cudaDeviceSynchronize
();
auto
tend
=
std
::
chrono
::
high_resolution_clock
::
now
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment