Ignore:
Timestamp:
Mar 4, 2021, 7:40:25 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
77d601f
Parents:
342af53 (diff), a5040fe (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

File:
1 edited

Legend:

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

    r342af53 r8e4aa05  
    99}
    1010
     11#include <bitmanip.hfa>
     12#include <fstream.hfa>
    1113#include <kernel.hfa>
    1214#include <parseargs.hfa>
     15#include <stdlib.hfa>
    1316
     17#include <stdlib.h>
    1418#include <string.h>
    1519
    1620Options options @= {
    1721        false, // log
     22        false, // stats
    1823
    1924        { // file_cache
     25                0,     // path
    2026                0,     // open_flags;
    2127                42u,   // hash_seed;
     
    3238
    3339        { // cluster
     40                1,     // nclusters;
    3441                1,     // nprocs;
    3542                1,     // nworkers;
    36                 0,     // flags;
     43                {},     // params;
    3744                false, // procstats
    3845                false, // viewhalts
     
    4148};
    4249
    43 const char * parse_options( int argc, char * argv[] ) {
    44         bool subthrd = false;
    45         bool eagrsub = false;
    46         bool fixedfd = false;
    47         bool sqkpoll = false;
    48         bool iokpoll = false;
    49         unsigned sublen = 16;
     50void parse_options( int argc, char * argv[] ) {
     51        // bool fixedfd = false;
     52        // bool sqkpoll = false;
     53        // bool iokpoll = false;
     54        unsigned nentries = 16;
     55        bool isolate = false;
     56
    5057
    5158        static cfa_option opt[] = {
    52                 {'p', "port",           "Port the server will listen on", options.socket.port},
    53                 {'c', "cpus",           "Number of processors to use", options.clopts.nprocs},
    54                 {'L', "log",            "Enable logs", options.log, parse_settrue},
    55                 {'t', "threads",        "Number of worker threads to use", options.clopts.nworkers},
    56                 {'b', "accept-backlog", "Maximum number of pending accepts", options.socket.backlog},
    57                 {'r', "request_len",    "Maximum number of bytes in the http request, requests with more data will be answered with Http Code 414", options.socket.buflen},
    58                 {'S', "seed",           "seed to use for hashing", options.file_cache.hash_seed },
    59                 {'C', "cache-size",     "Size of the cache to use, if set to small, will uses closes power of 2", options.file_cache.size },
    60                 {'l', "list-files",     "List the files in the specified path and exit", options.file_cache.list, parse_settrue },
    61                 {'s', "submitthread",   "If set, cluster uses polling thread to submit I/O", subthrd, parse_settrue },
    62                 {'e', "eagersubmit",    "If set, cluster submits I/O eagerly but still aggregates submits", eagrsub, parse_settrue},
    63                 {'f', "fixed-fds",      "If set, files are open eagerly and pre-registered with the cluster", fixedfd, parse_settrue},
    64                 {'k', "kpollsubmit",    "If set, cluster uses IORING_SETUP_SQPOLL, implies -f", sqkpoll, parse_settrue },
    65                 {'i', "kpollcomplete",  "If set, cluster uses IORING_SETUP_IOPOLL", iokpoll, parse_settrue },
    66                 {'L', "submitlength",   "Max number of submitions that can be submitted together", sublen },
     59                { 'p', "port",           "Port the server will listen on", options.socket.port},
     60                { 'c', "cpus",           "Number of processors to use", options.clopts.nprocs},
     61                { 't', "threads",        "Number of worker threads to use", options.clopts.nworkers},
     62                {'\0', "isolate",        "Create one cluster per processor", isolate, parse_settrue},
     63                {'\0', "log",            "Enable logs", options.log, parse_settrue},
     64                {'\0', "stats",          "Enable statistics", options.stats, parse_settrue},
     65                {'\0', "accept-backlog", "Maximum number of pending accepts", options.socket.backlog},
     66                {'\0', "request_len",    "Maximum number of bytes in the http request, requests with more data will be answered with Http Code 414", options.socket.buflen},
     67                {'\0', "seed",           "seed to use for hashing", options.file_cache.hash_seed },
     68                {'\0', "cache-size",     "Size of the cache to use, if set to small, will uses closes power of 2", options.file_cache.size },
     69                {'\0', "list-files",     "List the files in the specified path and exit", options.file_cache.list, parse_settrue },
     70                // { 'f', "fixed-fds",      "If set, files are open eagerly and pre-registered with the cluster", fixedfd, parse_settrue},
     71                // { 'k', "kpollsubmit",    "If set, cluster uses IORING_SETUP_SQPOLL, implies -f", sqkpoll, parse_settrue },
     72                // { 'i', "kpollcomplete",  "If set, cluster uses IORING_SETUP_IOPOLL", iokpoll, parse_settrue },
     73                {'e', "numentries",     "Number of I/O entries", nentries },
    6774
    6875        };
     
    7279        parse_args( argc, argv, opt, opt_cnt, "[OPTIONS]... [PATH]\ncforall http server", left );
    7380
    74         options.clopts.params.poller_submits = subthrd;
    75         options.clopts.params.eager_submits  = eagrsub;
    76 
    77         if( fixedfd ) {
    78                 options.file_cache.fixed_fds = true;
     81        if( !is_pow2(nentries) ) {
     82                unsigned v = nentries;
     83                v--;
     84                v |= v >> 1;
     85                v |= v >> 2;
     86                v |= v >> 4;
     87                v |= v >> 8;
     88                v |= v >> 16;
     89                v++;
     90                serr | "Warning: num_entries not a power of 2" | '(' | nentries | ')' | "raising to " | v;
     91                nentries = v;
     92        }
     93        if(isolate) {
     94                options.clopts.nclusters = options.clopts.nprocs;
     95                options.clopts.nprocs = 1;
     96        }
     97        options.clopts.params.num_entries = nentries;
     98        options.clopts.instance = alloc(options.clopts.nclusters);
     99        options.clopts.thrd_cnt = alloc(options.clopts.nclusters);
     100        options.clopts.cltr_cnt = 0;
     101        for(i; options.clopts.nclusters) {
     102                options.clopts.thrd_cnt[i] = 0;
    79103        }
    80104
    81         if( sqkpoll ) {
    82                 options.clopts.params.poll_submit = true;
    83                 options.file_cache.fixed_fds = true;
    84         }
    85105
    86         if( iokpoll ) {
    87                 options.clopts.params.poll_complete = true;
    88                 options.file_cache.open_flags |= O_DIRECT;
    89         }
     106        // if( fixedfd ) {
     107        //      options.file_cache.fixed_fds = true;
     108        // }
    90109
    91         options.clopts.params.num_ready = sublen;
     110        // if( sqkpoll ) {
     111        //      options.file_cache.fixed_fds = true;
     112        // }
    92113
    93         if( left[0] == 0p ) { return "."; }
     114        // if( iokpoll ) {
     115        //      options.file_cache.open_flags |= O_DIRECT;
     116        // }
     117
     118        if( left[0] == 0p ) { return; }
    94119
    95120        const char * path = left[0];
     
    97122
    98123        if( left[0] != 0p ) {
    99                 abort("Too many trailing arguments!\n");
     124                serr | "Too many trailing arguments!" | '\'' | path | '\'';
     125                while(left[0] != 0p) {
     126                        serr | " - " | left[0];
     127                        left++;
     128                }
     129                exit(EXIT_FAILURE);
    100130        }
    101131
    102         return path;
     132        options.file_cache.path = path;
    103133}
Note: See TracChangeset for help on using the changeset viewer.