Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
1175a7cc
Commit
1175a7cc
authored
Oct 24, 2015
by
Davis King
Browse files
Added methods to inspect where the current data is at.
parent
be944398
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
8 deletions
+40
-8
dlib/dnn/gpu_data.h
dlib/dnn/gpu_data.h
+6
-0
dlib/dnn/gpu_data_abstract.h
dlib/dnn/gpu_data_abstract.h
+34
-8
No files found.
dlib/dnn/gpu_data.h
View file @
1175a7cc
...
...
@@ -107,6 +107,12 @@ namespace dlib
return
data_device
.
get
();
}
bool
host_ready
(
)
const
{
return
host_current
;
}
bool
device_ready
(
)
const
{
return
device_current
&&
!
have_active_transfer
;
}
size_t
size
()
const
{
return
data_size
;
}
void
swap
(
gpu_data
&
item
)
...
...
dlib/dnn/gpu_data_abstract.h
View file @
1175a7cc
...
...
@@ -43,6 +43,8 @@ namespace dlib
- #size() == 0
- #host() == nullptr
- #device() == nullptr
- #host_ready() == true
- #device_ready() == true
!*/
// This object is not copyable, however, it is movable.
...
...
@@ -57,7 +59,7 @@ namespace dlib
/*!
ensures
- This function does not block.
- if (
the host version of the data is newer than the device's copy
) then
- if (
!device_ready()
) then
- Begins asynchronously copying host data to the device.
- A call to device() that happens before the transfer completes will
block until the transfer is complete. That is, it is safe to call
...
...
@@ -72,15 +74,36 @@ namespace dlib
- #size() == new_size
!*/
bool
host_ready
(
)
const
;
/*!
ensures
- returns true if and only if the host's copy of the data is current. The
host's data is current if there aren't any modifications to the data
which were made on the device side that have yet to be copied to the
host.
!*/
bool
device_ready
(
)
const
;
/*!
ensures
- returns true if and only if the device's copy of the data is current.
The device's data is current if there aren't any modifications to the
data which were made on the host side that have yet to be copied to the
device.
!*/
const
float
*
host
(
)
const
;
/*!
ensures
- returns a pointer to the host memory block of size() contiguous float
values or nullptr if size()==0.
- if (
the host's copy of the data is out of date
) then
- if (
!host_ready()
) then
- copies the data from the device to the host, while this is happening
the call to host() blocks.
- #host_ready() == true
!*/
float
*
host
(
...
...
@@ -89,10 +112,12 @@ namespace dlib
ensures
- returns a pointer to the host memory block of size() contiguous float
values or nullptr if size()==0.
- if (
the host's copy of the data is out of date
) then
- if (
!host_ready()
) then
- copies the data from the device to the host, while this is happening
the call to host() blocks.
- Marks the device side data as out of date so that the next call to
- #host_ready() == true
- #device_ready() == false
I.e. Marks the device side data as out of date so that the next call to
device() will perform a host to device transfer. If you want to begin
the transfer immediately then you can call async_copy_to_device() after
calling host().
...
...
@@ -106,9 +131,10 @@ namespace dlib
ensures
- returns a pointer to the device memory block of size() contiguous float
values or nullptr if size()==0.
- if (
the
device
's copy of the data is out of date
) then
- if (
!
device
_ready()
) then
- copies the data from the host to the device, while this is happening
the call to device() blocks.
- #device_ready() == true
!*/
float
*
device
(
...
...
@@ -119,11 +145,11 @@ namespace dlib
ensures
- returns a pointer to the device memory block of size() contiguous float
values or nullptr if size()==0.
- if (
the
device
's copy of the data is out of date
) then
- if (
!
device
_ready()
) then
- copies the data from the host to the device, while this is happening
the call to device() blocks.
-
Marks the host side data as out of date so that the next call to
host() will perform a device to host transfer.
-
#host_ready() == false
- #device_ready() == true
!*/
size_t
size
(
...
...
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