Skip to content

dbenkhal/POPiX

Repository files navigation

POPiX: Floating to Fixed-Point Program Tuner

License: GPL v3

Java Python C

POPIX a precision tuning framework with the new feature of generating fixed- point formats. It returns solutions suitable – at bit-level – for the IEEE-754 floating-point arithmetic, the fixed-point arithmetic, and the MPFR library for non-standard precision.

💡 Features

  • Analyzes a program written in a c-like language annotated with the precision desired by the user on the output
  • Produces an under-approximation of the ranges of the variables by dynamic analysis (10000 runs)
  • Generates and solves an ILP problem based on a semantic modelling of the numerical errors propagation
  • Finds the minimal number of bits needed at bit-level and in floating-point arithmetic with an accuracy guarantee on the result
  • Internally calls a fixed-point library to convert the associated indications into ones that exploit fixed-point computations

🔧 Prerequisites

To use POPiX, you must install the following dependencies:

🔨 Running the Example

  • Go inside Examples folder, choose an example and copy its code to the file popix_src.

  • Next, open Main.java, add your the POPiX path on your machine at Line 15, and the path of the fixed-point library at Line 208

  • Compile POPiX with the following commands

java -cp /path-to-antlr-jar org.antlr.v4.Tool -Dlanguage=Java *.g4
javac -cp  /path-to-jars *.java  src/Boolean/*.java src/Constraint/*.java src/Expression/*.java src/Number/*.java src/Statement/*.java src/Main.java src/Util/*.java
  • Now you can run POPiX to tune precision of the program in popix_src using the following command
cd src
java -cp /path-to-jars/:. Main
  • if you encounter some compilation error, try to add the path to generated Grammar files to the classpath

    java -cp /path-to-jars/:/path-to-generated-Grammaire-files/:.Main
    
  • To modify the user's accuracy requirement or the output variable, it is enough to modify it directly in the require_nsb(variable, nb_bits) statement which is usually the last line of each of our programs.

Generated Files

Once the execution process is done successfully, this will generate the follwowing files:

  • popix_lab: program source annotated with control points at each node of the AST
  • constraints: prints the semantic equations generated for the program source
  • popix_output: Optimized program annotated with the couple |ufp, nsb| where ufp is the weight of the most ignificant bit of the variable and nsb is the optimized precision returned by POPiX (at bit-level)
  • popix_float.py: MPFR code to create a program that gives an exact result (i.e. 500 bits)
  • popix_mpfr.py: MPFR code generated with the optimized precisions returned by our POPiX
  • popix_output.c: fixed-point program written in C with the fixed-point library instructions

If you would like to test other examples, the programs must follow the grammar that implements the POPiX language. The grammar is available in the file Grammaire.g4.

Result Metrics

In addition to the generated files, the POPiX metrics after tuning will be displayed directly on the console. You will find:

  • Information about the LP solver: number of constraints/variables in the solver and whether an optimal solution was found
  • Total number of bits before/after tuning at bit-level
  • % of optimization at bit-level and in IEEE754 formats (FP16, FP32, FP64, FP128, FPxx)
  • Execution time measurements for each step of the POPiX workflow

📑 Cite This Work

POPiX version 1.0 is already available at GitHub release. Please cite our PoPix articles (CF'24, CoDIT'23, DASIP'22).

@inproceedings{KhalifaM24,
  author       = {Dorra {Ben Khalifa} and
                  Matthieu Martel},
  title        = {Compile-Time Optimization of the Energy Consumption of Numerical Computations},
  booktitle    = {Proceedings of the 21th ACM International Conference on Computing Frontiers, CF 2024},
  pages        = {},
  publisher    = {{ACM}},
  year         = {2024}
}

@inproceedings{KhalifaM23,
  author       = {Dorra {Ben Khalifa} and
                  Matthieu Martel},
  title        = {On the Functional Properties of Automatically Generated Fixed-Point
                  Controllers},
  booktitle    = {9th International Conference on Control, Decision and Information
                  Technologies, CoDIT},
  pages        = {786--791},
  publisher    = {{IEEE}},
  year         = {2023}
}

@inproceedings{BessaiKBM22,
  author       = {Sofiane Bessa{\"{\i}} and
                  Dorra {Ben Khalifa} and
                  Hanane Benmaghnia and
                  Matthieu Martel},
  title        = {Fixed-Point Code Synthesis Based on Constraint Generation},
  booktitle    = {Design and Architecture for Signal and Image Processing - 15th International
                  Workshop, {DASIP} 2022, Budapest, Hungary, June 20-22, 2022, Proceedings},
  series       = {Lecture Notes in Computer Science},
  volume       = {13425},
  pages        = {108--120},
  publisher    = {Springer},
  year         = {2022}
}

📋 License

POPiX is licensed under the GNU GPL 3 license only. Copyright (c) 2023. All rights reserved.

This program and the accompanying materials are made available under the terms of the GNU General Public License v3.0 only (GPL-3.0-only) which accompanies this distribution, and is available at: https://www.gnu.org/licenses/gpl-3.0.en.html

Author : Dorra Ben Khalifa 📧 dorra.ben-khalifa@enac.fr