Changeset 60


Ignore:
Timestamp:
Feb 14, 2017, 11:30:19 AM (7 years ago)
Author:
meunier
Message:
  • Intégration des modifications de Clément, qui a intégré la version parallélisée de systemcass faite par Manuel.
Location:
sources
Files:
55 edited

Legend:

Unmodified
Added
Removed
  • sources/src/casc.h

    r59 r60  
    2424
    2525EXTERN char unstable;
    26 EXTERN int32 pending_write_vector_nb;
     26EXTERN int32 * pending_write_vector_nb;
     27#pragma omp threadprivate (pending_write_vector_nb)
    2728
    2829namespace sc_core {
  • sources/src/entity.cc

    r59 r60  
    188188    }
    189189    cerr << "Internal error : get_equi(" << pointer << ")\n";
     190    abort();
    190191    exit(11);
    191192}
     
    412413            }
    413414        }
     415#if 0
     416        sc_interface *reg = get_signal (*i);
     417        sc_interface *out = get_out_port (*i);
     418        if (reg) {
     419            std::cerr << "binding " << *i << " to reg "
     420                << reg << std::endl;
     421            bind_equi_to_table (*i, reg->get_pointer ());
     422        } else if (out) {
     423            std::cerr << "binding " << *i << " to out "
     424                << out << std::endl;
     425            bind_equi_to_table (*i, out->get_pointer ());
     426        } else {
     427            reg = get_localvar (*i);
     428            if (reg) {
     429                std::cerr << "binding " << *i << " to localvar "
     430                    << reg << std::endl;
     431                bind_equi_to_table (*i, reg->get_pointer ());
     432            } else {
     433                std::cerr << "binding " << *i << " to index "
     434                    << index << std::endl;
     435                bind_equi_to_table (*i, &(equi_table[index]));
     436                index += (i->begin()->data_size_in_bytes() - 1) / sizeof(tab_t) + 1;
     437            }
     438        }
     439#endif
    414440    }
    415441}
  • sources/src/gen_code.cc

    r59 r60  
    4949#include <iostream>
    5050#include <fstream>
     51#ifdef _OPENMP
     52#include <omp.h>
     53#endif
    5154
    5255#include "internal.h"
     
    5861#ifdef HAVE_CONFIG_H
    5962#include "config.h"
    60 #endif
    61 
    62 #ifdef _OPENMP
    63 #include <omp.h>
    6463#endif
    6564
     
    246245        method_process_list_t &
    247246        moore_func_list,
    248         strong_component_list_t &
     247        strong_component_list_t *
    249248        strongcomponents) {
    250249    if (dump_stage) {
     
    277276    gen_transition(o, transition_func_list);
    278277    gen_moore(o, moore_func_list);
    279     gen_mealy(o, strongcomponents);
     278    if (strongcomponents != NULL) {
     279        gen_mealy      (o, *strongcomponents);
     280    }
    280281
    281282    o << " \n}\n";
     
    575576 */
    576577
    577 static method_process_list_t func_list[2];
     578unsigned int nb_func[2];
     579static method_process_t **func_list[2];
     580#pragma omp threadprivate (nb_func, func_list)
    578581static strong_component_list_t quasistatic_list;
     582
     583unsigned long long busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml;
     584unsigned long long last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml;
     585#pragma omp threadprivate (busy_wait_f0, busy_wait_f1, busy_wait_up,busy_wait_ml)
     586#pragma omp threadprivate (last_wait_f0, last_wait_f1, last_wait_up,last_wait_ml)
    579587
    580588static void Call(const method_process_t & m) {
     
    611619}
    612620
     621unsigned int expected_globaltime = 0;
     622volatile unsigned int globaltime __attribute__ ((aligned (128))) = 0;
     623#pragma omp shared (globaltime)
     624#pragma omp threadprivate (expected_globaltime)
     625
     626unsigned int num_omp_threads;
    613627
    614628void quasistatic_simulate_1_cycle(void) {
    615     method_process_list_t::iterator mm;
    616     for (mm = func_list[0].begin(); mm != func_list[0].end(); ++mm) {
    617         method_process_t & m = **mm;
    618         Call(m);
    619     }
     629    int i;
     630
     631    for (i = 0; i < nb_func[0]; ++i) {
     632        Call(*(func_list[0][i]));
     633    }
     634#define USE_BUSY_WAIT 1
    620635    update();
    621     for (mm = func_list[1].begin(); mm != func_list[1].end(); ++mm) {
    622         method_process_t & m = **mm;
    623         Call(m);
    624     }
    625     quasistatic_mealy_generation();
     636#if USE_BUSY_WAIT
     637    expected_globaltime += num_omp_threads;
     638    if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime) {
     639        last_wait_up++;
     640    }
     641    __asm volatile("mfence");
     642    while (globaltime < expected_globaltime) {
     643        busy_wait_up++;
     644        __asm volatile("lfence");
     645    }
     646
     647#else
     648#pragma omp barrier
     649#endif
     650
     651    for (i = 0; i < nb_func[1]; ++i) {
     652        Call(*(func_list[1][i]));
     653    }
     654
     655#if USE_BUSY_WAIT
     656    expected_globaltime += num_omp_threads;
     657    if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime) {
     658        last_wait_f1++;
     659    }
     660    __asm volatile("mfence");
     661    while (globaltime < expected_globaltime) {
     662        busy_wait_f1++;
     663        __asm volatile("lfence");
     664    }
     665#else
     666#pragma omp barrier
     667#endif
     668    if (!quasistatic_list.empty()) {
     669#pragma omp master
     670        {
     671            quasistatic_mealy_generation();
     672        }
     673#if USE_BUSY_WAIT
     674        expected_globaltime += num_omp_threads;
     675        if (__sync_add_and_fetch(&globaltime, 1) == expected_globaltime) {
     676            last_wait_ml++;
     677        }
     678        __asm volatile("mfence");
     679        while (globaltime < expected_globaltime) {
     680            busy_wait_ml++;
     681            __asm volatile("lfence");
     682        }
     683#else
     684#pragma omp barrier
     685#endif
     686    }
     687
    626688}
    627689
     
    631693        method_process_list_t &
    632694        moore_func_list,
    633         strong_component_list_t &
     695        strong_component_list_t *
    634696        mealy_func_list) {
    635697    if (dump_stage) {
     
    637699    }
    638700
    639     func_list[0] = transition_func_list;
    640     func_list[1] = moore_func_list;
    641     quasistatic_list = mealy_func_list;
     701    nb_func[0] = transition_func_list.size();
     702    nb_func[1] = moore_func_list.size();
     703
     704    func_list[0] = (method_process_t**) malloc(sizeof (method_process_t*) * nb_func[0]);
     705    func_list[1] = (method_process_t**) malloc(sizeof (method_process_t*) * nb_func[1]);
     706
     707    unsigned int i;
     708    for (i = 0; i < nb_func[0]; ++i) {
     709        func_list[0][i] = (transition_func_list[i]);
     710    }
     711
     712    for (i = 0; i < nb_func[1]; ++i) {
     713        func_list[1][i] = (moore_func_list[i]);
     714    }
     715
     716    if (mealy_func_list != NULL) {
     717        quasistatic_list = *mealy_func_list;
     718    }
    642719
    643720    if (dump_stage) {
  • sources/src/gen_code.h

    r59 r60  
    2121#include "process_dependency.h"
    2222
     23#ifdef _OPENMP
     24#include <omp.h>
     25#endif
     26
    2327//-------------------------------------------------------------------
    2428#ifdef __GNUC__
     
    4044      method_process_list_t   &transition_list,
    4145      method_process_list_t   &moore_list,
    42       strong_component_list_t &mealy_list);
     46      strong_component_list_t *mealy_list);
    4347
    4448extern void  gen_scheduling_code_for_static_func(
     
    5559      method_process_list_t   &transition_list,
    5660      method_process_list_t   &moore_list,
    57       strong_component_list_t &strongcomponents);
     61      strong_component_list_t *strongcomponents);
    5862
    5963/* function when any dynamic link is impossible */
     
    8185inline void internal_sc_cycle2() {
    8286#ifdef DUMP_STAGE
    83     std::cerr << "begin of cycle #" << sc_simulation_time () << "\n";
    84 #endif
    85     func_simulate_1_cycle(); 
    86     ++nb_cycles;
     87#pragma omp master
     88    {
     89        std::cerr << "begin of cycle #" << sc_simulation_time() << "\n";
     90    }
     91#endif
     92
     93        func_simulate_1_cycle();
     94
     95        ++nb_cycles;
    8796#ifdef DUMP_STAGE
    88     std::cerr << "end of cycle\n";
     97#pragma omp master
     98    {
     99        std::cerr << "end of cycle\n";
     100    }
    89101#endif
    90102}
    91103
    92 
    93104inline void internal_sc_cycle1(int number_of_cycles) { 
    94     //while ((! have_to_stop) && (number_of_cycles != 0)) {
    95     while (!((have_to_stop) || (number_of_cycles == 0))) {
    96         trace_all(false);
    97         internal_sc_cycle2();
    98         trace_all(true);
    99         number_of_cycles = (number_of_cycles < 0) ? number_of_cycles : number_of_cycles - 1;
     105    extern unsigned long long busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml;
     106    extern unsigned long long last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml;
     107    extern unsigned int nb_func[2];
     108#pragma omp threadprivate (busy_wait_f0, busy_wait_f1, busy_wait_up, busy_wait_ml, nb_func)
     109#pragma omp threadprivate (last_wait_f0, last_wait_f1, last_wait_up, last_wait_ml)
     110    extern unsigned int expected_globaltime;
     111    extern volatile unsigned int globaltime;
     112#pragma omp shared (globaltime)
     113#pragma omp threadprivate (expected_globaltime)
     114
     115    extern unsigned int num_omp_threads;
     116
     117
     118#pragma omp parallel
     119    {
     120//        int cyclecount = number_of_cycles;
     121        busy_wait_f0 = busy_wait_f1 = busy_wait_up = busy_wait_ml = total_assig = 0;
     122        last_wait_f0 = last_wait_f1 = last_wait_up = last_wait_ml = 0;
     123
     124        expected_globaltime = 0;
     125#pragma omp master
     126        {
     127            globaltime = 0;
     128#ifdef _OPENMP
     129            num_omp_threads = omp_get_num_threads();
     130#else
     131            num_omp_threads = 1;
     132#endif
     133        }
     134
     135#pragma omp barrier
     136        // while (!((have_to_stop) | (cyclecount == 0))) {
     137        while (!((have_to_stop) || (number_of_cycles == 0))) {
     138#pragma omp master
     139            {
     140                trace_all(false);
     141            }
     142            internal_sc_cycle2();
     143#pragma omp master
     144            {
     145                trace_all(true);
     146            }
     147            // cyclecount = (number_of_cycles < 0) ? number_of_cycles : cyclecount - 1;
     148            number_of_cycles = (number_of_cycles < 0) ? number_of_cycles : number_of_cycles - 1;
     149        }
     150#pragma omp barrier
     151#if 0
     152#ifdef _OPENMP
     153#pragma omp critical
     154        {
     155            std::cerr << "Thread " << omp_get_thread_num() << " busy_wait " <<
     156                busy_wait_f0 << " " << busy_wait_up << " " <<
     157                busy_wait_f1 << " " << busy_wait_ml << std::endl;
     158        }
     159#pragma omp critical
     160        {
     161            std::cerr << "Thread " << omp_get_thread_num() << " last_wait " <<
     162                last_wait_f0 << " " << last_wait_up << " " <<
     163                last_wait_f1 << " " << last_wait_ml << std::endl;
     164        }
     165#pragma omp critical
     166        {
     167            std::cerr << "Thread " << omp_get_thread_num() << " nfuncs "
     168                << nb_func[0] << " " << nb_func[1] << " total_assig " <<
     169                total_assig << std::endl;
     170        }
     171#endif
     172#endif
    100173    }
    101174}
     
    117190
    118191    if (is_posted_write()) {
    119         // update posted value to external signals
     192        // update posted value to external signals             
     193#pragma omp parallel
    120194        update();
    121195        func_combinationals();
     
    126200    // don't need to do func_combinationals since 'unstable' flag is now false
    127201    if (is_posted_write()) {
     202#pragma omp parallel
    128203        update();
    129204        func_combinationals();
  • sources/src/global_functions.cc

    r59 r60  
    246246    pending_write_vector_capacity = get_signal_table_size();
    247247
    248     if (pending_write_vector_capacity == 0) {
    249         pending_write_vector = NULL;
    250     }
    251     else {
    252         pending_write_vector = (pending_write_vector_t) realloc(pending_write_vector, sizeof(pending_write_t) * pending_write_vector_capacity);
    253     }
     248    assert(pending_write_vector_capacity != 0);
     249
     250#ifdef _OPENMP
     251#define LINE_SIZE 128L
     252    int malloc_size = (sizeof (pending_write_t) * (pending_write_vector_capacity + 1) + (LINE_SIZE - 1)) & ~(LINE_SIZE - 1);
     253    assert((sizeof(pending_write_t) * (pending_write_vector_capacity + 1)) <= malloc_size && "bad allocation size");
     254
     255#pragma omp parallel
     256    {
     257        posix_memalign((void **) &pending_write_vector, LINE_SIZE, malloc_size);
     258        pending_write_vector_nb = (int32_t *) &pending_write_vector[0];
     259        pending_write_vector = &pending_write_vector[1];
     260        //printf("malloc 0x%x @%p, idx @0x%x\n", malloc_size, pending_write_vector, pending_write_vector_nb);
     261        *pending_write_vector_nb = 0;
     262    }
     263#else
     264    pending_write_vector = (pending_write_vector_t) malloc(sizeof(pending_write_t) * pending_write_vector_capacity);
     265#endif
     266
    254267
    255268    // create the clock list
     
    267280    }
    268281    // Check if any constructor wrote into registers
    269     if (pending_write_vector_nb != 0) {
     282    if (*pending_write_vector_nb != 0) {
    270283        cerr <<
    271284            "Error : Register/Signal writing is not allowed before sc_initialize.\n"
     
    285298    }
    286299
    287     pending_write_vector_nb = 0;
     300    *pending_write_vector_nb = 0;
    288301
    289302    check_all_ports();
  • sources/src/sc_main.cc

    r52 r60  
    3737#include <sstream>
    3838#include <list>
     39#include <omp.h>
    3940#include <set>
    4041#include <cstring> // strcmp
     
    393394
    394395    int ret = sc_main(argc, argv);
    395     free(pending_write_vector);
     396    //free(pending_write_vector);
    396397    close_systemcass();
    397398
  • sources/src/sc_module.cc

    r59 r60  
    3838#include <vector>
    3939#include <set>
     40#ifdef _OPENMP
     41#include <omp.h>
     42#endif
    4043
    4144#include "sc_module.h"
     
    124127// ----------------------------------------------------------------------------
    125128method_process_t::method_process_t(const char * nm, SC_ENTRY_FUNC fn, sc_module & mod) {
    126   name = nm;
    127   func = fn;
    128   module = &mod;
    129   dont_initialize = false;
     129    name = nm;
     130    func = fn;
     131    module = &mod;
     132    dont_initialize = false;
     133#ifdef _OPENMP
     134    omp_threadnum = omp_get_thread_num();
     135#endif
    130136}
    131137
  • sources/src/sc_module.h

    r52 r60  
    7070    sensitivity_list_t sensitivity_list;
    7171    bool dont_initialize;
     72    int omp_threadnum;
    7273
    7374    // constructors
  • sources/src/sc_port.cc

    r59 r60  
    5353    extern char unstable;
    5454    char unstable = 0; // not in sc_core namespace because dynamic link support C linkage only
    55     int32 pending_write_vector_nb = 0;
     55    int32 * pending_write_vector_nb = 0;
     56    unsigned long long int total_assig = 0;
     57#pragma omp threadprivate (pending_write_vector_nb, total_assig)
    5658}
    5759
     
    6567unsigned int pending_write_vector_capacity = 512;
    6668pending_write_vector_t pending_write_vector = NULL;
     69#pragma omp threadprivate (pending_write_vector)
    6770extern equi_list_t equi_list;
    6871
     
    218221            // signal table sorting doesn't give any better performance
    219222#if defined(DUMP_STAGE)
    220             cerr << "(" << pending_write_vector_nb
     223            cerr << "(" << *pending_write_vector_nb
    221224                << " internal pending writings) ";
    222225#endif
    223226            unsigned int i;
    224             for (i = 0; i < pending_write_vector_nb; ++i) {
     227            for (i = 0; i < *pending_write_vector_nb; ++i) {
    225228#define iter (sc_core::pending_write_vector[i])
    226229#ifdef CONFIG_DEBUG
     
    240243            }
    241244#ifdef DUMP_SIGNAL_STATS
    242             total_assig += pending_write_vector_nb;
    243 #endif
    244             pending_write_vector_nb = 0;
     245            total_assig += *pending_write_vector_nb;
     246#endif
     247            total_assig += *pending_write_vector_nb;
     248            *pending_write_vector_nb = 0;
    245249
    246250#if defined(DUMP_STAGE)
  • sources/src/sc_port_ext.h

    r52 r60  
    295295    std::cerr << "write " << value_ << " on in/out port (writing into a signal) '" << name() << "'\n";
    296296#endif
    297     //  T& ref = *(T*)(get_pointer());
     297  T *p = (T*)get_pointer();
     298  if (*p != value_) {
     299        *p = value_;
    298300#ifndef USE_PORT_DEPENDENCY
    299     unstable |= (value_) != val; //ref;
    300 #endif
    301     /*ref*/ val = (value_);
     301        if (unstable == 0)
     302                unstable = 1;
     303#endif
     304  }
    302305}
    303306
  • sources/src/sc_signal.h

    r59 r60  
    1818#include <iostream>
    1919#include <cstdlib>
     20#include <cstring>
    2021#include <typeinfo> // for typeid
    2122
     
    6768// Pending write to register (simple stack)
    6869typedef pending_write_t * pending_write_vector_t;
     70extern "C" int32_t * pending_write_vector_nb;
     71extern "C" unsigned long long int total_assig;
     72#pragma omp threadprivate(pending_write_vector_nb, total_assig)
     73extern unsigned int pending_write_vector_capacity;
     74
    6975extern pending_write_vector_t pending_write_vector;
    70 extern "C" unsigned int pending_write_vector_nb;
    71 extern unsigned int pending_write_vector_capacity;
    72 
     76#pragma omp threadprivate(pending_write_vector)
    7377
    7478template < typename T >
     
    9296    else {
    9397#if defined(CONFIG_DEBUG)
    94         if (pending_write_vector_nb >= pending_write_vector_capacity) {
     98        if (*pending_write_vector_nb >= pending_write_vector_capacity) {
    9599            std::cerr << "Error : The array for posted writing on register is too small.\n";
    96100            std::cerr << "Up to 1 writing per register is allowed during a cycle.\n";
     
    99103        }
    100104#endif
    101         pending_write_vector[pending_write_vector_nb].pointer = pointer_;
    102         // pending_write_vector[pending_write_vector_nb++].value = *(reinterpret_cast<const base_type*const>(&value_)); => bug !
    103         pending_write_vector[pending_write_vector_nb++].value = value_; // => bug avec blues !
     105        pending_write_vector[*pending_write_vector_nb].pointer = pointer_;
     106        // pending_write_vector[(*pending_write_vector_nb)++].value = *(reinterpret_cast<const base_type*const>(&value_)); => bug !
     107        pending_write_vector[(*pending_write_vector_nb)++].value = value_; // => bug avec blues !
    104108
    105109        // -> fix to use user-defined struct in sc_signal/sc_in/sc_out/sc_inout
    106         // pending_write_vector[pending_write_vector_nb++].value = *((base_type*)&value_); => bug !
     110        // pending_write_vector[(*pending_write_vector_nb)++].value = *((base_type*)&value_); => bug !
    107111#if 0
    108112        std::cerr << "posted write : ptr = " << pointer_ << ", val = " << value_ << "\n";
     
    119123
    120124inline bool is_posted_write() {
    121     return pending_write_vector_nb > 0;
     125    return *pending_write_vector_nb > 0;
    122126}
    123127
     
    165169
    166170    T val;
    167 
     171    T new_val;
    168172    typedef T data_type;
    169173    typedef sc_signal < T > this_type;
     
    216220        sc_signal< T >::write(read() + a.read());
    217221        return *this;
     222    }
     223
     224    inline void * operator new (size_t size, size_t align) {
     225        void * p;
     226        const size_t nsize = (size + align - 1) & ~(align - 1);
     227        if (nsize < size) {
     228            std::cerr << "sc_signal new() alignement doesn't work (" <<
     229                nsize << " < " << size << ")" << std::endl;
     230            abort();
     231        }
     232
     233        if (posix_memalign(&p, align, nsize) == 0) {
     234            return p;
     235        }
     236        else {
     237            return NULL;
     238        }
     239    }
     240
     241    inline void * operator new (size_t size) {
     242        return malloc(size);
     243    }
     244
     245    inline void * operator new (size_t size, void * p) {
     246        return p;
    218247    }
    219248
     
    247276    set_kind(kind_string);
    248277    sc_interface::init(sizeof(data_type));
     278#if 0
    249279    val = (T) 0; /* The simulator initializes the signal/register to 0.    */
    250     /* However, hardware initialization still has to be done. */
    251     /* This kind of initialization is for trace diffing.      */
     280                 /* However, hardware initialization still has to be done. */
     281                 /* This kind of initialization is for trace diffing.      */
     282#else
     283    memset(&val, 0, sizeof(val));
     284#endif
    252285}
    253286
     
    267300template < typename T >
    268301inline void sc_signal< T >::write(const data_type & value_) {
     302    if (sc_signal< T >::val == value_ && sc_signal< T >::new_val == value_) {
     303        return;
     304    }
    269305#ifdef CONFIG_DEBUG
    270306    if (get_pointer() == NULL) {
     
    279315    std::cerr << "write (posted) " << value_ << " on sc_signal (writing into register) '" << name() << "'\n";
    280316#endif
    281    
     317    sc_signal<T>::new_val = value_;
    282318    post_write(/*(tab_t*)&val*/ get_pointer(), value_);
    283319}
  • sources/src/sc_time.cc

    r59 r60  
    5555
    5656uint64 nb_cycles = 0;
     57#pragma omp threadprivate(nb_cycles)
    5758
    5859const sc_time SC_ZERO_TIME(0, SC_NS);
  • sources/src/sc_time.h

    r59 r60  
    4343
    4444extern uint64 nb_cycles;
     45#pragma omp threadprivate(nb_cycles)
    4546
    4647inline double sc_simulation_time() {
  • sources/src/schedulers.cc

    r59 r60  
    4949#include "graph_signals.h" // makegraph
    5050
     51#ifdef _OPENMP
     52#include <omp.h>
     53#endif
     54
    5155#ifdef HAVE_CONFIG_H
    5256#include "config.h"
     
    5761namespace sc_core {
    5862
     63// sort_functions splits and sorts instances_list into three functions lists :
     64method_process_list_t * transition_func_list;
     65method_process_list_t * moore_func_list;
     66#pragma omp threadprivate(transition_func_list, moore_func_list)
     67method_process_list_t combinational_func_list;
    5968/* ***************************** */
    6069/* Dumping functions (for debug) */
     
    7483/****************/
    7584
    76 // sort_functions splits and sorts instances_list into three functions lists :
    77 method_process_list_t transition_func_list;
    78 method_process_list_t moore_func_list;
    79 method_process_list_t combinational_func_list;
    8085
    8186
     
    115120void sort_functions() {
    116121    method_process_list_t::const_iterator m;
     122#pragma omp parallel
     123#pragma omp critical
     124    {
     125        transition_func_list = new method_process_list_t;
     126        moore_func_list = new method_process_list_t;
     127        for (m = method_process_list.begin(); m != method_process_list.end(); ++m) {
     128#ifdef _OPENMP
     129            if ((*m)->omp_threadnum == omp_get_thread_num())
     130#endif
     131            {
     132                if ((*m)->is_transition()) {
     133                    transition_func_list->push_back(*m);
     134                }
     135                else if ((*m)->is_genmoore()) {
     136                    moore_func_list->push_back(*m);
     137                }
     138            }
     139        }
     140        // Sort transition functions by method pointer (1) and by module pointer (2)
     141        std::sort(transition_func_list->begin(), transition_func_list->end(), sort_by_fct_ptr);
     142        // Sort generation functions by method pointer (1) and by module pointer (2)
     143        std::sort(moore_func_list->begin(), moore_func_list->end(), sort_by_fct_ptr);
     144    }
     145
    117146    for (m = method_process_list.begin(); m != method_process_list.end(); ++m) {
    118147        if ((*m)->is_combinational()) {
    119148            combinational_func_list.push_back(*m);
    120149        }
    121         else if ((*m)->is_transition ()) {
    122             transition_func_list.push_back(*m);
    123         }
    124         else if ((*m)->is_genmoore ()) {
    125             moore_func_list.push_back(*m);
    126         }
    127     }
    128     // Sort transition functions by method pointer (1) and by module pointer (2)
    129     std::sort (transition_func_list.begin(), transition_func_list.end(), sort_by_fct_ptr);
    130     // Sort generation functions by method pointer (1) and by module pointer (2)
    131     std::sort (moore_func_list.begin(), moore_func_list.end(), sort_by_fct_ptr);
     150    }
    132151}
    133152
     
    203222
    204223string get_scheduling(int scheduling_method) {
     224    string base_name;
    205225    /* marque les fonctions comme fonction de mealy ou non */
    206226    if (dump_funclist_info) {
     
    209229
    210230    sort_functions();
    211     if (dump_funclist_info) {
    212         cerr << "Transition functions : " << transition_func_list << "\n";
    213         cerr << "Moore generation functions : " << moore_func_list << "\n";
    214         cerr << "Mealy generation functions : " << combinational_func_list << "\n";
    215     }
     231#pragma omp parallel
     232#pragma omp critical
     233    {
     234        if (dump_funclist_info) {
     235#ifdef _OPENMP
     236            cerr << "Thread " << omp_get_thread_num() << "\n";
     237#endif
     238            cerr << "  Transition functions : " << *transition_func_list << "\n";
     239            cerr << "  Moore generation functions : " << *moore_func_list << "\n";
     240#pragma omp master
     241            {
     242                if (!combinational_func_list.empty()) {
     243                    cerr << "Mealy generation functions : " << combinational_func_list << "\n";
     244                }
     245            }
     246        }
    216247
    217248    /* Schedule */
    218     string base_name;
    219249    switch (scheduling_method) {
    220250        case BUCHMANN_SCHEDULING :
     
    225255            ProcessDependencyList * process_list = BuchmannScheduling();
    226256            if (dynamic_link_of_scheduling_code) {
    227                 base_name = gen_scheduling_code_for_dynamic_link(transition_func_list, moore_func_list, *process_list);
     257                base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, *process_list);
    228258            }
    229259            else {
    230                 gen_scheduling_code_for_static_func(transition_func_list, moore_func_list, *process_list);
     260                gen_scheduling_code_for_static_func(*transition_func_list, *moore_func_list, *process_list);
    231261            }
    232262            break;
     
    242272            ProcessDependencyList * process_list = MouchardScheduling();
    243273            if (dynamic_link_of_scheduling_code) {
    244                 base_name = gen_scheduling_code_for_dynamic_link(transition_func_list, moore_func_list, *process_list);
     274                base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, *process_list);
    245275            }
    246276            else {
    247                 gen_scheduling_code_for_static_func (transition_func_list, moore_func_list, *process_list);
     277                gen_scheduling_code_for_static_func (*transition_func_list, *moore_func_list, *process_list);
    248278            }
    249279            break;
     
    255285            // Hommais's thesis explains this scheduling method (like CASS strategy)
    256286            // Doesn't use port dependancies
    257             Graph * g = makegraph (&combinational_func_list);
    258             if (dump_all_graph && g) {
    259                 graph2dot("module_graph", *g);
    260             }
    261             strong_component_list_t * strong_list = strong_component(g);
     287            strong_component_list_t * strong_list = NULL;
     288#pragma omp master
     289            {
     290                Graph * g = makegraph (&combinational_func_list);
     291                if (dump_all_graph && g) {
     292                    graph2dot("module_graph", *g);
     293                }
     294                strong_list = strong_component(g);
     295            }
    262296            if (dynamic_link_of_scheduling_code) {
    263                 base_name = gen_scheduling_code_for_dynamic_link(transition_func_list, moore_func_list, *strong_list);
     297                base_name = gen_scheduling_code_for_dynamic_link(*transition_func_list, *moore_func_list, strong_list);
    264298            }
    265299            else {
    266                 gen_scheduling_code_for_quasistatic_func (transition_func_list, moore_func_list, *strong_list);
     300                gen_scheduling_code_for_quasistatic_func (*transition_func_list, *moore_func_list, strong_list);
    267301            }
    268302            break;
     
    272306                    "Please select a scheduling method.\n";
    273307            exit (35);
     308    }
    274309    }
    275310    return base_name;
  • sources/test_regression/02052006/system.cpp

    r55 r60  
    121121    sc_signal<bool> resetn("resetn");
    122122
     123    // Setup number of threads open-mp to 1 with the macro threads_omp()
     124    threads_omp();
     125
    123126    test test1("test1");
    124127    test1.clk(signal_clk);
  • sources/test_regression/04052005/system.cpp

    r55 r60  
    2323    e = 0x11;
    2424    f = 0x1A0;
     25
     26    // Setup number of threads open-mp to 1 with the macro threads_omp()
     27    threads_omp();
    2528
    2629    cout << "a = 0x" << hex << (unsigned int) a << " = " << a.to_string(SC_BIN) << "\n";
  • sources/test_regression/05092005/system.cpp

    r56 r60  
    2222    sc_clock signal_clk("my_clock", sc_time(1, sc_core::SC_NS));
    2323    sc_signal<bool> s[5];
     24
     25    // Setup number of threads open-mp to 1 with the macro threads_omp()
     26    threads_omp();
     27
    2428    hard a("a");
    2529    hard b("b");
  • sources/test_regression/07052005/system.cpp

    r56 r60  
    3939    i = e;
    4040
     41    // Setup number of threads open-mp to 1 with the macro threads_omp()
     42    threads_omp();
     43
    4144    cout << "a = 0x" << hex << (unsigned int) a << " = " << a.to_string(SC_BIN) << "\n";
    4245    //ASSERT(a.to_string(SC_BIN) == "0b000000111100010001");
  • sources/test_regression/07122006a/system.cpp

    r56 r60  
    1919    sc_signal<int> in ("in");
    2020    sc_signal<int> out("out");
     21
     22    // Setup number of threads open-mp to 1 with the macro threads_omp()
     23    threads_omp();
    2124
    2225    test test("test");
  • sources/test_regression/07122006b/system.cpp

    r55 r60  
    6565    sc_signal<int> out("out");
    6666
     67    // Setup number of threads open-mp to 1 with the macro threads_omp()
     68    threads_omp();
     69
    6770    test test("test");
    6871    test.clk(clk);
  • sources/test_regression/08092005/system.cpp

    r55 r60  
    4040    hard b("b");
    4141    hard c("c");
     42
     43    // Setup number of threads open-mp to 1 with the macro threads_omp()
     44    threads_omp();
    4245
    4346    a.clk(clk);
  • sources/test_regression/09092005a/system.cpp

    r56 r60  
    1414
    1515int sc_main (int argc, char ** argv) {
     16
     17    // Setup number of threads open-mp to 1 with the macro threads_omp()
     18    threads_omp();
    1619
    1720    sc_uint<ADDRSIZE> LINEADDR_MASK = ~(((sc_uint<ADDRSIZE>) ~0x0) >> (ADDRSIZE - OFFSETSIZE - BPFSIZE));
  • sources/test_regression/09092005b/system.cpp

    r55 r60  
    3939    hard b("b");
    4040    hard c("c");
     41
     42    // Setup number of threads open-mp to 1 with the macro threads_omp()
     43    threads_omp();
    4144
    4245    a.clk(clk1);
  • sources/test_regression/09092005c/system.cpp

    r56 r60  
    8282    top_level t("top_level");
    8383
     84    // Setup number of threads open-mp to 1 with the macro threads_omp()
     85    threads_omp();
     86
    8487    t.clk(clk);
    8588    t.o(out);
  • sources/test_regression/11062007/system.cpp

    r55 r60  
    104104    sc_signal<bool> s1("s1"),s2("s2"),s3("s3"),s4("s4"),s5("s5");
    105105
     106    // Setup number of threads open-mp to 1 with the macro threads_omp()
     107    threads_omp();
     108
    106109    A a("a");
    107110    B b("b");
  • sources/test_regression/14092005/system.cpp

    r56 r60  
    4848    sc_signal<int> s[10];
    4949    hard a("a");
     50
     51    // Setup number of threads open-mp to 1 with the macro threads_omp()
     52    threads_omp();
    5053
    5154    a.clk(clk1);
  • sources/test_regression/15042009a/system.cpp

    r55 r60  
    123123    top_level t("top_level");
    124124
     125    // Setup number of threads open-mp to 1 with the macro threads_omp()
     126    threads_omp();
     127
    125128    t.clk(clk);
    126129    t.o(out);
  • sources/test_regression/15042009b/system.cpp

    r55 r60  
    1717    a = ca;
    1818    b = cb;
     19
     20    // Setup number of threads open-mp to 1 with the macro threads_omp()
     21    threads_omp();
    1922
    2023    c = a & b;
  • sources/test_regression/15042009c/system.cpp

    r55 r60  
    3232    const long long int ca = 0xf00000000LLU;
    3333    a = ca;
     34
     35    // Setup number of threads open-mp to 1 with the macro threads_omp()
     36    threads_omp();
    3437
    3538    test_t<param_t> test1, test2;
  • sources/test_regression/15062006/system.cpp

    r55 r60  
    7777    sc_signal<int> s01("s01"), s02("s02"), s03("s03"), s04("s04");
    7878
     79    // Setup number of threads open-mp to 1 with the macro threads_omp()
     80    threads_omp();
     81
    7982    test<int> test1("test1");
    8083    test1.clk(signal_clk);
  • sources/test_regression/15092005a/system.cpp

    r55 r60  
    8989    top_level t("top_level");
    9090
     91    // Setup number of threads open-mp to 1 with the macro threads_omp()
     92    threads_omp();
     93
    9194    t.clk(clk);
    9295    t.o(out);
  • sources/test_regression/15092005b/system.cpp

    r55 r60  
    9292    top_level t("top_level");
    9393
     94    // Setup number of threads open-mp to 1 with the macro threads_omp()
     95    threads_omp();
     96
    9497    t.clk(clk);
    9598    t.o(out);
  • sources/test_regression/15092005c/system.cpp

    r55 r60  
    8787    top_level t("top_level");
    8888
     89    // Setup number of threads open-mp to 1 with the macro threads_omp()
     90    threads_omp();
     91
    8992    t.clk(clk);
    9093    t.o(out);
  • sources/test_regression/15092005d/system.cpp

    r55 r60  
    9090    top_level t("top_level");
    9191
     92    // Setup number of threads open-mp to 1 with the macro threads_omp()
     93    threads_omp();
     94
    9295    t.clk(clk);
    9396    t.o(out);
  • sources/test_regression/16022007/system.cpp

    r55 r60  
    213213        s15("s15");
    214214
     215    // Setup number of threads open-mp to 1 with the macro threads_omp()
     216    threads_omp();
    215217
    216218    M_0i1o a("a");
  • sources/test_regression/16062005a/system.cpp

    r55 r60  
    7575    }
    7676
     77    // Setup number of threads open-mp to 1 with the macro threads_omp()
     78    threads_omp();
     79
    7780    sc_clock clk("clock");
    7881    top_level1 top1("top1");
  • sources/test_regression/16062005b/system.cpp

    r55 r60  
    6565    }
    6666
     67    // Setup number of threads open-mp to 1 with the macro threads_omp()
     68    threads_omp();
     69
    6770    ofstream o;
    6871    o.open (argv[1], ios::out | ios::trunc);
  • sources/test_regression/16112005a/system.cpp

    r55 r60  
    4040    sc_signal<int> s1("s1"), s2("s2"), s3("s3"), s4("s4");
    4141
     42    // Setup number of threads open-mp to 1 with the macro threads_omp()
     43    threads_omp();
     44
    4245    m.i1 (s1);
    4346    m.i2 (s1);
  • sources/test_regression/16112005b/system.cpp

    r55 r60  
    3838    sc_signal<int> s1("s1"), s2("s2"), s3("s3"), s4("s4");
    3939
     40    // Setup number of threads open-mp to 1 with the macro threads_omp()
     41    threads_omp();
     42
    4043    m.i1(s1);
    4144    m.i3(s1);
  • sources/test_regression/16112005c/system.cpp

    r55 r60  
    3838    sc_signal<int> s1("s1"), s2("s2"), s3("s3"), s4("s4");
    3939
     40    // Setup number of threads open-mp to 1 with the macro threads_omp()
     41    threads_omp();
     42
    4043    m.i1 (s1);
    4144    m.i2 (s1);
  • sources/test_regression/16122005/system.cpp

    r55 r60  
    6767    }
    6868
     69    // Setup number of threads open-mp to 1 with the macro threads_omp()
     70    threads_omp();
     71
    6972    sc_clock clk("clock");
    7073    top_level1 top1("top1");
  • sources/test_regression/17022006/system.cpp

    r55 r60  
    6969    sc_signal<char> s04_0("s04_0"), s04_1("s04_1"), s04_2("s04_2");
    7070
     71    // Setup number of threads open-mp to 1 with the macro threads_omp()
     72    threads_omp();
     73
    7174    test test1("test1");
    7275    test1.clk(signal_clk);
  • sources/test_regression/17032005/system.cpp

    r55 r60  
    7676    test.clk(clk);
    7777    test.resetn(resetn);
     78
     79    // Setup number of threads open-mp to 1 with the macro threads_omp()
     80    threads_omp();
    7881
    7982    sc_trace_file * tf;
  • sources/test_regression/19042005/system.cpp

    r55 r60  
    7878    sc_signal< sc_uint<64> > s11("s11"), s12("s12"), s13("s13");
    7979    sc_signal< sc_uint<32> > s16("s16");
     80
     81    // Setup number of threads open-mp to 1 with the macro threads_omp()
     82    threads_omp();
    8083
    8184    test test1("test1");
  • sources/test_regression/19122005/system.cpp

    r55 r60  
    127127    sc_clock  signal_clk("my_clock", 1, 0.5);
    128128
     129    // Setup number of threads open-mp to 1 with the macro threads_omp()
     130    threads_omp();
     131
    129132    test test1("test1");
    130133    test1.clk(signal_clk);
  • sources/test_regression/20122006/system.cpp

    r55 r60  
    226226        s15("s15");
    227227
     228    // Setup number of threads open-mp to 1 with the macro threads_omp()
     229    threads_omp();
    228230
    229231    M_0i1o a("a");
  • sources/test_regression/21062005/system.cpp

    r55 r60  
    4848    sc_signal<int> s1("s1"), s2("s2"), s3("s3"), s4("s4");
    4949
     50    // Setup number of threads open-mp to 1 with the macro threads_omp()
     51    threads_omp();
     52
    5053    m.i1 (s1);
    5154    m.i2 (s1);
  • sources/test_regression/24082009/system.cpp

    r55 r60  
    4242    sc_signal<int> s1("s1"), s2("s2"), s3("s3"), s4("s4");
    4343
     44    // Setup number of threads open-mp to 1 with the macro threads_omp()
     45    threads_omp();
     46
    4447    A a("a");
    4548    A b("b");
  • sources/test_regression/25032005/system.cpp

    r55 r60  
    103103    sc_signal<bool> s1("s1"), s2("s2"), s3("s3"), s4("s4"), s5("s5");
    104104
     105    // Setup number of threads open-mp to 1 with the macro threads_omp()
     106    threads_omp();
     107
    105108    A a("a");
    106109    B b("b");
  • sources/test_regression/28102005/system.cpp

    r55 r60  
    4747    sc_clock clk("clock");
    4848
     49    // Setup number of threads open-mp to 1 with the macro threads_omp()
     50    threads_omp();
     51
    4952    check_time(0);
    5053    sc_start(sc_time(0, sc_core::SC_NS));
  • sources/test_regression/29032005/system.cpp

    r55 r60  
    216216        s15("s15");
    217217
     218    // Setup number of threads open-mp to 1 with the macro threads_omp()
     219    threads_omp();
    218220
    219221    M_0i1o a("a");
  • sources/test_regression/30032005a/system.cpp

    r55 r60  
    119119        s15("s15");
    120120
     121    // Setup number of threads open-mp to 1 with the macro threads_omp()
     122    threads_omp();
    121123
    122124    M1_3i3o a("a");
  • sources/test_regression/30032005b/system.cpp

    r55 r60  
    7474        s15("s15");
    7575
     76    // Setup number of threads open-mp to 1 with the macro threads_omp()
     77    threads_omp();
    7678
    7779    M1_1i1o a("a");
  • sources/test_regression/30032005c/system.cpp

    r55 r60  
    108108        s15("s15");
    109109
     110    // Setup number of threads open-mp to 1 with the macro threads_omp()
     111    threads_omp();
    110112
    111113    M1_3i2o a("a");
  • sources/test_regression/test.h

    r55 r60  
     1
     2#ifdef _OPENMP
     3    #include <omp.h>
     4#endif
    15
    26#define ASSERT(x)                    \
     
    812}
    913
     14#ifdef _OPENMP
     15    #define threads_omp()      \
     16    ({                         \
     17        omp_set_dynamic(false);\
     18        omp_set_num_threads(1);\
     19    })
     20#else
     21    #define threads_omp()
     22#endif
     23
Note: See TracChangeset for help on using the changeset viewer.