Exemplo n.º 1
0
static
bool
checked_double_parse(const char* s,
                     double& val) {
    if ((NULL != s) && ('\0' != *s) && (0 != strcmp(s,"."))) return false;
    val=parse_double(s);
    return true;
}
Exemplo n.º 2
0
static void action_comm_size(const char *const *action)
{
  const char *size = action[2];
  double clock = MSG_get_clock();

  communicator_size = parse_double(size);
  log_action(action, MSG_get_clock() - clock);
}
Exemplo n.º 3
0
static struct source *source_ptp_parse(char *parameter, char **settings)
{
	char *name, *value;
	struct source *source;
	int r = 0;

	source = xmalloc(sizeof(*source));
	source->type = PTP_DOMAIN;
	source->ptp.delay = DEFAULT_PTP_DELAY;
	source->ptp.ntp_poll = DEFAULT_PTP_NTP_POLL;
	source->ptp.phc2sys_poll = DEFAULT_PTP_PHC2SYS_POLL;
	source->ptp.interfaces = (char **)parray_new();
	source->ptp.ptp4l_settings = (char **)parray_new();
	source->ptp.ntp_options = xstrdup("");

	if (parse_int(parameter, &source->ptp.domain)) {
		pr_err("invalid ptp_domain number %s", parameter);
		goto failed;
	}

	for (; *settings; settings++) {
		parse_setting(*settings, &name, &value);
		if (!strcasecmp(name, "delay")) {
			r = parse_double(value, &source->ptp.delay);
		} else if (!strcasecmp(name, "ntp_poll")) {
			r = parse_int(value, &source->ptp.ntp_poll);
		} else if (!strcasecmp(name, "phc2sys_poll")) {
			r = parse_int(value, &source->ptp.phc2sys_poll);
		} else if (!strcasecmp(name, "ptp4l_option")) {
			parray_append((void ***)&source->ptp.ptp4l_settings,
				      xstrdup(value));
		} else if (!strcasecmp(name, "ntp_options")) {
			replace_string(value, &source->ptp.ntp_options);
		} else if (!strcasecmp(name, "interfaces")) {
			parse_words(value, &source->ptp.interfaces);
		} else {
			pr_err("unknown ptp_domain setting %s", name);
			goto failed;
		}

		if (r) {
			pr_err("invalid value %s for %s", value, name);
			goto failed;
		}
	}

	if (!*source->ptp.interfaces) {
		pr_err("no interfaces specified for ptp_domain %d",
		       source->ptp.domain);
		goto failed;
	}

	return source;
failed:
	source_destroy(source);
	return NULL;
}
Exemplo n.º 4
0
void
perf_opt_parse(int argc, char **argv)
{
	int c;
	opt_t *opt;
	isc_result_t result;
	unsigned int i;

	progname = isc_file_basename(argv[0]);

	perf_opt_add('h', perf_opt_boolean, NULL, "print this help",
		     NULL, NULL);

	while ((c = getopt(argc, argv, optstr)) != -1) {
		for (i = 0; i < nopts; i++) {
			if (opts[i].c == c)
				break;
		}
		if (i == nopts) {
			perf_opt_usage();
			exit(1);
		}
		if (c == 'h') {
			perf_opt_usage();
			exit(0);
		}
		opt = &opts[i];
		result = ISC_R_SUCCESS;
		switch (opt->type) {
		case perf_opt_string:
			*opt->u.stringp = optarg;
			break;
		case perf_opt_boolean:
			*opt->u.boolp = ISC_TRUE;
			break;
		case perf_opt_uint:
			*opt->u.uintp = parse_uint(opt->desc, optarg,
						   1, 0xFFFFFFFF);
			break;
		case perf_opt_timeval:
			*opt->u.uint64p = parse_timeval(opt->desc, optarg);
			break;
		case perf_opt_double:
			*opt->u.doublep = parse_double(opt->desc, optarg);
			break;
		case perf_opt_port:
			*opt->u.portp = parse_uint(opt->desc, optarg,
						   0, 0xFFFF);
			break;
		}
	}
	if (optind != argc) {
		fprintf(stderr, "unexpected argument %s\n", argv[optind]);
		perf_opt_usage();
		exit(1);
	}
}
Exemplo n.º 5
0
/* parses a 4-touple of the form {x, y, z, w}
 * where x, y, z, w are numbers */
static boolean parse_immediate_data(struct translate_ctx *ctx, unsigned type,
                                    union tgsi_immediate_data *values)
{
   unsigned i;
   int ret;

   eat_opt_white( &ctx->cur );
   if (*ctx->cur != '{') {
      report_error( ctx, "Expected `{'" );
      return FALSE;
   }
   ctx->cur++;
   for (i = 0; i < 4; i++) {
      eat_opt_white( &ctx->cur );
      if (i > 0) {
         if (*ctx->cur != ',') {
            report_error( ctx, "Expected `,'" );
            return FALSE;
         }
         ctx->cur++;
         eat_opt_white( &ctx->cur );
      }

      switch (type) {
      case TGSI_IMM_FLOAT64:
         ret = parse_double(&ctx->cur, &values[i].Uint, &values[i+1].Uint);
         i++;
         break;
      case TGSI_IMM_FLOAT32:
         ret = parse_float(&ctx->cur, &values[i].Float);
         break;
      case TGSI_IMM_UINT32:
         ret = parse_uint(&ctx->cur, &values[i].Uint);
         break;
      case TGSI_IMM_INT32:
         ret = parse_int(&ctx->cur, &values[i].Int);
         break;
      default:
         assert(0);
         ret = FALSE;
         break;
      }

      if (!ret) {
         report_error( ctx, "Expected immediate constant" );
         return FALSE;
      }
   }
   eat_opt_white( &ctx->cur );
   if (*ctx->cur != '}') {
      report_error( ctx, "Expected `}'" );
      return FALSE;
   }
   ctx->cur++;

   return TRUE;
}
Exemplo n.º 6
0
static void action_sleep(const char *const *action)
{
  const char *duration = action[2];
  double clock = MSG_get_clock();

  ACT_DEBUG("Entering %s", NAME);
  MSG_process_sleep(parse_double(duration));
  log_action(action, MSG_get_clock() - clock);
}
Exemplo n.º 7
0
static adv_error parse_generate_interpolate(const char* begin, const char* end, adv_generate_interpolate* interpolate)
{
	double d;
	adv_generate* data = &interpolate->gen;

	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	interpolate->hclock = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->hactive = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->hfront = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->hsync = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->hback = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->vactive = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->vfront = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->vsync = d;
	parse_separator(" \t", &begin, end);
	if (parse_double(&d, &begin, end))
		return -1;
	data->vback = d;
	parse_separator(" \t", &begin, end);
	if (begin != end)
		return -1;

	generate_normalize(data);

	return 0;
}
Exemplo n.º 8
0
static int parse_float (SLFUTURE_CONST char **sp, SLFUTURE_CONST char *smax, float *d)
{
   double x;
   if (1 == parse_double (sp, smax, &x))
     {
	*d = (float) x;
	return 1;
     }
   return 0;
}
Exemplo n.º 9
0
static void action_compute(const char *const *action)
{
  double clock = smpi_process_simulated_elapsed();
  smpi_execute_flops(parse_double(action[2]));

  if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){
    char *name = xbt_str_join_array(action, " ");
    XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock);
    free(name);
  }
}
Exemplo n.º 10
0
static void action_compute(const char *const *action)
{
  const char *amount = action[2];
  msg_task_t task = MSG_task_create("task", parse_double(amount), 0, NULL);
  double clock = MSG_get_clock();

  ACT_DEBUG("Entering %s", NAME);
  MSG_task_execute(task);
  MSG_task_destroy(task);
  log_action(action, MSG_get_clock() - clock);
}
Exemplo n.º 11
0
int HOST::parse_time_stats(FILE* fin) {
    char buf[256];

    while (fgets(buf, sizeof(buf), fin)) {
        if (match_tag(buf, "</time_stats>")) return 0;
        if (parse_double(buf, "<on_frac>", on_frac)) continue;
        if (parse_double(buf, "<connected_frac>", connected_frac)) continue;
        if (parse_double(buf, "<active_frac>", active_frac)) continue;
#if 0
        if (match_tag(buf, "<outages>")) continue;
        if (match_tag(buf, "<outage>")) continue;
        if (match_tag(buf, "<start>")) continue;
        if (match_tag(buf, "<end>")) continue;
        log_messages.printf(MSG_NORMAL,
            "HOST::parse_time_stats(): unrecognized: %s\n",
            buf
        );
#endif
    }
    return ERR_XML_PARSE;
}
Exemplo n.º 12
0
void CScreensaver::GetDefaultDisplayPeriods(struct ss_periods &periods)
{
    char*           default_data_dir_path = NULL;
    char            buf[1024];
    FILE*           f;
    MIOFILE         mf;

    periods.GFXDefaultPeriod = GFX_DEFAULT_PERIOD;
    periods.GFXSciencePeriod = GFX_SCIENCE_PERIOD;
    periods.GFXChangePeriod = GFX_CHANGE_PERIOD;
    periods.Show_default_ss_first = false;

#ifdef __APPLE__
    default_data_dir_path = "/Library/Application Support/BOINC Data";
#else
    default_data_dir_path = (char*)m_strBOINCDataDirectory.c_str();
#endif

    strlcpy(buf, default_data_dir_path, sizeof(buf));
    strlcat(buf, PATH_SEPARATOR, sizeof(buf));
    strlcat(buf, THE_SS_CONFIG_FILE, sizeof(buf));

    f = boinc_fopen(buf, "r");
    if (!f) return;
    
    mf.init_file(f);
    XML_PARSER xp(&mf);

    while (mf.fgets(buf, sizeof(buf))) {
        if (parse_bool(buf, "default_ss_first", periods.Show_default_ss_first)) continue;
        if (parse_double(buf, "<default_gfx_duration>", periods.GFXDefaultPeriod)) continue;
        if (parse_double(buf, "<science_gfx_duration>", periods.GFXSciencePeriod)) continue;
        if (parse_double(buf, "<science_gfx_change_interval>", periods.GFXChangePeriod)) continue;
        
    }
    fclose(f);
    
    BOINCTRACE(_T("CScreensaver::GetDefaultDisplayPeriods: m_bShow_default_ss_first=%d, m_fGFXDefaultPeriod=%f, m_fGFXSciencePeriod=%f, m_fGFXChangePeriod=%f\n"),
                    (int)periods.Show_default_ss_first, periods.GFXDefaultPeriod, periods.GFXSciencePeriod, periods.GFXChangePeriod);
}
Exemplo n.º 13
0
static adv_error monitor_range_parse(adv_monitor_range* range, const char* begin, const char* end, double mult)
{
	double v0;
	double v1;

	parse_separator(" \t", &begin, end);

	if (parse_double(&v0, &begin, end))
		return -1;

	parse_separator(" \t", &begin, end);

	if (*begin == '-') {
		++begin;

		parse_separator(" \t", &begin, end);

		if (parse_double(&v1, &begin, end))
			return -1;

		if (v0 < 0 || v0 > v1 || v1 > 300)
			return -1;

		range->low = mult * v0;
		range->high = mult * v1;
	} else {
		if (v0 < 0 || v0 > 300)
			return -1;

		range->low = mult * v0;
		range->high = range->low;
	}

	parse_separator(" \t", &begin, end);

	if (begin != end)
		return -1;

	return 0;
}
Exemplo n.º 14
0
int HOST::parse_net_stats(FILE* fin) {
    char buf[256];

    while (fgets(buf, sizeof(buf), fin)) {
        if (match_tag(buf, "</net_stats>")) return 0;
        if (parse_double(buf, "<bwup>", n_bwup)) continue;
        if (parse_double(buf, "<bwdown>", n_bwdown)) continue;

        // items reported by 5.10+ clients, not currently used
        //
        if (match_tag(buf, "<avg_time_up>")) continue;
        if (match_tag(buf, "<avg_up>")) continue;
        if (match_tag(buf, "<avg_time_down>")) continue;
        if (match_tag(buf, "<avg_down>")) continue;

        log_messages.printf(MSG_NORMAL,
            "HOST::parse_net_stats(): unrecognized: %s\n",
            buf
        );
    }
    return ERR_XML_PARSE;
}
Exemplo n.º 15
0
static int	parse_cylinder_3(char **line, int *i, t_cylinder *obj)
{
	if (!ft_strcmp(line[i[0]], "radius"))
	{
		if (!parse_double(line, i, &obj->radius))
			return (return_print("Error parsing cylinder radius", 0));
		else
		{
			if (obj->radius < 0)
				return (return_print("Error, radius can't be negative", 0));
			obj->radius = POW2(obj->radius);
		}
	}
	else if (!ft_strcmp(line[i[0]], "height"))
	{
		if (!parse_double(line, i, &obj->h))
			return (return_print("Error parsing cylinder height", 0));
		else if (obj->h < 0)
			return (return_print("Error, height can't be negative", 0));
	}
	return (1);
}
Exemplo n.º 16
0
int HOST_INFO::parse(MIOFILE& in, bool benchmarks_only) {
    char buf[1024];

    while (in.fgets(buf, sizeof(buf))) {
        if (match_tag(buf, "</host_info>")) return 0;
        else if (parse_double(buf, "<p_fpops>", p_fpops)) {
            // fix foolishness that could result in negative value here
            //
            if (p_fpops < 0) p_fpops = -p_fpops;
            continue;
        }
        else if (parse_double(buf, "<p_iops>", p_iops)) {
            if (p_iops < 0) p_iops = -p_iops;
            continue;
        }
        else if (parse_double(buf, "<p_membw>", p_membw)) {
            if (p_membw < 0) p_membw = -p_membw;
            continue;
        }
        else if (parse_double(buf, "<p_calculated>", p_calculated)) continue;

        if (benchmarks_only) continue;

        if (parse_int(buf, "<timezone>", timezone)) continue;
        else if (parse_str(buf, "<domain_name>", domain_name, sizeof(domain_name))) continue;
        else if (parse_str(buf, "<ip_addr>", ip_addr, sizeof(ip_addr))) continue;
        else if (parse_str(buf, "<host_cpid>", host_cpid, sizeof(host_cpid))) continue;
        else if (parse_int(buf, "<p_ncpus>", p_ncpus)) continue;
        else if (parse_str(buf, "<p_vendor>", p_vendor, sizeof(p_vendor))) continue;
        else if (parse_str(buf, "<p_model>", p_model, sizeof(p_model))) continue;
        else if (parse_str(buf, "<p_features>", p_features, sizeof(p_features))) continue;
        else if (parse_double(buf, "<m_nbytes>", m_nbytes)) continue;
        else if (parse_double(buf, "<m_cache>", m_cache)) continue;
        else if (parse_double(buf, "<m_swap>", m_swap)) continue;
        else if (parse_double(buf, "<d_total>", d_total)) continue;
        else if (parse_double(buf, "<d_free>", d_free)) continue;
        else if (parse_str(buf, "<os_name>", os_name, sizeof(os_name))) continue;
        else if (parse_str(buf, "<os_version>", os_version, sizeof(os_version))) continue;
        else if (match_tag(buf, "<coprocs>")) {
            coprocs.parse(in);
        }
    }
    return ERR_XML_PARSE;
}
Exemplo n.º 17
0
static void action_allReduce(const char *const *action) {
  double comm_size = parse_double(action[2]);
  double comp_size = parse_double(action[3]);
  double clock = smpi_process_simulated_elapsed();
#ifdef HAVE_TRACING
  int rank = smpi_comm_rank(MPI_COMM_WORLD);
  TRACE_smpi_computing_out(rank);
  TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
#endif
  smpi_mpi_reduce(NULL, NULL, comm_size, MPI_BYTE, MPI_OP_NULL, 0, MPI_COMM_WORLD);
  smpi_execute_flops(comp_size);
  smpi_mpi_bcast(NULL, comm_size, MPI_BYTE, 0, MPI_COMM_WORLD);
#ifdef HAVE_TRACING
  TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
  TRACE_smpi_computing_in(rank);
#endif

  if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){
    char *name = xbt_str_join_array(action, " ");
    XBT_VERB("%s %f", name, smpi_process_simulated_elapsed()-clock);
    free(name);
  }
}
Exemplo n.º 18
0
static int	parse_material_2(char **line, int *i, t_material *mat)
{
	if (!ft_strcmp(line[i[0]], "id"))
	{
		if (line[i[0] + 1] == NULL || !(ft_strlen(line[i[0] + 1]) > 0))
			return (return_print("Error parsing material id", 0));
		else
		{
			if (!(mat->name = ft_strdup(line[++i[0]])))
				return (return_print("malloc error", 0));
			i[1] |= 1;
		}
	}
	else if (!ft_strcmp(line[i[0]], "color")
		&& !parse_color(line, i, &mat->color))
		return (return_print("Error parsing material color", 0));
	else if (!ft_strcmp(line[i[0]], "ambiant")
		&& !parse_double(line, i, &mat->k_ambiant))
		return (return_print("Error parsing material ambiant", 0));
	else if (!ft_strcmp(line[i[0]], "specular")
		&& !parse_double(line, i, &mat->k_spec))
		return (return_print("Error parsing material specular", 0));
	return (parse_material_3(line, i, mat));
}
Exemplo n.º 19
0
	double parse_number(const char* json)
	{
		CE_ASSERT_NOT_NULL(json);

		TempAllocator512 alloc;
	 	Array<char> number(alloc);

		if (*json == '-')
		{
			array::push_back(number, '-');
			json = next(json, '-');
		}
		while (isdigit(*json))
		{
			array::push_back(number, *json);
			json = next(json);
		}

		if (*json == '.')
		{
			array::push_back(number, '.');
			while ((*(json = next(json))) && isdigit(*json))
			{
				array::push_back(number, *json);
			}
		}

		if (*json == 'e' || *json == 'E')
		{
			array::push_back(number, *json);
			json = next(json);

			if (*json == '-' || *json == '+')
			{
				array::push_back(number, *json);
				json = next(json);
			}
			while (isdigit(*json))
			{
				array::push_back(number, *json);
				json = next(json);
			}
		}

		// Ensure null terminated
		array::push_back(number, '\0');
		return parse_double(array::begin(number));
	}
Exemplo n.º 20
0
static void action_bcast(const char *const *action)
{
  int i;
  char *bcast_identifier;
  char mailbox[80];
  double comm_size = parse_double(action[2]);
  msg_task_t task = NULL;
  const char *process_name;
  double clock = MSG_get_clock();

  process_globals_t counters =
      (process_globals_t) MSG_process_get_data(MSG_process_self());

  xbt_assert(communicator_size, "Size of Communicator is not defined, "
             "can't use collective operations");

  process_name = MSG_process_get_name(MSG_process_self());

  bcast_identifier = bprintf("bcast_%d", counters->bcast_counter++);

  if (!strcmp(process_name, "p0")) {
    XBT_DEBUG("%s: %s is the Root", bcast_identifier, process_name);

    msg_comm_t *comms = xbt_new0(msg_comm_t, communicator_size - 1);

    for (i = 1; i < communicator_size; i++) {
      sprintf(mailbox, "%s_p0_p%d", bcast_identifier, i);
      comms[i - 1] =
          MSG_task_isend(MSG_task_create(mailbox, 0, comm_size, NULL), mailbox);
    }
    MSG_comm_waitall(comms, communicator_size - 1, -1);
    for (i = 1; i < communicator_size; i++)
      MSG_comm_destroy(comms[i - 1]);
    xbt_free(comms);

    XBT_DEBUG("%s: all messages sent by %s have been received",
              bcast_identifier, process_name);

  } else {
    sprintf(mailbox, "%s_p0_%s", bcast_identifier, process_name);
    MSG_task_receive(&task, mailbox);
    MSG_task_destroy(task);
    XBT_DEBUG("%s: %s has received", bcast_identifier, process_name);
  }

  log_action(action, MSG_get_clock() - clock);
  xbt_free(bcast_identifier);
}
Exemplo n.º 21
0
/* Parses expected server response to CFdDVK command: should be four newline
 * terminated numbers and a version string. */
static bool parse_archive_parameters(const char **string)
{
    return
        parse_double(string, &sample_frequency)  &&
        parse_char(string, '\n')  &&
        parse_uint(string, &first_decimation)  &&
        parse_char(string, '\n')  &&
        parse_uint(string, &second_decimation)  &&
        parse_char(string, '\n')  &&
        parse_version(string)  &&
        parse_char(string, '\n')  &&
        parse_uint(string, &fa_entry_count)  &&
        parse_char(string, '\n')  &&
        parse_uint(string, &continuous_decimation)  &&
        parse_char(string, '\n');
}
Exemplo n.º 22
0
bool
snp_type_info::
get_format_float(const char* const* word,
                 const char* key,
                 float& val) {

    const char* str(get_format_string_nocopy(word,key));
    if (NULL==str) return false;
    if ('\0'==*str) return false;
    if ('.'==*str) {
        if ('\0'==*(str+1)) return false;
        if (':'==*(str+1)) return false;
    }
    val=parse_double(str);
    return true;
}
Exemplo n.º 23
0
int RESULT::parse_from_client(FILE* fin) {
    char buf[256];

    // should be non-zero if exit_status is not found
    exit_status = ERR_NO_EXIT_STATUS;
    memset(this, 0, sizeof(RESULT));
    while (fgets(buf, sizeof(buf), fin)) {
        if (match_tag(buf, "</result>")) {
            return 0;
        }
        if (parse_str(buf, "<name>", name, sizeof(name))) continue;
        if (parse_int(buf, "<state>", client_state)) continue;
        if (parse_double(buf, "<final_cpu_time>", cpu_time)) continue;
        if (parse_double(buf, "<final_elapsed_time>", elapsed_time)) continue;
        if (parse_int(buf, "<exit_status>", exit_status)) continue;
        if (parse_int(buf, "<app_version_num>", app_version_num)) continue;
        if (parse_double(buf, "<fpops_per_cpu_sec>", fpops_per_cpu_sec)) continue;
        if (parse_double(buf, "<fpops_cumulative>", fpops_cumulative)) continue;
        if (parse_double(buf, "<intops_per_cpu_sec>", intops_per_cpu_sec)) continue;
        if (parse_double(buf, "<intops_cumulative>", intops_cumulative)) continue;
        if (match_tag(buf, "<file_info>")) {
            safe_strcat(xml_doc_out, buf);
            while (fgets(buf, sizeof(buf), fin)) {
                safe_strcat(xml_doc_out, buf);
                if (match_tag(buf, "</file_info>")) break;
            }
            continue;
        }
        if (match_tag(buf, "<stderr_out>" )) {
            while (fgets(buf, sizeof(buf), fin)) {
                if (match_tag(buf, "</stderr_out>")) break;
                safe_strcat(stderr_out, buf);
            }
            continue;
        }
        if (match_tag(buf, "<platform>")) continue;
        if (match_tag(buf, "<version_num>")) continue;
        if (match_tag(buf, "<plan_class>")) continue;
        if (match_tag(buf, "<completed_time>")) continue;
        if (match_tag(buf, "<file_name>")) continue;
        if (match_tag(buf, "<file_ref>")) continue;
        if (match_tag(buf, "</file_ref>")) continue;
        if (match_tag(buf, "<open_name>")) continue;
        if (match_tag(buf, "<ready_to_report>")) continue;
        if (match_tag(buf, "<ready_to_report/>")) continue;
        if (match_tag(buf, "<report_deadline>")) continue;
        if (match_tag(buf, "<wu_name>")) continue;

        log_messages.printf(MSG_NORMAL,
            "RESULT::parse_from_client(): unrecognized: %s\n",
            buf
        );
    }
    return ERR_XML_PARSE;
}
Exemplo n.º 24
0
static void action_compute(const char *const *action)
{
  CHECK_ACTION_PARAMS(action, 1, 0);
  double clock = smpi_process_simulated_elapsed();
  double flops= parse_double(action[2]);
  int rank = smpi_process_index();
  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
  extra->type=TRACING_COMPUTING;
  extra->comp_size=flops;
  TRACE_smpi_computing_in(rank, extra);

  smpi_execute_flops(flops);

  TRACE_smpi_computing_out(rank);
  log_timed_action (action, clock);
}
Exemplo n.º 25
0
// extract float value for key from the vcf info field
bool
snp_type_info::
get_info_float(const char* info,
               const char* key,
               float& val) {

    const char* tmp(NULL);
    do {
        if (NULL != tmp) info=tmp+1;
        if (0!=strncmp(info,key,strlen(key))) continue;
        if (NULL==(info=strchr(info,'='))) return false;
        const char* s(info+1);
        val=parse_double(s);
        return true;
    } while (NULL != (tmp=strchr(info,';')));
    return false;
}
Exemplo n.º 26
0
// Add a signature at the end of every <file_info> element,
//
int add_signatures(char* xml, R_RSA_PRIVATE_KEY& key) {
    char* p = xml, *q1, *q2, buf[BLOB_SIZE], buf2[BLOB_SIZE];
    char signature_hex[BLOB_SIZE];
    char signature_xml[BLOB_SIZE];
    char signed_xml[1024];
    int retval, len;

    while (1) {
        q1 = strstr(p, "<file_info>\n");
        if (!q1) break;
        q2 = strstr(q1, "</file_info>");
        if (!q2) {
            fprintf(stderr, "add_signatures: malformed XML: %s\n", xml);
            return ERR_XML_PARSE;
        }

        q1 += strlen("<file_info>\n");
        len = q2 - q1;
        memcpy(buf, q1, len);
        buf[len] = 0;
        char name[1024];
        if (!parse_str(buf, "<name>", name, sizeof(name))) {
            fprintf(stderr, "add_signatures: missing name: %s", buf);
            return ERR_XML_PARSE;
        }
        double max_nbytes;
        if (!parse_double(buf, "<max_nbytes>", max_nbytes)) {
            fprintf(stderr, "add_signatures: missing max_nbytes: %s", buf);
            return ERR_XML_PARSE;
        }
        sprintf(signed_xml, "<name>%s</name><max_nbytes>%.0f</max_nbytes>",
            name, max_nbytes
        );
        retval = generate_signature(signed_xml, signature_hex, key);
        sprintf(signature_xml,
            "<xml_signature>\n%s</xml_signature>\n", signature_hex
        );
        if (retval) return retval;
        strcpy(buf2, q2);
        strcpy(q1, buf);
        strcat(q1, signature_xml);
        strcat(q1, buf2);
        p = q1;
    }
    return 0;
}
Exemplo n.º 27
0
/*-------------------------------------------------------------------------*/
void
change_base(void)
{
	parse_double(&dnum);

    if (dnum >= 0) {
        switch (numbase) {
        case 8:  numbase = 10;  break;
        case 10: numbase = 16;  break;
        case 16: numbase = 8;   break;
        }

        format_double(dnum);
    } else strlcpy(dispstr, "error", sizeof(dispstr));

    DrawDisplay();
}
Exemplo n.º 28
0
static void action_Isend(const char *const *action)
{
  char to[250];
  const char *size = action[3];
  double clock = MSG_get_clock();
  process_globals_t globals =
      (process_globals_t) MSG_process_get_data(MSG_process_self());

  sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]);
  msg_comm_t comm =
      MSG_task_isend(MSG_task_create(to, 0, parse_double(size), NULL), to);
  xbt_dynar_push(globals->isends, &comm);

  XBT_DEBUG("Isend on %s", MSG_process_get_name(MSG_process_self()));
  log_action(action, MSG_get_clock() - clock);
  asynchronous_cleanup();
}
Exemplo n.º 29
0
static int parse_line(
    const char *linebuf,
    int *year,
    int *month,
    int *day,
    double *delta
) {
	char s[0x100]; // for substrings

	long tmp;

	substr(s, linebuf, 1, 4); // year
	if (!parse_long(s, &tmp)) {
		fprintf(stderr, "cannot parse year: \"%s\"\n", s);
		return 0;
	}
	*year = (int) tmp;

	substr(s, linebuf, 6, 3); // month name abbr
	if (!parse_month(s, &tmp)) {
		fprintf(stderr, "cannot parse month: \"%s\"\n", s);
		return 0;
	}
	*month = (int) tmp;

	substr(s, linebuf, 10, 2); // day
	if (!parse_long(s, &tmp)) {
		fprintf(stderr, "cannot parse day: \"%s\"\n", s);
		return 0;
	}
	*day = (int) tmp;

	substr(s, linebuf, 36, 13); // tai-utc delta
	if (!parse_double(s, delta)) {
		fprintf(stderr, "cannot parse delta: %s\n", s);
		return 0;
	}
	return 1;

//         1         2         3         4         5         6         7         8
//12345678901234567890123456789012345678901234567890123456789012345678901234567890
//                                    1234567890123
// 2012 JUL  1 =JD 2456109.5  TAI-UTC=  35.0       S + (MJD - 41317.) X 0.0      S
}
Exemplo n.º 30
0
/* My actions */
static void action_send(const char *const *action)
{
  char to[250];
  const char *size_str = action[3];
  double size = parse_double(size_str);
  double clock = MSG_get_clock();       /* this "call" is free thanks to inlining */

  sprintf(to, "%s_%s", MSG_process_get_name(MSG_process_self()), action[2]);

  ACT_DEBUG("Entering Send: %s (size: %g)", NAME, size);
  if (size < 65536) {
    action_Isend(action);
  } else {
    MSG_task_send(MSG_task_create(to, 0, size, NULL), to);
  }

  log_action(action, MSG_get_clock() - clock);
  asynchronous_cleanup();
}