Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
James Willenbring
Trilinos
Commits
1302f371
Commit
1302f371
authored
Aug 21, 2014
by
Carter Edwards
Browse files
Kokkos example: upgrade the BoxElemFixture to 64bit ids and numberings for large problems.
parent
1bf7183f
Changes
7
Hide whitespace changes
Inline
Side-by-side
packages/kokkos/example/fixture/BoxElemFixture.hpp
View file @
1302f371
...
...
@@ -66,13 +66,13 @@ struct MapGridUnitCube {
const
float
m_a
;
const
float
m_b
;
const
float
m_c
;
const
unsigned
m_max_x
;
const
unsigned
m_max_y
;
const
unsigned
m_max_z
;
const
size_t
m_max_x
;
const
size_t
m_max_y
;
const
size_t
m_max_z
;
MapGridUnitCube
(
const
unsigned
grid_max_x
,
const
unsigned
grid_max_y
,
const
unsigned
grid_max_z
,
MapGridUnitCube
(
const
size_t
grid_max_x
,
const
size_t
grid_max_y
,
const
size_t
grid_max_z
,
const
float
bubble_x
,
const
float
bubble_y
,
const
float
bubble_z
)
...
...
@@ -138,64 +138,64 @@ private:
Kokkos
::
Example
::
BoxElemPart
m_box_part
;
CoordinateMap
m_coord_map
;
Kokkos
::
View
<
double
*
[
SpaceDim
]
,
Device
>
m_node_coord
;
Kokkos
::
View
<
unsigned
*
[
SpaceDim
]
,
Device
>
m_node_grid
;
Kokkos
::
View
<
unsigned
*
[
ElemNode
]
,
Device
>
m_elem_node
;
Kokkos
::
View
<
unsigned
*
[
2
]
,
Device
>
m_recv_node
;
Kokkos
::
View
<
unsigned
*
[
2
]
,
Device
>
m_send_node
;
Kokkos
::
View
<
unsigned
*
,
Device
>
m_send_node_id
;
Kokkos
::
View
<
double
*
[
SpaceDim
]
,
Device
>
m_node_coord
;
Kokkos
::
View
<
size_t
*
[
SpaceDim
]
,
Device
>
m_node_grid
;
Kokkos
::
View
<
size_t
*
[
ElemNode
]
,
Device
>
m_elem_node
;
Kokkos
::
View
<
size_t
*
[
2
]
,
Device
>
m_recv_node
;
Kokkos
::
View
<
size_t
*
[
2
]
,
Device
>
m_send_node
;
Kokkos
::
View
<
size_t
*
,
Device
>
m_send_node_id
;
unsigned
char
m_elem_node_local
[
ElemNode
][
4
]
;
public:
typedef
Kokkos
::
View
<
const
unsigned
*
[
ElemNode
],
Device
>
elem_node_type
;
typedef
Kokkos
::
View
<
const
double
*
[
SpaceDim
],
Device
>
node_coord_type
;
typedef
Kokkos
::
View
<
const
unsigned
*
[
SpaceDim
],
Device
>
node_grid_type
;
typedef
Kokkos
::
View
<
const
unsigned
*
[
2
]
,
Device
>
comm_list_type
;
typedef
Kokkos
::
View
<
const
unsigned
*
,
Device
>
send_nodeid_type
;
typedef
Kokkos
::
View
<
const
size_t
*
[
ElemNode
],
Device
>
elem_node_type
;
typedef
Kokkos
::
View
<
const
double
*
[
SpaceDim
],
Device
>
node_coord_type
;
typedef
Kokkos
::
View
<
const
size_t
*
[
SpaceDim
],
Device
>
node_grid_type
;
typedef
Kokkos
::
View
<
const
size_t
*
[
2
]
,
Device
>
comm_list_type
;
typedef
Kokkos
::
View
<
const
size_t
*
,
Device
>
send_nodeid_type
;
KOKKOS_INLINE_FUNCTION
unsigned
node_count
()
const
{
return
m_node_grid
.
dimension_0
();
}
size_t
node_count
()
const
{
return
m_node_grid
.
dimension_0
();
}
KOKKOS_INLINE_FUNCTION
unsigned
node_count_owned
()
const
{
return
m_box_part
.
owns_node_count
();
}
size_t
node_count_owned
()
const
{
return
m_box_part
.
owns_node_count
();
}
KOKKOS_INLINE_FUNCTION
unsigned
node_count_global
()
const
{
return
m_box_part
.
global_node_count
();
}
size_t
node_count_global
()
const
{
return
m_box_part
.
global_node_count
();
}
KOKKOS_INLINE_FUNCTION
unsigned
elem_count
()
const
{
return
m_elem_node
.
dimension_0
();
}
size_t
elem_count
()
const
{
return
m_elem_node
.
dimension_0
();
}
KOKKOS_INLINE_FUNCTION
unsigned
elem_count_global
()
const
{
return
m_box_part
.
global_elem_count
();
}
size_t
elem_count_global
()
const
{
return
m_box_part
.
global_elem_count
();
}
KOKKOS_INLINE_FUNCTION
unsigned
elem_node_local
(
unsigned
inode
,
unsigned
k
)
const
size_t
elem_node_local
(
size_t
inode
,
int
k
)
const
{
return
m_elem_node_local
[
inode
][
k
]
;
}
KOKKOS_INLINE_FUNCTION
unsigned
node_grid
(
unsigned
inode
,
unsigned
iaxis
)
const
size_t
node_grid
(
size_t
inode
,
int
iaxis
)
const
{
return
m_node_grid
(
inode
,
iaxis
);
}
KOKKOS_INLINE_FUNCTION
size_t
node_global_index
(
unsigned
local
)
const
size_t
node_global_index
(
size_t
local
)
const
{
const
unsigned
node_grid
[
SpaceDim
]
=
const
size_t
node_grid
[
SpaceDim
]
=
{
m_node_grid
(
local
,
0
)
,
m_node_grid
(
local
,
1
)
,
m_node_grid
(
local
,
2
)
};
return
m_box_part
.
global_node_id
(
node_grid
);
}
KOKKOS_INLINE_FUNCTION
double
node_coord
(
unsigned
inode
,
unsigned
iaxis
)
const
double
node_coord
(
size_t
inode
,
int
iaxis
)
const
{
return
m_node_coord
(
inode
,
iaxis
);
}
KOKKOS_INLINE_FUNCTION
unsigned
node_grid_max
(
unsigned
iaxis
)
const
size_t
node_grid_max
(
int
iaxis
)
const
{
return
m_box_part
.
global_coord_max
(
iaxis
);
}
KOKKOS_INLINE_FUNCTION
unsigned
elem_node
(
unsigned
ielem
,
unsigned
inode
)
const
size_t
elem_node
(
size_t
ielem
,
size_t
inode
)
const
{
return
m_elem_node
(
ielem
,
inode
);
}
elem_node_type
elem_node
()
const
{
return
m_elem_node
;
}
...
...
@@ -216,7 +216,7 @@ public:
,
m_send_node
(
rhs
.
m_send_node
)
,
m_send_node_id
(
rhs
.
m_send_node_id
)
{
for
(
unsigned
i
=
0
;
i
<
ElemNode
;
++
i
)
{
for
(
int
i
=
0
;
i
<
ElemNode
;
++
i
)
{
m_elem_node_local
[
i
][
0
]
=
rhs
.
m_elem_node_local
[
i
][
0
]
;
m_elem_node_local
[
i
][
1
]
=
rhs
.
m_elem_node_local
[
i
][
1
]
;
m_elem_node_local
[
i
][
2
]
=
rhs
.
m_elem_node_local
[
i
][
2
]
;
...
...
@@ -235,7 +235,7 @@ public:
m_send_node
=
rhs
.
m_send_node
;
m_send_node_id
=
rhs
.
m_send_node_id
;
for
(
unsigned
i
=
0
;
i
<
ElemNode
;
++
i
)
{
for
(
int
i
=
0
;
i
<
ElemNode
;
++
i
)
{
m_elem_node_local
[
i
][
0
]
=
rhs
.
m_elem_node_local
[
i
][
0
]
;
m_elem_node_local
[
i
][
1
]
=
rhs
.
m_elem_node_local
[
i
][
1
]
;
m_elem_node_local
[
i
][
2
]
=
rhs
.
m_elem_node_local
[
i
][
2
]
;
...
...
@@ -245,11 +245,11 @@ public:
}
BoxElemFixture
(
const
BoxElemPart
::
Decompose
decompose
,
const
unsigned
global_size
,
const
unsigned
global_rank
,
const
unsigned
elem_nx
,
const
unsigned
elem_ny
,
const
unsigned
elem_nz
,
const
size_t
global_size
,
const
size_t
global_rank
,
const
size_t
elem_nx
,
const
size_t
elem_ny
,
const
size_t
elem_nz
,
const
float
bubble_x
=
1.1
f
,
const
float
bubble_y
=
1.2
f
,
const
float
bubble_z
=
1.3
f
)
...
...
@@ -270,7 +270,7 @@ public:
{
const
hex_data
elem_data
;
for
(
unsigned
i
=
0
;
i
<
ElemNode
;
++
i
)
{
for
(
int
i
=
0
;
i
<
ElemNode
;
++
i
)
{
m_elem_node_local
[
i
][
0
]
=
elem_data
.
eval_map
[
i
][
0
]
;
m_elem_node_local
[
i
][
1
]
=
elem_data
.
eval_map
[
i
][
1
]
;
m_elem_node_local
[
i
][
2
]
=
elem_data
.
eval_map
[
i
][
2
]
;
...
...
@@ -299,8 +299,8 @@ public:
const
size_t
ielem
=
i
/
ElemNode
;
const
size_t
inode
=
i
%
ElemNode
;
unsigned
elem_grid
[
SpaceDim
]
;
unsigned
node_grid
[
SpaceDim
]
;
size_t
elem_grid
[
SpaceDim
]
;
size_t
node_grid
[
SpaceDim
]
;
m_box_part
.
uses_elem_coord
(
ielem
,
elem_grid
);
...
...
@@ -315,7 +315,7 @@ public:
}
if
(
i
<
m_node_grid
.
dimension_0
()
)
{
unsigned
node_grid
[
SpaceDim
]
;
size_t
node_grid
[
SpaceDim
]
;
m_box_part
.
local_node_coord
(
i
,
node_grid
);
m_node_grid
(
i
,
0
)
=
node_grid
[
0
]
;
m_node_grid
(
i
,
1
)
=
node_grid
[
1
]
;
...
...
packages/kokkos/example/fixture/BoxElemPart.cpp
View file @
1302f371
...
...
@@ -53,29 +53,29 @@
namespace
Kokkos
{
namespace
Example
{
void
box_partition
(
const
unsigned
global_size
,
const
unsigned
global_rank
,
const
unsigned
global_box
[][
2
]
,
unsigned
box
[][
2
]
)
void
box_partition
(
const
size_t
global_size
,
const
size_t
global_rank
,
const
size_t
global_box
[][
2
]
,
size_t
box
[][
2
]
)
{
box
[
0
][
0
]
=
global_box
[
0
][
0
]
;
box
[
0
][
1
]
=
global_box
[
0
][
1
]
;
box
[
1
][
0
]
=
global_box
[
1
][
0
]
;
box
[
1
][
1
]
=
global_box
[
1
][
1
]
;
box
[
2
][
0
]
=
global_box
[
2
][
0
]
;
box
[
2
][
1
]
=
global_box
[
2
][
1
]
;
unsigned
ip
=
0
;
unsigned
np
=
global_size
;
size_t
ip
=
0
;
size_t
np
=
global_size
;
while
(
1
<
np
)
{
// P = [ ip + j * portion , ip + ( j + 1 ) * portion )
unsigned
jip
,
jup
;
size_t
jip
,
jup
;
{
const
unsigned
part
=
(
0
==
(
np
%
5
)
)
?
5
:
(
(
0
==
(
np
%
3
)
)
?
3
:
2
);
const
size_t
part
=
(
0
==
(
np
%
5
)
)
?
5
:
(
(
0
==
(
np
%
3
)
)
?
3
:
2
);
const
unsigned
portion
=
np
/
part
;
const
size_t
portion
=
np
/
part
;
if
(
2
<
part
||
global_rank
<
ip
+
portion
)
{
jip
=
portion
*
size_t
(
double
(
global_rank
-
ip
)
/
double
(
portion
)
);
...
...
@@ -89,16 +89,16 @@ void box_partition( const unsigned global_size ,
// Choose axis with largest count:
const
unsigned
nb
[
3
]
=
{
const
size_t
nb
[
3
]
=
{
box
[
0
][
1
]
-
box
[
0
][
0
]
,
box
[
1
][
1
]
-
box
[
1
][
0
]
,
box
[
2
][
1
]
-
box
[
2
][
0
]
};
const
unsigned
axis
=
nb
[
2
]
>
nb
[
1
]
?
(
nb
[
2
]
>
nb
[
0
]
?
2
:
0
)
const
int
axis
=
nb
[
2
]
>
nb
[
1
]
?
(
nb
[
2
]
>
nb
[
0
]
?
2
:
0
)
:
(
nb
[
1
]
>
nb
[
0
]
?
1
:
0
);
box
[
axis
][
1
]
=
box
[
axis
][
0
]
+
unsigned
(
double
(
nb
[
axis
])
*
(
double
(
jup
)
/
double
(
np
)
));
box
[
axis
][
0
]
=
box
[
axis
][
0
]
+
unsigned
(
double
(
nb
[
axis
])
*
(
double
(
jip
)
/
double
(
np
)
));
box
[
axis
][
1
]
=
box
[
axis
][
0
]
+
size_t
(
double
(
nb
[
axis
])
*
(
double
(
jup
)
/
double
(
np
)
));
box
[
axis
][
0
]
=
box
[
axis
][
0
]
+
size_t
(
double
(
nb
[
axis
])
*
(
double
(
jip
)
/
double
(
np
)
));
np
=
jup
-
jip
;
ip
=
ip
+
jip
;
...
...
@@ -113,42 +113,42 @@ void box_partition( const unsigned global_size ,
namespace
Kokkos
{
namespace
Example
{
void
BoxElemPart
::
local
(
const
unsigned
rank
,
unsigned
uses_elem
[][
2
]
,
unsigned
owns_node
[][
2
]
,
unsigned
uses_node
[][
2
]
)
const
void
BoxElemPart
::
local
(
const
size_t
rank
,
size_t
uses_elem
[][
2
]
,
size_t
owns_node
[][
2
]
,
size_t
uses_node
[][
2
]
)
const
{
if
(
BoxElemPart
::
DecomposeElem
==
m_decompose
)
{
Kokkos
::
Example
::
box_partition
(
m_global_size
,
rank
,
m_global_elem_box
,
uses_elem
);
for
(
unsigned
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
owns_node
[
i
][
0
]
=
uses_elem
[
i
][
0
]
;
owns_node
[
i
][
1
]
=
uses_elem
[
i
][
1
]
+
(
m_global_elem_box
[
i
][
1
]
==
uses_elem
[
i
][
1
]
?
1
:
0
);
}
}
else
{
const
unsigned
global_vert
[
3
][
2
]
=
const
size_t
global_vert
[
3
][
2
]
=
{
{
0
,
m_global_elem_box
[
0
][
1
]
+
1
},
{
0
,
m_global_elem_box
[
1
][
1
]
+
1
},
{
0
,
m_global_elem_box
[
2
][
1
]
+
1
}
};
Kokkos
::
Example
::
box_partition
(
m_global_size
,
rank
,
global_vert
,
owns_node
);
for
(
unsigned
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
uses_elem
[
i
][
0
]
=
global_vert
[
i
][
0
]
==
owns_node
[
i
][
0
]
?
owns_node
[
i
][
0
]
:
owns_node
[
i
][
0
]
-
1
;
uses_elem
[
i
][
1
]
=
global_vert
[
i
][
1
]
==
owns_node
[
i
][
1
]
?
owns_node
[
i
][
1
]
-
1
:
owns_node
[
i
][
1
]
;
}
}
for
(
unsigned
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
uses_node
[
i
][
0
]
=
uses_elem
[
i
][
0
]
;
uses_node
[
i
][
1
]
=
uses_elem
[
i
][
1
]
+
1
;
}
if
(
BoxElemPart
::
ElemQuadratic
==
m_elem_order
)
{
for
(
unsigned
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
owns_node
[
i
][
0
]
=
2
*
owns_node
[
i
][
0
]
;
uses_node
[
i
][
0
]
=
2
*
uses_node
[
i
][
0
]
;
owns_node
[
i
][
1
]
=
2
*
owns_node
[
i
][
1
]
-
1
;
...
...
@@ -160,16 +160,16 @@ void BoxElemPart::local( const unsigned rank ,
BoxElemPart
::
BoxElemPart
(
const
BoxElemPart
::
ElemOrder
elem_order
,
const
BoxElemPart
::
Decompose
decompose
,
const
unsigned
global_size
,
const
unsigned
global_rank
,
const
unsigned
elem_nx
,
const
unsigned
elem_ny
,
const
unsigned
elem_nz
)
const
size_t
global_size
,
const
size_t
global_rank
,
const
size_t
elem_nx
,
const
size_t
elem_ny
,
const
size_t
elem_nz
)
{
m_global_size
=
global_size
;
m_global_rank
=
global_rank
;
m_elem_order
=
elem_order
;
m_decompose
=
decompose
;
m_elem_order
=
elem_order
;
m_global_elem_box
[
0
][
0
]
=
0
;
m_global_elem_box
[
0
][
1
]
=
elem_nx
;
m_global_elem_box
[
1
][
0
]
=
0
;
m_global_elem_box
[
1
][
1
]
=
elem_ny
;
...
...
@@ -179,6 +179,11 @@ BoxElemPart::BoxElemPart(
m_global_node_box
[
1
][
0
]
=
0
;
m_global_node_box
[
1
][
1
]
=
0
;
m_global_node_box
[
2
][
0
]
=
0
;
m_global_node_box
[
2
][
1
]
=
0
;
m_owns_node_count
=
0
;
m_send_node_count
=
0
;
//----------------------------------------
if
(
ElemLinear
==
elem_order
)
{
m_global_node_box
[
0
][
1
]
=
elem_nx
+
1
;
m_global_node_box
[
1
][
1
]
=
elem_ny
+
1
;
...
...
@@ -207,11 +212,11 @@ BoxElemPart::BoxElemPart(
m_owns_node_count
=
1
;
m_send_node_count
=
0
;
for
(
unsigned
rr
=
1
;
rr
<
m_global_size
;
++
rr
)
{
for
(
size_t
rr
=
1
;
rr
<
m_global_size
;
++
rr
)
{
const
unsigned
rank
=
(
m_global_rank
+
rr
)
%
m_global_size
;
const
size_t
rank
=
(
m_global_rank
+
rr
)
%
m_global_size
;
unsigned
elem_box
[
3
][
2
]
,
o_node_box
[
3
][
2
]
,
u_node_box
[
3
][
2
]
;
size_t
elem_box
[
3
][
2
]
,
o_node_box
[
3
][
2
]
,
u_node_box
[
3
][
2
]
;
// Boxes for process 'rank'
local
(
rank
,
elem_box
,
o_node_box
,
u_node_box
);
...
...
@@ -238,7 +243,7 @@ BoxElemPart::BoxElemPart(
// Error checking:
unsigned
test_box
[
3
][
2
]
;
size_t
test_box
[
3
][
2
]
;
elem_count
+=
Kokkos
::
Example
::
box_count
(
elem_box
);
node_count
+=
Kokkos
::
Example
::
box_count
(
o_node_box
);
...
...
@@ -296,7 +301,7 @@ BoxElemPart::BoxElemPart(
{
size_t
count
=
0
;
for
(
unsigned
i
=
0
;
i
<
m_owns_node_count
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
m_owns_node_count
;
++
i
)
{
count
+=
m_owns_node
[
i
][
1
]
;
}
if
(
count
!=
Kokkos
::
Example
::
box_count
(
m_uses_node_box
)
)
{
...
...
@@ -343,7 +348,7 @@ void BoxElemPart::print( std::ostream & s ) const
<<
" }"
<<
std
::
endl
;
for
(
unsigned
i
=
1
;
i
<
m_owns_node_count
;
++
i
)
{
for
(
size_t
i
=
1
;
i
<
m_owns_node_count
;
++
i
)
{
s
<<
" P["
<<
m_owns_node
[
i
][
0
]
<<
"]"
<<
" recv node_box {"
<<
" ["
<<
m_owns_node_box
[
i
][
0
][
0
]
<<
","
<<
m_owns_node_box
[
i
][
0
][
1
]
<<
")"
...
...
@@ -353,7 +358,7 @@ void BoxElemPart::print( std::ostream & s ) const
<<
std
::
endl
;
}
for
(
unsigned
i
=
0
;
i
<
m_send_node_count
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
m_send_node_count
;
++
i
)
{
s
<<
" P["
<<
m_send_node
[
i
][
0
]
<<
"]"
<<
" send node_box {"
<<
" ["
<<
m_send_node_box
[
i
][
0
][
0
]
<<
","
<<
m_send_node_box
[
i
][
0
][
1
]
<<
")"
...
...
packages/kokkos/example/fixture/BoxElemPart.hpp
View file @
1302f371
...
...
@@ -54,11 +54,11 @@ namespace Kokkos {
namespace
Example
{
KOKKOS_INLINE_FUNCTION
void
box_intersect
(
unsigned
box
[][
2
]
,
const
unsigned
boxA
[][
2
]
,
const
unsigned
boxB
[][
2
]
)
void
box_intersect
(
size_t
box
[][
2
]
,
const
size_t
boxA
[][
2
]
,
const
size_t
boxB
[][
2
]
)
{
for
(
unsigned
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
box
[
i
][
0
]
=
boxA
[
i
][
0
]
>
boxB
[
i
][
0
]
?
boxA
[
i
][
0
]
:
boxB
[
i
][
0
]
;
box
[
i
][
1
]
=
boxA
[
i
][
1
]
<
boxB
[
i
][
1
]
?
boxA
[
i
][
1
]
:
boxB
[
i
][
1
]
;
if
(
box
[
i
][
0
]
>
box
[
i
][
1
]
)
box
[
i
][
1
]
=
box
[
i
][
0
]
;
...
...
@@ -66,7 +66,7 @@ void box_intersect( unsigned box[][2] ,
}
KOKKOS_INLINE_FUNCTION
size_t
box_count
(
const
unsigned
box
[][
2
]
)
size_t
box_count
(
const
size_t
box
[][
2
]
)
{
return
size_t
(
box
[
0
][
1
]
-
box
[
0
][
0
]
)
*
size_t
(
box
[
1
][
1
]
-
box
[
1
][
0
]
)
*
...
...
@@ -74,21 +74,21 @@ size_t box_count( const unsigned box[][2] )
}
KOKKOS_INLINE_FUNCTION
void
box_ghost_layer
(
const
unsigned
global_box
[][
2
]
,
const
unsigned
local_box
[][
2
]
,
const
unsigned
ghost_layer
,
unsigned
ghost_box
[][
2
]
)
void
box_ghost_layer
(
const
size_t
global_box
[][
2
]
,
const
size_t
local_box
[][
2
]
,
const
size_t
ghost_layer
,
size_t
ghost_box
[][
2
]
)
{
for
(
unsigned
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
ghost_box
[
i
][
0
]
=
global_box
[
i
][
0
]
+
ghost_layer
>
local_box
[
i
][
0
]
?
global_box
[
i
][
0
]
:
local_box
[
i
][
0
]
-
ghost_layer
;
ghost_box
[
i
][
1
]
=
global_box
[
i
][
1
]
<
local_box
[
i
][
1
]
+
ghost_layer
?
global_box
[
i
][
1
]
:
local_box
[
i
][
1
]
+
ghost_layer
;
}
}
void
box_partition
(
const
unsigned
global_size
,
const
unsigned
global_rank
,
const
unsigned
global_box
[][
2
]
,
unsigned
box
[][
2
]
);
void
box_partition
(
const
size_t
global_size
,
const
size_t
global_rank
,
const
size_t
global_box
[][
2
]
,
size_t
box
[][
2
]
);
}
// namespace Example
}
// namespace Kokkos
...
...
@@ -115,11 +115,11 @@ public:
BoxElemPart
(
const
ElemOrder
elem_order
,
const
Decompose
decompose
,
const
unsigned
global_size
,
const
unsigned
global_rank
,
const
unsigned
elem_nx
,
const
unsigned
elem_ny
,
const
unsigned
elem_nz
);
const
size_t
global_size
,
const
size_t
global_rank
,
const
size_t
elem_nx
,
const
size_t
elem_ny
,
const
size_t
elem_nz
);
KOKKOS_INLINE_FUNCTION
size_t
global_elem_count
()
const
...
...
@@ -144,9 +144,9 @@ public:
//----------------------------------------
KOKKOS_INLINE_FUNCTION
size_t
uses_elem_offset
(
const
unsigned
ix
,
const
unsigned
iy
,
const
unsigned
iz
)
const
size_t
uses_elem_offset
(
const
size_t
ix
,
const
size_t
iy
,
const
size_t
iz
)
const
{
return
size_t
(
ix
-
m_uses_elem_box
[
0
][
0
]
)
+
size_t
(
m_uses_elem_box
[
0
][
1
]
-
m_uses_elem_box
[
0
][
0
]
)
*
(
size_t
(
iy
-
m_uses_elem_box
[
1
][
0
]
)
+
size_t
(
m_uses_elem_box
[
1
][
1
]
-
m_uses_elem_box
[
1
][
0
]
)
*
(
...
...
@@ -154,10 +154,10 @@ public:
}
KOKKOS_INLINE_FUNCTION
void
uses_elem_coord
(
size_t
lid
,
unsigned
c
[]
)
const
void
uses_elem_coord
(
size_t
lid
,
size_t
c
[]
)
const
{
const
unsigned
nx
=
m_uses_elem_box
[
0
][
1
]
-
m_uses_elem_box
[
0
][
0
]
;
const
unsigned
ny
=
m_uses_elem_box
[
1
][
1
]
-
m_uses_elem_box
[
1
][
0
]
;
const
size_t
nx
=
m_uses_elem_box
[
0
][
1
]
-
m_uses_elem_box
[
0
][
0
]
;
const
size_t
ny
=
m_uses_elem_box
[
1
][
1
]
-
m_uses_elem_box
[
1
][
0
]
;
c
[
0
]
=
m_uses_elem_box
[
0
][
0
]
+
lid
%
nx
;
lid
/=
nx
;
c
[
1
]
=
m_uses_elem_box
[
1
][
0
]
+
lid
%
ny
;
lid
/=
ny
;
...
...
@@ -167,21 +167,21 @@ public:
//----------------------------------------
KOKKOS_INLINE_FUNCTION
unsigned
global_coord_max
(
unsigned
axis
)
const
size_t
global_coord_max
(
size_t
axis
)
const
{
return
m_global_node_box
[
axis
][
1
]
-
1
;
}
//----------------------------------------
KOKKOS_INLINE_FUNCTION
void
local_node_coord
(
size_t
lid
,
unsigned
coord
[]
)
const
void
local_node_coord
(
size_t
lid
,
size_t
coord
[]
)
const
{
// Local id within an 'owns' block (has sentinal)
unsigned
j
=
0
;
size_t
j
=
0
;
while
(
m_owns_node
[
j
][
1
]
<=
lid
)
{
lid
-=
m_owns_node
[
j
][
1
]
;
++
j
;
}
// Map to global coordinates:
const
unsigned
nx
=
m_owns_node_box
[
j
][
0
][
1
]
-
m_owns_node_box
[
j
][
0
][
0
]
;
const
unsigned
ny
=
m_owns_node_box
[
j
][
1
][
1
]
-
m_owns_node_box
[
j
][
1
][
0
]
;
const
size_t
nx
=
m_owns_node_box
[
j
][
0
][
1
]
-
m_owns_node_box
[
j
][
0
][
0
]
;
const
size_t
ny
=
m_owns_node_box
[
j
][
1
][
1
]
-
m_owns_node_box
[
j
][
1
][
0
]
;
coord
[
0
]
=
m_owns_node_box
[
j
][
0
][
0
]
+
lid
%
nx
;
lid
/=
nx
;
coord
[
1
]
=
m_owns_node_box
[
j
][
1
][
0
]
+
lid
%
ny
;
lid
/=
ny
;
...
...
@@ -189,11 +189,11 @@ public:
}
KOKKOS_INLINE_FUNCTION
unsigned
local_node_id
(
const
unsigned
c
[]
)
const
size_t
local_node_id
(
const
size_t
c
[]
)
const
{
// Find which 'owns' block and accumulate the offset of this block:
size_t
lid
=
0
;
unsigned
j
=
0
;
size_t
j
=
0
;
while
(
!
(
m_owns_node_box
[
j
][
0
][
0
]
<=
c
[
0
]
&&
c
[
0
]
<
m_owns_node_box
[
j
][
0
][
1
]
&&
m_owns_node_box
[
j
][
1
][
0
]
<=
c
[
1
]
&&
c
[
1
]
<
m_owns_node_box
[
j
][
1
][
1
]
&&
m_owns_node_box
[
j
][
2
][
0
]
<=
c
[
2
]
&&
c
[
2
]
<
m_owns_node_box
[
j
][
2
][
1
]
)
)
{
...
...
@@ -210,7 +210,7 @@ public:
}
KOKKOS_INLINE_FUNCTION
size_t
global_node_id
(
const
unsigned
c
[]
)
const
size_t
global_node_id
(
const
size_t
c
[]
)
const
{
return
size_t
(
c
[
0
]
-
m_global_node_box
[
0
][
0
]
)
+
size_t
(
m_global_node_box
[
0
][
1
]
-
m_global_node_box
[
0
][
0
]
)
*
(
size_t
(
c
[
1
]
-
m_global_node_box
[
1
][
0
]
)
+
size_t
(
m_global_node_box
[
1
][
1
]
-
m_global_node_box
[
1
][
0
]
)
*
(
...
...
@@ -220,47 +220,47 @@ public:
//----------------------------------------
KOKKOS_INLINE_FUNCTION
unsigned
recv_node_msg_count
()
const
{
return
m_owns_node_count
-
1
;
}
size_t
recv_node_msg_count
()
const
{
return
m_owns_node_count
-
1
;
}
KOKKOS_INLINE_FUNCTION
unsigned
recv_node_rank
(
unsigned
msg
)
const
{
return
m_owns_node
[
msg
+
1
][
0
]
;
}
size_t
recv_node_rank
(
size_t
msg
)
const
{
return
m_owns_node
[
msg
+
1
][
0
]
;
}
KOKKOS_INLINE_FUNCTION
unsigned
recv_node_count
(
unsigned
msg
)
const
{
return
m_owns_node
[
msg
+
1
][
1
]
;
}
size_t
recv_node_count
(
size_t
msg
)
const
{
return
m_owns_node
[
msg
+
1
][
1
]
;
}
//----------------------------------------
KOKKOS_INLINE_FUNCTION
unsigned
send_node_msg_count
()
const
{
return
m_send_node_count
;
}
size_t
send_node_msg_count
()
const
{
return
m_send_node_count
;
}
KOKKOS_INLINE_FUNCTION
unsigned
send_node_rank
(
unsigned
msg
)
const
{
return
m_send_node
[
msg
][
0
]
;
}
size_t
send_node_rank
(
size_t
msg
)
const
{
return
m_send_node
[
msg
][
0
]
;
}
KOKKOS_INLINE_FUNCTION
unsigned
send_node_count
(
unsigned
msg
)
const
{
return
m_send_node
[
msg
][
1
]
;
}
size_t
send_node_count
(
size_t
msg
)
const
{
return
m_send_node
[
msg
][
1
]
;
}
KOKKOS_INLINE_FUNCTION
unsigned
send_node_id_count
()
const
size_t
send_node_id_count
()
const
{
unsigned
count
=
0
;
for
(
unsigned
i
=
0
;
i
<
m_send_node_count
;
++
i
)
{
size_t
count
=
0
;
for
(
size_t
i
=
0
;
i
<
m_send_node_count
;
++
i
)
{
count
+=
m_send_node
[
i
][
1
]
;
}
return
count
;
}
KOKKOS_INLINE_FUNCTION
unsigned
send_node_id
(
unsigned
item
)
const
size_t
send_node_id
(
size_t
item
)
const
{
// Find which send list this send item is in:
unsigned
j
=
0
;
size_t
j
=
0
;
while
(
m_send_node
[
j
][
1
]
<=
item
)
{
item
-=
m_send_node
[
j
][
1
]
;
++
j
;
}
// Map to global coordinate:
const
unsigned
nx
=
m_send_node_box
[
j
][
0
][
1
]
-
m_send_node_box
[
j
][
0
][
0
]
;
const
unsigned
ny
=
m_send_node_box
[
j
][
1
][
1
]
-
m_send_node_box
[
j
][
1
][
0
]
;
const
size_t
nx
=
m_send_node_box
[
j
][
0
][
1
]
-
m_send_node_box
[
j
][
0
][
0
]
;
const
size_t
ny
=
m_send_node_box
[
j
][
1
][
1
]
-
m_send_node_box
[
j
][
1
][
0
]
;
unsigned
c
[
3
]
;
size_t
c
[
3
]
;
c
[
0
]
=
m_send_node_box
[
j
][
0
][
0
]
+
item
%
nx
;
item
/=
nx
;