Example #1
0
    //! @internal
    template <class Archive, class MapT> inline
    void load( Archive & ar, MapT & map )
    {
      size_type size;
      ar( make_size_tag( size ) );

      map.clear();
      map.reserve( size );

      for( size_type i = 0; i < size; ++i )
      {
        typename MapT::key_type key;
        typename MapT::mapped_type value;

        ar( make_map_item(key, value) );
        map.insert( {key, value} );
      }
    }
Example #2
0
    //! @internal
    template <class Archive, class MapT> inline
    void load( Archive & ar, MapT & map )
    {
      size_type size;
      ar( make_size_tag( size ) );

      map.clear();

      auto hint = map.begin();
      for( size_t i = 0; i < size; ++i )
      {
        typename MapT::key_type key;
        typename MapT::mapped_type value;

        ar( make_map_item(key, value) );
        #ifdef CEREAL_OLDER_GCC
        hint = map.insert( hint, std::make_pair(std::move(key), std::move(value)) );
        #else // NOT CEREAL_OLDER_GCC
        hint = map.emplace_hint( hint, std::move( key ), std::move( value ) );
        #endif // NOT CEREAL_OLDER_GCC
      }
    }
Example #3
0
int main(int argc, char* argv[])
{
    int retval = 0;
    ForestT* forest = NULL;
    NetVT*   net_values_FF = NULL;
    int* retvals = NULL;
    IdType** thread_modules = NULL;
    NetVT**  net_values_E = NULL;

    do
    {
        if ((retval = ReadInput(argc, argv))) break;
        if ((retval = MakeOrder()          )) break;
        if ((retval = GetDependency()      )) break;

        #pragma omp parallel
        {
            int thread_num = omp_get_thread_num();
            int num_threads = omp_get_num_threads();

            #pragma omp single
            {
                do
                {
                    retvals = new int[num_threads];
                    memset(retvals, 0, sizeof(int) * num_threads);
                    forest = new ForestT;
                    if ((retvals[thread_num] = forest->Init(num_threads, num_inputs, net_widths))) break;
                    thread_inputs = new ValueType*[num_threads];
                    thread_outputs = new ValueType*[num_threads];
                    thread_modules = new IdType*[num_threads];
                    for (SizeType i=0; i<num_threads; i++)
                    {
                        thread_inputs[i] = new ValueType[max_num_inputs];
                        thread_outputs[i] = new ValueType[max_num_outputs];
                        thread_modules[i] = new IdType[num_modules];
                    } 

                    net_values_FF = new NetVT[num_nets];
                    //prepare the inputs
                    for (SizeType i=0; i<num_inputs; i++)
                    {
                        MapT* map = &net_values_FF[i].root_Ids;
                        for (ValueType j=0; j< (1<<net_widths[i]); j++)
                        {
                            IdType temp_Id = NULL_Id;
                            retvals[thread_num] = forest->NewTree(thread_num, i, j, temp_Id);
                            if (retvals[thread_num] != 0) break;
                            map->insert(MapTP(j, temp_Id));
                        }
                    }
                    for (IdType i=0; i<num_modules; i++)
                        thread_modules[thread_num][i] = i;

                    // Evaluate the FF cicuit
                    if ((retvals[thread_num] = Evaluate(num_modules, thread_modules[thread_num], net_values_FF, NULL, forest, thread_num))) break;

                    if ((retvals[thread_num] = GenerateErrors())) break;
                    net_values_E = new NetVT*[num_errors];
                    for (SizeType i=0; i<num_errors; i++)
                        net_values_E[i] = new NetVT[num_nets];
                } while(0);

            }

            #pragma omp for
            for (IdType i=0; i<num_errors; i++)
            {
                if (retvals[thread_num] != 0) continue;
                IdType error_type = error_types.find(i)->second;
                IdType error_Id   = error_Ids  .find(i)->second;
                IdType error_ref  = error_refs .find(i)->second;
                IdType error_cond = error_conds.find(i)->second;
                IdType start_module_Id = NULL_Id;
                SizeType module_count = 0;
                
                // Place the error
                if ((retvals[thread_num] = ProcessError(error_type, error_Id, error_ref, error_cond, 
                    net_values_FF, net_values_E[i], start_module_Id, forest, thread_num))) continue;
                if (start_module_Id == NULL_Id) continue;

                // Get list of modules to evaluate
                if ((retvals[thread_num] = GetModuleList(start_module_Id, module_count, thread_modules[thread_num]))) continue;
                // Evaluate the faulty circuit
                if ((retvals[thread_num] = Evaluate(module_count, thread_modules[thread_num], net_values_FF, net_values_E[i], forest, thread_num))) continue;
            } 

            if (retvals[thread_num] != 0) cerr<<"Thread "<<thread_num<<" terminated with error code "<<retvals[thread_num]<<endl;
        }
    } while(0);

    if (retval != 0) cerr<<"Terminated with error code "<<retval<<endl;
    return retval;
}