Changeset 4f102fa for libcfa/src


Ignore:
Timestamp:
Oct 11, 2022, 8:28:32 PM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master
Children:
e5256bd
Parents:
116a2ea (diff), a55472cc (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:
libcfa/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/io.cfa

    r116a2ea r4f102fa  
    551551                enqueue(this.pending, (__outstanding_io&)pa);
    552552
    553                 wait( pa.sem );
     553                wait( pa.waitctx );
    554554
    555555                return pa.ctx;
     
    578578                                pa.ctx = ctx;
    579579
    580                                 post( pa.sem );
     580                                post( pa.waitctx );
    581581                        }
    582582
     
    613613                }
    614614
    615                 wait( ei.sem );
     615                wait( ei.waitctx );
    616616
    617617                __cfadbg_print_safe(io, "Kernel I/O : %u submitted from arbiter\n", have);
     
    631631                                        __submit_only(&ctx, ei.idxs, ei.have);
    632632
    633                                         post( ei.sem );
     633                                        post( ei.waitctx );
    634634                                }
    635635
  • libcfa/src/concurrency/io/types.hfa

    r116a2ea r4f102fa  
    107107        struct __outstanding_io {
    108108                inline Colable;
    109                 single_sem sem;
     109                oneshot waitctx;
    110110        };
    111111        static inline __outstanding_io *& Next( __outstanding_io * n ) { return (__outstanding_io *)Next( (Colable *)n ); }
  • libcfa/src/concurrency/kernel/cluster.hfa

    r116a2ea r4f102fa  
    2121
    2222#include <limits.h>
     23#include <inttypes.h>
    2324
    2425#include "clock.hfa"
     
    3031
    3132// warn normally all ints
    32 #define warn_large_before warnf( !strict || old_avg < 33_000_000_000, "Suspiciously large previous average: %'llu (%llx), %'ldms \n", old_avg, old_avg, program()`ms )
    33 #define warn_large_after warnf( !strict || ret < 33_000_000_000, "Suspiciously large new average after %'ldms cputime: %'llu (%llx) from %'llu-%'llu (%'llu, %'llu) and %'llu\n", program()`ms, ret, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg )
     33#define warn_large_before warnf( !strict || old_avg < 33_000_000_000, "Suspiciously large previous average: %'llu (%llx), %'" PRId64 "ms \n", old_avg, old_avg, program()`ms )
     34#define warn_large_after warnf( !strict || ret < 33_000_000_000, "Suspiciously large new average after %'" PRId64 "ms cputime: %'llu (%llx) from %'llu-%'llu (%'llu, %'llu) and %'llu\n", program()`ms, ret, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg )
    3435
    3536// 8X linear factor is just 8 * x
     
    4142static inline __readyQ_avg_t __to_readyQ_avg(unsigned long long intsc) { if(unlikely(0 == intsc)) return 0.0; else return log2(intsc); }
    4243
    43 #define warn_large_before warnf( !strict || old_avg < 35.0, "Suspiciously large previous average: %'lf, %'ldms \n", old_avg, program()`ms )
    44 #define warn_large_after warnf( !strict || ret < 35.3, "Suspiciously large new average after %'ldms cputime: %'lf from %'llu-%'llu (%'llu, %'llu) and %'lf\n", program()`ms, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg ); \
     44#define warn_large_before warnf( !strict || old_avg < 35.0, "Suspiciously large previous average: %'lf, %'" PRId64 "ms \n", old_avg, program()`ms )
     45#define warn_large_after warnf( !strict || ret < 35.3, "Suspiciously large new average after %'" PRId64 "ms cputime: %'lf from %'llu-%'llu (%'llu, %'llu) and %'lf\n", program()`ms, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg ); \
    4546verify(ret >= 0)
    4647
  • libcfa/src/parseargs.cfa

    r116a2ea r4f102fa  
    11#include "parseargs.hfa"
    22
     3#include <ctype.h>
    34#include <stdint.h>
    45#include <string.h>
    56#include <errno.h>
    67#include <unistd.h>
    7 #include <assert.h>
    88
    99extern "C" {
     
    7474
    7575        int maxv = 'h';
    76         assert( opt_count > 0 );
    77         char optstring[opt_count * 3] = { '\0' };
     76        char optstring[(opt_count * 3) + 2] = { '\0' };
    7877        {
    7978                int idx = 0;
     
    272271bool parse(const char * arg, int & value) {
    273272        char * end;
    274         int r = strtoll(arg, &end, 10);
     273
     274        errno = 0;
     275        long long int r = strtoll(arg, &end, 0);
     276        if(errno) return false;
    275277        if(*end != '\0') return false;
    276 
    277         value = r;
    278         return true;
     278        if(r > (int)MAX) return false;
     279        if(r < (int)MIN) return false;
     280
     281        value = r;
     282        return true;
     283}
     284
     285static unsigned long long int strict_strtoull( const char * arg, int base) {
     286        errno = 0;
     287        {
     288                const char * in = arg;
     289                for() {
     290                        if('\0' == *in) {
     291                                errno = EINVAL;
     292                                return 0;
     293                        }
     294                        if(!isspace(*in)) break;
     295                        in++;
     296                }
     297                if(!isdigit(*in)) {
     298                        errno = EINVAL;
     299                        return 0;
     300                }
     301        }
     302
     303        *char end;
     304        unsigned long long int r = strtoull(arg, &end, base);
     305        if(*end != '\0') errno = EINVAL;
     306        if(errno) return 0;
     307        return r;
    279308}
    280309
    281310bool parse(const char * arg, unsigned & value) {
    282         char * end;
    283         unsigned long long int r = strtoull(arg, &end, 10);
    284         if(*end != '\0') return false;
     311        unsigned long long int r = strict_strtoull(arg, 0);
     312        if(errno) return false;
    285313        if(r > (unsigned)MAX) return false;
    286314
     
    290318
    291319bool parse(const char * arg, unsigned long & value) {
    292         char * end;
    293         unsigned long long int r = strtoull(arg, &end, 10);
    294         if(*end != '\0') return false;
     320        unsigned long long int r = strict_strtoull(arg, 0);
     321        if(errno) return false;
    295322        if(r > (unsigned long)MAX) return false;
    296323
     
    300327
    301328bool parse(const char * arg, unsigned long long & value) {
    302         char * end;
    303         unsigned long long int r = strtoull(arg, &end, 10);
    304         if(*end != '\0') return false;
    305         if(r > (unsigned long long)MAX) return false;
    306 
    307         value = r;
    308         return true;
     329        unsigned long long int r = strict_strtoull(arg, 0);
     330        if(errno) return false;
     331        if(r > (unsigned long long)MAX) return false;
     332
     333        value = r;
     334        return true;
    309335}
    310336
Note: See TracChangeset for help on using the changeset viewer.