Changeset 038a0bd


Ignore:
Timestamp:
Jan 18, 2022, 8:49:43 PM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
6a33e40
Parents:
b5f17e1 (diff), adfd125 (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

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • benchmark/readyQ/transfer.cfa

    rb5f17e1 r038a0bd  
    11#include "rq_bench.hfa"
    22#include <fstream.hfa>
     3#include <locale.h>
    34
    45Duration default_preemption() {
     
    89#define PRINT(...)
    910
    10 __lehmer64_state_t lead_seed;
     11__uint128_t lead_seed;
    1112volatile unsigned leader;
    1213volatile size_t lead_idx;
     
    6869        waitgroup();
    6970
    70         unsigned nleader = __lehmer64( lead_seed ) % nthreads;
     71        unsigned nleader = lehmer64( lead_seed ) % nthreads;
    7172        __atomic_store_n( &leader, nleader, __ATOMIC_SEQ_CST );
    7273
     
    105106// ==================================================
    106107int main(int argc, char * argv[]) {
    107         __lehmer64_state_t lead_seed = getpid();
    108         for(10) __lehmer64( lead_seed );
     108        uint64_t lead_seed = getpid();
     109        for(10) lehmer64( lead_seed );
    109110        unsigned nprocs = 2;
    110111
     
    126127
    127128        lead_idx = 0;
    128         leader = __lehmer64( lead_seed ) % nthreads;
     129        leader = lehmer64( lead_seed ) % nthreads;
    129130
    130131        size_t rechecks = 0;
     
    167168        }
    168169
     170        setlocale( LC_NUMERIC, getenv( "LANG" ) );
    169171        sout | "Duration (ms)           : " | ws(3, 3, unit(eng((end - start)`dms)));
    170172        sout | "Number of processors    : " | nprocs;
  • libcfa/src/common.hfa

    rb5f17e1 r038a0bd  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // common --
    8 // 
     6//
     7// common.hfa --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Wed Jul 11 17:54:36 2018
     
    1212// Last Modified On : Wed May  5 14:02:04 2021
    1313// Update Count     : 18
    14 // 
     14//
    1515
    1616#pragma once
  • libcfa/src/concurrency/io.cfa

    rb5f17e1 r038a0bd  
    144144                __ioarbiter_flush( ctx );
    145145
    146                 __STATS__( true, io.calls.flush++; )
    147                 int ret = syscall( __NR_io_uring_enter, ctx.fd, ctx.sq.to_submit, min_comp, min_comp > 0 ? IORING_ENTER_GETEVENTS : 0, (sigset_t *)0p, _NSIG / 8);
    148                 if( ret < 0 ) {
    149                         switch((int)errno) {
    150                         case EAGAIN:
    151                         case EINTR:
    152                         case EBUSY:
    153                                 // Update statistics
    154                                 __STATS__( false, io.calls.errors.busy ++; )
    155                                 return false;
    156                         default:
    157                                 abort( "KERNEL ERROR: IO_URING SYSCALL - (%d) %s\n", (int)errno, strerror(errno) );
     146                if(ctx.sq.to_submit != 0 || min_comp > 0) {
     147
     148                        __STATS__( true, io.calls.flush++; )
     149                        int ret = syscall( __NR_io_uring_enter, ctx.fd, ctx.sq.to_submit, min_comp, min_comp > 0 ? IORING_ENTER_GETEVENTS : 0, (sigset_t *)0p, _NSIG / 8);
     150                        if( ret < 0 ) {
     151                                switch((int)errno) {
     152                                case EAGAIN:
     153                                case EINTR:
     154                                case EBUSY:
     155                                        // Update statistics
     156                                        __STATS__( false, io.calls.errors.busy ++; )
     157                                        return false;
     158                                default:
     159                                        abort( "KERNEL ERROR: IO_URING SYSCALL - (%d) %s\n", (int)errno, strerror(errno) );
     160                                }
    158161                        }
    159                 }
    160 
    161                 __cfadbg_print_safe(io, "Kernel I/O : %u submitted to io_uring %d\n", ret, ctx.fd);
    162                 __STATS__( true, io.calls.submitted += ret; )
    163                 /* paranoid */ verify( ctx.sq.to_submit <= *ctx.sq.num );
    164                 /* paranoid */ verify( ctx.sq.to_submit >= ret );
    165 
    166                 ctx.sq.to_submit -= ret;
    167 
    168                 /* paranoid */ verify( ctx.sq.to_submit <= *ctx.sq.num );
    169 
    170                 // Release the consumed SQEs
    171                 __release_sqes( ctx );
    172 
    173                 /* paranoid */ verify( ! __preemption_enabled() );
    174 
    175                 ctx.proc->io.pending = false;
     162
     163                        __cfadbg_print_safe(io, "Kernel I/O : %u submitted to io_uring %d\n", ret, ctx.fd);
     164                        __STATS__( true, io.calls.submitted += ret; )
     165                        /* paranoid */ verify( ctx.sq.to_submit <= *ctx.sq.num );
     166                        /* paranoid */ verify( ctx.sq.to_submit >= ret );
     167
     168                        ctx.sq.to_submit -= ret;
     169
     170                        /* paranoid */ verify( ctx.sq.to_submit <= *ctx.sq.num );
     171
     172                        // Release the consumed SQEs
     173                        __release_sqes( ctx );
     174
     175                        /* paranoid */ verify( ! __preemption_enabled() );
     176
     177                        ctx.proc->io.pending = false;
     178                }
     179
    176180                ready_schedule_lock();
    177181                bool ret = __cfa_io_drain( proc );
  • libcfa/src/concurrency/kernel.hfa

    rb5f17e1 r038a0bd  
    6868                unsigned last;
    6969                signed   cpu;
    70                 // unsigned long long int cutoff;
    7170        } rdq;
    7271
     
    154153};
    155154
    156 struct __attribute__((aligned(128))) __cache_id_t {
     155struct __attribute__((aligned(16))) __cache_id_t {
    157156        volatile unsigned id;
    158157};
  • libcfa/src/concurrency/ready_queue.cfa

    rb5f17e1 r038a0bd  
    303303                        lanes.help[idx].dst = 0;
    304304                        lanes.help[idx].tri = 0;
    305                 }
    306 
    307                 caches = alloc( cpu_info.llc_count );
    308                 for( idx; (size_t)cpu_info.llc_count ) {
    309                         (caches[idx]){};
    310305                }
    311306        #else
     
    404399                /* paranoid */ verify(cpu < cpu_info.hthrd_count);
    405400                unsigned this_cache = cpu_info.llc_map[cpu].cache;
    406                 __atomic_store_n(&lanes.caches[this / READYQ_SHARD_FACTOR].id, this_cache, __ATOMIC_RELAXED);
     401
     402                // Super important: don't write the same value over and over again
     403                // We want to maximise our chances that his particular values stays in cache
     404                if(lanes.caches[this / READYQ_SHARD_FACTOR].id != this_cache)
     405                        __atomic_store_n(&lanes.caches[this / READYQ_SHARD_FACTOR].id, this_cache, __ATOMIC_RELAXED);
    407406
    408407                const unsigned long long ctsc = rdtscl();
     
    506505        }
    507506
    508         static inline int pop_getcpu(processor * proc, __ready_queue_caches_t * caches) {
    509                 const int prv = proc->rdq.cpu;
    510                 const int cpu = __kernel_getcpu();
    511                 if( prv != proc->rdq.cpu ) {
    512                         unsigned pidx = cpu_info.llc_map[prv].cache;
    513                         /* paranoid */ verify(pidx < cpu_info.llc_count);
    514 
    515                         unsigned nidx = cpu_info.llc_map[cpu].cache;
    516                         /* paranoid */ verify(pidx < cpu_info.llc_count);
    517 
    518                         depart(caches[pidx]);
    519                         arrive(caches[nidx]);
    520 
    521                         __STATS( /* cpu migs++ */ )
    522                 }
    523                 return proc->rdq.cpu = cpu;
    524         }
    525 
    526507        // Pop from the ready queue from a given cluster
    527508        __attribute__((hot)) thread$ * pop_fast(struct cluster * cltr) with (cltr->ready_queue) {
     
    530511
    531512                processor * const proc = kernelTLS().this_processor;
    532                 const int cpu = pop_getcpu( proc, caches );
    533                 // const int cpu = __kernel_getcpu();
     513                const int cpu = __kernel_getcpu();
    534514                /* paranoid */ verify(cpu >= 0);
    535515                /* paranoid */ verify(cpu < cpu_info.hthrd_count);
     
    548528                        unsigned long long max = 0;
    549529                        for(i; READYQ_SHARD_FACTOR) {
    550                                 unsigned long long tsc = moving_average(ctsc - ts(lanes.data[start + i]), lanes.tscs[start + i].ma);
     530                                unsigned long long tsc = moving_average(ctsc, ts(lanes.data[start + i]), lanes.tscs[start + i].ma);
    551531                                if(tsc > max) max = tsc;
    552532                        }
     
    569549                        unsigned long long max = 0;
    570550                        for(i; READYQ_SHARD_FACTOR) {
    571                                 unsigned long long tsc = moving_average(ctsc - ts(lanes.data[start + i]), lanes.tscs[start + i].ma);
     551                                unsigned long long tsc = moving_average(ctsc, ts(lanes.data[start + i]), lanes.tscs[start + i].ma);
    572552                                if(tsc > max) max = tsc;
    573553                        }
     
    577557                                proc->rdq.target = MAX;
    578558                                lanes.help[target / READYQ_SHARD_FACTOR].tri++;
    579                                 if(moving_average(ctsc - lanes.tscs[target].tv, lanes.tscs[target].ma) > cutoff) {
    580                                         __STATS( __tls_stats()->ready.pop.helped[target]++; )
     559                                if(moving_average(ctsc, lanes.tscs[target].tv, lanes.tscs[target].ma) > cutoff) {
    581560                                        thread$ * t = try_pop(cltr, target __STATS(, __tls_stats()->ready.pop.help));
    582561                                        proc->rdq.last = target;
     
    587566
    588567                        unsigned last = proc->rdq.last;
    589                         if(last != MAX && moving_average(ctsc - lanes.tscs[last].tv, lanes.tscs[last].ma) > cutoff) {
    590                                 __STATS( __tls_stats()->ready.pop.helped[last]++; )
     568                        if(last != MAX && moving_average(ctsc, lanes.tscs[last].tv, lanes.tscs[last].ma) > cutoff) {
    591569                                thread$ * t = try_pop(cltr, last __STATS(, __tls_stats()->ready.pop.help));
    592570                                if(t) return t;
  • src/AST/Decl.hpp

    rb5f17e1 r038a0bd  
    3434// Must be included in *all* AST classes; should be #undef'd at the end of the file
    3535#define MUTATE_FRIEND \
    36     template<typename node_t> friend node_t * mutate(const node_t * node); \
     36        template<typename node_t> friend node_t * mutate(const node_t * node); \
    3737        template<typename node_t> friend node_t * shallowCopy(const node_t * node);
    3838
     
    135135        std::vector< ptr<Expr> > withExprs;
    136136
    137 
    138137        FunctionDecl( const CodeLocation & loc, const std::string & name, std::vector<ptr<TypeDecl>>&& forall,
    139138                std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns,
  • src/AST/Eval.hpp

    rb5f17e1 r038a0bd  
    2424template< typename... Args >
    2525UntypedExpr * call( const CodeLocation & loc, const std::string & name, Args &&... args ) {
    26         return new UntypedExpr { 
    27                 loc, new NameExpr { loc, name }, 
     26        return new UntypedExpr {
     27                loc, new NameExpr { loc, name },
    2828                std::vector< ptr< Expr > > { std::forward< Args >( args )... } };
    2929}
  • src/Validate/InitializerLength.cpp

    rb5f17e1 r038a0bd  
    1414//
    1515
    16 //#include "InitializerLength.hpp"
     16#include "InitializerLength.hpp"
    1717
    1818#include "AST/Expr.hpp"
  • src/Validate/InitializerLength.hpp

    rb5f17e1 r038a0bd  
    1414//
    1515
     16#pragma once
     17
     18namespace ast {
     19        class TranslationUnit;
     20}
     21
    1622namespace Validate {
    1723
Note: See TracChangeset for help on using the changeset viewer.