Пример #1
0
/**
 * HOW TO USE THIS SHIT CODE? SEE BELOW!
 */
int main() {
  column c1,c2,c3, c4;
  column* cols;
  header h1;
  line l1;

  strncpy(c1.name, "struct member", 80);
  strncpy(c2.name, "Description", 80);
  strncpy(c3.name, "Value", 80);
  strncpy(c4.name, "Offset", 80);

  c1.size = c3.size = c4.size = 0;
  c2.size = 0;
  h1.n_col = 4;
  cols = malloc(4 * sizeof(column));
  cols[0] = c1;
  cols[1] = c2;
  cols[2] = c3;
  cols[3] = c4;
  
  h1.col = cols;
  
  print_table_header(&h1, 0, 80);

  l1.n_col = 4;
  l1.col = cols;

  print_table_line(&l1, 0, 80);

  free(h1.col);
  

  return 0;
}
Пример #2
0
/**
 * Initialize buffer and start MPI benchmark
 */
int network_bandwidth_test(mpi_test_t arg) {
	unsigned_huge data_size = arg.data_size;

	unsigned_huge array_length = data_size / sizeof(TYPE);
	if((int)array_length < 0) {
		_printf("network_bandwidth_test has got invalid argument %d\n", data_size);
		_printf("(MPI_Send / MPI_Recv convert to int negative)\n");
		return -1;
	}
	arg.array_length = array_length;
	MPI_Status status;
	TYPE *buffer;

	unsigned_huge bytes_sent = array_length * sizeof(TYPE);
	buffer = (TYPE *) malloc(bytes_sent);
	if(buffer == NULL) {
		char *size_str = sprint_num_bytes(bytes_sent);
		_printf("network_bandwidth_test: cannot allocate %Lu bytes (%s) for buffer\n", bytes_sent, size_str);
		free(size_str);
		return -1;
	}
	arg.buffer = buffer;
	soft_barrier(MPI_COMM_WORLD, 1000);

	unsigned repetitions = mpi_calculate_repetitions(arg);
	unsigned long steps = mpi_calculate_steps(arg);
	arg.steps = steps;

	char *data_size_str = sprint_num_bytes(bytes_sent);
	double time;
	unsigned_huge r;
	statistic_t network_bandwidth = STATISTIC_T_INIT;
	statistic_t network_time = STATISTIC_T_INIT;

	if(world_size >= arg.processes) {
		for(r=0; r<config.warmup; r++) {
			arg.testfn(&arg);
		}
		for(r=0; r<repetitions; r++) {
			time = arg.testfn(&arg);
			time /= steps;
			double bandwidth = ((double) (bytes_sent)) / MB / time;
			calculate_statistics_iterative(&network_bandwidth, bandwidth);
			calculate_statistics_iterative(&network_time, time);
		}
	}

	if(world_rank == 0) {
		print_table_cell("%{world size}5d, ", world_size);
		print_table_cell("%{processes}5d, ", arg.processes);
		print_table_cell("%{repetitions}5d, ", repetitions);
		print_table_cell("%{steps}10Lu, ", steps);
		print_table_cell("%{datasize}10Lu, ", data_size);
		print_table_cell("%{bytes}6s, ", data_size_str);

		print_table_cell("%{bandwidth}" PRECISSION "f, ", network_bandwidth.mean);
		print_table_cell("%{bandwidth deviation}" PRECISSION "f, ", network_bandwidth.deviation);

		print_table_cell("%{time}" PRECISSION "f, ", network_time.mean);
		print_table_cell("%{time deviation}" PRECISSION "f, ", network_time.deviation);
		print_table_line();
	}

	free(data_size_str);
	free(buffer);
	//free(results);
	return 0;
}