Ejemplo n.º 1
0
void FieldStatic::sendSecondPass(size_t fromRow) {
    // (nextCalculatingRows + y) x [prevCalculatingRows]
    if (leftN != NOBODY) {
        START_TIME(rStartWithPrep);

        double *sBuff = sendBuff + fromRow * sendBucketSize;
        int sSize = 0;
        
        sBuff[sSize++] = shouldBalanceNext ? 1 : 0;
        if (shouldBalanceNext) {
            for (size_t i = 0; i < numProcs; ++i) {
                sBuff[sSize++] = nextBuckets[i];
            }
        }

        for (size_t row = fromRow, bundleSize = 0; row < height && bundleSize < bundleSizeLimit; ++row) {
            if (calculatingRows[row] == false) {
                continue;
            }
            sBuff[sSize++] = (nextCalculatingRows[row] ? 1 : -1) * curr[row * width + 1];

            ++bundleSize;
        }

        MPI_Request request;
        START_TIME(rStart);
        MPI_Isend(sBuff, sSize, MPI_DOUBLE, leftN, (int)fromRow, secondPassComm, &request);
        END_TIME(syncNetworkTime, rStart);
        END_TIME(syncNetworkWithPrepTime, rStartWithPrep);
    }
}
Ejemplo n.º 2
0
/***********************************************************************
 *  Configuration reading procedures :
 *  GetOptions      - read the sound configuration file.
 ***********************************************************************/
void
GetBaseOptions (const char *filename/* unused*/)
{
    START_TIME(started);
	ReloadASEnvironment( NULL, NULL, NULL, False, False );
    SHOW_TIME("BaseConfigParsingTime",started);
}
Ejemplo n.º 3
0
int main(int argc, char *argv[]){

  int res = 0;
  shrdPtr= (struct wonk*)malloc(sizeof(struct wonk));
  shrdPtr->a = 1;

  pthread_mutex_init(&lock,NULL);

	START_TIME();
  pthread_t acc[7],upd;
  pthread_create(&acc[0],NULL,accessorThread,(void*)shrdPtr);
  pthread_create(&acc[1],NULL,accessorThread,(void*)shrdPtr);
  pthread_create(&acc[2],NULL,accessorThread,(void*)shrdPtr);
  pthread_create(&acc[3],NULL,accessorThread,(void*)shrdPtr);
  pthread_create(&acc[4],NULL,accessorThread,(void*)shrdPtr);
  pthread_create(&acc[5],NULL,accessorThread,(void*)shrdPtr);
  pthread_create(&acc[6],NULL,accessorThread,(void*)shrdPtr);
  pthread_create(&upd,NULL,updaterThread,(void*)shrdPtr);

  pthread_join(upd,NULL);
  pthread_join(acc[0],(void*)&res);
  pthread_join(acc[1],(void*)&res);
  pthread_join(acc[2],(void*)&res);
  pthread_join(acc[3],(void*)&res);
  pthread_join(acc[4],(void*)&res);
  pthread_join(acc[5],(void*)&res);
  pthread_join(acc[6],(void*)&res);
	STOP_TIME();
  fprintf(stderr,"Final value of res was %d\n",res); 
	PRINT_TIME();
}
Ejemplo n.º 4
0
void
GetOptions (const char *filename)
{
    AudioConfig *config = ParseAudioOptions (filename, MyName);
	int i ;
    START_TIME(option_time);

    /* Need to merge new config with what we have already :*/
    /* now lets check the config sanity : */
    /* mixing set and default flags : */
    Config->set_flags |= config->set_flags;

  	if( config->playcmd != NULL ) 
		set_string_value( &(Config->playcmd), config->playcmd, NULL, 0 );
	for( i = 0 ; i < AFTERSTEP_EVENTS_NUM ; ++i ) 
  		if( config->sounds[i] != NULL ) 
			set_string_value( &(Config->sounds[i]), config->sounds[i], NULL, 0 );
    
	if( get_flags(config->set_flags, AUDIO_SET_DELAY) )
        Config->delay = config->delay;
    if( get_flags(config->set_flags, AUDIO_SET_RPLAY_HOST) && config->rplay_host != NULL )
		set_string_value( &(Config->rplay_host), config->rplay_host, NULL, 0 );
    if( get_flags(config->set_flags, AUDIO_SET_RPLAY_PRIORITY) )
        Config->rplay_priority = config->rplay_priority;
    if( get_flags(config->set_flags, AUDIO_SET_RPLAY_VOLUME) )
        Config->rplay_volume = config->rplay_volume;

    DestroyAudioConfig (config);
    SHOW_TIME("Config parsing",option_time);
}
Ejemplo n.º 5
0
void framerate_clean()
{
   if(!graf_init_lfb()) return;
   START_TIME(timer);
   for(int i = 0; i < 1000; i++) clear(i);
   STOP_TIME(timer);
   fps_clean = FPS(1000,timer);
   graf_close();
}
Ejemplo n.º 6
0
void FieldStatic::sendDoneAsFirstPass() {
    if (rightN != NOBODY) {
        MPI_Request request;
        START_TIME(rStart);
        MPI_Isend(NULL, 0, MPI_DOUBLE, rightN, 0, firstPassComm, &request);
        END_TIME(syncNetworkTime, rStart);
        END_TIME(syncNetworkWithPrepTime, rStart);
    }
}
Ejemplo n.º 7
0
void
GetOptions (const char *filename)
{
    START_TIME(option_time);
    IdentConfig *config = ParseIdentOptions( filename, MyName );

    if (config->style_defs)
        ProcessMyStyleDefinitions (&(config->style_defs));
    SHOW_TIME("Config parsing",option_time);
}
Ejemplo n.º 8
0
void FieldStatic::sendFirstPass(size_t fromRow) {
    // (crf + b + c + f) x [calculatingRows]
    if (rightN != NOBODY) {
        START_TIME(rStartWithPrep);
        double *sBuff = sendBuff + fromRow * sendBucketSize;

        int sSize = 0;
        sBuff[sSize++] = (shouldSendWeights ? -1 : 1) * (int)bundleSizeLimit;

        if (shouldSendWeights) {
            for (size_t i = 0; i < mySX + width - (rightN == NOBODY ? 0 : 1) - (leftN == NOBODY ? 0 : 1); ++i) {
                sBuff[sSize++] = weights[i];
                weights[i] = 0;
            }
            shouldSendWeights = false;
        }

        for (size_t row = fromRow, bundleSize = 0; row < height && bundleSize < bundleSizeLimit; ++row) {
            if (calculatingRows[row] == false) {
                continue;
            }

            size_t index = row * width + width - 2;
            sBuff[sSize++] = row;
            sBuff[sSize++] = mbF[index];
            sBuff[sSize++] = mcF[index];
            sBuff[sSize++] = mfF[index];
            ++bundleSize;
        }

        MPI_Request request;
        START_TIME(rStart);
        MPI_Isend(sBuff, sSize, MPI_DOUBLE, rightN, (int)fromRow, firstPassComm, &request);
        END_TIME(syncNetworkTime, rStart);
        END_TIME(syncNetworkWithPrepTime, rStartWithPrep);
    }
}
Ejemplo n.º 9
0
void FieldStatic::partitionAndCheck() {
    /*debug() << "NB ";
    for (size_t i = 0; i < numProcs; ++i) {
        debug(0) << nowBuckets[i] << " ";
    }
    (debug(0) << "\n").flush();*/

    smoothWeights();

    START_TIME(partitioningStart);

    auto buckets = balancing::fastPartition(weights, fullHeight, nowBuckets, numProcs);
    //auto buckets = balancing::partition(weights, fullHeight, numProcs);
    size_t deltaSum = 0;
    for (size_t i = 0; i < numProcs; ++i) {
        nextBuckets[i] = (size_t)buckets[i];
        deltaSum += std::abs((long)nextBuckets[i] - (long)nowBuckets[i]);
    }

    shouldBalanceNext = deltaSum > fullHeight / numProcs * algo::ftr().StaticBalanceThresholdFactor();

    if (bfout != NULL) {
        for (size_t i = 0; i < numProcs; ++i) {
            *bfout << (shouldBalanceNext ? nextBuckets : nowBuckets)[i];
            if (i < numProcs - 1) {
                *bfout << ",";
            }
        }
        *bfout << "\n";
        bfout->flush();
    }
    if (wfout != NULL) {
        for (size_t i = 0; i < fullHeight; ++i) {
            *wfout << weights[i];
            if (i < fullHeight - 1) {
                *wfout << ",";
            }
        }
        *wfout << "\n";
        wfout->flush();
    }

    memset(weights, 0, fullHeight * sizeof(double));

    END_TIME(partitioningTime, partitioningStart);
}
Ejemplo n.º 10
0
void FieldStatic::recieveSecondPass(size_t fromRow) {
    // (nextCalculatingRows + y) x [prevCalculatingRows]
    if (rightN != NOBODY) {
        START_TIME(rStart);

        MPI_Status status;
        MPI_Probe(rightN, (int)fromRow, secondPassComm, &status);
        int sSize;
        MPI_Get_count(&status, MPI_DOUBLE, &sSize);

        MPI_Recv(receiveBuff, sSize, MPI_DOUBLE, rightN, (int)fromRow, secondPassComm, MPI_STATUS_IGNORE);
        END_TIME(syncNetworkTime, rStart);

        sSize = 0;
        bool shouldReceiveBuckets = receiveBuff[sSize++] > 0;
        if (shouldReceiveBuckets) {
            for (size_t i = 0; i < numProcs; ++i) {
                nextBuckets[i] = receiveBuff[sSize++];
            }
            shouldBalanceNext = true;
        }

        for (size_t row = fromRow, bundleSize = 0; row < height && bundleSize < bundleSizeLimit; ++row) {
            if (calculatingRows[row] == false) {
                continue;
            }

            double value = receiveBuff[sSize++];
            nextCalculatingRows[row] = value > 0;
            curr[(row + 1) * width - 1] = nextCalculatingRows[row] ? value : -value;

            ++bundleSize;
        }

        END_TIME(syncNetworkWithPrepTime, rStart);
    }
}
Ejemplo n.º 11
0
DesignFlowStep_Status values_scheme::InternalExec()
{
   long step_time;
   START_TIME(step_time);
   THROW_ASSERT(HLS->Rliv, "Liveness analysis not yet computed");
   unsigned int i = 0;
   const std::list<vertex> & support = HLS->Rliv->get_support();

   const std::list<vertex>::const_iterator vEnd = support.end();
   for(std::list<vertex>::const_iterator vIt = support.begin(); vIt != vEnd; vIt++)
   {
      //std::cerr << "current state for sv " << HLS->Rliv->get_name(*vIt) << std::endl;
      const std::set<unsigned int>& live = HLS->Rliv->get_live_in(*vIt);
      const std::set<unsigned int>::const_iterator k_end = live.end();
      for(std::set<unsigned int>::const_iterator k = live.begin(); k != k_end; k++)
      {
         if(HLS->storage_value_information->storage_index_map.find(*k) == HLS->storage_value_information->storage_index_map.end())
         {
            HLS->storage_value_information->storage_index_map[*k] = i;
            HLS->storage_value_information->variable_index_vect.push_back(*k);
            i++;
         }
      }
   }
   HLS->storage_value_information->number_of_storage_values = i;
   if(output_level <= OUTPUT_LEVEL_PEDANTIC)
      INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "");
   INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "-->Storage Value Information of function " + HLSMgr->CGetFunctionBehavior(funId)->CGetBehavioralHelper()->get_function_name() + ":");
   INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "---Number of storage values inserted: "+boost::lexical_cast<std::string>(i));
   STOP_TIME(step_time);
   if(output_level >= OUTPUT_LEVEL_MINIMUM and output_level <= OUTPUT_LEVEL_PEDANTIC)
      INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "Time to compute storage value information: " + print_cpu_time(step_time) + " seconds");
   INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "<--");
   if(output_level <= OUTPUT_LEVEL_PEDANTIC)
      INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "");
   return DesignFlowStep_Status::SUCCESS;
}
Ejemplo n.º 12
0
syntax_error *lang_CPP::definitionsModified(const char* wscode, const char* targetYaml)
{
  cout << "Parsing settings..." << endl;
    parse_ide_settings(targetYaml);
  
  cout << targetYaml << endl;
  
  cout << "Creating swap." << endl;
  delete main_context;
  main_context = new jdi::context();
  
  cout << "Dumping whiteSpace definitions..." << endl;
  FILE *of = wscode ? fopen((makedir +"Preprocessor_Environment_Editable/IDE_EDIT_whitespace.h").c_str(),"wb") : NULL;
  if (of) fputs(wscode,of), fclose(of);
  
  cout << "Opening ENIGMA for parse..." << endl;
  
  llreader f("ENIGMAsystem/SHELL/SHELLmain.cpp");
  int res = 1;
  DECLARE_TIME();
  if (f.is_open()) {
    START_TIME();
    res = main_context->parse_C_stream(f, "SHELLmain.cpp");
    STOP_TIME();
  }
  
  jdi::definition *d;
  if ((d = main_context->get_global()->look_up("variant"))) {
    enigma_type__variant = d;   
    if (!(d->flags & jdi::DEF_TYPENAME))
      cerr << "ERROR! ENIGMA's variant is not a type!" << endl;
    else
      cout << "Successfully loaded builtin variant type" << endl;
  } else cerr << "ERROR! No variant type found!" << endl;
  if ((d = main_context->get_global()->look_up("var"))) {
    enigma_type__var = d;
    if (!(d->flags & jdi::DEF_TYPENAME))
      cerr << "ERROR! ENIGMA's var is not a type!" << endl;
    else
      cout << "Successfully loaded builtin var type" << endl;
  } else cerr << "ERROR! No var type found!" << endl;
  if ((d = main_context->get_global()->look_up("enigma"))) {
    if (d->flags & jdi::DEF_NAMESPACE) {
      if ((d = ((jdi::definition_scope*)d)->look_up("varargs"))) {
        enigma_type__varargs = d;
        if (!(d->flags & jdi::DEF_TYPENAME))
          cerr << "ERROR! ENIGMA's varargs is not a type!" << endl;
        else
          cout << "Successfully loaded builtin varargs type" << endl;
      } else cerr << "ERROR! No varargs type found!" << endl;
    } else cerr << "ERROR! Namespace enigma is... not a namespace!" << endl;
  } else cerr << "ERROR! Namespace enigma not found!" << endl;
  
  if (res) {
    cout << "ERROR in parsing engine file: The parser isn't happy. Don't worry, it's never happy.\n";
    cout << heaping_pile_of_dog_shit;
    
    ide_passback_error.set(0,0,0,"Parse failed; details in stdout. Bite me.");
    cout << "Continuing anyway." << endl;
    // return &ide_passback_error;
  } else {    
    cout << "Successfully parsed ENIGMA's engine (" << PRINT_TIME() << "ms)\n"
    << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    //cout << "Namespace std contains " << global_scope.members["std"]->members.size() << " items.\n";
  }
  
  cout << "Creating dummy primitives for old ENIGMA" << endl;
  for (jdip::tf_iter it = jdip::builtin_declarators.begin(); it != jdip::builtin_declarators.end(); ++it) {
    main_context->get_global()->members[it->first] = new jdi::definition(it->first, main_context->get_global(), jdi::DEF_TYPENAME);
  }
  
  cout << "Initializing EDL Parser...\n";
  
  parser_init();
  
  cout << "Grabbing locals...\n";
  
  shared_locals_load(requested_extensions);
  
  cout << "Determining build target...\n";
  
  extensions::determine_target();
  
  cout << " Done.\n";
  
  return &ide_passback_error;
}
Ejemplo n.º 13
0
int main(int argc, char *argv[])
{
   // Program name

   ParameterRef parameters;

   try
   {
      // ---------- General options ------------ //
      // Synthesis cpu time
      long total_time;
      START_TIME(total_time);
      // General options register

      // ---------- Initialization ------------ //

      // ---------- Parameter parsing ------------ //
      long cpu_time;
      START_TIME(cpu_time);
      parameters = ParameterRef(new EucalyptusParameter(argv[0], argc, argv));

      switch(parameters->Exec())
      {
         case PARAMETER_NOTPARSED:
         {
            exit_code = PARAMETER_NOTPARSED;
            throw "Bad Parameters format";
         }
         case EXIT_SUCCESS:
         {
            if(not (parameters->getOption<bool>(OPT_no_clean)))
            {
               boost::filesystem::remove_all(parameters->getOption<std::string>(OPT_output_temporary_directory));
            }
            return EXIT_SUCCESS;
         }
         case PARAMETER_PARSED:
         {
            exit_code = EXIT_FAILURE;
            break;
         }
         default:
         {
            THROW_ERROR("Bad Parameters parsing");
         }
      }

      int output_level = parameters->getOption<int>(OPT_output_level);
      STOP_TIME(cpu_time);
      if(output_level >= OUTPUT_LEVEL_MINIMUM)
         parameters->PrintFullHeader(std::cerr);

      /// eucalyptus does not perform a clock constrained synthesis
      if(!parameters->isOption(OPT_clock_period))
         parameters->setOption(OPT_clock_period, 0.0);

      // Technology library manager
      technology_managerRef TM = technology_managerRef(new technology_manager(parameters));


      ///creating the datastructure representing the target device
      const auto target_device = static_cast<TargetDevice_Type>(parameters->getOption<unsigned int>(OPT_target_device_type));
      target_deviceRef device = target_device::create_device(target_device, parameters, TM);
      device->set_parameter("clock_period", parameters->getOption<double>(OPT_clock_period));
      target_managerRef target = target_managerRef(new target_manager(parameters, TM, device));

      const DesignFlowManagerRef design_flow_manager(new DesignFlowManager(parameters));
      const DesignFlowGraphConstRef design_flow_graph = design_flow_manager->CGetDesignFlowGraph();

      const DesignFlowStepFactoryConstRef technology_flow_step_factory(new TechnologyFlowStepFactory(TM, device, design_flow_manager, parameters));
      design_flow_manager->RegisterFactory(technology_flow_step_factory);

      const std::string technology_flow_signature = TechnologyFlowStep::ComputeSignature(TechnologyFlowStep_Type::LOAD_TECHNOLOGY);
      const vertex technology_flow_step = design_flow_manager->GetDesignFlowStep(technology_flow_signature);
      const DesignFlowStepRef technology_design_flow_step = technology_flow_step ? design_flow_graph->CGetDesignFlowStepInfo(technology_flow_step)->design_flow_step : GetPointer<const TechnologyFlowStepFactory>(technology_flow_step_factory)->CreateTechnologyFlowStep(TechnologyFlowStep_Type::LOAD_TECHNOLOGY);
      design_flow_manager->AddStep(technology_design_flow_step);


#if HAVE_XILINX || HAVE_ALTERA || HAVE_LATTICE || HAVE_DESIGN_COMPILER
      if(parameters->isOption(OPT_component_name))
      {
         const DesignFlowStepRef design_flow_step(new RTLCharacterization(target, parameters->getOption<std::string>(OPT_component_name), design_flow_manager, parameters));
         design_flow_manager->AddStep(design_flow_step);
      }
#endif
      design_flow_manager->Exec();

#if HAVE_EXPERIMENTAL
      if (parameters->isOption(OPT_import_ip_core))
      {
         START_TIME(cpu_time);
         std::string core_hdl = parameters->getOption<std::string>(OPT_import_ip_core);
         core_generationRef core_gen = core_generationRef(new core_generation(parameters));
         core_gen->convert_to_XML(core_hdl, device->get_type());
         STOP_TIME(cpu_time);
         PRINT_OUT_MEX(DEBUG_LEVEL_MINIMUM, output_level, " ==== Core generation performed in " + print_cpu_time(cpu_time) + " seconds; ====\n");
      }

      if (parameters->isOption(OPT_export_ip_core))
      {
         START_TIME(cpu_time);
         std::string core_name = parameters->getOption<std::string>(OPT_export_ip_core);
         core_generationRef core_gen = core_generationRef(new core_generation(parameters));
         core_gen->export_core(TM, core_name);
         STOP_TIME(cpu_time);
         PRINT_OUT_MEX(DEBUG_LEVEL_MINIMUM, output_level, " ==== Core exported in " + print_cpu_time(cpu_time) + " seconds; ====\n");
      }
#endif
      STOP_TIME(total_time);
      PRINT_MSG(" ==== Total Execution Time: " + print_cpu_time(total_time) + " seconds; ====\n");

      if(not (parameters->getOption<bool>(OPT_no_clean)))
      {
         boost::filesystem::remove_all(parameters->getOption<std::string>(OPT_output_temporary_directory));
      }
      return EXIT_SUCCESS; // Eucalyptus tool has completed execution without errors
   }

   // exception catching
   catch (const char * str)
   {
      std::cerr << str << std::endl;
   }
   catch (const std::string& str)
   {
      std::cerr << str << std::endl;
   }
   catch (std::exception &e)
   {
      std::cerr << e.what() << std::endl;
   }
   catch (...)
   {
      std::cerr << "Unknown error type" << std::endl;
   }

   switch(exit_code)
   {
      case PARAMETER_NOTPARSED:
      {
         parameters->PrintUsage(std::cout);
         break;
      }
      case EXIT_FAILURE:
      {
         parameters->PrintBugReport(std::cout);
         break;
      }
      default:
      {

      }
   }
   if(parameters and not (parameters->getOption<bool>(OPT_no_clean)))
   {
      boost::filesystem::remove_all(parameters->getOption<std::string>(OPT_output_temporary_directory));
   }
   return exit_code;

}
Ejemplo n.º 14
0
void read_technology_library(technology_managerRef TM, const ParameterConstRef Param, const target_deviceRef device)
{
#if HAVE_EXPERIMENTAL || HAVE_FROM_LIBERTY || HAVE_LIBRARY_COMPILER
   int output_level = Param->getOption<int>(OPT_output_level);
#endif
#ifndef NDEBUG
   int debug_level = Param->get_class_debug_level("parse_technology");
#endif

#if HAVE_FROM_LIBERTY
   //parsing of liberty format
   if (Param->isOption(OPT_input_liberty_library_file))
   {
      long lib2xmlTime;
      std::string LibFile = Param->getOption<std::string>(OPT_input_liberty_library_file);

      std::string XmlList;
      std::vector<std::string> SplittedLibs;
      boost::algorithm::split(SplittedLibs, LibFile, boost::algorithm::is_any_of(";"));
      for (unsigned int i = 0; i < SplittedLibs.size(); i++)
      {
         if (SplittedLibs.size() == 0) continue;
         boost::trim(SplittedLibs[i]);
         std::vector<std::string> SplittedLib;
         boost::algorithm::split(SplittedLib, SplittedLibs[i], boost::algorithm::is_any_of(":"));
         std::string LibraryFile, LibraryName;
         if (SplittedLib.size() < 1 or SplittedLib.size() > 2)
            THROW_ERROR("Malformed input liberty description: \"" + SplittedLibs[i] + "\"");
         if (SplittedLib.size() == 1)
         {
            LibraryFile = SplittedLib[0];
         }
         else
         {
            LibraryName = SplittedLib[0];
            LibraryFile = SplittedLib[1];
         }
         if (!boost::filesystem::exists(LibraryFile))
            THROW_ERROR("Liberty file \"" + LibraryFile + "\" does not exists!");
         START_TIME(lib2xmlTime);
         std::string TargetXML = Param->getOption<std::string>(OPT_output_temporary_directory) + "/library_" + boost::lexical_cast<std::string>(i) + ".xml";
         lib2xml(LibraryFile, TargetXML, Param);
         if (XmlList.size()) XmlList += ";";
         XmlList += TargetXML;
         STOP_TIME(lib2xmlTime);
         PRINT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "(koala) Read and converted the liberty file \"" + LibraryFile + "\" in "
                       + boost::lexical_cast<std::string>(print_cpu_time(lib2xmlTime)) + " seconds;\n");
      }
      ///FIXME: setting parameters
      const_cast<Parameter *>(Param.get())->setOption("input_xml_library_file", XmlList);
   }
#endif

#if HAVE_BOOLEAN_PARSER_BUILT
   if (Param->isOption("input_genlib_library_file"))
   {
      long genlibTime;
      START_TIME(genlibTime);
      PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "(koala) Reading the genlib technology library");
      std::string LibraryName = Param->getOption<std::string>("genlib_library_file");
      technology_managerRef local_TM = technology_managerRef(new technology_manager(Param));
      read_genlib_technology_File(LibraryName, local_TM, Param);
      STOP_TIME(genlibTime);
      PRINT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "(koala) Read the technology library file \"" + LibraryName + "\" in "
                    + boost::lexical_cast<std::string>(print_cpu_time(genlibTime)) + " seconds;\n");
      write_technology_File(technology_manager::XML, "genlib", local_TM, device->get_type());
      ///FIXME: setting parameters
      const_cast<Parameter *>(Param.get())->setOption("input_xml_library_file", "genlib.xml");
      const_cast<Parameter *>(Param.get())->removeOption("input_genlib_library_file");
   }
#endif

   if (Param->isOption("input_xml_library_file"))
   {
      PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "(koala) Reading the XML technology library");

      std::string LibraryName;
      std::string XmlLibraryList = Param->getOption<std::string>("input_xml_library_file");
      std::vector<std::string> SplittedLibs;
      boost::algorithm::split(SplittedLibs, XmlLibraryList, boost::algorithm::is_any_of(";"));
      for (unsigned int i = 0; i < SplittedLibs.size(); i++)
      {
         if (SplittedLibs.size() == 0) continue;
         LibraryName = SplittedLibs[i];
         long xmlTime;
         START_TIME(xmlTime);
         read_technology_File(SplittedLibs[i], TM, Param, device);
         STOP_TIME(xmlTime);
         PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "(koala) Read the XML technology library file \"" + LibraryName + "\" in "
                       + boost::lexical_cast<std::string>(print_cpu_time(xmlTime)) + " seconds;\n");
      }

#if HAVE_BOOLEAN_PARSER_BUILT
      if (Param->getOption<bool>(OPT_dump_genlib))
      {
         std::string genlib_name(LibraryName.substr(0, LibraryName.find_last_of('.')) + ".genlib");
         PRINT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "(koala) Dumping the technology library in genlib format");
#if HAVE_CIRCUIT_BUILT
         dump_genlib(genlib_name, TM);
#endif
      }
#endif
   }

#if HAVE_EXPERIMENTAL
   if (Param->isOption("input_lef_library_file"))
   {
      std::string FileList = Param->getOption<std::string>("input_lef_library_file");
      std::vector<std::string> SplittedLibs;
      boost::algorithm::split(SplittedLibs, FileList, boost::algorithm::is_any_of(";"));
      for (unsigned int i = 0; i < SplittedLibs.size(); i++)
      {
         if (SplittedLibs.size() == 0) continue;
         boost::trim(SplittedLibs[i]);

         std::vector<std::string> SplittedName;
         boost::algorithm::split(SplittedName, SplittedLibs[i], boost::algorithm::is_any_of(":"));

         if (SplittedName.size() != 2) THROW_ERROR("Malformed LEF description: \"" + SplittedLibs[i] + "\"");
         std::string LibraryName = SplittedName[0];
         std::string LefFileName = SplittedName[1];

         if (!boost::filesystem::exists(LefFileName))
            THROW_ERROR("Lef file \"" + LefFileName + "\" does not exists!");

         if (!TM->is_library_manager(LibraryName))
            THROW_ERROR("Library \"" + LibraryName + "\" is not contained into the datastructure");
         const library_managerRef& LM = TM->get_library_manager(LibraryName);
         LM->set_info(library_manager::LEF, LefFileName);

         PRINT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "(koala) Stored LEF file \"" + LefFileName + "\" for library \""
                       + LibraryName + "\";\n");
      }
   }
#endif

#if HAVE_LIBRARY_COMPILER
   if (Param->isOption("input_db_library_file"))
   {
      std::string FileList = Param->getOption<std::string>("input_db_library_file");
      std::vector<std::string> SplittedLibs;
      boost::algorithm::split(SplittedLibs, FileList, boost::algorithm::is_any_of(";"));
      for (unsigned int i = 0; i < SplittedLibs.size(); i++)
      {
         if (SplittedLibs.size() == 0) continue;
         boost::trim(SplittedLibs[i]);

         std::vector<std::string> SplittedName;
         boost::algorithm::split(SplittedName, SplittedLibs[i], boost::algorithm::is_any_of(":"));

         if (SplittedName.size() != 2) THROW_ERROR("Malformed db description: \"" + SplittedLibs[i] + "\"");
         std::string LibraryName = SplittedName[0];
         std::string dbFileName = SplittedName[1];

         if (!TM->is_library_manager(LibraryName))
            THROW_ERROR("Library \"" + LibraryName + "\" is not contained into the datastructure");
         const library_managerRef LM = TM->get_library_manager(LibraryName);
         LM->set_info(library_manager::DB, dbFileName);

         PRINT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "(koala) Stored DB file \"" + dbFileName + "\" for library \""
                       + LibraryName + "\";\n");
      }
   }
#endif
}
Ejemplo n.º 15
0
int main(int argc, char* argv[])
{
	char *image_file = "rose512.jpg" ;
	ASImage *im ;
	ASVisual *asv ;
	int screen = 0, depth = 24;
	Display *dpy = NULL;

	/* see ASView.1 : */
	set_application_name( argv[0] );
#if (HAVE_AFTERBASE_FLAG==1)
	set_output_threshold(OUTPUT_LEVEL_DEBUG);
#ifdef DEBUG_ALLOCS
	fprintf( stderr, "have DEBUG_ALLOCS\n");
#endif
#ifdef AFTERBASE_DEBUG_ALLOCS
	fprintf( stderr, "have AFTERBASE_DEBUG_ALLOCS\n");
#endif
#endif

	if( argc > 1 )
	{
		if( strcmp( argv[1], "-h" ) == 0 )
		{
			usage();
			return 0;
		}
		image_file = argv[1] ;
	}else
	{
		show_warning( 	"Image filename was not specified. "
						"Using default: \"%s\"", image_file );
		usage();
	}
#ifndef X_DISPLAY_MISSING
	dpy = XOpenDisplay(NULL);
	XSynchronize (dpy, True);
	_XA_WM_DELETE_WINDOW = XInternAtom( dpy, "WM_DELETE_WINDOW", 
										False);
	screen = DefaultScreen(dpy);
	depth = DefaultDepth( dpy, screen );
#endif	
	/* see ASView.3 : */
	asv = create_asvisual( dpy, screen, depth, NULL );
	/* asv = create_asvisual_for_id( dpy, screen, depth, 0x28, None, NULL ); */

	/* see ASView.2 : */
	im = file2ASImage( image_file, 0xFFFFFFFF, SCREEN_GAMMA, 0, getenv("IMAGE_PATH"), NULL );

	/* The following could be used to dump JPEG version of the image into
	 * stdout : */
	/* 	ASImage2file( im, NULL, NULL, ASIT_Jpeg, NULL ); 
		ASImage2file( im, NULL, "asview.png", ASIT_Png, NULL );
		ASImage2file( im, NULL, "asview.gif", ASIT_Gif, NULL );
	*/

	if( im != NULL )
	{
#ifndef X_DISPLAY_MISSING
		Window w ;
#if 0
		/* test example for get_asimage_channel_rects() : */
		XRectangle *rects ;	unsigned int rects_count =0; int i ;
		rects = get_asimage_channel_rects( im, IC_ALPHA, 10, 
											&rects_count );
		fprintf( stderr, " %d rectangles generated : \n", rects_count );
		for( i = 0 ; i < rects_count ; ++i )
			fprintf( stderr, "\trect[%d]=%dx%d%+d%+d;\n", 
					 i, rects[i].width, rects[i].height, 
					 rects[i].x, rects[i].y );
#endif


#if 0		 
		/* test example for fill_asimage : */
		fill_asimage(asv, im, 0, 0, 50, 50, 0xFFFF0000);
		fill_asimage(asv, im, 50, 50, 100, 50, 0xFFFF0000);
		fill_asimage(asv, im, 0, 100, 200, 50, 0xFFFF0000);
		fill_asimage(asv, im, 150, 0, 50, 50, 0xFFFF0000);
#endif
#if 0
		/* test example for conversion to argb32 :*/
		{
			ASImage *tmp = tile_asimage( asv, im, 0, 0, im->width, im->height, TINT_NONE, ASA_ARGB32, 
										  0, ASIMAGE_QUALITY_DEFAULT );	 
			destroy_asimage( &im );
			set_flags( tmp->flags, ASIM_DATA_NOT_USEFUL|ASIM_XIMAGE_NOT_USEFUL );
			im = tmp ;
		}		   
#endif		   
		/* see ASView.4 : */
		w = create_top_level_window( asv, DefaultRootWindow(dpy), 32, 32,
			                         im->width, im->height, 1, 0, NULL,
									 "ASView", image_file );
		if( w != None )
		{
			Pixmap p ;
	  		
			XMapRaised   (dpy, w);
			XSync(dpy,False);
			/* see ASView.5 : */
	  		p = create_visual_pixmap( asv, DefaultRootWindow(dpy), im->width, im->height, 0 );
	
			{
				START_TIME(started);
				/* for( int i = 0 ; i < 100 ; ++i )  To test performance! */
				asimage2drawable( asv, p, im, NULL, 0, 0, 0, 0, im->width, im->height, False);
				SHOW_TIME("", started);
			}
			/* print_storage(NULL); */
			destroy_asimage( &im );
			/* see common.c:set_window_background_and_free(): */
			p = set_window_background_and_free( w, p );
		}
		/* see common.c: wait_closedown() : */
		wait_closedown(w);
		dpy = NULL;
		
		/* no longer need this - lets clean it up :*/
		destroy_asvisual( asv, False );
		asv = NULL ;

#else
		/* writing result into the file */
		ASImage2file( im, NULL, "asview.png", ASIT_Png, NULL );
#endif
	}

#ifdef DEBUG_ALLOCS
    /* different cleanups of static memory pools : */
    flush_ashash_memory_pool();
	asxml_var_cleanup();
	custom_color_cleanup();
    build_xpm_colormap( NULL );
	flush_default_asstorage();
	/* requires libAfterBase */
	print_unfreed_mem();
#endif

    return 0 ;
}
Ejemplo n.º 16
0
bool FieldStatic::recieveFirstPass(size_t fromRow, bool first) {
    // (crf + b + c + f) x [calculatingRows]
    if (leftN != NOBODY) {
        START_TIME(rStart);

        MPI_Status status;
        MPI_Probe(leftN, (int)fromRow, firstPassComm, &status);
        int sSize;
        MPI_Get_count(&status, MPI_DOUBLE, &sSize);

        MPI_Request request;
        MPI_Irecv(receiveBuff, sSize, MPI_DOUBLE, leftN, (int)fromRow, firstPassComm, &request);
        if (sSize == 0) {
            MPI_Cancel(&request);
            sendDoneAsFirstPass();
            return false;
        } else {
            MPI_Wait(&request, MPI_STATUS_IGNORE);
        }

        END_TIME(syncNetworkTime, rStart);

        size_t idxBuffer = 0;
        double bsFlag = receiveBuff[idxBuffer++];
        bool receiveWeights = bsFlag < 0;
        bundleSizeLimit = (receiveWeights ? -1 : 1) * bsFlag;

        if (receiveWeights) {
            for (size_t i = 0; i < mySX; ++i) {
                weights[i] = receiveBuff[idxBuffer++];
            }
            shouldSendWeights = true;
        }

        size_t lastRow = fromRow;
        for (; idxBuffer < sSize;) {
            size_t row = receiveBuff[idxBuffer++];

            while (lastRow < row) {
                calculatingRows[lastRow++] = false;
            }
            calculatingRows[lastRow++] = true;

            size_t index = row * width;
            mbF[index] = receiveBuff[idxBuffer++];
            mcF[index] = receiveBuff[idxBuffer++];
            mfF[index] = receiveBuff[idxBuffer++];
        }

        if ((sSize - 1) / 4 < bundleSizeLimit) {
            while (lastRow < height) {
                calculatingRows[lastRow++] = false;
            }
        }

        END_TIME(syncNetworkWithPrepTime, rStart);

        if (receiveWeights && shouldSendWeights && rightN == NOBODY) {
            partitionAndCheck();
        }
    }

    return true;
}
Ejemplo n.º 17
0
void FieldStatic::balance() {
    /*debug() << "=============\nBalancing " << t << "\n";debug(0).flush();

    debug() << "NB ";
    for (size_t i = 0; i < numProcs; ++i) {
        debug(0) << nowBuckets[i] << " ";
    }
    (debug(0) << "\n").flush();

    debug() << "BB ";
    for (size_t i = 0; i < numProcs; ++i) {
        debug(0) << nextBuckets[i] << " ";
    }
    (debug(0) << "\n").flush();*/

    //debug() << "! " << height << " " << width << " " << mySY << "\n"; debug(0).flush();

    START_TIME(balanceStart);

    size_t sy = 0, nextSY = 0;
    size_t topShift = (topN == NOBODY ? 0 : 1);
    size_t bottomShift = (bottomN == NOBODY ? 0 : 1);
    size_t subheight = height - topShift - bottomShift;
    size_t myBucketStart = mySY;
    size_t myBucketEnd = mySY + subheight;
    size_t selfSendFrom = 0;
    //debug() << "> " << subheight << "  " << myBucketStart << " " << myBucketEnd << "\n"; debug(0).flush();
    size_t reqIdx = 0;

    // SEND
    for (size_t i = 0; i < numProcs; ++i) {
        if (i == myCoord) {
            nextSY = sy;
        }

        size_t bucketStart = sy - (i == 0 ? 0 : 1);
        size_t bucketEnd = sy + nextBuckets[i] + (i == numProcs - 1 ? 0 : 1);
        size_t fromRow = 0, toRow = 0;

        //debug() << "        " << i << " " << bucketStart << " " << bucketEnd << " vs " << myBucketStart << " " << myBucketEnd << "\n"; debug(0).flush();

        if (bucketStart <= myBucketStart && myBucketEnd <= bucketEnd) {
            fromRow = topShift;
            toRow = subheight + topShift;
            //debug() << "SF " << i << "   " << fromRow << " " << toRow << " " << toRow - fromRow << "\n"; debug(0).flush();
        }
        else if (myBucketStart <= bucketStart && bucketStart < myBucketEnd) {
            fromRow = (bucketStart - myBucketStart) + topShift;
            toRow = std::min(bucketEnd - myBucketStart, subheight) + topShift;
            //debug() << "SU " << i << "   " << fromRow << " " << toRow << " " << toRow - fromRow << "\n"; debug(0).flush();
        }
        else if (myBucketStart < bucketEnd && bucketEnd <= myBucketEnd) {
            fromRow = topShift;
            toRow = (bucketEnd - myBucketStart) + topShift;
            //debug() << "SB " << i << "   " << fromRow << " " << toRow << " " << toRow - fromRow << "\n"; debug(0).flush();
        }

        if (fromRow != toRow) {
            if (i == myCoord) {
                selfSendFrom = fromRow;
            } else {
                MPI_Isend(prev + fromRow * width, (int)((toRow - fromRow) * width),
                          MPI_DOUBLE, (int)i, 0, balanceComm, balanceRequests + reqIdx++);
            }
        }

        sy += nextBuckets[i];
    }

    mySY = nextSY;
    subheight = nextBuckets[myCoord];
    myBucketStart = mySY - topShift;
    myBucketEnd = mySY + subheight + bottomShift;
    subheight += topShift + bottomShift;
    height = subheight;
    //debug() << "< " << subheight << "  " << myBucketStart << " " << myBucketEnd << "\n"; debug(0).flush();

    sy = 0;
    for (size_t i = 0; i < numProcs; ++i) {
        size_t bucketStart = sy;
        size_t bucketEnd = sy + nowBuckets[i];
        size_t fromRow = 0, toRow = 0;

        if (bucketStart <= myBucketStart && myBucketEnd <= bucketEnd) {
            fromRow = 0;
            toRow = subheight;
            //debug() << "RF " << i << "   " << fromRow << " " << toRow << " " << toRow - fromRow << "\n"; debug(0).flush();
        }
        else if (myBucketStart <= bucketStart && bucketStart < myBucketEnd) {
            fromRow = (bucketStart - myBucketStart);
            toRow = std::min(bucketEnd - myBucketStart, subheight);
            //debug() << "RU " << i << "   " << fromRow << " " << toRow << " " << toRow - fromRow << "\n"; debug(0).flush();
        }
        else if (myBucketStart < bucketEnd && bucketEnd <= myBucketEnd) {
            fromRow = 0;
            toRow = (bucketEnd - myBucketStart);
            //debug() << "RB " << i << "   " << fromRow << " " << toRow << " " << toRow - fromRow << "\n"; debug(0).flush();
        }

        if (fromRow != toRow) {
            if (i == myCoord) {
                memcpy(buff + fromRow * width, prev + selfSendFrom * width, (toRow - fromRow) * width * sizeof(double));
            } else {
                MPI_Irecv(buff + fromRow * width, (int)((toRow - fromRow) * width),
                          MPI_DOUBLE, (int)i, 0, balanceComm, balanceRequests + reqIdx++);
            }
        }

        sy += nowBuckets[i];
    }

    MPI_Waitall((int)reqIdx, balanceRequests, MPI_STATUSES_IGNORE);
    std::swap(buff, prev);
    std::swap(nowBuckets, nextBuckets);

    END_TIME(balancingTime, balanceStart);

    //debug() << "! " << height << " " << width << " " << mySY << "\n"; debug(0).flush();
}
Ejemplo n.º 18
0
DesignFlowStep_Status weighted_clique_register::InternalExec()
{
   const FunctionBehaviorConstRef FB = HLSMgr->CGetFunctionBehavior(funId);
   long step_time;
   START_TIME(step_time);
   const CliqueCovering_Algorithm clique_covering_algorithm = GetPointer<const WeightedCliqueRegisterBindingSpecialization>(hls_flow_step_specialization)->clique_covering_algorithm;
   refcount< clique_covering<CG_vertex_descriptor> > register_clique = clique_covering<CG_vertex_descriptor>::create_solver(clique_covering_algorithm);
   create_compatibility_graph();

   std::vector<CG_vertex_descriptor>::const_iterator v_it_end = verts.end();
   unsigned int vertex_index = 0;
   unsigned int num_registers = 0;
   for(std::vector<CG_vertex_descriptor>::const_iterator v_it = verts.begin(); v_it != v_it_end; ++v_it, ++vertex_index)
      register_clique->add_vertex(*v_it, STR(vertex_index));
   if(vertex_index>0)
   {
      boost::graph_traits<compatibility_graph>::edge_iterator cg_ei,cg_ei_end;
      for(boost::tie(cg_ei,cg_ei_end) = boost::edges(CG); cg_ei != cg_ei_end; ++cg_ei)
      {
         CG_vertex_descriptor src = boost::source(*cg_ei, CG);
         CG_vertex_descriptor tgt = boost::target(*cg_ei, CG);
         register_clique->add_edge(src, tgt, CG[*cg_ei].weight);
      }
      if(parameters->getOption<bool>(OPT_print_dot))
      {
         const auto functionName = FB->CGetBehavioralHelper()->get_function_name();
         const auto output_directory = parameters->getOption<std::string>(OPT_dot_directory) + "/" + functionName + "/";
         if (!boost::filesystem::exists(output_directory))
            boost::filesystem::create_directories(output_directory);
         const auto file_name = output_directory + "HLS_RegisterBinding.dot";
         register_clique->writeDot(file_name);
      }
      /// performing clique covering
      no_check_clique<CG_vertex_descriptor> cq;
      register_clique->exec(no_filter_clique<CG_vertex_descriptor>(), cq);
      /// vertex to clique map
      std::map<CG_vertex_descriptor, unsigned int> v2c;
      /// retrieve the solution
      num_registers = static_cast<unsigned int>(register_clique->num_vertices());
      for (unsigned int i = 0; i < num_registers; ++i)
      {
         std::set<CG_vertex_descriptor> clique = register_clique->get_clique(i);
         std::set<CG_vertex_descriptor>::const_iterator v_end = clique.end();
         for (std::set<CG_vertex_descriptor>::const_iterator v = clique.begin(); v != v_end; ++v)
         {
            v2c[*v] = i;
         }
      }
      /// finalize
      HLS->Rreg = reg_bindingRef(new reg_binding(HLS, HLSMgr));
      const std::list<vertex> & support = HLS->Rliv->get_support();

      const std::list<vertex>::const_iterator vEnd = support.end();
      for(std::list<vertex>::const_iterator vIt = support.begin(); vIt != vEnd; vIt++)
      {
         const std::set<unsigned int>& live = HLS->Rliv->get_live_in(*vIt);
         std::set<unsigned int>::iterator k_end = live.end();
         for(std::set<unsigned int>::iterator k = live.begin(); k != k_end; k++)
         {
            unsigned int storage_value_index = HLS->storage_value_information->get_storage_value_index(*vIt, *k);
            HLS->Rreg->bind(storage_value_index, v2c[verts[storage_value_index]]);
         }
      }
   }
   else
   {
      HLS->Rreg = reg_bindingRef(new reg_binding(HLS, HLSMgr));
      num_registers = 0;
   }
   HLS->Rreg->set_used_regs(num_registers);
   STOP_TIME(step_time);
   if(output_level <= OUTPUT_LEVEL_PEDANTIC)
      INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "");
   INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "-->Register binding information for function " + FB->CGetBehavioralHelper()->get_function_name() + ":");
   INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, std::string("---Register allocation algorithm obtains ") + (num_registers == register_lower_bound ? "an optimal" : "a sub-optimal") + " result: " + STR(num_registers) + " registers"+(num_registers == register_lower_bound?"":("(LB:"+STR(register_lower_bound)+")")));
   if (output_level >= OUTPUT_LEVEL_VERY_PEDANTIC)
      HLS->Rreg->print();
   if(output_level >= OUTPUT_LEVEL_MINIMUM and output_level <= OUTPUT_LEVEL_PEDANTIC)
      INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "Time to perform register binding: " + print_cpu_time(step_time) + " seconds");
   INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "<--");
   if(output_level <= OUTPUT_LEVEL_PEDANTIC)
      INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, output_level, "");
   return DesignFlowStep_Status::SUCCESS;
}
Ejemplo n.º 19
0
int main(int argc, char* argv[]) {
// 	if (argc != 7) {
// 		fprintf(stderr, "Usage: %s <N> <N> <block size> <block size> <index> <B|PW|SEQ>\n", argv[0]);
// 		return 1;
// 	}
	parseInitializationType("SEQ");
	long N = 100;
	long BS = 20;
	// long L = atol(argv[4]);
	long L = 16;
	
	if (BS > N) {
		printf("0");
		return 1;
	}
	
	typedef double (*m_t)[N/BS + 2][BS][BS];
	
	m_t A = (m_t) alloc_and_gen_matrix(N + BS*2, BS);
	
	
	for (int i=0; i<N/BS; ++i) {
	  for (int j=0; j<N/BS; ++j) {
	    for (int k=0; k<BS; ++k) {
	      for (int l=0; l<BS; ++l) {
		//printf (" %f", A[i][j][k][l]);
	      }
	    }
// 	    printf ("\n");
	  }
	}
// 	printf ("\n");
	
	
	#pragma omp taskwait
	
	Extrae_init();
	printf("extrae init\n");
	START_TIME();
	for (int iters=0; iters<L; iters++) {
		for (long i=1; i <= N/BS; i++) {
			for (long j=1; j <= N/BS; j++) {
				wrapperxxxxxxx(i, j, (N+BS+BS), BS, A[i][j], A[i-1][j], A[i][j-1], A[i+1][j], A[i][j+1]);
			}
		}
	}
	printf("extrae fini\n");
	Extrae_fini();
  
	#pragma omp taskwait
	STOP_TIME();
	
	//#pragma omp critical 
	{
	for (int iters=0; iters<N; iters++) {
		for (int i=0; i <= N; i++) {
			//printf (" %f", *A[iters][i]);
		}
// 		printf ("\n");
	}
// 	printf ("\n");
	}
	
	if (getenv("MEASURE_TIME") == NULL) {
		// Megaelements per second
		printf("%f", ((double)(L*N*N))/GET_TIME());
	} else {
		printf("%f", GET_TIME() / 1000000.0);
	}
	
	return 0;
}
Ejemplo n.º 20
0
void
MergeWinListOptions ( ASModuleConfig *asm_to, ASModuleConfig *asm_from)
{
    int i ;
    START_TIME(option_time);

	WinListConfig *to = AS_WINLIST_CONFIG(asm_to);
	WinListConfig *from = AS_WINLIST_CONFIG(asm_from);
	if( to && from )
	{

    	/* Need to merge new config with what we have already :*/
    	/* now lets check the config sanity : */
    	/* mixing set and default flags : */
    	ASCF_MERGE_FLAGS(to,from);

		ASCF_MERGE_GEOMETRY_KEYWORD(WINLIST, to, from, Geometry);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, MinSize);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, MaxSize);

		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, MaxRows);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, MaxColumns);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, MaxColWidth);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, MinColWidth);

		ASCF_MERGE_STRING_KEYWORD(WINLIST, to, from, FocusedStyle);
		ASCF_MERGE_STRING_KEYWORD(WINLIST, to, from, UnfocusedStyle);
		ASCF_MERGE_STRING_KEYWORD(WINLIST, to, from, StickyStyle);
		ASCF_MERGE_STRING_KEYWORD(WINLIST, to, from, UrgentStyle);

		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, UseName);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, Align);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, FBevel);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, UBevel);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, SBevel);

		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, FCompositionMethod);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, UCompositionMethod);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, SCompositionMethod);

		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, HSpacing);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, VSpacing);

		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, IconAlign);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, IconLocation);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, IconSize);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, NoCollidesSpacing);
		ASCF_MERGE_SCALAR_KEYWORD(WINLIST, to, from, ShowHints);

    	for( i = 0 ; i < MAX_MOUSE_BUTTONS ; ++i )
        	if( from->Action[i] )
        	{
            	destroy_string_list( to->Action[i], 0 );
            	to->Action[i] = from->Action[i];
				from->Action[i] = NULL ;
        	}

#define MERGE_COLLIDES_ITEM(type) \
	 	do{ to->type##Collides = saferealloc( to->type##Collides, (from->type##Collides_nitems+to->type##Collides_nitems)*sizeof(char*)); \
		memcpy(&(to->type##Collides[to->type##Collides_nitems]), from->type##Collides, from->type##Collides_nitems*sizeof(char*) ) ; \
		to->type##Collides_nitems += from->type##Collides_nitems; \
		from->type##Collides_nitems = 0 ; free( from->type##Collides ); from->type##Collides = NULL ; }while(0)

		if( from->NoCollides_nitems > 0 )		MERGE_COLLIDES_ITEM(No);
		if( from->AllowCollides_nitems > 0 )		MERGE_COLLIDES_ITEM(Allow);
	}
    SHOW_TIME("to parsing",option_time);
}