README.md

Parallel heterogeneous architecture constraint toolkit (PHACT) is a complete solver, capable of using all the devices compatible with OpenCL of a machine to solve a CSP. It can load CSPs implemented in C according to PHACT's interface, or modeled in MiniZinc or FlatZinc and whose variables domains are constituted by positive integers or booleans.

List of accepted arguments: -D [GPU|CPU|ACC][:n][/[wg]/[wi]] - Select the device/s to use. Examples: -D CPU:1/64/1 -D GPU:2 -D ACC//1 - Use first CPU with 64 work-groups and 1 work-item per work-group, second GPU with the default number of work-groups and of work-items, and all accelerators with default number of work-groups and one work-item per work-group; -D CPU:1 -D GPU:1 -INTERVALS - Use first CPU and first GPU with INTERVAL domains; -D CPU -D GPU - Use all GPUs and all CPUs with default number of work-groups and work-items; If none -D argument is introduced, all the devices compatible with OpenCL will be used.

-E [QUEENS | COSTAS | GOLOMB | SUDOKU | ALL-DIFF | QAP | LANGFORD | STEINER | LATIN | ALL-INTERVAL | MARKET-SPLIT | SCHURS] - Select one of the sample CSPs implemented through PHACT's interface; -FZN /home/user/csp.fzn - Solve the Flatzinc model in the file "/home/user/csp.fzn". If only the mame of the file is given, it will be searched in src/csps/csp.fzn. Flex and Bison programs are required; -MZN /home/user/csp.mzn /home/user/csp.dzn - Solve the Minizinc model in the files "/home/user/csp.mzn" and "/home/user/csp.dzn". If only the mame of the files is given, they will be searched in src/csps/csp.Xzn. Mzn2fzn, Flex and Bison programs are required.

-MZN /home/user/csp.mzn [/home/user/csp.dzn] -MZN2FZN-ONLY - Only converts the MZN file in "/home/user/csp.mzn" and "/home/user/csp.dzn" to the FZN file "/home/user/csp.fzn". If only the mame of the file is given, it will be searched in src/csps/csp.Xzn. Mzn2fzn program is required.

(int) - CSP dimension. "(int)" should be replaced by each dimension of the CSP to solve. Not used when solving a Minizinc or Flatzinc model.

[-COUNT|-ONE|-OPT] - Select what must be done with the CSP. When solving FlatZinc models, it overrides the model selection: -COUNT - Count all the solutions; -ONE - Find one solution. Default for CSPs modeled with PHACT C interface; -OPT - Do optimization.

[-INTERVALS] - Use interval representation for domains, instead of bitmaps.

[-N-SS n] - Number of sub-search spaces to create. "n" should be replaced by the number of sub-search spaces to create. If not present, the default number of sub-search spaces will be created;

[-ANTI-FIRST-FAIL | -FIRST-FAIL | -INPUT-ORDER | -LARGEST | -MAX-REGRET | -MOST-CONSTRAINED | -OCCURRENCE | -SMALLEST] - Method to select the variable to label: -ANTI-FIRST-FAIL - Select the variable to label that has more values in its domain; -FIRST-FAIL - Select the variable to label that has less values in its domain; -LARGEST - Select the variable to label that has the largest value in its domain; -INPUT-ORDER - Select the variable to label by the order on which they were created. Default; -MAX-REGRET - Select the variable to label that has the largest difference between the two smallest values in its domain; -MOST-CONSTRAINED - Select the variable to label that has the smallest domain, breaking ties using the number of constrains; -OCCURRENCE - Select the variable to label that is more constrained; -SMALLEST - Select the variable to label that has the smallest value in its domain.

[-INDOMAIN-INTERVAL | -INDOMAIN-MAX | -INDOMAIN-MIDDLE | -INDOMAIN-MEDIAN | -INDOMAIN-MIN | -INDOMAIN-REVERSE-SPLIT | -INDOMAIN-SPLIT] - Method to select the value to assign to the variable for labeling: -INDOMAIN-INTERVAL - Select the first contiguous interval or, if none, select half of the domain; -INDOMAIN-MAX - Select the maximum value to assign; -INDOMAIN-MIDDLE - Select the mean value of the domain bounds; -INDOMAIN-MEDIAN - Select the median value of the domain values; -INDOMAIN-MIN - Select the minimum value to assign. Default; -INDOMAIN-REVERSE-SPLIT - Splits the domain about half and tries the second half; -INDOMAIN-SPLIT - Splits the domain about half and tries the first half.

-STATS - Print statistics about the solving process; -PRINT-SOLUTIONS - Print all the solutions (only available when using only one thread per device); -PRINT-CSP - Before starting the exploration, prints all the variables with their domains, the constraints and the relation between them; -V - Print more information and timings about what is being done by each device; -Q - Print only the best solution, the solution, or the number of solutions, depending if optimizing, searching for one solution or counting the number of solutions;

-H - Show this information.

Notes on compilation: To compile PHACT execute one of the following commands on folder "PHACT/Debug": make all - To solve CSPs with variables whose domains have values between 0 and 1023; make all CFLAGS="-D BITS=n" - To solve CSPs with variables whose domains have values between 0 and n. When recompiling PHACT to change CL_BITS value, please run "make clean" before; make all CFLAGS="-D COMPILE_FZN=0" - Required when the programs mzn2fzn, flex or bison are not available. Minizinc and Flatzinc interpreter will not be available.

Note on execution: The OpenCL drivers implemented by some vendors for their devices will try to vectorize the kernel. When using PHACT in some devices, that may result in crashing the OpenCL compiler, or in a poor performance of PHACT. For that motive, it is recommended to disable this OpenCL feature by introducing "CL_CONFIG_USE_VECTORIZER=false" at the beginning of PHACT execution command.

Execution examples: For counting the number of solutions of the Costas Array 10 problem using all the devices compatible with OpenCL on the running machine, execute the following command on folder "PHACT/Debug": ./PHACT -E COSTAS 10 -COUNT

For finding one solution for the n-Queens 30 problem using all the GPUs compatible with OpenCL on the running machine, execute the following command on folder "PHACT/Debug": ./PHACT -E QUEENS 30 -D GPU

For finding one solution for a new CSP modeled in the file "/src/csps/CSP.c" and using the CPU on the running machine, after recompiling PHACT,execute the following command on folder "PHACT/Debug": ./PHACT -D CPU

For solving the CSP modeled in the FlatZinc file "PHACT/Debug/src/csps/CSP.fzn" file using all the GPUs compatible with OpenCL on the running machine, execute the following command on folder "PHACT/Debug": ./PHACT CSP.fzn -D GPU

For solving the CSP modeled in the MiniZinc files "PHACT/Debug/src/csps/CSP.mzn" and "PHACT/Debug/src/csps/CSP.dzn" files using all the devices compatible with OpenCL on the running machine, execute the following command on folder "PHACT/Debug": ./PHACT -MZN CSP.mzn CSP.dzn