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
8bdceeae
There was an error fetching the commit references. Please try again later.
Commit
8bdceeae
authored
5 years ago
by
Tomáš Oberhuber
Browse files
Options
Downloads
Patches
Plain Diff
Implementing unit tests for Segments.
parent
47d413b3
No related branches found
No related tags found
1 merge request
!48
Segments
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/UnitTests/Containers/Segments/SegmentsTest.hpp
+38
-1
38 additions, 1 deletion
src/UnitTests/Containers/Segments/SegmentsTest.hpp
src/UnitTests/Containers/Segments/SegmentsTest_Ellpack.h
+6
-0
6 additions, 0 deletions
src/UnitTests/Containers/Segments/SegmentsTest_Ellpack.h
with
44 additions
and
1 deletion
src/UnitTests/Containers/Segments/SegmentsTest.hpp
+
38
−
1
View file @
8bdceeae
...
@@ -25,7 +25,7 @@ void test_SetSegmentsSizes_EqualSizes()
...
@@ -25,7 +25,7 @@ void test_SetSegmentsSizes_EqualSizes()
const
IndexType
segmentsCount
=
20
;
const
IndexType
segmentsCount
=
20
;
const
IndexType
segmentSize
=
5
;
const
IndexType
segmentSize
=
5
;
TNL
::
Containers
::
Vector
<
IndexType
,
DeviceType
,
IndexType
>
segmentsSizes
(
segmentsCount
);
TNL
::
Containers
::
Vector
<
IndexType
,
DeviceType
,
IndexType
>
segmentsSizes
(
segmentsCount
);
segmentsSizes
=
5
;
//
segmentSize;
segmentsSizes
=
segmentSize
;
Segments
segments
(
segmentsSizes
);
Segments
segments
(
segmentsSizes
);
...
@@ -92,4 +92,41 @@ void test_SetSegmentsSizes_EqualSizes_EllpackOnly()
...
@@ -92,4 +92,41 @@ void test_SetSegmentsSizes_EqualSizes_EllpackOnly()
EXPECT_EQ
(
segments3
.
getSegmentSize
(
i
),
segmentSize
);
EXPECT_EQ
(
segments3
.
getSegmentSize
(
i
),
segmentSize
);
}
}
template
<
typename
Segments
>
void
test_GetMaxInSegments
()
{
using
DeviceType
=
typename
Segments
::
DeviceType
;
using
IndexType
=
typename
Segments
::
IndexType
;
const
IndexType
segmentsCount
=
20
;
const
IndexType
segmentSize
=
5
;
const
IndexType
size
=
segmentsCount
*
segmentSize
;
Segments
segments
(
segmentsCount
,
segmentSize
);
TNL
::
Containers
::
Vector
<
IndexType
,
DeviceType
,
IndexType
>
segmentsSizes
(
segmentsCount
);
segmentsSizes
=
segmentSize
;
Segments
segments
(
segmentsSizes
);
TNL
::
Containers
::
Vector
<
IndexType
,
DeviceType
,
IndexType
>
v
(
size
);
for
(
IndexType
i
=
0
;
i
<
size
;
i
++
)
v
.
setElement
(
i
,
i
);
TNL
::
Containers
::
Vector
<
IndexType
,
DeviceType
,
IndexType
>
result
(
segmentsCount
);
const
auto
v_view
=
v
.
getConstView
();
auto
result_view
=
result
.
getView
();
auto
fetch
=
[
=
]
__cuda_callable__
(
IndexType
i
)
->
IndexType
{
return
v_view
[
i
];
}
auto
reduce
=
[]
__cuda_callable__
(
IndexType
&
a
,
const
IndexType
b
)
{
a
=
TNL
::
max
(
a
,
b
);
}
auto
keep
=
[
=
]
__cuda_callable__
(
IndexType
&
i
,
const
IndexType
a
)
mutable
{
result_view
[
i
]
=
a
;
}
segments
.
allReduction
(
fetch
,
reduction
,
keep
,
std
::
numeric_limits
<
ResultType
>::
min
()
);
}
#endif
#endif
This diff is collapsed.
Click to expand it.
src/UnitTests/Containers/Segments/SegmentsTest_Ellpack.h
+
6
−
0
View file @
8bdceeae
...
@@ -59,6 +59,12 @@ TYPED_TEST( EllpackSegmentsTest, setSegmentsSizes_EqualSizes_EllpackOnly )
...
@@ -59,6 +59,12 @@ TYPED_TEST( EllpackSegmentsTest, setSegmentsSizes_EqualSizes_EllpackOnly )
test_SetSegmentsSizes_EqualSizes_EllpackOnly
<
EllpackSegmentsType
>
();
test_SetSegmentsSizes_EqualSizes_EllpackOnly
<
EllpackSegmentsType
>
();
}
}
TYPED_TEST
(
EllpackSegmentsTest
,
getMaxInSegments
)
{
using
EllpackSegmentsType
=
typename
TestFixture
::
EllpackSegmentsType
;
test_GetMaxInSegments
<
EllpackSegmentsType
>
();
}
#endif
#endif
...
...
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