04-20-09-Num Cores

From Msim

Jump to: navigation, search

This refers to the fixes to main.c and options.c to handle num_cores in a config file and large config files


Options.c has a limit to the number of arguments it can handle. If there are too many it throws the error: option line too complex in file `%s'
This can be handled by increasing the size of MAX_LINE_ARGS, we have (arbitrarily) increased it to 65536.

#define MAX_LINE_ARGS 65536

In order to handle the command line options for multiple cores, the option "-num_cores" is processed before the option handler takes effect. This is because the number of cores determines what options are available (-rob:size would become -rob:size_0, -rob:size_1... -rob:size_N if multiple cores are present).

The additions (from main.c) are shown in bold:

//Here we pre-process the number of contexts and cores. This enables us to modify the options handler to
//take parameters for multiple cores - and ultimately, to place multiple contexts
contexts_at_init_time = 0;
cores_at_init_time = 1;
for(int i=0;i<argc;i++)
{
 std::string temp(argv[i]);
 v_argv->push_back(argv[i]);
 if(temp.find(".arg")!=std::string::npos)
 {
  contexts_at_init_time++;
  contexts.insert(contexts.end(),context());
 }
 if(temp.find("-num_cores")!=std::string::npos)
 {
  cores_at_init_time = atoi(argv[i+1]);
 }
 
 //If the num_cores option is in the config file, it won't be read in time
 //Here, we can read it early
 if(temp.find("-config")!=std::string::npos)
 {
  std::ifstream infile;
  infile.open(argv[i+1],std::ios::in);
  std::string temp;
  while(infile >> temp)
  {
   if(temp=="-num_cores")
   {
    infile >> cores_at_init_time;
    break;
   }
  }
  infile.close();
 }
}



Personal tools