Exemple #1
0
int main(int argc, char* argv[])
{
  argc -= handleOpts(argc, argv);
  if (argc < 2){
    fprintf(stderr, usage, argv[0]);
    exit(1);
  }
  optClientno = atoi(argv[optind+1]);

  ConfigParser cp(argv[optind]);
  cp.Parse();
  bool load_complete = false;
  for (auto& section : cp._section_names){
    if (section.find("Workload") != std::string::npos){
      std::string workload = section;

      Config cfg(&cp, workload);
      // SYSTEM-SPECIFIC
      std::string system_conf = cfg.get<std::string>("yesql", "");

      std::string dir = cfg.get<std::string>("logdir", ".");
      LOG("Got %s as logdir", dir.c_str());
      if (dir.back() != '/')
        dir.append("/");
      dir.append("client-");
      dir.append(std::to_string(optClientno));
      dir.append("-");
      dir.append(workload);
      dir.append(".txt");
      LOG("Setting log as %s\n", dir.c_str());
      SetLog(dir.c_str());
      LOG("About to initialize\n");
      if (!load_complete){
        sqlite3_initialize();
// FIXME        SetDebugLevel(0);
      } else {
// FIXME        SetDebugLevel(0);
      }
      int nthreads = cfg.get<int>("threads", 1);
      bool do_load = false;
      if (!load_complete)
        do_load = cfg.get<bool>("load", true);
      LOG("About to do a yesql experiment with %d threads\n", nthreads);
      do_experiment(nthreads, system_conf.c_str(), &cfg, do_load);
      load_complete = true;
    }
  }
  return 0;
}
int main(int argc, char* argv[])
{
  argc -= handleOpts(argc, argv);
  if (argc < 2){
    fprintf(stderr, "Usage: %s [config.ini]\n", argv[0]);
    exit(1);
  }
  optClientno = atoi(argv[optind+1]);

  ConfigParser cp(argv[optind]);
  cp.Parse();

  for (auto& section : cp._sections){
    if (section.first.find("Workload") != std::string::npos){
      std::string workload = section.first;

      Config cfg(&cp, workload);
      // SYSTEM-SPECIFIC
      std::string system_conf;
      if (!optServerPort) system_conf = cfg.get<std::string>("yesql", "");
      else system_conf = std::string(optServerPort);

      std::string dir = cfg.get<std::string>("logdir", ".");
      if (dir.back() != '/')
        dir.append("/");
      dir.append("client-");
      dir.append(std::to_string(optClientno));
      dir.append("-");
      dir.append(workload);
      dir.append(".txt");
      SetLog(dir.c_str());
      LOG("Starting a YESQL expt.\n");
      int nthreads = cfg.get<int>("threads", 1);
      do_experiment(nthreads, system_conf.c_str(), &cfg, false);
    }
  }
  return 0;
}
Exemple #3
0
void IntegratorRep::initialize(const State& initState) {
  try
  { invalidateIntegratorInternalState();

    // Copy the supplied initial state into the integrator.
    updAdvancedState() = initState;

    // Freeze the number and kinds of state variables.
    getSystem().realizeModel(updAdvancedState());

    // Freeze problem dimensions; at this point the state represents an
    // instance of a physically realizable system.
    getSystem().realize(getAdvancedState(), Stage::Instance);

    // Some Systems need to get control whenever time is advanced
    // successfully (and irreversibly) so that they can do discrete updates.
    systemHasTimeAdvancedEvents = getSystem().hasTimeAdvancedEvents();

    // Allocate integrator-local data structures now that we know the sizes.
    const int ny = getAdvancedState().getNY();
    const int nc = getAdvancedState().getNYErr();
    const int ne = getAdvancedState().getNEventTriggers();
    timeScaleInUse = getSystem().getDefaultTimeScale();

    // Set accuracy and consTol to their user-requested values or
    // to the appropriate defaults.
    setAccuracyAndTolerancesFromUserRequests();

    // Now we can ask the System for information about its event triggers.
    // (Event trigger info is Instance stage information.) Note that the event
    // localization windows here are expressed in terms of the system timescale
    // -- be sure to multiply by timescale before using.
    getSystem().calcEventTriggerInfo(getAdvancedState(), eventTriggerInfo);

    // Realize Time stage, apply prescribed motions, and attempt to project q's
    // and u's onto the
    // position and velocity constraint manifolds to drive constraint errors
    // below accuracy*unitTolerance for each constraint. We'll allow project()
    // to throw an exception if it fails since we can't recover from here.
    // However, we won't set the LocalOnly option which means project() is
    // allowed to thrash around wildly to attempt to find *some* solution.
    // Also force repeated updates of iteration matrix to maximize chances of
    // finding a solution; we're not in a hurry here.
    realizeAndProjectKinematicsWithThrow(updAdvancedState(),
        ProjectOptions::ForceProjection, ProjectOptions::ForceFullNewton);

    // Inform any state-using System elements (especially Measures) that we
    // are starting a simulation and give them a chance to initialize their own
    // continuous (z) variables and discrete variables.

    // Handler is allowed to throw an exception if it fails since we don't
    // have a way to recover.
    HandleEventsOptions handleOpts(getConstraintToleranceInUse());
    HandleEventsResults results;
    getSystem().handleEvents(updAdvancedState(),
                             Event::Cause::Initialization,
                             Array_<EventId>(),
                             handleOpts, results);
    SimTK_ERRCHK_ALWAYS(
        results.getExitStatus()!=HandleEventsResults::ShouldTerminate,
        "Integrator::initialize()",
        "An initialization event handler requested termination.");

    // Now evaluate the state through the Acceleration stage to calculate
    // the initial state derivatives.
    realizeStateDerivatives(getAdvancedState());

    // Now that we have valid update values for auto-update discrete variables,
    // use them to reinitialize the discrete state variables. This one time
    // only, the value swapped in from the discrete variable here is not yet
    // suitable for use as an update value, during time integration since it
    // has never been realized to Instance stage. So we'll force a
    // re-evaluation.
    updAdvancedState().autoUpdateDiscreteVariables();
    getAdvancedState().invalidateAllCacheAtOrAbove(Stage::Instance);
    // Re-realize to fill in the swapped-in update values.
    realizeStateDerivatives(getAdvancedState());

    // Record the continuous parts of this now-realized initial state as the
    // previous state as well (previous state is used when we have to back up
    // from a failed step attempt).
    saveStateAndDerivsAsPrevious(getAdvancedState());

    // The initial state is set so it looks like we just *completed* a step to
    // get here. That way if the first reportTime is zero, this will get
    // reported.
    setStepCommunicationStatus(CompletedInternalStepNoEvent);
    startOfContinuousInterval = true;

    // This will be set to something meaningful when the simulation ends.
    terminationReason = Integrator::InvalidTerminationReason;

    // Call this virtual method in case the concrete integrator class has
    // additional initialization needs. Note that it gets the State as we have
    // adjusted it, NOT the one originally passed to initialize().
    methodInitialize(getAdvancedState());

  } catch (const std::exception& e) {
    SimTK_THROW1(Integrator::InitializationFailed, e.what());
  } /* catch (...) {
    SimTK_THROW1(Integrator::InitializationFailed, "UNKNOWN EXCEPTION");
  } */
}