Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sbalzarini Lab
S
Software
P
Parallel Computing
OpenFPM
openfpm_pdata
Commits
8eb4ab81
Commit
8eb4ab81
authored
Mar 02, 2016
by
Pietro Incardona
Browse files
Adding missing file
parent
4d2f4e28
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/Decomposition/Distribution/Distribution_unit_tests.hpp
View file @
8eb4ab81
...
...
@@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE( Metis_distribution_test)
// operator= functions
// operator== functions
BOOST_REQUIRE_EQUAL
(
sizeof
(
MetisDistribution
<
3
,
float
>
),
68
0
ul
);
BOOST_REQUIRE_EQUAL
(
sizeof
(
MetisDistribution
<
3
,
float
>
),
5
68ul
);
}
BOOST_AUTO_TEST_CASE
(
Parmetis_distribution_test
)
...
...
@@ -231,6 +231,8 @@ BOOST_AUTO_TEST_CASE( Parmetis_distribution_test)
}
//! [refine with parmetis the decomposition]
BOOST_REQUIRE_EQUAL
(
sizeof
(
MetisDistribution
<
3
,
float
>
),
568ul
);
}
BOOST_AUTO_TEST_CASE
(
DistPametis_distribution_test
)
...
...
src/Decomposition/Distribution/parmetis_util.hpp
View file @
8eb4ab81
...
...
@@ -207,6 +207,25 @@ public:
{
// TODO Move into VCluster
MPI_Comm_dup
(
MPI_COMM_WORLD
,
&
comm
);
// Nullify Mg
Mg
.
nvtxs
=
NULL
;
Mg
.
ncon
=
NULL
;
Mg
.
xadj
=
NULL
;
Mg
.
adjncy
=
NULL
;
Mg
.
vwgt
=
NULL
;
Mg
.
vsize
=
NULL
;
Mg
.
adjwgt
=
NULL
;
Mg
.
nparts
=
NULL
;
Mg
.
tpwgts
=
NULL
;
Mg
.
ubvec
=
NULL
;
Mg
.
options
=
NULL
;
Mg
.
objval
=
NULL
;
Mg
.
part
=
NULL
;
Mg
.
edgecut
=
NULL
;
Mg
.
itr
=
NULL
;
Mg
.
numflag
=
NULL
;
Mg
.
wgtflag
=
NULL
;
}
//TODO deconstruct new variables
...
...
@@ -302,66 +321,10 @@ public:
last
=
vtxdist
.
get
(
p_id
+
1
)
-
1
;
nvertex
=
last
.
id
-
first
.
id
+
1
;
// Get the number of vertex
Mg
.
nvtxs
=
new
idx_t
[
1
];
Mg
.
nvtxs
[
0
]
=
nvertex
;
// Set the number of constrains
Mg
.
ncon
=
new
idx_t
[
1
];
Mg
.
ncon
[
0
]
=
1
;
// Set to null the weight of the vertex (init after in constructAdjList) (can be removed)
Mg
.
vwgt
=
NULL
;
// Set to null the weight of the edge (init after in constructAdjList) (can be removed)
Mg
.
adjwgt
=
NULL
;
setDefaultParameters
(
w
);
// construct the adjacency list
constructAdjList
(
g
,
m2g
);
// Set the total number of partitions
Mg
.
nparts
=
new
idx_t
[
1
];
Mg
.
nparts
[
0
]
=
nc
;
//! Set option for the graph partitioning (set as default)
Mg
.
options
=
new
idx_t
[
4
];
Mg
.
options
[
0
]
=
0
;
Mg
.
options
[
1
]
=
0
;
Mg
.
options
[
2
]
=
0
;
Mg
.
options
[
3
]
=
0
;
//! is an output vector containing the partition for each vertex
//! adaptiveRepart itr value
Mg
.
itr
=
new
real_t
[
1
];
Mg
.
itr
[
0
]
=
1000.0
;
//! init tpwgts to have balanced vertices and ubvec
Mg
.
tpwgts
=
new
real_t
[
Mg
.
nparts
[
0
]];
Mg
.
ubvec
=
new
real_t
[
Mg
.
nparts
[
0
]];
for
(
size_t
s
=
0
;
s
<
(
size_t
)
Mg
.
nparts
[
0
];
s
++
)
{
Mg
.
tpwgts
[
s
]
=
1.0
/
Mg
.
nparts
[
0
];
Mg
.
ubvec
[
s
]
=
1.05
;
}
Mg
.
edgecut
=
new
idx_t
[
1
];
Mg
.
edgecut
[
0
]
=
0
;
//! This is used to indicate the numbering scheme that is used for the vtxdist, xadj, adjncy, and part arrays. (0 for C-style, start from 0 index)
Mg
.
numflag
=
new
idx_t
[
1
];
Mg
.
numflag
[
0
]
=
0
;
//! This is used to indicate if the graph is weighted. wgtflag can take one of four values:
Mg
.
wgtflag
=
new
idx_t
[
1
];
if
(
w
)
Mg
.
wgtflag
[
0
]
=
3
;
else
Mg
.
wgtflag
[
0
]
=
0
;
}
/*! \brief Decompose the graph
...
...
@@ -444,6 +407,93 @@ public:
constructAdjList
(
g
,
m2g
);
}
/*! \brief Seth the default parameters for parmetis
*
*
*/
void
setDefaultParameters
(
bool
w
)
{
Mg
.
nvtxs
=
new
idx_t
[
1
];
// Set the number of constrains
Mg
.
ncon
=
new
idx_t
[
1
];
Mg
.
ncon
[
0
]
=
1
;
// Set to null the weight of the vertex (init after in constructAdjList) (can be removed)
Mg
.
vwgt
=
NULL
;
// Set to null the weight of the edge (init after in constructAdjList) (can be removed)
Mg
.
adjwgt
=
NULL
;
// Set the total number of partitions
Mg
.
nparts
=
new
idx_t
[
1
];
Mg
.
nparts
[
0
]
=
nc
;
//! Set option for the graph partitioning (set as default)
Mg
.
options
=
new
idx_t
[
4
];
Mg
.
options
[
0
]
=
0
;
Mg
.
options
[
1
]
=
0
;
Mg
.
options
[
2
]
=
0
;
Mg
.
options
[
3
]
=
0
;
//! is an output vector containing the partition for each vertex
//! adaptiveRepart itr value
Mg
.
itr
=
new
real_t
[
1
];
Mg
.
itr
[
0
]
=
1000.0
;
//! init tpwgts to have balanced vertices and ubvec
Mg
.
tpwgts
=
new
real_t
[
Mg
.
nparts
[
0
]];
Mg
.
ubvec
=
new
real_t
[
Mg
.
nparts
[
0
]];
for
(
size_t
s
=
0
;
s
<
(
size_t
)
Mg
.
nparts
[
0
];
s
++
)
{
Mg
.
tpwgts
[
s
]
=
1.0
/
Mg
.
nparts
[
0
];
Mg
.
ubvec
[
s
]
=
1.05
;
}
Mg
.
edgecut
=
new
idx_t
[
1
];
Mg
.
edgecut
[
0
]
=
0
;
//! This is used to indicate the numbering scheme that is used for the vtxdist, xadj, adjncy, and part arrays. (0 for C-style, start from 0 index)
Mg
.
numflag
=
new
idx_t
[
1
];
Mg
.
numflag
[
0
]
=
0
;
//! This is used to indicate if the graph is weighted. wgtflag can take one of four values:
Mg
.
wgtflag
=
new
idx_t
[
1
];
if
(
w
)
Mg
.
wgtflag
[
0
]
=
3
;
else
Mg
.
wgtflag
[
0
]
=
0
;
}
const
Parmetis
<
Graph
>
&
operator
=
(
const
Parmetis
<
Graph
>
&
pm
)
{
comm
=
pm
.
comm
;
v_cl
=
pm
.
v_cl
;
p_id
=
pm
.
p_id
;
nc
=
pm
.
nc
;
setDefaultParameters
(
pm
.
Mg
.
wgtflag
[
0
]
==
3
);
return
*
this
;
}
const
Parmetis
<
Graph
>
&
operator
=
(
Parmetis
<
Graph
>
&&
pm
)
{
comm
=
pm
.
comm
;
v_cl
=
pm
.
v_cl
;
p_id
=
pm
.
p_id
;
nc
=
pm
.
nc
;
setDefaultParameters
(
pm
.
Mg
.
wgtflag
[
0
]
==
3
);
return
*
this
;
}
};
#endif
src/Graph/ids.hpp
0 → 100644
View file @
8eb4ab81
/*
* ids.hpp
*
* Created on: Mar 1, 2016
* Author: i-bird
*/
#ifndef SRC_GRAPH_IDS_HPP_
#define SRC_GRAPH_IDS_HPP_
/*! Here we define different the remapped-id
*
* rid, gid and lid are all unsigned long integer, and can be easily interchanged by mistake
* encapsulating avoid that this could happen. The second is readability, from the definition
* of function/structure we see immediately which id parameter accept/store
*
*/
struct
rid
{
idx_t
id
;
inline
bool
operator
<=
(
const
rid
&
r
)
const
{
return
id
<=
r
.
id
;
}
inline
bool
operator
<
(
const
rid
&
r
)
const
{
return
id
<
r
.
id
;
}
inline
rid
operator
-
(
int
i
)
const
{
struct
rid
tmp
;
tmp
.
id
=
id
-
i
;
return
tmp
;
}
inline
rid
operator
-
(
struct
rid
i
)
const
{
struct
rid
tmp
;
tmp
.
id
=
id
-
i
.
id
;
return
tmp
;
}
inline
rid
operator
+
(
int
i
)
const
{
struct
rid
tmp
;
tmp
.
id
=
id
+
i
;
return
tmp
;
}
inline
rid
&
operator
+=
(
const
rid
&
i
)
{
id
+=
i
.
id
;
return
*
this
;
}
inline
rid
&
operator
++
()
{
id
++
;
return
*
this
;
}
inline
bool
operator
==
(
const
rid
&
r
)
const
{
return
id
==
r
.
id
;
}
};
/*! Here we define different the remapped-id
*
* rid, gid and lid are all unsigned long integer, and can be easily interchanged by mistake
* encapsulating avoid that this could happen. The second is readability, from the definition
* of function/structure we see immediately which id parameter accept/store
*
*/
struct
gid
{
size_t
id
;
};
/*! Here we define different the remapped-id
*
* rid, gid and lid are all unsigned long integer, and can be easily interchanged by mistake
* encapsulating avoid that this could happen. The second is readability, from the definition
* of function/structure we see immediately which id parameter accept/store
*
*/
struct
lid
{
size_t
id
;
};
// define hash map for gid rid and lid
namespace
std
{
template
<
>
struct
hash
<
rid
>
{
inline
std
::
size_t
operator
()(
const
rid
&
k
)
const
{
return
k
.
id
;
}
};
template
<
>
struct
hash
<
gid
>
{
inline
std
::
size_t
operator
()(
const
gid
&
k
)
const
{
return
k
.
id
;
}
};
template
<
>
struct
hash
<
lid
>
{
inline
std
::
size_t
operator
()(
const
lid
&
k
)
const
{
return
k
.
id
;
}
};
}
#endif
/* SRC_GRAPH_IDS_HPP_ */
src/Grid/grid_dist_id.hpp
View file @
8eb4ab81
...
...
@@ -491,6 +491,7 @@ class grid_dist_id
// Create the sub-domains
dec
.
setParameters
(
div
,
domain
,
bc
,
ghost
);
dec
.
decompose
();
// Calculate ghost boxes
dec
.
calculateGhostBoxes
();
...
...
@@ -506,8 +507,6 @@ class grid_dist_id
// fill the global size of the grid
for
(
size_t
i
=
0
;
i
<
dim
;
i
++
)
{
this
->
g_sz
[
i
]
=
g_sz
[
i
];}
dec
.
decompose
();
// Create local grid
Create
();
}
...
...
src/Grid/grid_dist_id_unit_test_ext_dom.hpp
0 → 100644
View file @
8eb4ab81
/*
* grid_dist_id_unit_test_ext_dom.hpp
*
* Created on: Feb 24, 2016
* Author: i-bird
*/
#ifndef SRC_GRID_GRID_DIST_ID_UNIT_TEST_EXT_DOM_HPP_
#define SRC_GRID_GRID_DIST_ID_UNIT_TEST_EXT_DOM_HPP_
// Test duplicated topology
void
Test3D_extended_grid
(
const
Box
<
3
,
float
>
&
domain
,
long
int
k
)
{
long
int
big_step
=
k
/
30
;
big_step
=
(
big_step
==
0
)
?
1
:
big_step
;
long
int
small_step
=
21
;
Vcluster
&
v_cl
=
*
global_v_cluster
;
if
(
v_cl
.
getProcessingUnits
()
>
32
)
return
;
print_test
(
"Testing 3D extended grid k<="
,
k
);
// 3D test
for
(
;
k
>=
2
;
k
-=
(
k
>
2
*
big_step
)
?
big_step
:
small_step
)
{
BOOST_TEST_CHECKPOINT
(
"Testing 3D extended grid k="
<<
k
);
// grid size
size_t
sz
[
3
];
sz
[
0
]
=
k
;
sz
[
1
]
=
k
;
sz
[
2
]
=
k
;
// factor
float
factor
=
pow
(
global_v_cluster
->
getProcessingUnits
()
/
2.0
f
,
1.0
f
/
3.0
f
);
// Ghost
Ghost
<
3
,
float
>
g
(
0.01
/
factor
);
//! [Construct an extended grid]
// Distributed grid with id decomposition
grid_dist_id
<
3
,
float
,
Point_test
<
float
>
,
CartDecomposition
<
3
,
float
>>
g_dist1
(
sz
,
domain
,
g
);
// Extend the grid by 2 points
Box
<
3
,
size_t
>
ext
({
2
,
2
,
2
},{
2
,
2
,
2
});
// another grid perfectly overlapping the previous, extended by 2 points
grid_dist_id
<
3
,
float
,
Point_test
<
float
>
,
CartDecomposition
<
3
,
float
>>
g_dist2
(
g_dist1
,
ext
);
//! [Construct an extended grid]
bool
ret
=
g_dist2
.
getDecomposition
().
check_consistency
();
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
// Given an iterator on grid 1
auto
dom_g1
=
g_dist1
.
getDomainIterator
();
// And a sub-iterator on grid 2 overlapping grid 1
auto
dom_g2
=
g_dist2
.
getSubDomainIterator
({
2
,
2
,
2
},{
k
+
2
-
1
,
k
+
2
-
1
,
k
+
2
-
1
});
grid_key_dx
<
3
>
kb
({
2l
,
2l
,
2l
});
// the 2 iterator must match
bool
check
=
true
;
while
(
dom_g2
.
isNext
())
{
auto
key1
=
dom_g1
.
get
();
auto
key2
=
dom_g2
.
get
();
grid_key_dx
<
3
>
g1_k
=
g_dist1
.
getGKey
(
key1
);
grid_key_dx
<
3
>
g2_k
=
g_dist2
.
getGKey
(
key2
);
g2_k
=
g2_k
-
kb
;
check
&=
(
g1_k
==
g2_k
)
?
true
:
false
;
std
::
cout
<<
"KEY: "
<<
g1_k
.
to_string
()
<<
" "
<<
g2_k
.
to_string
()
<<
"
\n
"
;
if
(
check
==
false
)
{
std
::
cout
<<
"ERROR: "
<<
g1_k
.
to_string
()
<<
" "
<<
g2_k
.
to_string
()
<<
"
\n
"
;
break
;
}
++
dom_g1
;
++
dom_g2
;
}
BOOST_REQUIRE_EQUAL
(
check
,
true
);
}
}
#endif
/* SRC_GRID_GRID_DIST_ID_UNIT_TEST_EXT_DOM_HPP_ */
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