This repository contains the two-part final project for the Advanced and Parallel Programming course. The work involves high-performance computing in C and the development of a custom interpreter in Python.
The goal is to develop a program that renders the Mandelbrot set as a grayscale image in .pgm format
- Parallel Computing: The core calculation is parallelized using OpenMP to optimize performance.
- Memory Efficiency: Image saving is handled via mmap.
-
Mathematical Model: * Calculates the sequence
$z_{n+1} = z_n^2 + c$ with a divergence radius$r=2$ .- Interior points are colored white (255).
- Exterior points use a logarithmic color scale
$\lfloor255 \times \frac{\log(n)}{\log(M)}\rfloor$ based on the divergence speed$n$ .
-
CLI Support: Accepts the filename, max iterations (
$M$ ), and vertical resolution ($n_{rows}$ ) as command-line arguments. -
Architecture: Modular design with separate modules for fractal logic (
mandelbrot.c/h) and image management (pgm.c/h), compiled via Makefile.
This part involves extending a Lisp-like interpreter to support advanced programming constructs.
- Variables & Arrays: * Variable allocation (
alloc) and array allocation (valloc).- Value assignment for variables (
setq) and specific array indices (setv).
- Value assignment for variables (
- Control Flow:
- Conditionals:
ifstatements for branching logic. - Loops:
whileandforloops for iterative execution.
- Conditionals:
- Subroutines: Ability to define reusable code blocks (
defsub) and execute them viacall. - Comparisons: Support for boolean operators:
>,>=,=,!=,<, and<=. - Sequencing: Built-in support for executing sequences of 2, 3, or 4 operations (
prog2,prog3,prog4).
- Documentation: All significant functions are documented with descriptions of tasks, inputs, and outputs.
- Error Handling: The C program returns non-zero codes on failure, while the Python interpreter raises specific, coherent exceptions.
- Compliance: Every source file includes the student's full name, surname, and ID (matricola) in the header.and Python components must be delivered together in a single compressed archive.