cl_aux_functions.h
5.73 KB
1
2
3
4
5
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
58
59
60
61
62
63
64
65
66
67
68
69
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* aux_functions.h
*
* Created on: 06/03/2016
* Author: Pedro
*/
#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
* t - next tree level to fill
*/
#define GET_CURR_TREE_LEVEL_IDX(t) ((t) * CL_N_VS)
/*
* Return the first index of the previous tree level
* t - next tree level to fill
*/
#define GET_PREV_TREE_LEVEL_IDX(t) (((t) - 1) * CL_N_VS)
#ifndef __OPENCL_VERSION__
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
void v_get_id_to_label(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);
#endif
#if CL_WORK == CL_OPT
void upd_opt_var_hist_g(__global DOMAIN_ *hist, __global unsigned int *val_to_opt TTL_CTR);
#endif
#if CL_N_SHARED_SS > 0
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);
#endif
#if CL_CS_IGNORE
void clear_cs_ignore(__global char *cs_ignore);
#endif
#if CL_PRINT_CSP
void cs_print_type_device(CL_CS_MEM cl_constr* cs);
void print_label_heur_device(char l);
void print_assign_heur_device(char a);
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
#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
, CL_INTS_MEM int* c_consts
#endif
#if CL_D_TYPE == CL_BITMAP
, CL_B_DS_MEM cl_bitmap* b_ds
#endif
);
#endif
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
#if CL_D_TYPE == CL_BITMAP
, CL_B_DS_MEM cl_bitmap *b_ds
#endif
#if (CS_MAXIMIZE == 1 || CS_MINIMIZE == 1) && CL_WORK == CL_OPT
, __global unsigned int *val_to_opt_g
#endif
, __global int *ss_aux_mem TTL_CTR);
#endif
#endif /* SRC_KERNELS_CL_AUX_FUNCTIONS_H_ */