# MVAPICH2 Performance Optimization Options

When using MVAPICH2 as the MPI library, you can configure inter-process communication algorithms by setting environment variables within your job script. The key options are listed below, and users can optimize execution performance by setting environment variables for collective communications that are heavily used within their code.

The <mark style="color:red;">**MV2\_INTRA**</mark> environment variable is used for MPI process communication within a node, while the <mark style="color:blue;">**MV2\_INTER**</mark> environment variable is used for MPI process communication between nodes. For MPI\_Alltoall, the same algorithm is applied for both INTRA and INTER cases. Routines for transmitting data of varying sizes (e.g., MPI\_Alltoallv) or non-blocking routines (e.g., MPI\_Ibcast), the same settings can be applied, and the configuration method is as follows:

* Key Environment Variables for MVAPICH2 Library Collective Communication

| MPI communication |                                                                             Environment variable                                                                            | Setting range |
| :---------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------: |
|    MPI\_Gather    |    <p><mark style="color:red;"><strong>MV2\_INTRA</strong></mark>\_GATHER\_TUNING</p><p><mark style="color:blue;"><strong>MV2\_INTER</strong></mark>\_GATHER\_TUNING</p>    |     0 \~ 3    |
|     MPI\_Bcast    |     <p><mark style="color:red;"><strong>MV2\_INTRA</strong></mark>\_BCAST\_TUNING</p><p><mark style="color:blue;"><strong>MV2\_INTER</strong></mark>\_BCAST\_TUNING</p>     |    0 \~ 10    |
|    MPI\_Scatter   |   <p><mark style="color:red;"><strong>MV2\_INTRA</strong></mark>\_SCATTER\_TUNING</p><p><mark style="color:blue;"><strong>MV2\_INTER</strong></mark>\_SCATTER\_TUNING</p>   |     1 \~ 5    |
|   MPI\_Allreduce  | <p><mark style="color:red;"><strong>MV2\_INTRA</strong></mark>\_ALLREDUCE\_TUNING</p><p><mark style="color:blue;"><strong>MV2\_INTER</strong></mark>\_ALLREDUCE\_TUNING</p> |     1 \~ 6    |
|    MPI\_Reduce    |    <p><mark style="color:red;"><strong>MV2\_INTRA</strong></mark>\_REDUCE\_TUNING</p><p><mark style="color:blue;"><strong>MV2\_INTER</strong></mark>\_REDUCE\_TUNING</p>    |     1 \~ 6    |
|   MPI\_Allgather  | <p><mark style="color:red;"><strong>MV2\_INTRA</strong></mark>\_ALLGATHER\_TUNING</p><p><mark style="color:blue;"><strong>MV2\_INTER</strong></mark>\_ALLGATHER\_TUNING</p> |    1 \~ 11    |
|   MPI\_Alltoall   |                                                                            MV2\_ALLTOALL\_TUNING                                                                            |     0 \~ 4    |

※ Usage example (when creating a bash script): export MV2\_INTER\_ALLREDUCE\_TUNING=2

※ For detailed explanations of each environment variable, refer to <http://mvapich.cse.ohio-state.edu/userguide/>

{% hint style="info" %}
Last updated on November 08, 2024.
{% endhint %}
