Blame view

src/kernels/cl_aux_functions.h 5.73 KB
94b2b13d   Pedro Roque   PHACT source
1
2
3
4
/*
 * aux_functions.h
 *
 *  Created on: 06/03/2016
4d26a735   Pedro Roque   Increased recogni...
5
 *      Author: Pedro
94b2b13d   Pedro Roque   PHACT source
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 */

#ifndef SRC_KERNELS_CL_AUX_FUNCTIONS_H_
#define SRC_KERNELS_CL_AUX_FUNCTIONS_H_

#ifndef __OPENCL_VERSION__
#include <sys/types.h>

#include "../config.h"
#include "../domains.h"
#include "cl_ttl.h"
#include "cl_variables.h"
#include "cl_constraints.h"
#endif

#define CL_PRINT_CSP 0	// 1 to print the CSP as received in the device, 0 to not print

// For shared SS flags
#define EMPTY 0
#define FILLED 1

#define LW_L(a) ((__local unsigned int *)a)[0]	// lower 32bits - lower word
#define UW_L(a) ((__local unsigned int *)a)[1]	// upper 32bits - upper word
#define LW_G(a) ((__global unsigned int *)a)[0]	// lower 32bits - lower word
#define UW_G(a) ((__global unsigned int *)a)[1]	// upper 32bits - upper word

#if CL_CS_IGNORE == 1

#define CS_IGNORE_CALL , cs_ignore
#define CS_IGNORE_FUNC , __global char* cs_ignore

#else

#define CS_IGNORE_CALL
#define CS_IGNORE_FUNC

#endif

#if CL_STATS == 1

#define PROPAGATED_CALL , &propagated
#define PROPAGATED_FUNC , bool* propagated

#else

#define PROPAGATED_CALL
#define PROPAGATED_FUNC

#endif

/*
 * Return the first index of the tree level that is not filled yet
4d26a735   Pedro Roque   Increased recogni...
58
 * t - next tree level to fill
94b2b13d   Pedro Roque   PHACT source
59
60
61
62
63
 */
#define GET_CURR_TREE_LEVEL_IDX(t) ((t) * CL_N_VS)

/*
 * Return the first index of the previous tree level
4d26a735   Pedro Roque   Increased recogni...
64
 * t - next tree level to fill
94b2b13d   Pedro Roque   PHACT source
65
66
67
68
69
 */
#define GET_PREV_TREE_LEVEL_IDX(t) (((t) - 1) * CL_N_VS)

#ifndef __OPENCL_VERSION__

4d26a735   Pedro Roque   Increased recogni...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
void v_add_to_prop(CL_MEMORY unsigned short *vs_id_to_prop_, CL_MEMORY VARS_PROP *vs_prop_, int v_id_to_prop);
void v_get_id_to_prop(CL_MEMORY unsigned short *vs_id_to_prop_, CL_MEMORY VARS_PROP *vs_prop_, unsigned int *prop_v_id TTL_CTR);

#if CL_FZN_SEQ && CL_FZN_SEQ_N_LABELS > 1

void v_get_id_to_label(CL_MEMORY VARS_PROP *vs_prop_, CL_VS_MEM VARS *vs, unsigned int *prop_v_id, int *last_label_h_idx, __global int *label_hs TTL_CTR);

void v_get_id_to_label_anti_first_fail(CL_MEMORY VARS_PROP *vs_prop_, CL_VS_MEM VARS *vs, unsigned int *prop_v_id TTL_CTR);
void v_get_id_to_label_first_fail(CL_MEMORY VARS_PROP *vs_prop_, CL_VS_MEM VARS *vs, unsigned int *prop_v_id TTL_CTR);
void v_get_id_to_label_input_order(CL_MEMORY VARS_PROP *vs_prop_, CL_VS_MEM VARS *vs, unsigned int *prop_v_id TTL_CTR);
void v_get_id_to_label_largest(CL_MEMORY VARS_PROP *vs_prop_, CL_VS_MEM VARS *vs, unsigned int *prop_v_id TTL_CTR);
void v_get_id_to_label_max_regret(CL_MEMORY VARS_PROP *vs_prop_, CL_VS_MEM VARS *vs, unsigned int *prop_v_id TTL_CTR);
void v_get_id_to_label_most_constrained(CL_MEMORY VARS_PROP *vs_prop_, CL_VS_MEM VARS *vs, unsigned int *prop_v_id TTL_CTR);
void v_get_id_to_label_occurrence(CL_MEMORY VARS_PROP *vs_prop_, CL_VS_MEM VARS *vs, unsigned int *prop_v_id TTL_CTR);
void v_get_id_to_label_smallest(CL_MEMORY VARS_PROP *vs_prop_, CL_VS_MEM VARS *vs, unsigned int *prop_v_id TTL_CTR);

void v_assign(CL_MEMORY VARS_PROP *v, __global DOMAIN_ *hist, __global int *hist_labeleds_n_vals, CL_VS_MEM VARS *v_g);

void v_assign_interval(CL_MEMORY VARS_PROP *v, __global DOMAIN_ *hist, __global int *hist_labeleds_n_vals);
void v_assign_max(CL_MEMORY VARS_PROP *v, __global DOMAIN_ *hist, __global int *hist_labeleds_n_vals);
void v_assign_median(CL_MEMORY VARS_PROP *v, __global DOMAIN_ *hist, __global int *hist_labeleds_n_vals);
void v_assign_middle(CL_MEMORY VARS_PROP *v, __global DOMAIN_ *hist, __global int *hist_labeleds_n_vals);
void v_assign_min(CL_MEMORY VARS_PROP *v, __global DOMAIN_ *hist, __global int *hist_labeleds_n_vals);
void v_assign_reverse_split(CL_MEMORY VARS_PROP *v, __global DOMAIN_ *hist, __global int *hist_labeleds_n_vals);
void v_assign_split(CL_MEMORY VARS_PROP *v, __global DOMAIN_ *hist, __global int *hist_labeleds_n_vals);

#else

94b2b13d   Pedro Roque   PHACT source
98
void v_get_id_to_label(CL_MEMORY VARS_PROP* vs_prop_, CL_VS_MEM VARS* vs, unsigned int* prop_v_id TTL_CTR);
4d26a735   Pedro Roque   Increased recogni...
99
100
101
102

void v_assign(CL_MEMORY VARS_PROP* v, __global DOMAIN_* hist, __global int* hist_labeleds_n_vals);

#endif
94b2b13d   Pedro Roque   PHACT source
103
104

#if CL_WORK == CL_OPT
4d26a735   Pedro Roque   Increased recogni...
105
void upd_opt_var_hist_g(__global DOMAIN_ *hist, __global unsigned int *val_to_opt TTL_CTR);
94b2b13d   Pedro Roque   PHACT source
106
107
108
#endif

#if CL_N_SHARED_SS > 0
4d26a735   Pedro Roque   Increased recogni...
109
110
111
112
void get_shared_store( __global DOMAIN_* shared_ss, __global int* shared_ss_flags, CL_MEMORY unsigned short* vs_id_to_prop_, CL_MEMORY VARS_PROP* vs_prop_,
		__global DOMAIN_* hist, int* hist_tree_level, __global int* hist_labeleds_id, __global int* hist_labeleds_n_vals, unsigned int* prop_v_id TTL_CTR);
void set_shared_store( __global DOMAIN_* shared_ss, __global int* shared_ss_flags, CL_MEMORY VARS_PROP* vs_prop_, int v_id, __global DOMAIN_* hist,
		__global int* hist_labeleds_n_vals TTL_CTR);
94b2b13d   Pedro Roque   PHACT source
113
114
115
#endif

#if CL_CS_IGNORE
4d26a735   Pedro Roque   Increased recogni...
116
void clear_cs_ignore(__global char *cs_ignore);
94b2b13d   Pedro Roque   PHACT source
117
118
119
120
#endif

#if CL_PRINT_CSP
void cs_print_type_device(CL_CS_MEM cl_constr* cs);
4d26a735   Pedro Roque   Increased recogni...
121
122
void print_label_heur_device(char l);
void print_assign_heur_device(char a);
94b2b13d   Pedro Roque   PHACT source
123
void print_CSP_device(CL_VS_MEM VARS* vs, CL_CS_MEM cl_constr* cs, CL_INTS_MEM int* cs_per_v_idx, CL_INTS_MEM int* vs_per_c_idx
4d26a735   Pedro Roque   Increased recogni...
124
#if CS_AT_LEAST == 1 || CS_AT_MOST == 1 || CS_AT_MOST_ONE == 1 || CS_EXACTLY == 1 || CS_INT_LIN_EQ == 1 || CS_INT_LIN_LE == 1 || CS_INT_LIN_NE == 1 || CS_INT_LIN_VAR == 1 || CS_ARRAY_INT_ELEMENT == 1  || CS_BOOL_LIN_EQ == 1 || CS_BOOL_LIN_LE == 1
94b2b13d   Pedro Roque   PHACT source
125
126
127
128
129
		, CL_INTS_MEM int* c_consts
#endif
#if CL_D_TYPE == CL_BITMAP
		, CL_B_DS_MEM cl_bitmap* b_ds
#endif
4d26a735   Pedro Roque   Increased recogni...
130
);
94b2b13d   Pedro Roque   PHACT source
131
132
#endif

4d26a735   Pedro Roque   Increased recogni...
133
134
135
void get_new_str( __global unsigned int *atoms, CL_VS_MEM VARS *vs, __global DOMAIN_ *hist, CL_MEMORY VARS_PROP *vs_prop_,
		CL_MEMORY unsigned short *vs_id_to_prop_, int *hist_tree_level, __global int *hist_labeleds_id, __global int *hist_labeleds_n_vals,
		unsigned int *prop_v_id
94b2b13d   Pedro Roque   PHACT source
136
#if CL_D_TYPE == CL_BITMAP
4d26a735   Pedro Roque   Increased recogni...
137
		, CL_B_DS_MEM cl_bitmap *b_ds
94b2b13d   Pedro Roque   PHACT source
138
139
#endif
#if (CS_MAXIMIZE == 1 || CS_MINIMIZE == 1) && CL_WORK == CL_OPT
4d26a735   Pedro Roque   Increased recogni...
140
		, __global unsigned int *val_to_opt_g
94b2b13d   Pedro Roque   PHACT source
141
#endif
4d26a735   Pedro Roque   Increased recogni...
142
		, __global int *ss_aux_mem TTL_CTR);
94b2b13d   Pedro Roque   PHACT source
143
144
145
146

#endif

#endif /* SRC_KERNELS_CL_AUX_FUNCTIONS_H_ */