Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
M
MPI_Distributed_Programming
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
saad.aswad
MPI_Distributed_Programming
Commits
7a70f960
Commit
7a70f960
authored
Jan 04, 2026
by
saad.aswad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[P2] Add skeleton for manual reduce
parent
5ef116de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
manual_reduce.py
src/problem2/manual_reduce.py
+29
-0
No files found.
src/problem2/manual_reduce.py
0 → 100644
View file @
7a70f960
# problem2/manual_reduce.py
from
mpi4py
import
MPI
import
numpy
as
np
def
manual_reduce
(
sendbuf
,
recvbuf
,
op
,
root
,
comm
):
"""
Implementation of MPI_Reduce using tree-based communication.
Toplogy:
rank i children: 2*i+1, 2*i+2
rank i parent: (i-1)//2
"""
rank
=
comm
.
Get_rank
()
size
=
comm
.
Get_size
()
# Start with local data
# We assume sendbuf is a numpy array (for addition)
# Copy sendbuf to a local accumulator (or directly to recvbuf if leaf,
# but we need a temp buffer for accumulation)
# Logic:
# 1. Receive from children (if any).
# 2. Add to local accumulator.
# 3. If rank != root, Send accumulator to parent.
# 4. If rank == root, copy accumulator to recvbuf.
pass
def
main
():
pass
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