Commit 4d7eb207 authored by saad.aswad's avatar saad.aswad

[P1] Add skeleton for prefix sum

parent abe13aec
# problem1/prefix_sum.py
from mpi4py import MPI
import sys
import os
# Add common directory to path to import utils
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from common import utils
def prefix_mpi(local_data, comm):
"""
Computes distributed prefix sum.
Step 1: Local Prefix Sum
Step 2: Exchange Block Sums (Sequential on Rank 0 usually, or Allgather)
Step 3: Add offsets
"""
# Step 1: Local Prefix Sum
local_prefix = [] # Placeholder
# Step 2: Block sums
# Step 3: Add offsets
return local_prefix
def main():
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
# Placeholder for logic
if rank == 0:
print(f"Running Prefix Sum with {size} processes")
if __name__ == "__main__":
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment