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
8a6abd72
Commit
8a6abd72
authored
Oct 27, 2021
by
Pierre NARVOR
Browse files
[cuda/functors] Modified warning fix in FunctorCompound (not pretty...)
parent
d4d8f116
Changes
3
Hide whitespace changes
Inline
Side-by-side
cuda/include/rtac_base/cuda/FunctorCompound.h
View file @
8a6abd72
...
...
@@ -80,7 +80,9 @@ struct FunctorCompound
// below is to suppress the warning but has no effect on the code. See
// here for more info :
// https://stackoverflow.com/questions/64523302/cuda-missing-return-statement-at-end-of-non-void-function-in-constexpr-if-fun
return
std
::
get
<
Level
>
(
functors_
)(
input
);
// CAUTION : THIS CODE IMPLIES THAT ALL FUNCTORS OUTPUT MUST BE DEFAULT
// CONSTRUCTIBLE. MAYBE KEEPING THE WARNING IS BETTER.
return
typename
functor_get
<
Level
>::
OutputT
();
}
public:
...
...
cuda/tests/functors/src/functors_test.cpp
View file @
8a6abd72
...
...
@@ -7,9 +7,33 @@ using namespace rtac::cuda;
#include "functors_test.h"
template
<
typename
T
>
void
print_type
(
std
::
ostream
&
os
=
std
::
cout
)
{
os
<<
"'print_not_defined'"
;
}
template
<
>
void
print_type
<
float
>
(
std
::
ostream
&
os
)
{
os
<<
"'float'"
;
}
template
<
>
void
print_type
<
float4
>
(
std
::
ostream
&
os
)
{
os
<<
"'float4'"
;
}
template
<
class
FunctorT
>
void
print_functor_type
(
std
::
ostream
&
os
=
std
::
cout
)
{
os
<<
"(InputT : "
;
print_type
<
typename
FunctorT
::
InputT
>
(
os
);
os
<<
", OutputT : "
;
print_type
<
typename
FunctorT
::
OutputT
>
(
os
);
os
<<
")"
<<
endl
;
}
int
main
()
{
int
N
=
10
;
print_functor_type
<
Vectorize4
>
();
print_functor_type
<
Norm4
>
();
print_functor_type
<
MultiType
>
();
//MultiType fm(Norm4(), Vectorize4()); // why this not working ?
//auto fm = MultiType(Norm4(), Vectorize4());
MultiType
fm
(
std
::
make_tuple
(
Norm4
(),
Vectorize4
()));
print_functor_type
<
decltype
(
fm
)
>
();
//cout << std::get<0>(fm.functors_) << endl;
cout
<<
fm
(
1.0
f
)
<<
endl
;
HostVector
<
float
>
input
(
N
);
for
(
int
n
=
0
;
n
<
N
;
n
++
)
{
...
...
@@ -18,7 +42,7 @@ int main()
//auto output = scaling(input, functor::Scaling<float>({2.0f}));
auto
f
=
Saxpy
(
functors
::
Offset
<
float
>
({
3.0
f
}),
functors
::
Scaling
<
float
>
({
2.0
f
}));
Saxpy
f
=
Saxpy
(
functors
::
Offset
<
float
>
({
3.0
f
}),
functors
::
Scaling
<
float
>
({
2.0
f
}));
cout
<<
f
(
1.0
f
)
<<
endl
;
auto
output
=
saxpy
(
input
,
Saxpy
(
functors
::
Offset
<
float
>
({
3.0
f
}),
...
...
cuda/tests/functors/src/functors_test.h
View file @
8a6abd72
...
...
@@ -7,8 +7,39 @@
namespace
rtac
{
namespace
cuda
{
struct
Vectorize4
{
using
InputT
=
float
;
using
OutputT
=
float4
;
float
x
;
RTAC_HOSTDEVICE
float4
operator
()(
float
input
)
const
{
return
float4
({
input
,
input
,
input
,
input
});
}
};
struct
Norm4
{
using
InputT
=
float4
;
using
OutputT
=
float
;
float
x
;
RTAC_HOSTDEVICE
float
operator
()(
const
float4
&
input
)
const
{
// return length(input); // WHY U NOT WORKING ???
return
sqrt
(
input
.
x
*
input
.
x
+
input
.
y
*
input
.
y
+
input
.
z
*
input
.
z
+
input
.
w
*
input
.
w
);
}
};
using
MultiType
=
functors
::
FunctorCompound
<
Norm4
,
Vectorize4
>
;
using
Saxpy
=
functors
::
FunctorCompound
<
functors
::
Offset
<
float
>
,
functors
::
Scaling
<
float
>>
;
DeviceVector
<
float
>
scaling
(
const
DeviceVector
<
float
>&
input
,
const
functors
::
Scaling
<
float
>&
func
);
DeviceVector
<
float
>
saxpy
(
const
DeviceVector
<
float
>&
input
,
const
Saxpy
&
func
);
...
...
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