Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
681abe78
Commit
681abe78
authored
Oct 18, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimized code a little
parent
3ba21975
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
gpu_data.cpp
dlib/dnn/gpu_data.cpp
+3
-2
gpu_data.h
dlib/dnn/gpu_data.h
+1
-1
No files found.
dlib/dnn/gpu_data.cpp
View file @
681abe78
...
@@ -49,9 +49,9 @@ namespace dlib
...
@@ -49,9 +49,9 @@ namespace dlib
void
gpu_data
::
void
gpu_data
::
copy_to_host
()
const
copy_to_host
()
const
{
{
wait_for_transfer_to_finish
();
if
(
!
host_current
)
if
(
!
host_current
)
{
{
wait_for_transfer_to_finish
();
std
::
cout
<<
"cudaMemcpy to host"
<<
std
::
endl
;
std
::
cout
<<
"cudaMemcpy to host"
<<
std
::
endl
;
CHECK_CUDA
(
cudaMemcpy
(
data_host
.
get
(),
data_device
.
get
(),
data_size
*
sizeof
(
float
),
cudaMemcpyDeviceToHost
));
CHECK_CUDA
(
cudaMemcpy
(
data_host
.
get
(),
data_device
.
get
(),
data_size
*
sizeof
(
float
),
cudaMemcpyDeviceToHost
));
host_current
=
true
;
host_current
=
true
;
...
@@ -78,9 +78,9 @@ namespace dlib
...
@@ -78,9 +78,9 @@ namespace dlib
size_t
new_size
size_t
new_size
)
)
{
{
wait_for_transfer_to_finish
();
if
(
new_size
==
0
)
if
(
new_size
==
0
)
{
{
wait_for_transfer_to_finish
();
data_size
=
0
;
data_size
=
0
;
host_current
=
true
;
host_current
=
true
;
device_current
=
true
;
device_current
=
true
;
...
@@ -89,6 +89,7 @@ namespace dlib
...
@@ -89,6 +89,7 @@ namespace dlib
}
}
else
if
(
new_size
!=
data_size
)
else
if
(
new_size
!=
data_size
)
{
{
wait_for_transfer_to_finish
();
data_size
=
new_size
;
data_size
=
new_size
;
host_current
=
true
;
host_current
=
true
;
device_current
=
true
;
device_current
=
true
;
...
...
dlib/dnn/gpu_data.h
View file @
681abe78
...
@@ -21,7 +21,7 @@ namespace dlib
...
@@ -21,7 +21,7 @@ namespace dlib
- if (data_device) then
- if (data_device) then
- data_device == a pointer to size() floats in device memory.
- data_device == a pointer to size() floats in device memory.
- if (there might be an active
transfer between host and
device) then
- if (there might be an active
async transfer from host to
device) then
- have_active_transfer == true
- have_active_transfer == true
- We use the host_current and device_current bools to keep track of which
- We use the host_current and device_current bools to keep track of which
...
...
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