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
57486ffe
There was an error fetching the commit references. Please try again later.
Commit
57486ffe
authored
5 years ago
by
Tomáš Oberhuber
Browse files
Options
Downloads
Patches
Plain Diff
Fixes in SharedPointer documentation.
parent
cc136efa
No related branches found
No related tags found
1 merge request
!44
Tutorials
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/TNL/Pointers/SharedPointerCuda.h
+50
-49
50 additions, 49 deletions
src/TNL/Pointers/SharedPointerCuda.h
src/TNL/Pointers/SharedPointerHost.h
+39
-39
39 additions, 39 deletions
src/TNL/Pointers/SharedPointerHost.h
with
89 additions
and
88 deletions
src/TNL/Pointers/SharedPointerCuda.h
+
50
−
49
View file @
57486ffe
...
...
@@ -31,8 +31,8 @@ namespace Pointers {
#if ! defined HAVE_CUDA_UNIFIED_MEMORY
/**
* \brief Specialization of the
Unique
Pointer for the CUDA device.
*
* \brief Specialization of the
\ref Shared
Pointer for the CUDA device.
*
* \tparam Object is a type of object to be owned by the pointer.
*/
template
<
typename
Object
>
...
...
@@ -41,7 +41,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
private:
/**
* \typedef Enabler
*
*
* Convenient template alias for controlling the selection of copy- and
* move-constructors and assignment operators using SFINAE.
* The type Object_ is "enabled" iff Object_ and Object are not the same,
...
...
@@ -58,7 +58,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
public:
/**
* \typedef ObjectType is the type of object owned by the pointer.
* \typedef ObjectType is the type of object owned by the pointer.
*/
using
ObjectType
=
Object
;
...
...
@@ -78,7 +78,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Constructor with parameters of the Object constructor.
*
*
* \tparam Args is variadic template type of arguments of the Object constructor.
* \tparam args are arguments passed to the Object constructor.
*/
...
...
@@ -92,7 +92,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Copy constructor.
*
*
* \param pointer is the source shared pointer.
*/
SharedPointer
(
const
SharedPointer
&
pointer
)
// this is needed only to avoid the default compiler-generated constructor
...
...
@@ -104,11 +104,11 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Copy constructor.
*
*
* This is specialization for compatible object types.
*
*
* See \ref Enabler.
*
*
* \param pointer is the source shared pointer.
*/
template
<
typename
Object_
,
...
...
@@ -122,7 +122,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Move constructor.
*
*
* \param pointer is the source shared pointer.
*/
SharedPointer
(
SharedPointer
&&
pointer
)
// this is needed only to avoid the default compiler-generated constructor
...
...
@@ -135,11 +135,11 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Move constructor.
*
*
* This is specialization for compatible object types.
*
*
* See \ref Enabler.
*
*
* \param pointer is the source shared pointer.
*/
template
<
typename
Object_
,
...
...
@@ -154,7 +154,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Create new object based in given constructor parameters.
*
*
* \tparam Args is variadic template type of arguments to be passed to the
* object constructor.
* \param args are arguments to be passed to the object constructor.
...
...
@@ -191,9 +191,9 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Arrow operator for accessing the object owned by constant smart pointer.
*
*
* \return constant pointer to the object owned by this smart pointer. It
* returns pointer to object image on the CUDA device if it is called from CUDA
* returns pointer to object image on the CUDA device if it is called from CUDA
* kernel and pointer to host image otherwise.
*/
__cuda_callable__
...
...
@@ -209,9 +209,9 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Arrow operator for accessing the object owned by non-constant smart pointer.
*
*
* \return pointer to the object owned by this smart pointer. It
* returns pointer to object image on the CUDA device if it is called from CUDA
* returns pointer to object image on the CUDA device if it is called from CUDA
* kernel and pointer to host image otherwise.
*/
__cuda_callable__
...
...
@@ -228,9 +228,9 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Dereferencing operator for accessing the object owned by constant smart pointer.
*
*
* \return constant reference to the object owned by this smart pointer. It
* returns reference to object image on the CUDA device if it is called from CUDA
* returns reference to object image on the CUDA device if it is called from CUDA
* kernel and reference to host image otherwise.
*/
__cuda_callable__
...
...
@@ -246,9 +246,9 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Dereferencing operator for accessing the object owned by non-constant smart pointer.
*
*
* \return reference to the object owned by this smart pointer. It
* returns reference to object image on the CUDA device if it is called from CUDA
* returns reference to object image on the CUDA device if it is called from CUDA
* kernel and reference to host image otherwise.
*/
__cuda_callable__
...
...
@@ -265,7 +265,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Conversion to boolean type.
*
*
* \return Returns true if the pointer is not empty, false otherwise.
*/
__cuda_callable__
...
...
@@ -290,7 +290,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
*
* No synchronization of this pointer will be performed due to calling
* this method.
*
*
* \tparam Device says what image of the object one want to dereference. It
* can be either \ref DeviceType or Devices::Host.
* \return constant reference to the object image on given device.
...
...
@@ -312,10 +312,10 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
* \brief Non-constant object reference getter.
*
* After calling this method, the object owned by the pointer might need
* to be synchronized. One should not forget to call
* \ref Pointers::synchronizeSmartPointersOnDevice< Devices::Cuda >()
* to be synchronized. One should not forget to call
* \ref Pointers::synchronizeSmartPointersOnDevice< Devices::Cuda >()
* before calling CUDA kernel using object from this smart pointer.
*
*
* \tparam Device says what image of the object one want to dereference. It
* can be either \ref DeviceType or Devices::Host.
* \return constant reference to the object image on given device.
...
...
@@ -338,9 +338,9 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Assignment operator.
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
* \param ptr input pointer
* \return constant reference to \ref this
*/
...
...
@@ -359,11 +359,11 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Assignment operator for compatible object types.
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
* See \ref Enabler.
*
*
* \param ptr input pointer
* \return constant reference to \ref this
*/
...
...
@@ -384,9 +384,9 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Move operator.
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
* \param ptr input pointer
* \return constant reference to \ref this
*/
...
...
@@ -405,11 +405,11 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Move operator.
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
* See \ref Enabler.
*
*
* \param ptr input pointer
* \return constant reference to \ref this
*/
...
...
@@ -430,10 +430,11 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
/**
* \brief Cross-device pointer synchronization.
*
* For the smart pointers in the host, this method does nothing.
*
* \return true.
*
* This method is usually called by the smart pointers register when calling
* \ref Pointers::synchronizeSmartPointersOnDevice< Devices::Cuda >()
*
* \return true if the synchronization was successful, false otherwise.
*/
bool
synchronize
()
{
...
...
@@ -560,8 +561,8 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
// unable to dereference this-pd on the device
Object
*
cuda_pointer
;
};
#else
#else
// Implementation with CUDA unified memory. It is very slow, we keep it only for experimental reasons.
template
<
typename
Object
>
class
SharedPointer
<
Object
,
Devices
::
Cuda
>
:
public
SmartPointer
...
...
@@ -582,7 +583,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
public:
using
ObjectType
=
Object
;
using
DeviceType
=
Devices
::
Cuda
;
using
DeviceType
=
Devices
::
Cuda
;
SharedPointer
(
std
::
nullptr_t
)
:
pd
(
nullptr
)
...
...
@@ -712,7 +713,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer
{
this
->
free
();
this
->
pd
=
(
PointerData
*
)
ptr
.
pd
;
if
(
this
->
pd
!=
nullptr
)
if
(
this
->
pd
!=
nullptr
)
this
->
pd
->
counter
+=
1
;
return
*
this
;
}
...
...
This diff is collapsed.
Click to expand it.
src/TNL/Pointers/SharedPointerHost.h
+
39
−
39
View file @
57486ffe
...
...
@@ -25,15 +25,15 @@ namespace TNL {
namespace
Pointers
{
/**
* \brief Specialization of the
Unique
Pointer for the host system.
*
* \brief Specialization of the
\ref Shared
Pointer for the host system.
*
* \tparam Object is a type of object to be owned by the pointer.
*/
template
<
typename
Object
>
class
SharedPointer
<
Object
,
Devices
::
Host
>
:
public
SmartPointer
{
private:
/**
* \typedef Enabler
* Convenient template alias for controlling the selection of copy- and
...
...
@@ -52,7 +52,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
public:
/**
* \typedef ObjectType is the type of object owned by the pointer.
* \typedef ObjectType is the type of object owned by the pointer.
*/
using
ObjectType
=
Object
;
...
...
@@ -63,7 +63,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
using
DeviceType
=
Devices
::
Host
;
/**
* \brief Constructor of empty pointer.
* \brief Constructor of
an
empty pointer.
*/
SharedPointer
(
std
::
nullptr_t
)
:
pd
(
nullptr
)
...
...
@@ -71,7 +71,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Constructor with parameters of the Object constructor.
*
*
* \tparam Args is variadic template type of arguments of the Object constructor.
* \tparam args are arguments passed to the Object constructor.
*/
...
...
@@ -87,7 +87,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Copy constructor.
*
*
* \param pointer is the source shared pointer.
*/
SharedPointer
(
const
SharedPointer
&
pointer
)
// this is needed only to avoid the default compiler-generated constructor
...
...
@@ -98,11 +98,11 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Copy constructor.
*
*
* This is specialization for compatible object types.
*
*
* See \ref Enabler.
*
*
* \param pointer is the source shared pointer.
*/
template
<
typename
Object_
,
...
...
@@ -115,7 +115,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Move constructor.
*
*
* \param pointer is the source shared pointer.
*/
SharedPointer
(
SharedPointer
&&
pointer
)
// this is needed only to avoid the default compiler-generated constructor
...
...
@@ -126,11 +126,11 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Move constructor.
*
*
* This is specialization for compatible object types.
*
*
* See \ref Enabler.
*
*
* \param pointer is the source shared pointer.
*/
template
<
typename
Object_
,
...
...
@@ -143,7 +143,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Create new object based in given constructor parameters.
*
*
* \tparam Args is variadic template type of arguments to be passed to the
* object constructor.
* \param args are arguments to be passed to the object constructor.
...
...
@@ -176,7 +176,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Arrow operator for accessing the object owned by constant smart pointer.
*
*
* \return constant pointer to the object owned by this smart pointer.
*/
const
Object
*
operator
->
()
const
...
...
@@ -187,7 +187,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Arrow operator for accessing the object owned by non-constant smart pointer.
*
*
* \return pointer to the object owned by this smart pointer.
*/
Object
*
operator
->
()
...
...
@@ -198,7 +198,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Dereferencing operator for accessing the object owned by constant smart pointer.
*
*
* \return constant reference to the object owned by this smart pointer.
*/
const
Object
&
operator
*
()
const
...
...
@@ -209,7 +209,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Dereferencing operator for accessing the object owned by non-constant smart pointer.
*
*
* \return reference to the object owned by this smart pointer.
*/
Object
&
operator
*
()
...
...
@@ -220,7 +220,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Conversion to boolean type.
*
*
* \return Returns true if the pointer is not empty, false otherwise.
*/
operator
bool
()
const
...
...
@@ -243,7 +243,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
*
* No synchronization of this pointer will be performed due to calling
* this method.
*
*
* \tparam Device says what image of the object one want to dereference. It
* can be either \ref DeviceType or Devices::Host.
* \return constant reference to the object image on given device.
...
...
@@ -261,7 +261,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
*
* No synchronization of this pointer will be performed due to calling
* this method.
*
*
* \tparam Device says what image of the object one want to dereference. It
* can be either \ref DeviceType or Devices::Host.
* \return constant reference to the object image on given device.
...
...
@@ -276,9 +276,9 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Assignment operator.
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
* \param ptr input pointer
* \return constant reference to \ref this
*/
...
...
@@ -293,11 +293,11 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Assignment operator for compatible object types.
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
* See \ref Enabler.
*
*
* \param ptr input pointer
* \return constant reference to \ref this
*/
...
...
@@ -314,9 +314,9 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Move operator.
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
* \param ptr input pointer
* \return constant reference to \ref this
*/
...
...
@@ -330,11 +330,11 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Move operator.
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
*
* It assigns object owned by the pointer \ref ptr to \ref this pointer.
*
* See \ref Enabler.
*
*
* \param ptr input pointer
* \return constant reference to \ref this
*/
...
...
@@ -350,9 +350,9 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
/**
* \brief Cross-device pointer synchronization.
*
* For the smart pointers
i
n the host, this method does nothing.
*
*
* For the smart pointers
o
n the host, this method does nothing.
*
* \return true.
*/
bool
synchronize
()
...
...
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