utils/cpuaffinity.h

utils/cpuaffinity.h

utils/cpuaffinity.h

Functions

Name
intget_online_cores_count()
intthread_set_affinity(pthread_t thread, unsigned core)
intthread_set_affinity_from_vec(pthread_t thread, const std::vector< unsigned > & cores)
intthread_clear_affinity(pthread_t thread)

Defines

Name
_GNU_SOURCE

Functions Documentation

function get_online_cores_count

int get_online_cores_count()

function thread_set_affinity

int thread_set_affinity(
    pthread_t thread,
    unsigned core
)

function thread_set_affinity_from_vec

int thread_set_affinity_from_vec(
    pthread_t thread,
    const std::vector< unsigned > & cores
)

function thread_clear_affinity

int thread_clear_affinity(
    pthread_t thread
)

Macros Documentation

define _GNU_SOURCE

#define _GNU_SOURCE 

Source code

/*
 * Copyright (C) 2019-2024 Matthias Klumpp <matthias@tenstral.net>
 *
 * Licensed under the GNU Lesser General Public License Version 3
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the license, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this software.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <pthread.h>
#include <vector>

int get_online_cores_count();
int thread_set_affinity(pthread_t thread, unsigned core);
int thread_set_affinity_from_vec(pthread_t thread, const std::vector<unsigned> &cores);
int thread_clear_affinity(pthread_t thread);

Updated on 2024-11-06 at 17:10:29 +0000