A complete framework for the generation, simulation, analysis, and tracking of approximate code variants, with support for scientific applications, integration with the RISC-V toolchain, Prof5 profiler, error analysis, and parallel execution.
- Overview
- Features
- Complete Project Workflow
- Project Structure
- Environment Installation and Configuration
- How to Use
- Control Files
- License
PaCA automates the generation of approximate code variants, compiles, simulates, analyzes performance and accuracy, and tracks variants in approximate computing experiments, especially for the RISC-V architecture.
- Automatic generation of code variants with approximate operators.
- Cross-compilation for RISC-V.
- Automated simulation via Spike.
- Performance analysis with Prof5.
- Error analysis between variants and the reference.
- Tracking of executed variants, failures, and checkpoints.
- Pruning of redundant variants.
- Support for multiple scientific applications.
- Parallel execution (multi-threaded).
- Detailed logs and organization of results.
- Environment preparation: Installation of the pre-configured Docker environment.
- Variant generation: Automatic creation of multiple versions of the base code with approximate operators.
- Compilation: Each variant is compiled for the RISC-V architecture.
- Simulation: The variants are executed in the Spike simulator.
- Performance analysis: Prof5 collects detailed execution metrics.
- Error analysis: The outputs of the variants are compared with the reference to measure accuracy.
- Tracking and control: The system records executed variants, failures, and checkpoints for resumption.
- Variant pruning: Redundant variants are eliminated to optimize the process.
- Storage and logs: All results, logs, and artifacts are organized into specific directories.
PaCA/
├── src/
│ ├── apps/ # Supported applications (fft, kmeans, etc)
│ ├── database/ # Variant tracking
│ ├── execution/ # Compilation and simulation
│ ├── utils/ # Utilities (error analysis, pruning, logging)
│ ├── code_parser.py
│ ├── config.py
│ ├── generator.py
│ ├── generate_variants.py
│ ├── run.py
│ └── transformations.py
├── data/
│ └── reference/ # Approximate functions (approx.h)
├── storage/
│ ├── dump/ # Object code dumps
│ ├── executable/ # Compiled executables
│ ├── logs/ # Execution logs
│ ├── output/ # Simulation outputs
│ └── prof5_results/ # Profiler results
└── modified_codes/ # Generated code variants
Recommended: use the pre-built Docker container!
-
Download and run the Docker container:
docker pull gregoriokn/lscad_approx:v2 docker run -it --rm -v $(pwd):/workspace -w /workspace gregoriokn/lscad_approx:v2 /bin/bashThe container already includes the RISC-V toolchain, Spike, and Python dependencies.
-
(Optional) Install additional Python dependencies:
pip install -r requirements.txt
-
Configure paths in
src/config_base.pyandsrc/config.pyaccording to your environment/directories.
Run a supported application (e.g., fft, kmeans):
python src/run.py --app [application_name] --workers [num_threads]--app: Application name (e.g., fft, kmeans)--workers: Number of threads for parallelization (optional)
Generate code variants from a source file:
python src/generate_variants.py --input [input_file] --output [output_folder]--input: Path to the base source file--output: Folder where the variants will be saved
- Create a new module in
src/apps/(e.g.,my_app.py) - Implement the functions:
prepare_environment(base_config)generate_variants(base_config)find_variants_to_simulate(base_config)simulate_variant(variant_file, variant_hash, base_config, status_monitor)
- Add it to the
AVAILABLE_APPSdictionary insrc/run.py
- Simulation results:
storage/output/ - Profiler results:
storage/prof5_results/ - Execution logs:
storage/logs/ - Error analysis: use
src/utils/error_analyzer.py
- Executed variants log:
executed.txt - Failure log:
failures.txt - Checkpoint for resumption:
checkpoint.txt - Detailed tracking:
src/database/variant_tracker.py
executed.txt: Variants already simulatedfailures.txt: Variants that failedcheckpoint.txt: State for automatic resumption
Academic project. All rights reserved.