split.h 1.61 KB
/*
 * split.h
 *
 *  Created on: 19/02/2015
 *      Author: Pedro
 */

#ifndef SRC_SPLIT_H_
#define SRC_SPLIT_H_

#include <stdbool.h>

#include "CL/cl.h"
#include "CL/cl_platform.h"

#include "devices.h"
#include "kernels/cl_constraints.h"
#include "kernels/cl_variables.h"
#include "config.h"

typedef struct platf_args {
	cl_platform_id platform_id;		// OpenCL platform ID
	cl_uint n_devs;					// Number of devices on this OpenCL platform
} platf_args;

typedef struct threads_data {
	unsigned int depth;		// Tree expansion depth needed to get n_ss disjoint search spaces
	unsigned int n_ss;		// Number of sub-search spaces created
	unsigned int *next_str;	// Index in stores where the next unexplored sub-search space is placed (atomic read and write)
	cl_uint *val_to_opt;	// Max value on the domain of the variable to optimize (atomic read and write)
	unsigned char *sol_found;	// To set to 1 when only one solution is wanted and is found (atomic read and write)
	device_info *dev_info;		// Information about the device to use
	device_args *dev_args;		// Device arguments (buffers, etc.)
	platf_args *platform_args;	// All platforms info
	unsigned int dev_number;	// Number of this device on dev_info
	bool local;		// If local memory of each device should be used
} threads_data;

cl_ulong solve_CSP();
bool filter_CSP();

void* solve_on_device(void *thread_arg);

void set_next_block_size(device_info *dev_info, unsigned int dev_idx, unsigned int n_ss, unsigned int *last_str_explored);
void split_ss(unsigned int *depth, unsigned int *n_ss, unsigned int n_vs_to_label);

#endif /* SRC_SPLIT_H_ */