Exemplo n.º 1
0
config_setting_t *config_setting_set_int64_elem(config_setting_t *vector,
                                                int idx, long long value)
{
  config_setting_t *element = NULL;

  if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST))
    return(NULL);

  if(idx < 0)
  {
    if(! __config_vector_checktype(vector, CONFIG_TYPE_INT64))
      return(NULL);

    element = config_setting_create(vector, NULL, CONFIG_TYPE_INT64);
  }
  else
  {
    element = config_setting_get_elem(vector, idx);

    if(! element)
      return(NULL);
  }

  if(! config_setting_set_int64(element, value))
    return(NULL);

  return(element);
}
Exemplo n.º 2
0
void config_setting_copy_simple(config_setting_t *parent, const config_setting_t *src)
{
	if (config_setting_is_aggregate(src)) {
		config_setting_copy_aggregate(parent, src);
	}
	else {
		config_setting_t *set;
		
		if( config_setting_get_member(parent, config_setting_name(src)) != NULL )
			return;
		
		if ((set = config_setting_add(parent, config_setting_name(src), config_setting_type(src))) == NULL)
			return;

		if (CONFIG_TYPE_INT == config_setting_type(src)) {
			config_setting_set_int(set, config_setting_get_int(src));
			config_setting_set_format(set, src->format);
		} else if (CONFIG_TYPE_INT64 == config_setting_type(src)) {
			config_setting_set_int64(set, config_setting_get_int64(src));
			config_setting_set_format(set, src->format);
		} else if (CONFIG_TYPE_FLOAT == config_setting_type(src)) {
			config_setting_set_float(set, config_setting_get_float(src));
		} else if (CONFIG_TYPE_STRING == config_setting_type(src)) {
			config_setting_set_string(set, config_setting_get_string(src));
		} else if (CONFIG_TYPE_BOOL == config_setting_type(src)) {
			config_setting_set_bool(set, config_setting_get_bool(src));
		}
	}
}
Exemplo n.º 3
0
config_setting_t *cfgSetInt64(config_setting_t *parent, const TCHAR *name, long long value)
{
	config_setting_t *setting;
	char uName[CONFIG_UTF8_MAXSTRING];

	UTF8_Encode(name, uName, CONFIG_UTF8_MAXSTRING);

	setting = config_setting_add(parent, uName, CONFIG_TYPE_INT64);
	config_setting_set_int64(setting, value);

	return setting;
}
Exemplo n.º 4
0
/*********************
return RET_NOK on error
*********************/
ret_code_t entry_copy_config(config_setting_t * source, config_setting_t * dest)
{
	config_setting_t * new_source;
	config_setting_t * new_dest;
	int index = -1;
	int int_value;
	long long long_value;
	double double_value;
	const char * string;

	while((new_source=config_setting_get_elem(source,index+1))!= NULL ) {
		index++;
		if(config_setting_is_group(new_source)) {
			if(!entry_copy_aggregate(new_source,dest,CONFIG_TYPE_GROUP)) {
				return RET_NOK;
			}
		}

		else if(config_setting_is_array(new_source)) {
			if(!entry_copy_aggregate(new_source,dest,CONFIG_TYPE_ARRAY)) {
				return RET_NOK;
			}
		}

		else if(config_setting_is_list(new_source)) {
			if(!entry_copy_aggregate(new_source,dest,CONFIG_TYPE_LIST)) {
				return RET_NOK;
			}
		}

		else {
			switch(config_setting_type(new_source)) {
			case CONFIG_TYPE_INT:
				int_value = config_setting_get_int(new_source);
				new_dest = config_setting_add (dest, config_setting_name(new_source),CONFIG_TYPE_INT);
				config_setting_set_int(new_dest,int_value);
				continue;
			case CONFIG_TYPE_INT64:
				long_value = config_setting_get_int64(new_source);
				new_dest = config_setting_add (dest, config_setting_name(new_source),CONFIG_TYPE_INT64);
				config_setting_set_int64(new_dest,long_value);
				continue;
			case CONFIG_TYPE_FLOAT:
				double_value = config_setting_get_float(new_source);
				new_dest = config_setting_add (dest, config_setting_name(new_source),CONFIG_TYPE_FLOAT);
				config_setting_set_float(new_dest,double_value);
				continue;
			case CONFIG_TYPE_BOOL:
				int_value = config_setting_get_bool(new_source);
				new_dest = config_setting_add (dest, config_setting_name(new_source),CONFIG_TYPE_BOOL);
				config_setting_set_bool(new_dest,int_value);
				continue;
			case CONFIG_TYPE_STRING:
				string = config_setting_get_string(new_source);
				new_dest = config_setting_add (dest, config_setting_name(new_source),CONFIG_TYPE_STRING);
				config_setting_set_string(new_dest,string);
				continue;
			default:
				return RET_NOK;
			}
		}
	}

	return RET_OK;
}
Exemplo n.º 5
0
// load the default configuration in cfg
static void set_default_config(config_t * cfg) {
	static const unsigned AACCESSES = 4 * 1024 * 1024;
	static const unsigned BEGIN = BEGIN_INIT;
	static const char SPAWN[] = "linear";
	static const long long END = END_INIT;
	static const float FREQUENCY = 1;
	static const bool LOGGING = false;
	static const char LOGFILE[] = "adhd_log";
	static const char PATTERN[] = "random";
	static const unsigned PROCESSES = 1;
	static const unsigned REPETITIONS = 50;
	static const long long STEP = STEP_INIT;
	static const char SCALING[] = "linear";
	static const bool SILENT = false;
	static const unsigned THREADS = 1;

	static const long long STREAM_STEP = 10 * (1 << 20);
	static const long long STREAM_END = 100 * (1 << 20);

	static const long long FLOPS_STEP = 10 * (1 << 10);
	static const long long FLOPS_END = 1 * (1 << 20);
	static const long long FLOPS_CALCULATIONS = 1000 * 1000 * 1000;

	config_setting_t *setting;
	config_setting_t *root;
	root = config_root_setting(cfg);

	// generic group
	{
		config_setting_t *generic =
			config_setting_add(root, FLD_GENERIC_GROUP, CONFIG_TYPE_GROUP);

		// array of names of enabled programs (uses corresponding group names for
		// the sake of simplicity)
		{
			config_setting_t *programs =
				config_setting_add(generic, FLD_PROGRAMS_GROUP, CONFIG_TYPE_ARRAY);

			static const char *names[] = {
				FLD_WALKARRAY_GROUP,
				FLD_STREAMARRAY_GROUP,
				FLD_FLOPSARRAY_GROUP,
				NULL // mark end of list
			};

			for (size_t i = 0; names[i]; ++i) {
				setting = config_setting_add(programs, NULL, CONFIG_TYPE_STRING);
				config_setting_set_string(setting, names[i]);
			}
		}

		// CPU frequency to calculate cycle estimate
		// TODO: use actual cycle counter in the CPU
		// (this is a feature with a design impact, as SMP complicates matters ... :))
		setting = config_setting_add(generic, FLD_GENERIC_GPU_FREQUENCY, CONFIG_TYPE_FLOAT);
		config_setting_set_float(setting, FREQUENCY);

		// logging enabled?
		setting = config_setting_add(generic, FLD_GENERIC_LOGGING, CONFIG_TYPE_BOOL);
		config_setting_set_bool(setting, LOGGING);

		// base filename to log process timings to
		setting = config_setting_add(generic, FLD_GENERIC_LOGFILE, CONFIG_TYPE_STRING);
		config_setting_set_string(setting, LOGFILE);

		// process spawn method
		setting = config_setting_add(generic, FLD_GENERIC_SPAWN, CONFIG_TYPE_STRING);
		config_setting_set_string(setting, SPAWN);

		// number of processes to run: begin
		// TODO: just like arrays we could have a linear or exponential increment
		setting = config_setting_add(generic, FLD_GENERIC_PROCESSES_BEGIN, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, PROCESSES);

		// number of processes to run: end
		setting = config_setting_add(generic, FLD_GENERIC_PROCESSES_END, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, PROCESSES);

		// number of threads per process to run: begin
		// TODO: just like arrays we could have a linear or exponential increment
		setting = config_setting_add(generic, FLD_GENERIC_THREADS_BEGIN, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, THREADS);

		// number of threads per process to run: end
		setting = config_setting_add(generic, FLD_GENERIC_THREADS_END, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, THREADS);

		// silent mode
		setting = config_setting_add(generic, FLD_GENERIC_SILENT, CONFIG_TYPE_BOOL);
		config_setting_set_bool(setting, SILENT);
	}

	// walking array group
	{
		config_setting_t *array =
			config_setting_add(root, FLD_WALKARRAY_GROUP, CONFIG_TYPE_GROUP);

		// array accesses
		setting = config_setting_add(array, FLD_WALKARRAY_ACCESSES, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, AACCESSES);

		// repetitions of a single test, to be able to calculate an average
		// and a standard deviation, indicating run precision
		setting = config_setting_add(array, FLD_WALKARRAY_REPEAT, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, REPETITIONS);

		// initial array size
		setting = config_setting_add(array, FLD_WALKARRAY_BEGINLENGTH, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, BEGIN);

		// maximal array size
		setting = config_setting_add(array, FLD_WALKARRAY_ENDLENGTH, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, END);

		// increment factor
		setting = config_setting_add(array, FLD_WALKARRAY_INCREMENT, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, STEP);

		// increment type
		// (linear adds the increment, exponential multiplies the previous length)
		setting = config_setting_add(array, FLD_WALKARRAY_SCALING, CONFIG_TYPE_STRING);
		config_setting_set_string(setting, SCALING);

		// walking pattern
		// (sequentially increasing/decreasing or random)
		setting = config_setting_add(array, FLD_WALKARRAY_PATTERN, CONFIG_TYPE_STRING);
		config_setting_set_string(setting, PATTERN);
	}

	// streaming array group
	{
		config_setting_t *array =
			config_setting_add(root, FLD_STREAMARRAY_GROUP, CONFIG_TYPE_GROUP);

		// initial array size
		setting = config_setting_add(array, FLD_STREAMARRAY_BEGINLENGTH, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, BEGIN);

		// maximal array size
		setting = config_setting_add(array, FLD_STREAMARRAY_ENDLENGTH, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, STREAM_END);

		// increment factor
		setting = config_setting_add(array, FLD_STREAMARRAY_INCREMENT, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, STREAM_STEP);

		// increment type
		// (linear adds the increment, exponential multiplies the previous length)
		setting = config_setting_add(array, FLD_STREAMARRAY_SCALING, CONFIG_TYPE_STRING);
		config_setting_set_string(setting, SCALING);
	}

	// flops array group
	{
		config_setting_t *array =
			config_setting_add(root, FLD_FLOPSARRAY_GROUP, CONFIG_TYPE_GROUP);

		// initial array size
		setting = config_setting_add(array, FLD_FLOPSARRAY_BEGINLENGTH, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, BEGIN);

		// maximal array size
		setting = config_setting_add(array, FLD_FLOPSARRAY_ENDLENGTH, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, FLOPS_END);

		// increment factor
		setting = config_setting_add(array, FLD_FLOPSARRAY_INCREMENT, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, FLOPS_STEP);

		// increment type
		// (linear adds the increment, exponential multiplies the previous length)
		setting = config_setting_add(array, FLD_FLOPSARRAY_SCALING, CONFIG_TYPE_STRING);
		config_setting_set_string(setting, SCALING);

		// number of calculations to perform
		setting = config_setting_add(array, FLD_FLOPSARRAY_CALCULATIONS, CONFIG_TYPE_INT64);
		config_setting_set_int64(setting, FLOPS_CALCULATIONS);
	}
}