/* * domains.h * * Created on: 06/01/2017 * Author: Pedro */ #ifndef SRC_DOMAINS_H_ #define SRC_DOMAINS_H_ // Host configuration #ifndef __OPENCL_VERSION__ #include #include #include #include "CL/cl.h" #include "CL/cl_platform.h" // when interval domains are used typedef cl_ushort2 interval; // [16-bits;16-bits] <-> [min,max] #ifndef BITS #define BITS 1024 // Bitmap size used on host #endif #ifndef H_WORD #define H_WORD 64 // Size of words used on host #endif // host word parameters #if H_WORD < 33 #define H_ONE 1U // 32 bits bitmap with value 1 in host #define H_DIV 5 // right shift value to apply division to 32 bits bitmap in host #define H_WORD_TYPE cl_uint // single 32 bits word bitmap type in host #else #define H_ONE 1ULL // 64 bits bitmap with value 1 in host in host #define H_DIV 6 // right shift value to apply division to 64 bits bitmap in host #define H_WORD_TYPE cl_ulong // single 64 bits word bitmap type in host #endif #define H_ALL_ONES ((H_WORD_TYPE) -1) // 32 or 64 bits bitmap fill with 1 in host #if BITS < 33 #define H_N_WORDS 1 // number of words that represent the bitmap (CSP variable domain) in host #define H_BITS 32 // number of bits of one bitmap word in host #elif BITS < 65 #if H_WORD == 64 #define H_N_WORDS 1 // number of words that represent the bitmap (CSP variable domain) in host #else #define H_N_WORDS 2 // number of words that represent the bitmap (CSP variable domain) in host #endif #define H_BITS 64 // number of bits of one bitmap word in host #else #if (BITS % 64) > 0 #define H_BITS (BITS / 64 * 64 + 64) // number of bits of one bitmap word in host #else #define H_BITS (BITS / 64 * 64) // number of bits of one bitmap word in host #endif #define H_N_WORDS H_BITS / H_WORD // number of words that represent the bitmap (CSP variable domain) in host #endif #if H_N_WORDS == 1 typedef H_WORD_TYPE bitmap; // bitmap of type cl_uint or cl_ulong in host #else typedef H_WORD_TYPE bitmap[H_N_WORDS]; // bitmap with an array of cl_uint or cl_ulong in host #endif // never used. Just for compilation and syntax correction #define CL_BITMAP 0 #define CL_INTERVAL 1 #define CL_D_TYPE CL_BITMAP #define DOMAIN_ cl_bitmap #define CL_D_MIN 0 // 32 bits 1 word #define CL_WORD 32 #define CL_BITS 32 #define CL_D_MAX 32 #define CL_ONE_ 1U #define CL_DIV 5 #define CL_REM 31 #define CL_N_WORDS 1 #define CL_WORD_TYPE cl_uint typedef CL_WORD_TYPE cl_bitmap; /* // 64 bits 1 word #define CL_WORD 64 #define CL_BITS 64 #define CL_D_MAX 64 #define CL_ONE_ 1UL #define CL_DIV 6 #define CL_REM 63 #define CL_N_WORDS 1 #define CL_WORD_TYPE cl_ulong typedef CL_WORD_TYPE cl_bitmap; */ /* // 64 bits 2 words #define CL_WORD 64 #define CL_BITS 128 #define CL_D_MAX 128 #define CL_ONE_ 1UL #define CL_DIV 6 #define CL_REM 63 #define CL_N_WORDS 2 #define CL_WORD_TYPE cl_ulong typedef CL_WORD_TYPE cl_bitmap[CL_N_WORDS]; */ #define CL_ALL_ONES ((CL_WORD_TYPE) -1) // Device configuration (used during kernel compilation) #else // Choose domains size on OpenCL kernel compilation // host word parameters #if CL_WORD < 33 #define CL_ONE_ 1U // 32 bits bitmap with value 1 in device #define CL_DIV 5 // right shift value to apply division to 32 bits bitmap in device #define CL_REM 31 // right shift value to apply multiplication to 32 bits bitmap in device #define CL_WORD_TYPE uint // single32 bits word bitmap type in device #else #define CL_ONE_ 1UL // 64 bits bitmap with value 1 in device #define CL_DIV 6 // right shift value to apply division to 64 bits bitmap in device #define CL_REM 63 // right shift value to apply multiplication to 64 bits bitmap in device #define CL_WORD_TYPE ulong // single 64 bits word bitmap type in device #endif #define CL_ALL_ONES ((CL_WORD_TYPE) -1) // 32 or 64 bits bitmap fill with 1 in device #if CL_BITS < 33 #define CL_N_WORDS 1 // number of words that represent the bitmap (CSP variable domain) in host #elif CL_BITS < 65 #if CL_WORD == 32 #define CL_N_WORDS 2 // number of words that represent the bitmap (CSP variable domain) in host #else #define CL_N_WORDS 1 // number of words that represent the bitmap (CSP variable domain) in host #endif #else #define CL_N_WORDS (CL_BITS / CL_WORD) // number of words that represent the bitmap (CSP variable domain) in device #endif #if CL_N_WORDS == 1 typedef CL_WORD_TYPE cl_bitmap; // single 32 or 64 bits word bitmap type in device #else typedef CL_WORD_TYPE cl_bitmap[CL_N_WORDS]; // single 64 bits word bitmap type in device #endif // types of representation of the domain of the CSP variables in the device #define CL_BITMAP 0 // bitmaps #define CL_INTERVAL 1 // single interval [16-bits;16-bits] = [min;max] // default type of representation of the domain of the CSP variables in the device #ifndef CL_D_TYPE #define CL_D_TYPE CL_BITMAP #endif #if CL_D_TYPE == CL_BITMAP // bitmap representation structures #define DOMAIN_ cl_bitmap #define VARS cl_var_bitmap #define VARS_PROP cl_var_p_bitmap #elif CL_D_TYPE == CL_INTERVAL // interval representation structures typedef ushort2 interval; #define DOMAIN_ interval #define VARS cl_var_interval #define VARS_PROP cl_var_p_interval #endif // default maximum domain value #ifndef CL_D_MAX #define CL_D_MAX 32 #endif // default minimum domain value #ifndef CL_D_MIN #define CL_D_MIN 0 #endif #endif #endif /* SRC_DOMAINS_H_ */