Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs267
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
recolic-hust
cs267
Commits
4650565d
There was an error fetching the commit references. Please try again later.
Unverified
Commit
4650565d
authored
6 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
sync
parent
7e33fd4d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hw2/appendable_array.cuh
+2
-2
2 additions, 2 deletions
hw2/appendable_array.cuh
hw2/cuda_ass.cuh
+7
-0
7 additions, 0 deletions
hw2/cuda_ass.cuh
with
9 additions
and
2 deletions
hw2/appendable_array.cuh
+
2
−
2
View file @
4650565d
...
@@ -125,11 +125,11 @@ namespace rlib {
...
@@ -125,11 +125,11 @@ namespace rlib {
__device__
bool
dev_apply_new_cap
()
{
__device__
bool
dev_apply_new_cap
()
{
void
*
new_mem
=
nullptr
;
void
*
new_mem
=
nullptr
;
(
cudaMalloc
(
&
new_mem
,
cap
));
rlib
::
dev_cuda_assert
(
cudaMalloc
(
&
new_mem
,
cap
));
if
(
new_mem
==
nullptr
)
if
(
new_mem
==
nullptr
)
return
false
;
return
false
;
if
(
mem
!=
nullptr
)
{
if
(
mem
!=
nullptr
)
{
(
memcpy
(
new_mem
,
mem
,
m_size
*
sizeof
(
T
)));
rlib
::
dev_cuda_assert
(
memcpy
(
new_mem
,
mem
,
m_size
*
sizeof
(
T
)));
// hope it success.......
// hope it success.......
//(cudaFree(mem)); // let it leak!!! It doesn't matter now.
//(cudaFree(mem)); // let it leak!!! It doesn't matter now.
}
}
...
...
This diff is collapsed.
Click to expand it.
hw2/cuda_ass.cuh
+
7
−
0
View file @
4650565d
...
@@ -6,6 +6,13 @@ namespace rlib {
...
@@ -6,6 +6,13 @@ namespace rlib {
if
(
err
!=
cudaError
::
cudaSuccess
)
if
(
err
!=
cudaError
::
cudaSuccess
)
throw
std
::
runtime_error
(
"CUDA runtime error: err code is "
+
std
::
to_string
(
err
)
+
", please refer to https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1g3f51e3575c2178246db0a94a430e0038"
);
throw
std
::
runtime_error
(
"CUDA runtime error: err code is "
+
std
::
to_string
(
err
)
+
", please refer to https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1g3f51e3575c2178246db0a94a430e0038"
);
}
}
__device__
bool
dev_cuda_assert
(
cudaError_t
err
)
{
if
(
err
!=
cudaError
::
cudaSuccess
)
{
printf
(
"FUCK! CUDA runtime error: %d"
,
err
);
return
false
;
}
return
true
;
}
}
}
...
...
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
register
or
sign in
to comment