Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
User Manual

User Manual
Results will update as you type.
  • Application Guide
  • Status of System
  • Usage Guide
  • Compute partitions
    • CPU CLX partition
      • Workflow CPU CLX
      • Slurm partition CPU CLX
      • Examples and Recipes
        • Compilation on CPU CLX
        • OpenMPI on CPU CLX
        • Intel MPI on CPU CLX
        • OpenMP on CPU CLX
        • Hybrid Jobs
        • Linking the MKL version of fftw3
        • Multiple programs multiple data
      • Fat Tree OPA network of CLX partition
      • Operating system migration from CentOS to Rocky Linux
    • CPU Genoa partition
    • GPU A100 partition
    • GPU PVC partition
    • Next-Gen Technology Pool
  • Software
  • FAQ
  • NHR Community
  • Contact

    You‘re viewing this with anonymous access, so some content might be blocked.
    /
    Hybrid Jobs

    Hybrid Jobs

    Juni 03, 2024

    A hybrid job uses both OpenMP and MPI for parallelization. This requires the number of tasks and CPUs per task to be set up correctly. Here is an example of such a job. We will use Intel MPI in this example, but this also works using OpenMPI.

    Code

    hybrid_hello_world.c Quelle erweitern
    #include <mpi.h>
    #include <stdio.h>
     
    int main(int argc, char** argv) {
        // Initialize the MPI environment
        MPI_Init(NULL, NULL);
     
        // Get the number of processes
        int world_size;
        MPI_Comm_size(MPI_COMM_WORLD, &world_size);
     
        // Get the rank of the process
        int world_rank;
        MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
     
        // Get the name of the processor
        char processor_name[MPI_MAX_PROCESSOR_NAME];
        int name_len;
        MPI_Get_processor_name(processor_name, &name_len);
     
        int nthreads, tid;
     
        /* Fork a team of threads giving them their own copies of variables */
        #pragma omp parallel private(nthreads, tid)
        {
       
        /* Obtain thread number */
        tid = omp_get_thread_num();
        printf("Hello World from thread = %d, processor %s, rank %d out of %d processors\n", tid, processor_name, world_rank, world_size);
       
        /* Only master thread does this */
        if (tid == 0)
          {
          nthreads = omp_get_num_threads();
          printf("Number of threads = %d\n", nthreads);
          }
       
        }  /* All threads join master thread and disband */
     
     
        // Finalize the MPI environment.
        MPI_Finalize();
    }

    Compilation

    This can be compiles with both the Intel or the GNU compiler.

    Compilation With the Intel Compiler
    module load intel
    module load impi
    mpiicc -qopenmp  -Wl,-rpath,$LD_RUN_PATH -o hybrid_hello_world.bin hybrid_hello_world.c
    Compilation with the GNU Compiler
    module load gcc
    module load impi
    mpigcc -fopenmp -Wl,-rpath,$LD_RUN_PATH -o hybrid_hello_world.bin hybrid_hello_world.c

    Batch Job

    Job Script
    #!/bin/bash
    #SBATCH --time=00:10:00
    #SBATCH --nodes=2
    #SBATCH --tasks-per-node=4
    #SBATCH --cpus-per-task=10
    #SBATCH --partition=standard96:test
     
    module load impi
    export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
    srun ./hybrid_hello_world.bin

    Related articles

    • Seite:
      Slurm usage
    • Seite:
      Workflow CPU CLX
    • Seite:
      Advanced options
    • Seite:
      Hybrid Jobs
    • Seite:
      INTEL-MPI version 19 slower than INTEL-MPI version 18



    , multiple selections available, Use left or right arrow keys to navigate selected items
    hybrid
    job
    example
    intel
    impi
    kb-how-to-article
    {"serverDuration": 11, "requestCorrelationId": "a21bcfa2b4934ba88b08eab2ebe201ce"}