User Tools

Site Tools


c:mpi:scatter-gather

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
c:mpi:scatter-gather [2024/01/17 10:45] – created odeftac:mpi:scatter-gather [2024/01/17 10:50] (current) odefta
Line 72: Line 72:
 **Data Preparation**: The master process creates an array (scatter_data) and another array (gather_data) for the gathered results. **Data Preparation**: The master process creates an array (scatter_data) and another array (gather_data) for the gathered results.
  
-**Scatter Operation**: MPI_Scatter is used to distribute segments of the scatter_data array to each process.+**Scatter Operation**: **MPI_Scatter** is used to distribute segments of the scatter_data array to each process.
  
 **Data Processing**: Each process modifies its segment of data. In this example, each element is multiplied by 2. **Data Processing**: Each process modifies its segment of data. In this example, each element is multiplied by 2.
  
-**Gather Operation**: MPI_Gather collects the modified segments from each process and assembles them into the gather_data array in the master process.+**Gather Operation**: **MPI_Gather** collects the modified segments from each process and assembles them into the gather_data array in the master process.
  
 **Output**: The master process prints the gathered data. **Output**: The master process prints the gathered data.
Line 83: Line 83:
  
 **Finalization**: The MPI environment is finalized. **Finalization**: The MPI environment is finalized.
 +
 +This program demonstrates how to use **MPI_Scatter** to distribute data and **MPI_Gather** to collect the results. The total number of elements in **scatter_data** should be a multiple of the number of processes.
  
c/mpi/scatter-gather.1705481149.txt.gz · Last modified: 2024/01/17 10:45 by odefta