Skip to content

C++ interface to CPU affinity management

License

BSD-3-Clause, BSD-3-Clause licenses found

Licenses found

BSD-3-Clause
LICENSE
BSD-3-Clause
COPYING
Notifications You must be signed in to change notification settings

dcdillon/cpuaff

cpuaff - website

IMPORTANT

The PPA for Ubuntu packages has been moved to ppa:dcdillon/cpuaff.

Short Description

cpuaff is a C++ library that abstracts CPU affinity settings for multiple platforms. It is a header-only library on some platforms. Other platforms are supported using hwloc. The project aims to fully support all platforms as header-only eventually.

For a more detailed description of cpuaff, click here

To see a list of supported platforms click here.

Releases

The latest source release is cpuaff-1.0.6.

The latest Ubuntu packages are available from ppa:dcdillon/cpuaff.

To get other releases, go to the downloads page.

For installation instructions, click here

Simple Example

#include <cpuaff/cpuaff.hpp>
#include <iostream>

int main(int argc, char *argv[])
{
    cpuaff::affinity_manager manager;

    if (manager.has_cpus())
    {
        cpuaff::cpu_set cpus;
        manager.get_affinity(cpus);

        std::cout << "Initial Affinity:" << std::endl;

        cpuaff::cpu_set::iterator i = cpus.begin();
        cpuaff::cpu_set::iterator iend = cpus.end();

        for (; i != iend; ++i)
        {
            std::cout << "  " << (*i) << std::endl;
        }

        std::cout << std::endl;

        // set the affinity to all the processing units on
        // the first core
        cpuaff::cpu_set core_0;
        manager.get_cpus_by_core(core_0, 0);

        manager.set_affinity(core_0);
        manager.get_affinity(cpus);

        std::cout << "Affinity After Calling set_affinity():"
                  << std::endl;
        i = cpus.begin();
        iend = cpus.end();

        for (; i != iend; ++i)
        {
            std::cout << "  " << (*i) << std::endl;
        }

        return 0;
    }

    std::cerr << "cpuaff: unable to load cpus." << std::endl;
    return -1;
}

Pronunciation

Due to popular demand, we now have a guide on pronunciation. cpuaff is pronounced "spoof" because all other pronunciations I have come up with sound like garbled French.

Licensing

cpuaff is distributed under the New BSD (or BSD 3-Clause) license.

About

C++ interface to CPU affinity management

Resources

License

BSD-3-Clause, BSD-3-Clause licenses found

Licenses found

BSD-3-Clause
LICENSE
BSD-3-Clause
COPYING

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages