int main(int argc, char* argv[])
{
	TestConfig loTest;
    loTest.SetKeySize(10);
    loTest.SetValueSize(10);
    loTest.SetType("set");
    DatabaseSetup();
    DatabaseSetTest(loTest);
    return 0;
}
Exemple #2
0
void record_full_timings(TimingType & timings,
                         F functor,
                         TestConfig & config,
                         TestData & data)
{
  typedef typename TestData::value_type  ScalarType;

  double result = 0;
  functor(data); //startup run (ensures kernel compilation)
  for (unsigned int work_groups = config.min_work_groups(); work_groups <= config.max_work_groups(); work_groups *= 2)           //iterate over number of work groups (compute units)
  {
    for (unsigned int local_workers = config.min_local_size(); local_workers <= config.max_local_size(); local_workers *= 2)   //iterate over local thread number
    {
      //set parameter:
      set_kernel_params(config.program_name(), config.kernel_name(), work_groups, local_workers);

      //std::cout << "Benchmarking kernel " << config.kernel_name() << std::endl;
      result = execute(functor, data);

      //check for valid result: (kernels have an automatic fallback to smaller values included)
      if (!validate_result(config.program_name(), config.kernel_name(), work_groups, local_workers))
      {
      std::cout << "Kernel start failed for kernel " << config.kernel_name() << " [" << work_groups << " groups, " << local_workers << " per group]" << std::endl;
        break;
      }
      else
        timings[result] = std::make_pair(work_groups * local_workers, local_workers);
    }
  }
}
Exemple #3
0
void optimize_restricted(viennacl::io::parameter_database & paras,
                         TimingType & timings,
                         F functor,
                         TestConfig & config,
                         TestData & data)
{
  record_restricted_timings(timings, functor, config, data);
  record_kernel_parameters(paras, config.kernel_name(), timings);
#ifdef ENABLE_VIENNAPROFILER
  write_viennaprofiler(timings, config.program_name(), config.kernel_name());
#endif
  print_best(timings, config.kernel_name());
  print_default_restricted(timings, config.kernel_name());
}
int DatabaseSetTest(TestConfig& conf)
{
	int			numTest;
	Stopwatch	sw;
	Table*		table;
	Transaction* tx;
	bool		ret;
	int			limit = 16*KB;
	int			sum;

	if (conf.argc < 5)
	{
		Log_Message("\n\tusage: %s <keySize> <valueSize>", conf.typeString);
		return 1;
	}
	
	Log_SetTrace(true);
	
	if (DatabaseSetup())
	{
		Log_Message("Cannot initialize database!", 1);
		return 1;
	}
	
	table = database.GetTable("keyspace");
	if (!table)
	{
		Log_Message("Cannot initialize table!", 1);
		return 1;
	}
	
	conf.SetKeySize(atoi(conf.argv[3]));
	conf.SetValueSize(atoi(conf.argv[4]));

	Log_Message("Test type = %s, keySize = %d, valueSize = %d",
			conf.typeString, conf.keySize, conf.valueSize);
	
	tx = NULL;
	tx = new Transaction(table);
	sw.Start();
	tx->Begin();
	sw.Stop();
	
	sum = 0;
	numTest = conf.datasetTotal / conf.valueSize;
	for (int i = 0; i < numTest; i++)
	{
		if (conf.rndkey)
			GenRandomString(conf.key, conf.keySize);
		else
			conf.key.Writef("key%B:%d", conf.padding.length, conf.padding.buffer, i);
		
		sw.Start();
		ret = table->Set(tx, conf.key, conf.value);
		sw.Stop();
		if (!ret)
		{
			Log_Message("Test failed, ret = %s (%s failed after %d)", ret ? "true" : "false", conf.typeString, i);
			return 1;
		}
		
		sum += conf.keySize + conf.valueSize;
		if (sum > limit)
		{			
			sw.Start();
			tx->Commit();
			sw.Stop();
			
			double mbps = sum / (sw.elapsed / 1000.0) / 1000000;
			Log_Message("num = %d, elapsed = %ld, thruput = %lf MB/s", i, sw.elapsed, mbps);
			sw.Reset();
			
			sw.Start();
			tx->Begin();
			sw.Stop();

			sum = 0;
		}
	}

	sw.Start();
	tx->Commit();
	sw.Stop();

	double mbps = (conf.valueSize + conf.keySize) * numTest / (sw.elapsed / 1000.0) / 1000000;
	Log_Message("Test succeeded, %s/sec = %lf (num = %d, elapsed = %ld, thruput = %lf MB/s)", conf.typeString, numTest / (sw.elapsed / 1000.0), numTest, sw.elapsed, mbps);
	
	return 0;
}