Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_io
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_io
Commits
eaf601ec
Commit
eaf601ec
authored
3 years ago
by
jstark
Browse files
Options
Downloads
Patches
Plain Diff
Fixing MPI Broadcasting.
parent
f361582b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#4155
failed
3 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/CSVReader/CSVReader.hpp
+7
-7
7 additions, 7 deletions
src/CSVReader/CSVReader.hpp
src/CSVReader/tests/CSVReader_unit_test.cpp
+1
-15
1 addition, 15 deletions
src/CSVReader/tests/CSVReader_unit_test.cpp
with
8 additions
and
22 deletions
src/CSVReader/CSVReader.hpp
+
7
−
7
View file @
eaf601ec
...
...
@@ -41,7 +41,9 @@ T string_to_type(const std::string & string_to_convert)
template
<
typename
T
>
void
read_csv_to_vector
(
const
std
::
string
&
input_file
,
openfpm
::
vector
<
T
>
&
output_vector
,
size_t
&
m
,
size_t
&
n
)
{
int
total_size
=
0
;
size_t
total_size
=
0
;
m
=
0
;
n
=
0
;
auto
&
v_cl
=
create_vcluster
();
// File is accessed and read only by one process
if
(
v_cl
.
rank
()
==
0
)
...
...
@@ -54,9 +56,6 @@ void read_csv_to_vector(const std::string & input_file, openfpm::vector<T> & out
}
std
::
ifstream
file
(
input_file
);
// Create file pointer and open file
std
::
string
line
,
element
;
m
=
0
;
n
=
0
;
size_t
elems
=
0
;
while
(
getline
(
file
,
line
))
// Read entire row and store as one string in line
{
std
::
stringstream
stream_line
(
line
);
// Needed to break line into elements later one
...
...
@@ -72,9 +71,10 @@ void read_csv_to_vector(const std::string & input_file, openfpm::vector<T> & out
// the number of columns
}
// Distribute size of the lin. vector to all other processes s.t. their output_vector can be resized accordingly.
MPI_Bcast
(
&
total_size
,
1
,
MPI_INT
,
0
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
m
,
1
,
MPI_INT
,
0
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
n
,
1
,
MPI_INT
,
0
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
total_size
,
1
,
MPI_UNSIGNED
,
0
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
m
,
1
,
MPI_UNSIGNED
,
0
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
n
,
1
,
MPI_UNSIGNED
,
0
,
MPI_COMM_WORLD
);
if
(
v_cl
.
rank
()
!=
0
)
{
output_vector
.
resize
(
total_size
);
...
...
This diff is collapsed.
Click to expand it.
src/CSVReader/tests/CSVReader_unit_test.cpp
+
1
−
15
View file @
eaf601ec
...
...
@@ -13,23 +13,11 @@ BOOST_AUTO_TEST_CASE(csv_reader_int_test)
#else
std
::
string
csv_file
=
std
::
string
(
"test_data/integer.csv"
);
#endif
std
::
cout
<<
"CWD = "
<<
get_cwd
()
<<
std
::
endl
;
// Read csv file into vector while linearizing
openfpm
::
vector
<
int
>
v_lin
;
// Vector to which csv file will be read to
size_t
m
,
n
;
// Number of rows m and columns n
read_csv_to_vector
(
csv_file
,
v_lin
,
m
,
n
);
auto
&
v_cl
=
create_vcluster
();
std
::
cout
<<
"My rank is "
<<
v_cl
.
rank
()
<<
std
::
endl
;
auto
v_iter
=
v_lin
.
getIterator
();
while
(
v_iter
.
isNext
())
{
auto
key
=
v_iter
.
get
();
std
::
cout
<<
"Element number "
<<
key
<<
" of rank "
<<
v_cl
.
rank
()
<<
" is "
<<
v_lin
.
get
(
key
)
<<
std
::
endl
;
++
v_iter
;
}
read_csv_to_vector
(
csv_file
,
v_lin
,
m
,
n
);
BOOST_CHECK
(
m
==
4
);
BOOST_CHECK
(
n
==
3
);
...
...
@@ -41,8 +29,6 @@ BOOST_AUTO_TEST_CASE(csv_reader_int_test)
BOOST_CHECK
(
v_lin
.
get
(
i
*
n
+
1
)
==
(
i
+
1
)
*
2
);
BOOST_CHECK
(
v_lin
.
get
(
i
*
n
+
2
)
==
v_lin
.
get
(
i
*
n
)
*
v_lin
.
get
(
i
*
n
+
1
));
}
std
::
cout
<<
"Rank "
<<
v_cl
.
rank
()
<<
" reaches end of unit test."
<<
std
::
endl
;
}
...
...
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