Ejemplo n.º 1
0
static struct value *sys_getenv(struct info *info, struct value *n) {
    assert(n->tag == V_STRING);
    struct value *v = make_value(V_STRING, ref(info));
    v->string = dup_string(getenv(n->string->str));
    return v;
}
Ejemplo n.º 2
0
/* V_STRING -> V_FILTER */
static struct value *xform_excl(struct info *info, struct value *s) {
    assert(s->tag == V_STRING);
    struct value *v = make_value(V_FILTER, ref(info));
    v->filter = make_filter(ref(s->string), 0);
    return v;
}
Ejemplo n.º 3
0
int fill_all_vlan_dhcpr_table_test()
{
    indigo_error_t rv;
    of_list_bsn_tlv_t *key, *value;
    void              *entry_priv;
    dhc_relay_t       *dhc_relay;

    int k;
    int vlan_no;
    int vr_ip_no;

    uint32_t      virtualRouterIP = 1;
    of_mac_addr_t mac = { .addr = {0x55, 0x16, 0xc7, 0x01, 0x02, 0x03} };
    uint32_t      dhcpServerIP    = 2;
    uint16_t      cir_value[VLAN_MAX+1];
    of_octets_t   cir_id;

    int num_of_vlan = VLAN_MAX;
    int extra_vlan = 2; //Test error

    //NOTE: no need to do htonl or htons,
    //What ever value we send here, we get over there
    //No need to convert.

    //Initialize cir_value
    for (k = 0; k <= num_of_vlan; k++) {
        cir_value[k] = (k+1);
    }


    printf("TEST:1 fill all\n");
    /* Add 1st half having circuit */
    for (k = 0; k < num_of_vlan/2 ; k++) {

        cir_id.bytes = sizeof(cir_value[k]);
        cir_id.data  = (uint8_t*)&cir_value[k];

        key = make_key(k);
        value = make_value((virtualRouterIP+k),
                           mac,
                           (dhcpServerIP+k),
                           &cir_id);

        if((rv = ops->add(table_priv, key, value, &entry_priv)) != INDIGO_ERROR_NONE) {
            printf("Error out of range table %u, rv=%u", k, rv);
            exit(1);
        }
    }

    /* Add 2nd half non circuit */
    printf("Range k=%u - %u\n", num_of_vlan/2, num_of_vlan);
    for (k = num_of_vlan/2; k<= num_of_vlan+extra_vlan ; k++) {
        key = make_key(k);
        value = make_value((virtualRouterIP+k),
                           mac,
                           (dhcpServerIP+k),
                           NULL);

        if((rv = ops->add(table_priv, key, value, &entry_priv)) != INDIGO_ERROR_NONE) {
            printf("Test Add table incorret Vlan range %u, rv=%u\n", k, rv);
        }
    }

    vlan_no = dhcpr_table_get_vlan_entry_count();
    vr_ip_no = dhcpr_table_get_virtual_router_ip_entry_count();
    AIM_TRUE_OR_DIE(vlan_no  == num_of_vlan+1, "vlan=%u", vlan_no);
    AIM_TRUE_OR_DIE(vr_ip_no == num_of_vlan+1, "vr_ip_no=%u", vr_ip_no);

    printf("TEST:2 modify all\n");
    /* Modify 1/4:
     * --Same virtual Router
     * --No circuit
     * */
    for (k = 0; k < num_of_vlan/4 ; k++) {
        dhc_relay = dhcpr_get_dhcpr_entry_from_vlan_table(k);
        AIM_TRUE_OR_DIE(dhc_relay);
        key = make_key(k);
        value = make_value((virtualRouterIP+k),
                           mac,
                           (dhcpServerIP+k),
                           NULL);

        if((rv = ops->modify(table_priv, dhc_relay, key, value)) != INDIGO_ERROR_NONE) {
            printf("Error Add table %u, rv=%u", k, rv);
            exit(1);
        }
    }
    /* Modify 1/4-2/4:
     * --Diff virtual Router
     * --No circuit
     * */
    for (k = num_of_vlan/4; k < num_of_vlan/2; k++) {
        dhc_relay = dhcpr_get_dhcpr_entry_from_vlan_table(k);
        AIM_TRUE_OR_DIE(dhc_relay);
        key = make_key(k);
        value = make_value((virtualRouterIP+k+num_of_vlan),
                           mac,
                           (dhcpServerIP+k),
                           NULL);

        if((rv = ops->modify(table_priv, dhc_relay, key, value)) != INDIGO_ERROR_NONE) {
            printf("Error Add table %u, rv=%u", k, rv);
            exit(1);
        }
    }

    /* Modify 2/4-3/4
     * -- Same virtual router
     * -- Add circuit
     * */
    for (k = num_of_vlan/2; k<= 3*num_of_vlan/4 ; k++) {
        dhc_relay = dhcpr_get_dhcpr_entry_from_vlan_table(k);
        AIM_TRUE_OR_DIE(dhc_relay);

        cir_id.bytes = sizeof(cir_value[k]);
        cir_id.data  = (uint8_t*)&cir_value[k];
        key = make_key(k);
        value = make_value((virtualRouterIP+k),
                           mac,
                           (dhcpServerIP+k),
                           &cir_id);

        if((rv = ops->modify(table_priv, dhc_relay, key, value)) != INDIGO_ERROR_NONE) {
            printf("Error Add table %u, rv=%u", k, rv);
            exit(1);
        }
    }

    /* Modify 2/4-3/4
     * -- Diff virtual router
     * -- Add circuit
     * */
    for (k = 3*num_of_vlan/4; k<= num_of_vlan ; k++) {
        dhc_relay = dhcpr_get_dhcpr_entry_from_vlan_table(k);
        AIM_TRUE_OR_DIE(dhc_relay);
        cir_id.bytes = sizeof(cir_value[k]);
        cir_id.data  = (uint8_t*)&cir_value[k];
        key = make_key(k);
        value = make_value((virtualRouterIP+k+num_of_vlan),
                           mac,
                           (dhcpServerIP+k),
                           &cir_id);

        if((rv = ops->modify(table_priv, dhc_relay, key, value)) != INDIGO_ERROR_NONE) {
            printf("Error Add table %u, rv=%u", k, rv);
            exit(1);
        }
    }

    vlan_no = dhcpr_table_get_vlan_entry_count();
    vr_ip_no = dhcpr_table_get_virtual_router_ip_entry_count();
    AIM_TRUE_OR_DIE(vlan_no  == num_of_vlan+1, "vlan=%u", vlan_no);
    AIM_TRUE_OR_DIE(vr_ip_no == num_of_vlan+1, "vr_ip_no=%u", vr_ip_no);

    printf("TEST:3 delete all\n");
    for (k = 0; k<= num_of_vlan; k++) {
        dhc_relay = dhcpr_get_dhcpr_entry_from_vlan_table(k);
        AIM_TRUE_OR_DIE(dhc_relay);
        key = make_key(k);
        ops->del(table_priv, dhc_relay, key);
    }
    /* Delete all */
    vlan_no = dhcpr_table_get_vlan_entry_count();
    vr_ip_no = dhcpr_table_get_virtual_router_ip_entry_count();
    AIM_TRUE_OR_DIE(vlan_no == 0);
    AIM_TRUE_OR_DIE(vr_ip_no == 0);

    return 1;
}
Ejemplo n.º 4
0
// ### make-simple-bit-vector size => simple-bit-vector
Value SYS_make_simple_bit_vector(Value arg)
{
    return make_value(new_simple_bit_vector(check_index(arg, 0, ARRAY_DIMENSION_LIMIT - 1)));
}
Ejemplo n.º 5
0
void GlobalData::read_parameters (int ac, char* av[]) {

  std::string input_file;
  std::string output_file;
  // Variables that will store parsed values for quarks.
  std::vector<std::string> quark_configs;
  // Variables that will store parsed values for operators.
  std::vector<std::string> operator_list_configs;
  // Variables that will store parsed values for correlators.
  std::vector<std::string> correlator_list_configs;

  // Declare a group of options that will be allowed only on command line
  po::options_description generic("Command line options");
  generic.add_options()("help,h", "produce help message")("version,v",
      "print version string")("verbose",
      "does additional tests and prints more details")("input,i",
      po::value<std::string>(&input_file)->default_value("LapHs.in"),
      "name of input file.")("output,o",
      po::value<std::string>(&output_file)->default_value("LapHs.out"),
      "name of output file.");

  // Declare a group of options that will be
  // allowed both on command line and in input file
  po::options_description config("Input file options");
  // parallelisation options
  config.add_options()
    ("nb_omp_threads",  
      po::value<size_t>(&nb_omp_threads)->default_value(1),
      "nb_omp_threads: number of openMP threads")
    ("nb_eigen_threads",
      po::value<size_t>(&nb_eigen_threads)->default_value(1),
      "nb_eigen_threads: number of threads Eigen uses internally");
  // lattice options
  config.add_options()
    ("output_path",
      po::value<std::string>(&path_output)-> 
                                          default_value("../../contractions"),
      "path for output")
    ("overwrite_old",
      po::value<std::string>(&overwrite)->default_value("no"), 
      "shall old correlator files be overwritten, yes or no")
    ("config_path",
      po::value<std::string>(&path_config)->default_value("../../configs"),
      "path for configurations")
    ("lattice", 
      po::value<std::string>(&name_lattice)-> default_value("lattice"),
      "Codename of the lattice")
    ("Lt", 
      po::value<int>(&Lt)->default_value(0),
      "Lt: temporal lattice extend")
    ("Lx",
      po::value<int>(&Lx)->default_value(0),
      "Lx: lattice extend in x direction")
    ("Ly",
      po::value<int>(&Ly)->default_value(0),
      "Ly: lattice extend in y direction")
    ("Lz",
      po::value<int>(&Lz)->default_value(0),
      "Lz: lattice extend in z direction");
  // eigenvector options
  config.add_options()
    ("number_of_eigen_vec",
      po::value<int>(&number_of_eigen_vec)->default_value(0),
      "Number of eigen vectors")
    ("path_eigenvectors",
      po::value<std::string>(&path_eigenvectors)->default_value("."),
      "directory of eigenvectors")
    ("name_eigenvectors",
      po::value<std::string>(&name_eigenvectors)->
                                                 default_value("eigenvector"),
      "name of eigenvectors\nThe full name is internally created to:\n"
      "\"name_of_eigenvectors.eigenvector\n. time slice.configuration\"");
  // quark options
  config.add_options()
    ("quarks.quark", make_value(&quark_configs),
     "quark input, must be of type:\n"
     "quark = \n type:number of rnd. vec.:\n"
     " dil type time:number of dil time:\n"
     " dil type ev:number of dil ev:\n"
     " dil type Dirac:number of dil Dirac:\n"
     " path of the perambulators for these quarks");
  // operator list options
  config.add_options()
    ("operator_lists.operator_list", make_value(&operator_list_configs),
     "operator input is rather complicated - see documentation!!");
  // correlator list options
  config.add_options()
    ("correlator_lists.correlator_list", make_value(&correlator_list_configs),
     "correlator input is rather complicated - see documentation!!");
  // configuration options
  config.add_options()
    ("start_config",
      po::value<int>(&start_config)->default_value(-1), 
      "First configuration")
    ("end_config", 
      po::value<int>(&end_config)->default_value(0),
      "Last configuration")
    ("delta_config",
      po::value<int>(&delta_config)->default_value(0),
      "Stepsize between two configurations");

  po::options_description cmdline_options;
  cmdline_options.add(generic).add(config);

  po::options_description input_file_options;
  input_file_options.add(config);

  po::options_description visible("Allowed options");
  visible.add(generic).add(config);
  po::positional_options_description p;
  p.add("input-file", -1);

  po::variables_map vm;
  po::store(po::command_line_parser(ac, av).options(cmdline_options).
                                            positional(p).run(), vm);
  po::notify(vm);

  // *************************************************************************
  // command line options ****************************************************
  if(vm.count("help")){
    std::cout << visible << "\n";
    exit(0);
  }
  if(vm.count("verbose")){
    verbose = 1;
  }
  else verbose = 0;
  if(vm.count("version")){
    std::cout << "Contraction code for LapHs perambulators. Version 0.1. \n";
    exit(0);
  }
  std::ifstream ifs(input_file.c_str());
  if(!ifs){
    std::cout << "CANNOT open input file: " << input_file << "\n";
    exit(0);
  }
  else{
    po::store(parse_config_file(ifs, input_file_options), vm);
    po::notify(vm);
  }
  ifs.close();

  // reading input file options
  input_handling(quark_configs, operator_list_configs, 
                 correlator_list_configs);

  // setting the lookup tables for all needed quantum numbers to calculate
  // the wanted correlators
  init_lookup_tables();

  // TODO: should be put in a separate function
  // setting the sizes and numbers of random vectors and perambulators
  rnd_vec_construct.nb_entities = 0;
  for(const auto& q: quarks)
    rnd_vec_construct.nb_entities += q.number_of_rnd_vec;
  rnd_vec_construct.length = Lt * 4 * number_of_eigen_vec;
  peram_construct.nb_entities = rnd_vec_construct.nb_entities;
  for(const auto& q: quarks){
    for(size_t r = 0; r < q.number_of_rnd_vec; r++){
      peram_construct.size_rows.push_back(rnd_vec_construct.length);
      peram_construct.size_cols.push_back((Lt / q.number_of_dilution_T) * 
                                           q.number_of_dilution_E * 
                                           q.number_of_dilution_D);
    }
  }
}
Ejemplo n.º 6
0
Layout * StandardObject::update_layout()
{
  assert(_layout->is_invalid());
  Layout * old_layout = _layout;
  LispClass * lisp_class = old_layout->lisp_class();
  Layout * new_layout = lisp_class->class_layout();
  assert(!new_layout->is_invalid());
  StandardObject * new_instance =
    new StandardObject(widetag(), new_layout, new_layout->numslots());
  assert(new_instance->_layout == new_layout);

  Value added = NIL;
  Value discarded = NIL;
  Value plist = NIL;
  // Old local slots.
  Value * old_slot_names = old_layout->slot_names();
  unsigned long old_numslots = old_layout->numslots();
  for (unsigned long i = 0; i < old_numslots; i++)
    {
      Value slot_name = old_slot_names[i];
      long j = new_layout->slot_index(slot_name);
      if (j >= 0)
        new_instance->_slots[j] = _slots[i];
      else
        {
          discarded = make_cons(slot_name, discarded);
          if (_slots[i] != UNBOUND_VALUE)
            {
              plist = make_cons(slot_name, plist);
              plist = make_cons(_slots[i], plist);
            }
        }
    }
  // Old shared slots.
  Value rest = old_layout->shared_slots(); // A list.
  while (rest != NIL)
    {
      Value location = car(rest);
      Value slot_name = car(location);
      int i = new_layout->slot_index(slot_name);
      if (i >= 0)
        new_instance->_slots[i] = xcdr(location);
      rest = xcdr(rest);
    }
  // Go through all the new local slots to compute the added slots.
  Value * new_slot_names = new_layout->slot_names();
  INDEX new_numslots = new_layout->numslots();
  for (INDEX i = 0; i < new_numslots; i++)
    {
      Value slot_name = new_slot_names[i];
      int j = old_layout->slot_index(slot_name);
      if (j >= 0)
        continue;
      Value location = old_layout->shared_slot_location(slot_name);
      if (location != NIL)
        continue;
      // Not found.
      added = make_cons(slot_name, added);
    }
  // Swap slots.
  Value * temp_slots = _slots;
  _slots = new_instance->_slots;
  new_instance->_slots = temp_slots;
  INDEX temp_numslots = _numslots;
  _numslots = new_instance->_numslots;
  new_instance->_numslots = temp_numslots;
  // Swap layouts.
  Layout * temp_layout = _layout;
  _layout = new_instance->_layout;
  new_instance->_layout = temp_layout;
  assert(!_layout->is_invalid());
  // Call UPDATE-INSTANCE-FOR-REDEFINED-CLASS.
  TypedObject * function = the_symbol(S_update_instance_for_redefined_class)->function();
  if (function)
    current_thread()->execute(function, make_value(this), added, discarded, plist);
  else
    signal_undefined_function(S_update_instance_for_redefined_class);
  return new_layout;
}