Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
MPI_HW
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hasan.bahjat
MPI_HW
Commits
f29891e9
Commit
f29891e9
authored
Nov 18, 2024
by
hasan.bahjat
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update MPI_Allrduce.c Add Beautiifull Print with usefull info, Add Time Ellapsed
parent
22d51672
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
MPI_Allrduce.c
MPI_Allrduce.c
+25
-5
No files found.
MPI_Allrduce.c
View file @
f29891e9
...
@@ -78,21 +78,41 @@ int main(int argc, char** argv) {
...
@@ -78,21 +78,41 @@ int main(int argc, char** argv) {
//[1] Use the naive implementation of MPI_Allreduce
//[1] Use the naive implementation of MPI_Allreduce
int
global_value_naive
=
0
;
int
global_value_naive
=
0
;
naive_allreduce
(
local_value
,
global_value_naive
,
MPI_COMM_WORLD
);
printf
(
"[Worker @ %d] I received global sum (naive): %d
\n
"
,
rank
,
global_value_naive
);
// Start timing
double
start_time_naive
=
MPI_Wtime
();
// naive MPI All Reduce
naive_allreduce
(
local_value
,
global_value_naive
,
MPI_COMM_WORLD
);
// End timing
double
end_time_naive
=
MPI_Wtime
();
double
time_naive
=
end_time_naive
-
start_time_naive
;
printf
(
"[Worker @ %d] My Naive MPI_Allreduce: Global sum = %d, Time = %.6f seconds
\n
"
,
rank
,
global_value_naive
,
time_naive
);
// [2] Use the built-in MPI_Allreduce for comparison
// [2] Use the built-in MPI_Allreduce for comparison
int
global_value_builtin
=
0
;
int
global_value_builtin
=
0
;
// Start timing
double
start_time_builtin
=
MPI_Wtime
();
// Mpi Alllreduce buld in
// Mpi Alllreduce buld in
MPI_Allreduce
(
MPI_Allreduce
(
&
local_value
,
&
local_value
,
&
global_value_builtin
,
&
global_value_builtin
,
1
,
MPI_INT
,
1
,
MPI_INT
,
MPI_SUM
,
MPI_SUM
,
MPI_COMM_WORLD
MPI_COMM_WORLD
);
);
// End timing
double
end_time_builtin
=
MPI_Wtime
();
double
time_builtin
=
end_time_builtin
-
start_time_builtin
;
printf
(
"[Worker @ %d] I received global sum (MPI_Allreduce): %d
\n
"
,
rank
,
global_value_builtin
);
printf
(
"[Worker @ %d] Built-in MPI_Allreduce: Global sum = %d, Time = %.6f seconds
\n
"
,
rank
,
global_value_builtin
,
time_builtin
);
// Fina;ize
// Fina;ize
MPI_Finalize
();
MPI_Finalize
();
...
...
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