Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Pierre NARVOR
rtac_base
Commits
86561a71
Commit
86561a71
authored
Oct 30, 2021
by
Pierre NARVOR
Browse files
[cuda] Added compiler check in DeviceVector and HostVector to keep Eigen separated from CUDA
parent
135249e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
cuda/include/rtac_base/cuda/DeviceVector.h
View file @
86561a71
...
...
@@ -6,10 +6,12 @@
#include <cuda_runtime.h>
#include <rtac_base/
types/common
.h>
#include <rtac_base/
cuda/utils
.h>
#include <rtac_base/types/SharedVector.h>
#ifndef RTAC_CUDACC
#include <rtac_base/types/common.h>
#endif
#include <rtac_base/cuda/utils.h>
namespace
rtac
{
namespace
cuda
{
...
...
@@ -46,7 +48,6 @@ class DeviceVector
DeviceVector
(
const
DeviceVector
<
T
>&
other
);
DeviceVector
(
const
HostVector
<
T
>&
other
);
DeviceVector
(
const
std
::
vector
<
T
>&
other
);
DeviceVector
(
const
types
::
Vector
<
T
>&
other
);
~
DeviceVector
();
void
copy_from_host
(
size_t
size
,
const
T
*
data
);
...
...
@@ -54,7 +55,11 @@ class DeviceVector
DeviceVector
&
operator
=
(
const
DeviceVector
<
T
>&
other
);
DeviceVector
&
operator
=
(
const
HostVector
<
T
>&
other
);
DeviceVector
&
operator
=
(
const
std
::
vector
<
T
>&
other
);
#ifndef RTAC_CUDACC
DeviceVector
(
const
types
::
Vector
<
T
>&
other
);
DeviceVector
&
operator
=
(
const
types
::
Vector
<
T
>&
other
);
#endif
void
resize
(
size_t
size
);
size_t
size
()
const
;
...
...
@@ -107,13 +112,6 @@ DeviceVector<T>::DeviceVector(const std::vector<T>& other) :
*
this
=
other
;
}
template
<
typename
T
>
DeviceVector
<
T
>::
DeviceVector
(
const
types
::
Vector
<
T
>&
other
)
:
DeviceVector
(
other
.
size
())
{
*
this
=
other
;
}
template
<
typename
T
>
DeviceVector
<
T
>::~
DeviceVector
()
{
...
...
@@ -163,6 +161,14 @@ DeviceVector<T>& DeviceVector<T>::operator=(const std::vector<T>& other)
return
*
this
;
}
#ifndef RTAC_CUDACC
template
<
typename
T
>
DeviceVector
<
T
>::
DeviceVector
(
const
types
::
Vector
<
T
>&
other
)
:
DeviceVector
(
other
.
size
())
{
*
this
=
other
;
}
template
<
typename
T
>
DeviceVector
<
T
>&
DeviceVector
<
T
>::
operator
=
(
const
types
::
Vector
<
T
>&
other
)
{
...
...
@@ -173,6 +179,7 @@ DeviceVector<T>& DeviceVector<T>::operator=(const types::Vector<T>& other)
cudaMemcpyHostToDevice
)
);
return
*
this
;
}
#endif
template
<
typename
T
>
void
DeviceVector
<
T
>::
allocate
(
size_t
size
)
...
...
cuda/include/rtac_base/cuda/HostVector.h
View file @
86561a71
...
...
@@ -6,10 +6,12 @@
#include <cuda_runtime.h>
#include <rtac_base/
types/common
.h>
#include <rtac_base/
cuda/utils
.h>
#include <rtac_base/types/SharedVector.h>
#include <rtac_base/cuda/utils.h>
#ifndef RTAC_CUDACC
#include <rtac_base/types/common.h>
#endif
namespace
rtac
{
namespace
cuda
{
...
...
@@ -46,13 +48,16 @@ class HostVector
HostVector
(
const
HostVector
<
T
>&
other
);
HostVector
(
const
DeviceVector
<
T
>&
other
);
HostVector
(
const
std
::
vector
<
T
>&
other
);
HostVector
(
const
types
::
Vector
<
T
>&
other
);
~
HostVector
();
HostVector
&
operator
=
(
const
HostVector
<
T
>&
other
);
HostVector
&
operator
=
(
const
DeviceVector
<
T
>&
other
);
HostVector
&
operator
=
(
const
std
::
vector
<
T
>&
other
);
#ifndef RTAC_CUDACC
HostVector
(
const
types
::
Vector
<
T
>&
other
);
HostVector
&
operator
=
(
const
types
::
Vector
<
T
>&
other
);
#endif
void
resize
(
size_t
size
);
size_t
size
()
const
;
...
...
@@ -113,13 +118,6 @@ HostVector<T>::HostVector(const std::vector<T>& other) :
*
this
=
other
;
}
template
<
typename
T
>
HostVector
<
T
>::
HostVector
(
const
types
::
Vector
<
T
>&
other
)
:
HostVector
(
other
.
size
())
{
*
this
=
other
;
}
template
<
typename
T
>
HostVector
<
T
>::~
HostVector
()
{
...
...
@@ -159,6 +157,14 @@ HostVector<T>& HostVector<T>::operator=(const std::vector<T>& other)
return
*
this
;
}
#ifndef RTAC_CUDACC
template
<
typename
T
>
HostVector
<
T
>::
HostVector
(
const
types
::
Vector
<
T
>&
other
)
:
HostVector
(
other
.
size
())
{
*
this
=
other
;
}
template
<
typename
T
>
HostVector
<
T
>&
HostVector
<
T
>::
operator
=
(
const
types
::
Vector
<
T
>&
other
)
{
...
...
@@ -169,6 +175,7 @@ HostVector<T>& HostVector<T>::operator=(const types::Vector<T>& other)
cudaMemcpyHostToHost
)
);
return
*
this
;
}
#endif
template
<
typename
T
>
void
HostVector
<
T
>::
allocate
(
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