Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_pdata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_pdata
Commits
e5756fb2
Commit
e5756fb2
authored
8 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Patches
Plain Diff
Adding nnprcs test
parent
8fd4e3d4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openfpm_data
+1
-1
1 addition, 1 deletion
openfpm_data
src/Decomposition/nn_processor_unit_test.hpp
+174
-38
174 additions, 38 deletions
src/Decomposition/nn_processor_unit_test.hpp
with
175 additions
and
39 deletions
openfpm_data
@
a5ff72b5
Subproject commit
360031739584423b20497b1364d2c3bcf26c5143
Subproject commit
a5ff72b524862871657f5769aa4d814c2486df0c
This diff is collapsed.
Click to expand it.
src/Decomposition/nn_processor_unit_test.hpp
+
174
−
38
View file @
e5756fb2
...
@@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test)
...
@@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test)
nn_prcs
<
2
,
float
>
nnp
(
v_cl
);
nn_prcs
<
2
,
float
>
nnp
(
v_cl
);
nnp
.
create
(
box_nn_processor
,
sub_domains
);
nnp
.
create
(
box_nn_processor
,
sub_domains
);
BOOST_REQUIRE_EQUAL
(
nnp
.
getNNProcessors
(),
3
);
BOOST_REQUIRE_EQUAL
(
nnp
.
getNNProcessors
(),
3
ul
);
if
(
v_cl
.
getProcessUnitID
()
==
0
)
if
(
v_cl
.
getProcessUnitID
()
==
0
)
{
{
...
@@ -201,67 +201,203 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test)
...
@@ -201,67 +201,203 @@ BOOST_AUTO_TEST_CASE( nn_processor_np_test)
BOOST_AUTO_TEST_CASE
(
nn_processor_box_periodic_test
)
BOOST_AUTO_TEST_CASE
(
nn_processor_box_periodic_test
)
{
{
constexpr
unsigned
int
dim
=
3
;
// Vcluster
typedef
float
T
;
Vcluster
&
v_cl
=
create_vcluster
()
;
Box
<
dim
,
T
>
domain
({
0.0
,
0.0
,
0.0
},{
1.0
,
1.0
,
1.0
});
/*!
Point
<
dim
,
T
>
middle
({
0.5
,
0.5
,
0.5
});
*
* We test this situation
*
* \verbatim
+-------+-------+
| | |
| 0 | 1 |
| | |
| | |
+---------------+
| | |
| 2 | 3 |
| | |
| | |
+-------+-------+
const
size_t
bc
[
dim
]
=
{
PERIODIC
,
PERIODIC
,
PERIODIC
};
* \endverbatim
*
*
*/
// Vcluster
if
(
v_cl
.
getProcessingUnits
()
!=
4
)
Vcluster
&
v_cl
=
create_vcluster
()
;
return
;
Ghost
<
dim
,
T
>
ghost
(
0.01
);
Box
<
2
,
float
>
domain
({
0.0
,
0.0
},{
1.0
,
1.0
});
const
size_t
bc
[
2
]
=
{
PERIODIC
,
PERIODIC
};
//////////////
Ghost
<
2
,
float
>
ghost
(
0.01
);
nn_prcs
<
dim
,
T
>
nnp
(
v_cl
);
openfpm
::
vector
<
openfpm
::
vector
<
long
unsigned
int
>>
box_nn_processor
;
openfpm
::
vector
<
SpaceBox
<
2
,
float
>>
sub_domains
;
/* std::unordered_map<size_t, N_box<dim,T>> & nnp_sub = nnp.get_nn_processor_subdomains();
create_decomposition2x2
(
box_nn_processor
,
sub_domains
);
openfpm::vector<size_t> & nnp_np = nnp.get_nn_processors();
//
we add the boxes
//
////////////
size_t tot_n = 0;
nn_prcs
<
2
,
float
>
nnp
(
v_cl
);
HyperCube<dim> hyp;
nnp
.
create
(
box_nn_processor
,
sub_domains
);
// check that nn_processor contain the correct boxes
for (long int i = dim-1 ; i >= 0 ; i--)
nnp
.
applyBC
(
domain
,
ghost
,
bc
);
if
(
v_cl
.
getProcessUnitID
()
==
0
)
{
{
std::vector<comb<dim>> cmbs = hyp.getCombinations_R(i);
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
1
).
size
(),
4
);
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
2
).
size
(),
4
);
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
3
).
size
(),
4
);
for (size_t j = 0 ; j < cmbs.size() ; j++)
openfpm
::
vector
<
Box
<
2
,
float
>>
bv
;
{
// Create a fake processor number
size_t prc = i;
Point<dim,T> p1 = (middle * toPoint<dim,T>::convert(cmbs[j]) + middle)* 1.0/1.1;
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
0
},{
1.0
,
0.5
}));
Point<dim,T> p2 = p1 + Point<dim,T>({0.1,0.1,0.1}) * 1.0/1.1;
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
0.0
},{
0.0
,
0.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
1.0
},{
1.0
,
1.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
1.0
},{
0.0
,
1.5
}));
Box<dim,T> bx(p1,p2);
bool
ret
=
nnp
.
getNearSubdomains
(
1
)
==
bv
;
nnp_sub[prc+1].id = prc;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
nnp_sub[prc+1].bx.add(bx);
tot_n++;
bv
.
clear
();
}
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
0.5
},{
0.5
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
0.5
},{
1.5
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
-
0.5
},{
0.5
,
0.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
-
0.5
},{
1.5
,
0.0
}));
ret
=
nnp
.
getNearSubdomains
(
2
)
==
bv
;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
bv
.
clear
();
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
0.5
},{
1.0
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
0.5
},{
0.0
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
-
0.5
},{
1.0
,
0.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
-
0.5
},{
0.0
,
0.0
}));
ret
=
nnp
.
getNearSubdomains
(
3
)
==
bv
;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
}
}
else
if
(
v_cl
.
getProcessUnitID
()
==
1
)
{
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
0
).
size
(),
4
);
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
2
).
size
(),
4
);
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
3
).
size
(),
4
);
openfpm
::
vector
<
Box
<
2
,
float
>>
bv
;
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
0
},{
0.5
,
0.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
0.0
},{
1.5
,
0.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
1.0
},{
0.5
,
1.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
1.0
},{
1.5
,
1.5
}));
bool
ret
=
nnp
.
getNearSubdomains
(
0
)
==
bv
;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
for (size_t i = 0; i < dim; i++)
bv
.
clear
();
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
0.5
},{
0.5
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
0.5
},{
1.5
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
-
0.5
},{
0.5
,
0.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
-
0.5
},{
1.5
,
0.0
}));
ret
=
nnp
.
getNearSubdomains
(
2
)
==
bv
;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
bv
.
clear
();
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
0.5
},{
1.0
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
0.5
},{
0.0
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
-
0.5
},{
1.0
,
0.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
-
0.5
},{
0.0
,
0.0
}));
ret
=
nnp
.
getNearSubdomains
(
3
)
==
bv
;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
}
else
if
(
v_cl
.
getProcessUnitID
()
==
2
)
{
{
nnp_np.add(i+1);
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
0
).
size
(),
4
);
}*/
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
1
).
size
(),
4
);
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
3
).
size
(),
4
);
// check that nn_processor contain the correct boxes
openfpm
::
vector
<
Box
<
2
,
float
>>
bv
;
nnp
.
applyBC
(
domain
,
ghost
,
bc
);
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
0
},{
0.5
,
0.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
0.0
},{
1.5
,
0.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
1.0
},{
0.5
,
1.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
1.0
},{
1.5
,
1.5
}));
if
(
v_cl
.
getProcessUnitID
()
==
0
)
bool
ret
=
nnp
.
getNearSubdomains
(
0
)
==
bv
;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
bv
.
clear
();
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
0
},{
1.0
,
0.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
0.0
},{
0.0
,
0.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
1.0
},{
1.0
,
1.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
1.0
},{
0.0
,
1.5
}));
ret
=
nnp
.
getNearSubdomains
(
1
)
==
bv
;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
bv
.
clear
();
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
0.5
},{
1.0
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
0.5
},{
0.0
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
-
0.5
},{
1.0
,
0.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
-
0.5
},{
0.0
,
0.0
}));
ret
=
nnp
.
getNearSubdomains
(
3
)
==
bv
;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
}
else
if
(
v_cl
.
getProcessUnitID
()
==
3
)
{
{
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
0
).
size
(),
4
);
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
1
).
size
(),
4
);
BOOST_REQUIRE_EQUAL
(
nnp
.
getNearSubdomains
(
2
).
size
(),
4
);
openfpm
::
vector
<
Box
<
2
,
float
>>
bv
;
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
0
},{
0.5
,
0.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
0.0
},{
1.5
,
0.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
1.0
},{
0.5
,
1.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
1.0
},{
1.5
,
1.5
}));
bool
ret
=
nnp
.
getNearSubdomains
(
0
)
==
bv
;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
bv
.
clear
();
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
0
},{
1.0
,
0.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
0.0
},{
0.0
,
0.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.5
,
1.0
},{
1.0
,
1.5
}));
bv
.
add
(
Box
<
2
,
float
>
({
-
0.5
,
1.0
},{
0.0
,
1.5
}));
ret
=
nnp
.
getNearSubdomains
(
1
)
==
bv
;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
bv
.
clear
();
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
0.5
},{
0.5
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
0.5
},{
1.5
,
1.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
0.0
,
-
0.5
},{
0.5
,
0.0
}));
bv
.
add
(
Box
<
2
,
float
>
({
1.0
,
-
0.5
},{
1.5
,
0.0
}));
/* for (size_t i = 0 ; i < nnp.getNearSubdomains(2).size() ; i++)
{
Box<2,float> b = nnp.getNearSubdomains(2).get(i);
std::cout << "BOX: " << b.toString() << std::endl;
}*/
ret
=
nnp
.
getNearSubdomains
(
2
)
==
bv
;
BOOST_REQUIRE_EQUAL
(
ret
,
true
);
}
}
// BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(nnp.IDtoProc(2)).size(),12ul);
// BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(nnp.IDtoProc(0)).size(),8ul*8ul);
// BOOST_REQUIRE_EQUAL(nnp.getNearSubdomains(nnp.IDtoProc(1)).size(),12ul*4ul);
}
}
BOOST_AUTO_TEST_SUITE_END
()
BOOST_AUTO_TEST_SUITE_END
()
...
...
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