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
57adea26
There was an error fetching the commit references. Please try again later.
Unverified
Commit
57adea26
authored
6 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
bug fix
parent
292211ab
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hw2/appendable_array.cuh
+20
-2
20 additions, 2 deletions
hw2/appendable_array.cuh
with
20 additions
and
2 deletions
hw2/appendable_array.cuh
+
20
−
2
View file @
57adea26
...
...
@@ -74,8 +74,8 @@ namespace rlib {
}
~
appendable_stdlayout_array
()
{
//
if(mem != nullptr)
//
rlib::cuda_assert(cudaFree(mem));
if
(
mem
!=
nullptr
)
rlib
::
cuda_assert
(
cudaFree
(
mem
));
// Never free memory to make program faster.
}
...
...
@@ -89,7 +89,25 @@ namespace rlib {
std
::
memcpy
(
new_mem
,
mem
,
m_size
*
sizeof
(
T
));
mem
=
(
T
*
)
new_mem
;
}
public
:
// Make this class available in cudaManaged memory automatically.
static
void
*
operator
new
(
size_t
size
)
{
void
*
ptr
=
nullptr
;
rlib
::
cuda_assert
(
cudaMallocManaged
(
&
ptr
,
size
));
return
ptr
;
}
static
void
*
operator
new
[](
size_t
size
)
{
return
operator
new
(
size
);
}
static
void
operator
delete
(
void
*
ptr
)
{
rlib
::
cuda_assert
(
cudaFree
(
ptr
));
}
static
void
operator
delete
[](
void
*
ptr
)
{
return
operator
delete
(
ptr
);
}
};
}
#endif
...
...
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