static void init_set(unsigned set)
{
	long int r;
	int i;

	permute_array(buffers[set], num_buffers, exchange_buf);

	if (current_set == 1 && options.gpu_busy_load == 0) {
		gpu_busy_load++;
		if (gpu_busy_load > 10)
			gpu_busy_load = 6;
	}

	for (i = 0; i < num_buffers; i++) {
		r = random();
		if ((r & 3) != 0)
		    continue;
		r >>= 2;

		if ((r & 3) != 0)
			buffers[set][i].tiling = I915_TILING_X;
		else
			buffers[set][i].tiling = I915_TILING_NONE;
		r >>= 2;
		if (options.forced_tiling >= 0)
			buffers[set][i].tiling = options.forced_tiling;

		if (buffers[set][i].tiling == I915_TILING_NONE) {
			/* min 64 byte stride */
			r %= 8;
			buffers[set][i].stride = 64 * (1 << r);
		} else if (IS_GEN2(devid)) {
			/* min 128 byte stride */
			r %= 7;
			buffers[set][i].stride = 128 * (1 << r);
		} else {
			/* min 512 byte stride */
			r %= 5;
			buffers[set][i].stride = 512 * (1 << r);
		}

		sanitize_stride(&buffers[set][i]);

		set_tiling(buffers[set][i].bo,
			   &buffers[set][i].tiling,
			   buffers[set][i].stride);

		if (options.trace_tile != -1 && i == options.trace_tile/options.tiles_per_buf)
			printf("changing buffer %i containing tile %i: tiling %i, stride %i\n", i,
					options.trace_tile,
					buffers[set][i].tiling, buffers[set][i].stride);
	}
}
Example #2
0
/******************************** Determinant *******************************/
double determinant_dt(const matrix_dt *A)
{
	/* Brute force determinant calculation. Nothing elegant (or fast) about
	 * it.
	 */
	double det = 0.0;
	uint32_t *p;
	uint32_t i;

	if(A->rows != A->cols)
		return 0;

	if(!(p = malloc(sizeof(p[0]) * A->cols)))
		return 0;

	for(i = 0; i < A->cols; i++)
		p[i] = i;

	do {
		double product;

		if(array_inversions(p, A->cols) & 0x1) {
			/* odd - negative */
			product = -1.0;
		} else {
			/* even - positive */
			product = 1.0;
		}

		for(i = 0; i < A->cols; i++) {
			product *= A->values[p[i] * A->cols + i];
		}

		det += product;

	} while(permute_array(p, A->rows));

	free(p);
	return det;
}
int main(int argc, char **argv)
{
	int i, j;
	unsigned *current_permutation, *tmp_permutation;
	pid_t signal_helper = -1;

	drm_fd = drm_open_any();
	devid = intel_get_drm_devid(drm_fd);

	parse_options(argc, argv);

	/* start our little helper early before too may allocations occur */
	signal(SIGUSR1, SIG_IGN);
	if (options.use_signal_helper)
		signal_helper = fork_signal_helper();

	init();

	check_render_copyfunc();

	tile_permutation = malloc(num_total_tiles*sizeof(uint32_t));
	current_permutation = malloc(num_total_tiles*sizeof(uint32_t));
	tmp_permutation = malloc(num_total_tiles*sizeof(uint32_t));
	assert(tile_permutation);
	assert(current_permutation);
	assert(tmp_permutation);

	fan_out();

	for (i = 0; i < options.total_rounds; i++) {
		printf("round %i\n", i);
		if (i % 64 == 63) {
			fan_in_and_check();
			printf("everything correct after %i rounds\n", i + 1);
		}

		target_set = (current_set + 1) & 1;
		init_set(target_set);

		for (j = 0; j < num_total_tiles; j++)
			current_permutation[j] = j;
		permute_array(current_permutation, num_total_tiles, exchange_uint);

		copy_tiles(current_permutation);

		memcpy(tmp_permutation, tile_permutation, sizeof(unsigned)*num_total_tiles);

		/* accumulate the permutations */
		for (j = 0; j < num_total_tiles; j++)
			tile_permutation[j] = current_permutation[tmp_permutation[j]];

		current_set = target_set;
	}

	fan_in_and_check();

	fprintf(stderr, "num failed tiles %u, max incoherent bytes %lu\n",
		stats.num_failed, stats.max_failed_reads*sizeof(uint32_t));

	intel_batchbuffer_free(batch);
	drm_intel_bufmgr_destroy(bufmgr);

	close(drm_fd);

	if (signal_helper != -1)
		kill(signal_helper, SIGQUIT);

	return 0;
}