Changeset 6117fc0 for benchmark


Ignore:
Timestamp:
Jan 20, 2022, 11:18:11 AM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
d3261710
Parents:
753fb978
Message:

Httpforall now pins kernel threads

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/http/main.cfa

    r753fb978 r6117fc0  
    66#include <unistd.h>
    77extern "C" {
     8        #include <sched.h>
    89        #include <signal.h>
    910        #include <sys/socket.h>
     
    6768        (this.self){ "Server Cluster", options.clopts.params };
    6869
     70        cpu_set_t fullset;
     71        CPU_ZERO(&fullset);
     72        int ret = sched_getaffinity(getpid(), sizeof(fullset), &fullset);
     73        if( ret != 0 ) abort | "sched_getaffinity failed with" | errno | strerror( errno );
     74        int cnt = CPU_COUNT(&fullset);
     75
    6976        this.procs = alloc(options.clopts.nprocs);
    7077        for(i; options.clopts.nprocs) {
    7178                (this.procs[i]){ "Benchmark Processor", this.self };
     79
     80                int c = 0;
     81                int n = 1 + (i % cnt);
     82                for(int j = 0; j < CPU_SETSIZE; j++) {
     83                        if(CPU_ISSET(j, &fullset)) n--;
     84                        if(n == 0) {
     85                                c = j;
     86                                break;
     87                        }
     88                }
     89                cpu_set_t localset;
     90                CPU_ZERO(&localset);
     91                CPU_SET(c, &localset);
     92                ret = pthread_setaffinity_np(this.procs[i].kernel_thread, sizeof(localset), &localset);
     93                if( ret != 0 ) abort | "sched_getaffinity failed with" | ret | strerror( ret );
    7294
    7395                #if !defined(__CFA_NO_STATISTICS__)
Note: See TracChangeset for help on using the changeset viewer.