Changeset 615767b for doc/theses


Ignore:
Timestamp:
Oct 1, 2020, 3:54:39 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
91131689
Parents:
ebec8ed (diff), dd53f75 (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 into master

Location:
doc/theses/thierry_delisle_PhD/code/readQ_example
Files:
6 added
1 deleted
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • doc/theses/thierry_delisle_PhD/code/readQ_example/proto-gui/main.cpp

    rebec8ed r615767b  
    1 #include "thrdlib/thread.h"
     1#include "thrdlib/thread.hpp"
    22
    33#include <cassert>
     
    55#include <algorithm>
    66#include <atomic>
     7#include <iostream>
    78#include <memory>
    89#include <vector>
    910
    1011#include <getopt.h>
     12using thrdlib::thread_t;
     13
     14
     15extern __attribute__((aligned(128))) thread_local struct {
     16        void * volatile this_thread;
     17        void * volatile this_processor;
     18        void * volatile this_stats;
     19
     20        struct {
     21                volatile unsigned short disable_count;
     22                volatile bool enabled;
     23                volatile bool in_progress;
     24        } preemption_state;
     25
     26        #if defined(__SIZEOF_INT128__)
     27                __uint128_t rand_seed;
     28        #else
     29                uint64_t rand_seed;
     30        #endif
     31        struct {
     32                uint64_t fwd_seed;
     33                uint64_t bck_seed;
     34        } ready_rng;
     35} kernelTLS __attribute__ ((tls_model ( "initial-exec" )));
    1136
    1237//--------------------
     
    3661                        assert( expected == reset );
    3762                        if( std::atomic_compare_exchange_strong( &state, &expected, self) ) {
    38                                 thrdlib_park( self );
     63                                thrdlib::park( self );
    3964                                ret = true;
    4065                                goto END;
     
    5479                if( got == reset ) return false;
    5580
    56                 thrdlib_unpark( got );
     81                thrdlib::unpark( got );
    5782                return true;
    5883        }
     
    109134        the_stats_thread = self;
    110135        fence();
    111         thrdlib_park( self );
     136        thrdlib::park( self );
    112137
    113138        std::vector<bool> seen;
     
    115140
    116141        while(last_produced < nproduce) {
    117                 thrdlib_yield();
     142                thrdlib::yield();
    118143                thrd_stats.stats.ran++;
    119144                if( last_produced > 0 ) seen.at(last_produced - 1) = true;
     
    147172
    148173void Renderer( thread_t self ) {
    149         thrdlib_unpark( the_stats_thread );
     174        thrdlib::unpark( the_stats_thread );
    150175        for(unsigned i = 0; i < nproduce; i++) {
    151176                auto & frame = frames[i % nframes];
     
    178203        fsize    = 1000;
    179204        nproduce = 60;
     205
     206        const char * framework;
    180207
    181208        for(;;) {
     
    196223                        case -1:
    197224                                /* paranoid */ assert(optind <= argc);
     225                                if( optind == argc ) {
     226                                        std::cerr << "Must specify a framework" << std::endl;
     227                                        goto usage;
     228
     229                                }
     230                                framework = argv[optind];
    198231                                goto run;
    199232                        case 'b':
     
    228261                                std::cerr << opt << std::endl;
    229262                        usage:
    230                                 std::cerr << "Usage: " << argv[0] << " [options]" << std::endl;
     263                                std::cerr << "Usage: " << argv[0] << " [options] framework" << std::endl;
    231264                                std::cerr << std::endl;
    232265                                std::cerr << "  -b, --buff=COUNT    Number of frames to buffer" << std::endl;
     
    237270        }
    238271        run:
     272        assert( framework );
    239273
    240274        frames.reset(new Frame[nframes]);
     
    246280        std::cout << "(Buffering " << nframes << ")" << std::endl;
    247281
    248         thrdlib_setproccnt( 2 );
    249 
    250         thread_t stats     = thrdlib_create( Stats    );
     282        thrdlib::init( framework, 2 );
     283
     284        thread_t stats     = thrdlib::create( Stats );
    251285        std::cout << "Created Stats Thread" << std::endl;
    252         while( the_stats_thread == nullptr ) thrdlib_yield();
     286        while( the_stats_thread == nullptr ) thrdlib::yield();
     287
    253288        std::cout << "Creating Main Threads" << std::endl;
    254         thread_t renderer  = thrdlib_create( Renderer  );
    255         // while(true);
    256         thread_t simulator = thrdlib_create( Simulator );
     289        thread_t renderer  = thrdlib::create( Renderer  );
     290        thread_t simulator = thrdlib::create( Simulator );
    257291
    258292        std::cout << "Running" << std::endl;
    259293
    260         thrdlib_join( simulator );
    261         thrdlib_join( renderer  );
    262         thrdlib_join( stats     );
     294        thrdlib::join( simulator );
     295        thrdlib::join( renderer  );
     296        thrdlib::join( stats     );
     297
     298        thrdlib::clean();
    263299
    264300        std::cout << "----------" << std::endl;
  • doc/theses/thierry_delisle_PhD/code/readQ_example/thrdlib/pthread.cpp

    rebec8ed r615767b  
    1 #pragma once
    2 
    31#include <pthread.h>
    42#include <errno.h>
     
    5654#undef CHECKED
    5755
    58 #if defined(__cforall) || defined(__cpluplus)
     56//--------------------
     57// Basic types
     58struct pthread_runner_t {
     59        pthread_t handle;
     60        __bin_sem_t sem;
     61};
     62typedef pthread_runner_t * thread_t;
     63
     64static_assert(sizeof(thread_t) == sizeof(void*), "thread_t musst be of same size as void*");
     65
    5966extern "C" {
    60 #endif
    61         //--------------------
    62         // Basic types
    63         struct pthread_runner_t {
    64                 pthread_t handle;
    65                 __bin_sem_t sem;
    66         };
    67         typedef pthread_runner_t * thread_t;
    68 
    6967        //--------------------
    7068        // Basic thread support
     
    9896        //--------------------
    9997        // Basic kernel features
    100         void thrdlib_setproccnt( int ) {
    101 
    102         }
    103 
    104 
    105 #if defined(__cforall) || defined(__cpluplus)
     98        void thrdlib_init( int ) {}
    10699}
    107 #endif
Note: See TracChangeset for help on using the changeset viewer.