0% found this document useful (0 votes)
5 views1 page

Lab2 1

The document outlines a Python script using mpi4py for parallel processing. It prompts the user to input a list size and its elements, then calculates the sum of all elements, even numbers, and odd numbers in the list. The results are communicated between different processes using MPI send and receive functions.

Uploaded by

CS INSIDE FI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Lab2 1

The document outlines a Python script using mpi4py for parallel processing. It prompts the user to input a list size and its elements, then calculates the sum of all elements, even numbers, and odd numbers in the list. The results are communicated between different processes using MPI send and receive functions.

Uploaded by

CS INSIDE FI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

from mpi4py • import • MPla

-MPl .COMM WORLDC


comm
rank-comm. Get _ rank(
size-comm
n=int( input( "Enter the size of the
list " )
print( "Enter the - list - members" ) a
•forÄÄn•
s-int( input( ) F
I . append( s) c
• add=Oc
•forÄÄnA•.c
add-add* ic
print("The addition •of' the• list •
elements •are• •
, add)ü
• comm . send(l , dest=l
• comm . send(l , dest-2)a
elif• : a
add even=Oo
• I-comm. recv(
•forÄÄn 1: c
add even-add even+ia
from, the process-2 , the
addition • of • all • even • numbers , im the
list
•add odd-On
l=comm. recv(
forÄÄn I : a
if i%2--1:
•add odd-add odd+in
from&eorocess-3, •the
addition •of • all • odd • numbers • in the •
list

You might also like