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
856bac74
There was an error fetching the commit references. Please try again later.
Commit
856bac74
authored
4 years ago
by
Tomáš Oberhuber
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring Adaptive CSR kernel.
parent
dcd87dec
No related branches found
No related tags found
1 merge request
!83
To/matrices
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TNL/Algorithms/Segments/details/CSRAdaptiveKernelBlockDescriptor.h
+86
-0
86 additions, 0 deletions
...ithms/Segments/details/CSRAdaptiveKernelBlockDescriptor.h
with
86 additions
and
0 deletions
src/TNL/Algorithms/Segments/details/CSRAdaptiveKernelBlockDescriptor.h
+
86
−
0
View file @
856bac74
...
...
@@ -22,6 +22,90 @@ enum class Type {
VECTOR
=
2
};
#ifdef CSR_ADAPTIVE_UNION
template
<
typename
Index
>
union
CSRAdaptiveKernelBlockDescriptor
{
CSRAdaptiveKernelBlockDescriptor
(
Index
row
,
Type
type
=
Type
::
VECTOR
,
Index
index
=
0
)
noexcept
{
this
->
index
[
0
]
=
row
;
this
->
index
[
1
]
=
index
;
this
->
byte
[
sizeof
(
Index
)
==
4
?
7
:
15
]
=
(
uint8_t
)
type
;
}
CSRAdaptiveKernelBlockDescriptor
(
Index
row
,
Type
type
,
Index
nextRow
,
Index
maxID
,
Index
minID
)
noexcept
{
this
->
index
[
0
]
=
row
;
this
->
index
[
1
]
=
0
;
this
->
twobytes
[
sizeof
(
Index
)
==
4
?
2
:
4
]
=
maxID
-
minID
;
if
(
type
==
Type
::
STREAM
)
this
->
twobytes
[
sizeof
(
Index
)
==
4
?
3
:
5
]
=
nextRow
-
row
;
if
(
type
==
Type
::
STREAM
)
this
->
byte
[
sizeof
(
Index
)
==
4
?
7
:
15
]
|=
0b1000000
;
else
if
(
type
==
Type
::
VECTOR
)
this
->
byte
[
sizeof
(
Index
)
==
4
?
7
:
15
]
|=
0b10000000
;
}
CSRAdaptiveKernelBlockDescriptor
()
=
default
;
__cuda_callable__
Type
getType
()
const
{
if
(
byte
[
sizeof
(
Index
)
==
4
?
7
:
15
]
&
0b1000000
)
return
Type
::
STREAM
;
if
(
byte
[
sizeof
(
Index
)
==
4
?
7
:
15
]
&
0b10000000
)
return
Type
::
VECTOR
;
return
Type
::
LONG
;
}
__cuda_callable__
const
Index
&
getFirstSegment
()
const
{
return
index
[
0
];
}
/***
* \brief Returns number of elements covered by the block.
*/
__cuda_callable__
const
Index
getSize
()
const
{
return
twobytes
[
sizeof
(
Index
)
==
4
?
2
:
4
];
}
/***
* \brief Returns number of segments covered by the block.
*/
__cuda_callable__
const
Index
getSegmentsInBlock
()
const
{
return
(
twobytes
[
sizeof
(
Index
)
==
4
?
3
:
5
]
&
0x3FFF
);
}
void
print
(
std
::
ostream
&
str
)
const
{
Type
type
=
this
->
getType
();
str
<<
"Type: "
;
switch
(
type
)
{
case
Type
::
STREAM
:
str
<<
" Stream "
;
break
;
case
Type
::
VECTOR
:
str
<<
" Vector "
;
break
;
case
Type
::
LONG
:
str
<<
" Long "
;
break
;
}
str
<<
" first segment: "
<<
getFirstSegment
();
str
<<
" block end: "
<<
getSize
();
str
<<
" index in warp: "
<<
index
[
1
];
}
Index
index
[
2
];
// index[0] is row pointer, index[1] is index in warp
uint8_t
byte
[
sizeof
(
Index
)
==
4
?
8
:
16
];
// byte[7/15] is type specificator
uint16_t
twobytes
[
sizeof
(
Index
)
==
4
?
4
:
8
];
//twobytes[2/4] is maxID - minID
//twobytes[3/5] is nextRow - row
};
#else
template
<
typename
Index
>
union
CSRAdaptiveKernelBlockDescriptor
...
...
@@ -106,6 +190,8 @@ union CSRAdaptiveKernelBlockDescriptor
//twobytes[3/5] is nextRow - row
};
#endif
template
<
typename
Index
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
str
,
const
CSRAdaptiveKernelBlockDescriptor
<
Index
>&
block
)
{
...
...
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