Example #1
0
int main(int argc, char **argv)
{
	unsigned block_count;

	// Initialize the MPI environment
	MPI_Init(NULL, NULL);

	// Get the number of processes
	int proc_cnt;
	MPI_Comm_size(MPI_COMM_WORLD, &proc_cnt);

	// Get the rank of the process
	int proc_id;
	MPI_Comm_rank(MPI_COMM_WORLD, &proc_id);

	//~ printf("Hello world from processor %d out of %d processors\n", proc_id, proc_cnt);

	int width, height, seed;
	if(argc < 4) {
		printf("run program: %s WIDTH HEIGHT SEED\n", argv[0]);
		return 1;
	}
	//~ printf("enter width: ");
	//~ scanf("%d", &width);
	//~ printf("enter height: ");
	//~ scanf("%d", &height);
	//~ printf("enter seed: ");
	//~ scanf("%d", &seed);
	
	sscanf(argv[1], "%d", &width);
	sscanf(argv[2], "%d", &height);
	sscanf(argv[3], "%d", &seed);
	
	//~ Tetromino_block * all_blocks = generate_blocks(WIDTH, HEIGHT, SEED, block_count);
	Tetromino_block * all_blocks = generate_blocks(width, height, seed, block_count);
	//~ Problem * problem = init_problem(all_blocks, block_count, WIDTH, HEIGHT, proc_cnt, proc_id);
	Problem * problem = init_problem(all_blocks, block_count, width, height, proc_cnt, proc_id);
	unsigned * parcial_solution = new unsigned[problem->cells/TETROMINO_SIZE];
	solve(problem, parcial_solution, 0);
	int sig_index = problem->tree->best_posib_sig;
	if(problem->best_solution_src == problem->proc_id) {
		usleep(100);
		printf("\n----- END ----- END ----- END ----- END ----- END ----- END ----- END -----\n");
		printf("width: %d, height %d, seed %d\n", width, height, seed);
		printf("best posible price %f, disb: %d, level %d\n", problem->tree->best_posib_price, problem->tree->signatures[sig_index].disbalance, problem->tree->signatures[sig_index].level);
		print_best_solution(problem);
	}

	delete_problem(problem);
	delete [] parcial_solution;
	delete [] all_blocks;

	// Finalize the MPI environment.
	MPI_Finalize();

	return 0;
}
int main(STARPU_ATTRIBUTE_UNUSED int argc,
	STARPU_ATTRIBUTE_UNUSED char **argv)
{
	int ret;

	if (argc < 2)
	{
		FPRINTF(stderr, "usage : %s filename [tile size]\n", argv[0]);
		exit(-1);
	}

	if (argc == 3)
	{
		/* third argument is the tile size */
		char *argptr;
		r = strtol(argv[2], &argptr, 10);
		c = r;
	}

	inputfile = argv[1];

	/* start the runtime */
	ret = starpu_init(NULL);
	if (ret == -ENODEV)
		return 77;
	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");

	sem_init(&sem, 0, 0U);

	init_problem();

	launch_spmv_codelets();

	sem_wait(&sem);
	sem_destroy(&sem);

	unregister_data();
	print_results();

	double totalflop = 2.0*c*r*totaltasks;

	double timing = end - start;
	FPRINTF(stderr, "Computation took (in ms)\n");
	FPRINTF(stdout, "%2.2f\n", timing/1000);
	FPRINTF(stderr, "Flop %e\n", totalflop);
	FPRINTF(stderr, "GFlops : %2.2f\n", totalflop/timing/1000);

	return 0;
}
Example #3
0
glpk_wrapper::glpk_wrapper(box const & b, std::unordered_set<Enode *> const & es)
    : domain(b), lp(glp_create_prob()), solver_type(SIMPLEX), changed(true) {
    init_problem();
    add(es);
}
Example #4
0
glpk_wrapper::glpk_wrapper(box const & b)
    : domain(b), lp(glp_create_prob()), solver_type(SIMPLEX), changed(true) {
    init_problem();
}