Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
649bf42b
There was an error fetching the commit references. Please try again later.
Commit
649bf42b
authored
6 years ago
by
Tomáš Oberhuber
Committed by
Tomáš Oberhuber
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Updating the File documentation.
parent
3ade215f
No related branches found
No related tags found
1 merge request
!29
Revision
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TNL/File.h
+30
-21
30 additions, 21 deletions
src/TNL/File.h
with
30 additions
and
21 deletions
src/TNL/File.h
+
30
−
21
View file @
649bf42b
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
namespace
TNL
{
namespace
TNL
{
/**
/**
* \brief This class serves for binary IO. It allows to do IO even for data allocated on GPU
* \brief This class serves for binary IO. It allows to do IO even for data allocated on GPU
together with on-the-fly data type conversion.
*
*
* \par Example
* \par Example
* \include FileExample.cpp
* \include FileExample.cpp
...
@@ -57,7 +57,7 @@ class File
...
@@ -57,7 +57,7 @@ class File
* Throws \ref std::ios_base::failure on failure.
* Throws \ref std::ios_base::failure on failure.
*
*
* \param fileName String which indicates file name.
* \param fileName String which indicates file name.
* \param mode Indicates in what mode the will be opened - see. \ref File::Mode.
* \param mode Indicates in what mode the
file
will be opened - see. \ref File::Mode.
*/
*/
void
open
(
const
String
&
fileName
,
void
open
(
const
String
&
fileName
,
Mode
mode
=
static_cast
<
Mode
>
(
static_cast
<
int
>
(
Mode
::
In
)
|
static_cast
<
int
>
(
Mode
::
Out
)
)
);
Mode
mode
=
static_cast
<
Mode
>
(
static_cast
<
int
>
(
Mode
::
In
)
|
static_cast
<
int
>
(
Mode
::
Out
)
)
);
...
@@ -78,34 +78,43 @@ class File
...
@@ -78,34 +78,43 @@ class File
}
}
/**
/**
* \brief Method for
re
ading data
with given \e Type
from the file.
* \brief Method for
lo
ading data from the file.
*
*
* The data will be stored in \e buffer allocated on device given by the
* The data will be stored in \e buffer allocated on device given by the
* \e Device parameter.
* \e Device parameter. The data type of the buffer is given by the
* template parameter \e Type. The second template parameter
* \e SourceType defines the type of data in the source file. If both
* types are different, on-the-fly conversion takes place during the
* data loading.
*
*
* Throws \ref std::ios_base::failure on failure.
* Throws \ref std::ios_base::failure on failure.
*
*
* \tparam Type
T
ype of data.
* \tparam Type
t
ype of data
to be loaded to the \e buffer
.
* \tparam
Device Device where the
data
are
stored
after reading. For example \ref Devices::Host or \ref Devices::Cuda.
* \tparam
SourceType type of
data stored
on the file,
* \tparam
SourceType Type of index by which the elements are indexed
.
* \tparam
Device device where the data are stored after reading. For example \ref Devices::Host or \ref Devices::Cuda
.
* \param buffer Pointer in memory where the elements are loaded and stored after reading.
* \param buffer Pointer in memory where the elements are loaded and stored after reading.
* \param elements
N
umber of elements t
he user wants to get (read)
from
given
file.
* \param elements
n
umber of elements t
o be loaded
from
the
file.
*/
*/
template
<
typename
Type
,
typename
SourceType
=
Type
,
typename
Device
=
Devices
::
Host
>
template
<
typename
Type
,
typename
SourceType
=
Type
,
typename
Device
=
Devices
::
Host
>
void
load
(
Type
*
buffer
,
std
::
streamsize
elements
=
1
);
void
load
(
Type
*
buffer
,
std
::
streamsize
elements
=
1
);
/**
/**
* \brief Method
that can write particular data type from CPU into given file. (Function that writes particular elements into given
file.
)
* \brief Method
for saving data to the
file.
*
*
* Returns \e true when the elements are successfully written into given file. Otherwise returns \e false.
* The data from the \e buffer (with type \e Type) allocated on the device
* \e Device will be saved into the file. \e TargetType defines as what
* data type the buffer shall be saved. If the type is different from the
* data type, on-the-fly data type conversion takes place during the data
* saving.
*
*
* Throws \ref std::ios_base::failure on failure.
* Throws \ref std::ios_base::failure on failure.
*
*
* \tparam Type Type of data.
* \tparam Type type of data in the \e buffer.
* \tparam Device Place from where the data are loaded before writing into file. For example \ref Devices::Host or \ref Devices::Cuda.
* \tparam TargetType tells as what type data the buffer shall be saved.
* \tparam Index Type of index by which the elements are indexed.
* \tparam Device device from where the data are loaded before writing into file. For example \ref Devices::Host or \ref Devices::Cuda.
* \param buffer Pointer in memory where the elements are loaded from before writing into file.
* \tparam Index type of index by which the elements are indexed.
* \param elements Number of elements the user wants to write into the given file.
* \param buffer buffer that is going to be saved to the file.
* \param elements number of elements saved to the file.
*/
*/
template
<
typename
Type
,
typename
TargetType
=
Type
,
typename
Device
=
Devices
::
Host
>
template
<
typename
Type
,
typename
TargetType
=
Type
,
typename
Device
=
Devices
::
Host
>
void
save
(
const
Type
*
buffer
,
std
::
streamsize
elements
=
1
);
void
save
(
const
Type
*
buffer
,
std
::
streamsize
elements
=
1
);
...
@@ -156,12 +165,12 @@ class File
...
@@ -156,12 +165,12 @@ class File
std
::
fstream
file
;
std
::
fstream
file
;
String
fileName
;
String
fileName
;
/
**
/
///
*
When we transfer data between the GPU and the CPU we use 5 MB buffer. This
//
When we transfer data between the GPU and the CPU we use 5 MB buffer. This
*
size should ensure good performance -- see.
//
size should ensure good performance -- see.
*
http://wiki.accelereyes.com/wiki/index.php/GPU_Memory_Transfer .
//
http://wiki.accelereyes.com/wiki/index.php/GPU_Memory_Transfer .
*
We use the same buffer size even for retyping data during IO operations.
//
We use the same buffer size even for retyping data during IO operations.
*
/
/
/
static
constexpr
std
::
streamsize
TransferBufferSize
=
5
*
2
<<
20
;
static
constexpr
std
::
streamsize
TransferBufferSize
=
5
*
2
<<
20
;
};
};
...
...
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