Changeset f5a51db for benchmark


Ignore:
Timestamp:
Feb 8, 2022, 11:53:13 AM (4 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
Children:
cc7bbe6
Parents:
97c215f (diff), 1cf8a9f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
benchmark/io/http
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/http/Makefile.am

    r97c215f rf5a51db  
    2121include $(top_srcdir)/tools/build/cfa.make
    2222
    23 AM_CFLAGS = -O2 -Wall -Wextra -I$(srcdir) -lrt -pthread # -Werror
     23AM_CFLAGS = -O3 -Wall -Wextra -I$(srcdir) -lrt -pthread # -Werror
    2424AM_CFAFLAGS = -quiet -nodebug
    2525AM_LDFLAGS = -quiet -nodebug
  • benchmark/io/http/main.cfa

    r97c215f rf5a51db  
    1 #define __USE_GNU
     1#define _GNU_SOURCE
    22
    33#include <errno.h>
     
    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__)
     
    146168        int waited = 0;
    147169        for() {
    148                 ret = bind( server_fd, (struct sockaddr *)&address, sizeof(address) );
     170                int sockfd = server_fd;
     171                __CONST_SOCKADDR_ARG addr;
     172                addr.__sockaddr__ = (struct sockaddr *)&address;
     173                socklen_t addrlen = sizeof(address);
     174                ret = bind( sockfd, addr, addrlen );
    149175                if(ret < 0) {
    150176                        if(errno == EADDRINUSE) {
Note: See TracChangeset for help on using the changeset viewer.