int
main(int argc, char **argv)
{
    int i = 0;
    int ret = 0;

    /* Clean up if we're told to exit */
    signal(SIGINT, sigint_handler);

    // First init the RAPL library
    if (0 != init_rapl()) {
        fprintf(stdout, "Init failed!\n");
        terminate_rapl();
        return MY_ERROR;
    }
    num_node = get_num_rapl_nodes_pkg();

    ret = cmdline(argc, argv);
    if (ret) {
        terminate_rapl();
        return ret;
    }

    do_print_energy_info();

    terminate_rapl();
}
示例#2
0
int main(int argc, char **argv) {
	int i = 0;
	int ret = 0;

	// First init the RAPL library
	ret = init_rapl();
	if (ret) {
		fprintf(stdout, "Init failed (%d)!\n",ret);
		terminate_rapl();
		return ret;
	}
	num_node = get_num_rapl_nodes_pkg();

	ret = cmdline(argc, argv);
	if (ret) {
		terminate_rapl();
		return ret;
	}

	ret = do_set_power_limit();
	terminate_rapl();
	
	return ret;
}
示例#3
0
void stm_init(int threads) {

	int max_tx_per_tuning_cycle;

	max_concurrent_threads = threads;

	FILE* fid;
	if ((fid = fopen("mcats_conf.txt", "r")) == NULL) {
		printf("\nError opening MCATS configuration file.\n");
		exit(1);
	}

	if (fscanf(fid, "TX_PER_CYCLE=%d INITIAL_MAX_ADMITTED_TX=%d", &max_tx_per_tuning_cycle, &max_allowed_running_transactions)!=2) {
		printf("\nThe number of input parameters of the MCATS configuration file does not match the number of required parameters.\n");
		exit(1);
	}

	tx_per_tuning_cycle = max_tx_per_tuning_cycle / max_concurrent_threads;
	main_thread = current_collector_thread = 0;
	running_transactions = 0;

	if (init_rapl() != 0) {
		printf("\nRAPL could not be initialized\n");
		exit(1);
	}

  	/* Set on conflict callback */

#else

void stm_init()
{

#endif /* ! STM_MCATS */

#ifdef STM_SCA
	sca_saturating_threshold = 1;
	sca_serializing_lock = 0;
#endif /* ! STM_SCA */

#if CM == CM_MODULAR
  char *s;
#endif /* CM == CM_MODULAR */
#ifdef SIGNAL_HANDLER
  struct sigaction act;
#endif /* SIGNAL_HANDLER */

  PRINT_DEBUG("==> stm_init()\n");

  if (_tinystm.initialized)
    return;

  PRINT_DEBUG("\tsizeof(word)=%d\n", (int)sizeof(stm_word_t));

  PRINT_DEBUG("\tVERSION_MAX=0x%lx\n", (unsigned long)VERSION_MAX);

  COMPILE_TIME_ASSERT(sizeof(stm_word_t) == sizeof(void *));
  COMPILE_TIME_ASSERT(sizeof(stm_word_t) == sizeof(atomic_t));

#ifdef EPOCH_GC
  gc_init(stm_get_clock);
#endif /* EPOCH_GC */

#if CM == CM_MODULAR
  s = getenv(VR_THRESHOLD);
  if (s != NULL)
    _tinystm.vr_threshold = (int)strtol(s, NULL, 10);
  else
    _tinystm.vr_threshold = VR_THRESHOLD_DEFAULT;
  PRINT_DEBUG("\tVR_THRESHOLD=%d\n", _tinystm.vr_threshold);
#endif /* CM == CM_MODULAR */

  /* Set locks and clock but should be already to 0 */
  memset((void *)_tinystm.locks, 0, LOCK_ARRAY_SIZE * sizeof(stm_word_t));
#ifdef INVISIBLE_TRACKING
  memset((void* )_tinystm.last_id_tx_class,-1,LOCK_ARRAY_SIZE * sizeof(stm_word_t));
#endif
  CLOCK = 0;

  stm_quiesce_init();

  tls_init();

#ifdef SIGNAL_HANDLER
  if (getenv(NO_SIGNAL_HANDLER) == NULL) {
    /* Catch signals for non-faulting load */
    act.sa_handler = signal_catcher;
    act.sa_flags = 0;
    sigemptyset(&act.sa_mask);
    if (sigaction(SIGBUS, &act, NULL) < 0 || sigaction(SIGSEGV, &act, NULL) < 0) {
      perror("sigaction");
      exit(1);
    }
  }
#endif /* SIGNAL_HANDLER */
  _tinystm.initialized = 1;
}