Giter Club home page Giter Club logo

ls_affinity's Introduction

ls_affinity

List CPU affinity. The program supports 4 different modes of operation; serial, multithreaded (using OpenMP), MPI, and hybrid OpenMP/MPI. This program is mainly meant as a debugging aid for understanding the interaction between MPI runtimes and workload managers.

Prerequisites

You need the hwloc library. To compile the MPI version of the program, you need a MPI library with development headers (typically including a mpicc compiler wrapper). For the OpenMP version, you need a compiler with OpenMP support. To build the program using the provided makefile, GNU make is (probably) required.

Building

The out-of-the-box makefile assumes GCC. If you use the Intel compiler, use the Makefile.intel makefile, that is, run "make -f Makefile.intel". If you use another compiler, you can make a copy of the main makefile with a suitable suffic such as "Makefile.foo", and edit it appropriately.

Running

Environment variables for OpenMP binding

As of OpenMP 3.1, there is the OMP_PROC_BIND environment variable which can be set to the values "true" or "false". For more specific binding schemes one must fall back on compiler specific methods. For GCC, use GOMP_CPU_AFFINITY, for the Intel compiler use KMP_AFFINITY.

Example

Running 2 MPI processes with 4 threads per rank on a computer with 8 hardware threads, by default with OpenMPI 1.4 one gets e.g.

$ OMP_NUM_THREADS=4 mpirun -n 2 ./ls_affinity_mpi_openmp 
On host XXX, MPI rank 1 thread 0 bound to PU(s) 0-7
On host XXX, MPI rank 0 thread 0 bound to PU(s) 0-7
On host XXX, MPI rank 1 thread 1 bound to PU(s) 0-7
On host XXX, MPI rank 1 thread 3 bound to PU(s) 0-7
On host XXX, MPI rank 1 thread 2 bound to PU(s) 0-7
On host XXX, MPI rank 0 thread 1 bound to PU(s) 0-7
On host XXX, MPI rank 0 thread 3 bound to PU(s) 0-7
On host XXX, MPI rank 0 thread 2 bound to PU(s) 0-7

By setting the affinity for both OpenMP and OpenMPI one gets

$ GOMP_CPU_AFFINITY=0-7 OMP_NUM_THREADS=4 mpirun -n 2 -bind-to-core -cpus-per-proc 4 ./ls_affinity_mpi_openmp 
On host XXX, MPI rank 0 thread 0 bound to PU(s) 0
On host XXX, MPI rank 1 thread 0 bound to PU(s) 4
On host XXX, MPI rank 0 thread 1 bound to PU(s) 1
On host XXX, MPI rank 1 thread 1 bound to PU(s) 5
On host XXX, MPI rank 1 thread 2 bound to PU(s) 6
On host XXX, MPI rank 1 thread 3 bound to PU(s) 7
On host XXX, MPI rank 0 thread 2 bound to PU(s) 2
On host XXX, MPI rank 0 thread 3 bound to PU(s) 3

In the program output, "PU(s)" means "processing unit", per the hwloc terminology: "The smallest processing element that can be represented by a hwloc object. It may be a single-core processor, a core of a multicore processor, or a single thread in a SMT processor. hwloc's PU acronym stands for Processing Unit. "

ls_affinity's People

Contributors

jabl avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.