Beispiel #1
0
static __isl_give isl_printer *allocate_device_arrays(
	__isl_take isl_printer *p, struct gpu_prog *prog)
{
	int i;

	for (i = 0; i < prog->n_array; ++i) {
		struct gpu_array_info *array = &prog->array[i];

		if (!gpu_array_requires_device_allocation(&prog->array[i]))
			continue;
		p = ppcg_ast_expr_print_macros(array->bound_expr, p);
	
		if(print_device_arrays_or_not(&prog->array[i]))
		{
			p = isl_printer_start_line(p);
			p = isl_printer_print_str(p,
				"cudaCheckReturn(cudaMalloc((void **) &dev_");
			p = isl_printer_print_str(p, prog->array[i].name);
			p = isl_printer_print_str(p, ", ");
			p = gpu_array_info_print_size(p, &prog->array[i]);
			p = isl_printer_print_str(p, "));");
			p = isl_printer_end_line(p);
		}
	}
	p = isl_printer_start_line(p);
	p = isl_printer_end_line(p);
	return p;
}
Beispiel #2
0
/* Free the accessed device arrays.
 */
static __isl_give isl_printer *opencl_release_device_arrays(
	__isl_take isl_printer *p, struct gpu_prog *prog)
{
	int i;

	for (i = 0; i < prog->n_array; ++i) {
		struct gpu_array_info *array = &prog->array[i];
		if (!gpu_array_requires_device_allocation(array))
			continue;

		p = release_device_array(p, array);
	}
	return p;
}
Beispiel #3
0
static __isl_give isl_printer *declare_device_arrays(__isl_take isl_printer *p,
	struct gpu_prog *prog)
{
	int i;

	for (i = 0; i < prog->n_array; ++i) {
		if (!gpu_array_requires_device_allocation(&prog->array[i]))
			continue;

		p = declare_device_array(p, &prog->array[i]);
	}
	p = isl_printer_start_line(p);
	p = isl_printer_end_line(p);
	return p;
}
Beispiel #4
0
static __isl_give isl_printer *opencl_declare_device_arrays(
	__isl_take isl_printer *p, struct gpu_prog *prog)
{
	int i;

	for (i = 0; i < prog->n_array; ++i) {
		if (!gpu_array_requires_device_allocation(&prog->array[i]))
			continue;
		p = isl_printer_start_line(p);
		p = isl_printer_print_str(p, "cl_mem dev_");
		p = isl_printer_print_str(p, prog->array[i].name);
		p = isl_printer_print_str(p, ";");
		p = isl_printer_end_line(p);
	}
	p = isl_printer_start_line(p);
	p = isl_printer_end_line(p);
	return p;
}
Beispiel #5
0
static __isl_give isl_printer *free_device_arrays(__isl_take isl_printer *p,
	struct gpu_prog *prog)
{
	int i;

	for (i = 0; i < prog->n_array; ++i) {
		if (!gpu_array_requires_device_allocation(&prog->array[i]))
			continue;
		if(print_device_arrays_or_not(&prog->array[i]))
		{
			p = isl_printer_start_line(p);
			p = isl_printer_print_str(p, "cudaCheckReturn(cudaFree(dev_");
			p = isl_printer_print_str(p, prog->array[i].name);
			p = isl_printer_print_str(p, "));");
			p = isl_printer_end_line(p);
		}
	}
	return p;
}