sheralisaleem/parallel-compute-benchmark
๐ PDC Inventory Engine
Parallel Data Computing Engine โ A high-performance C-based HTTP server demonstrating scalable parallel computing paradigms with a modern React dashboard.
  
๐ Overview
The PDC Inventory Engine is a sophisticated benchmarking platform that compares three parallel computing paradigms in real-time:
- Sequential (Single-threaded) โ Baseline performance metric
- POSIX Threads (Pthreads) โ Multi-threaded parallelism with 4 worker threads
- OpenMP โ Compiler-directive-based auto-parallelization
The project includes a REST API backend (C with HTTP server) and an interactive React dashboard that visualizes performance metrics across different data workload sizes.
๐ฏ Key Features
โจ Three Parallel Computing Approaches
- Linear sequential processing for baseline comparison
- POSIX Threads implementation with dynamic thread pool
- OpenMP pragmatic parallel directives
๐ Dynamic Memory Management
- Automatic reallocation based on workload size
- Configurable data set ranging from 10M to 250M items
- Efficient memory cleanup after computation
๐ Real-time Performance Dashboard
- Beautiful dark/light mode interface
- Live execution logging with colored output
- Performance metrics visualization with Recharts
- Speedup calculation (relative to sequential baseline)
๐ RESTful HTTP API
- Clean endpoint-based architecture
- JSON response format with execution timing
- CORS support for cross-origin requests
- Configurable item count via query parameters
๐ธ Demo
Interactive dashboard showing real-time performance metrics across parallel computing paradigms
๐ค Live Demo (Hugging Face)
Try it live without any local setup:
[โถ Open on Hugging Face Spaces](https://huggingface.co/spaces/sheralisaleem/parallel-compute-benchmark)
Note: The hosted demo runs on shared HuggingFace infrastructure. Results reflect server-side performance, not your local machine. For accurate benchmarks on your hardware, run locally (see Quick Start).
๐๏ธ Architecture
Project Structure
parallel-compute-benchmark/
โโโ server.c # HTTP server & routing layer
โโโ compute.h # Public interface definitions
โโโ compute.c # Computation implementations (linear, pthreads, openmp)
โโโ index.html # React dashboard (single-file app)
โโโ Dockerfile # Docker config for HuggingFace deployment
โโโ requirements.txt # System dependencies
โโโ README.md # This fileComponent Breakdown
`server.c` (HTTP Server)
- Manages socket communication on port 7860 (HuggingFace) / 8080 (local)
- Parses HTTP requests and routes to computation endpoints
- Measures execution time with nanosecond precision
- Sends JSON responses with performance metrics
`compute.c/compute.h` (Computation Layer)
process_linear()โ Sequential loop processingprocess_pthreads()โ POSIX Threads with work chunkingprocess_openmp()โ Compiler-parallel with#pragma omp- Global
inventoryarray (dynamically allocated)
`index.html` (Dashboard)
- React 18 + Tailwind CSS frontend
- Real-time performance charts with Recharts
- Configuration panel for workload sizing
- Live console output simulation
`Dockerfile` (Deployment)
- Based on
gcc:13image - Installs OpenMP, compiles the server, exposes port 7860
๐ง Requirements
System Requirements
- OS: Linux, macOS, or BSD (POSIX-compliant)
- Compiler: GCC 9+ or Clang 10+ with C99 support
- Build Tools: GNU Make
- Libraries:
- POSIX Threads (pthreads)
- OpenMP runtime (libomp)
- Standard C library (libc)
Optional Tools
- gdb โ Debugging
- valgrind โ Memory profiling
- cmake โ Advanced build configuration
- Docker โ For containerized/HuggingFace deployment
Installation on Ubuntu/Debian
sudo apt-get update
sudo apt-get install build-essential libpthread-stubs0-dev libomp-devInstallation on macOS
brew install gcc libomp๐ Quick Start
1. Clone & Navigate
git clone https://github.com/sheralisaleem/parallel-compute-benchmark.git
cd parallel-compute-benchmark2. Compile
gcc -O2 -o pdc_server server.c compute.c -lm -lpthread -fopenmpCompile Flags Explained:
-O2โ Level 2 optimization (balance speed & compile time)-lmโ Link math library-lpthreadโ Link POSIX Threads-fopenmpโ Enable OpenMP support
3. Run Server
./pdc_serverExpected Output:
========================================================
PDC Backend Server is Running! (Modular Architecture)
View the Dashboard at: http://localhost:8080
========================================================4. Open Dashboard
Navigate to http://localhost:8080 in your web browser.
๐ณ Docker Deployment
Run Locally with Docker
docker build -t pdc-server .
docker run -p 7860:7860 pdc-serverThen open http://localhost:7860.
Deploy to Hugging Face Spaces
- Create a new Space at huggingface.co/new-space, select Docker as the SDK.
- Clone your Space and push the repo files:
git clone https://huggingface.co/spaces/YOUR_USERNAME/parallel-compute-benchmark
cd parallel-compute-benchmark
# copy your project files in
git add .
git commit -m "Deploy PDC server"
git push- HuggingFace will auto-build and serve at:
https://YOUR_USERNAME-parallel-compute-benchmark.hf.space
The Dockerfile in the repo handles everything โ no manual build steps needed.
๐ก API Endpoints
Base URL
http://localhost:8080 # local
https://YOUR_USERNAME-parallel-compute-benchmark.hf.space # HuggingFaceEndpoints
1. Dashboard (GET /)
Serves the interactive React dashboard.
curl http://localhost:8080/2. Sequential Computation (GET /run/linear)
Executes single-threaded baseline processing.
curl "http://localhost:8080/run/linear?items=50000000"Response:
{ "status": "success", "time": 2.145 }3. POSIX Threads (GET /run/pthreads)
Executes parallel processing with 4 threads.
curl "http://localhost:8080/run/pthreads?items=50000000"Response:
{ "status": "success", "time": 0.589 }4. OpenMP (GET /run/openmp)
Executes compiler-parallelized processing.
curl "http://localhost:8080/run/openmp?items=50000000"Response:
{ "status": "success", "time": 0.512 }Query Parameters
items(int) โ Number of items to process (default: 50,000,000)- Range: 10M โ 250M recommended
- Example:
?items=100000000
Response Headers
Access-Control-Allow-Origin: *
Content-Type: application/json๐ Dashboard Features
Configuration Panel
- Workload Size โ Input custom item count or select presets
- Presets: 10M, 50M, 100M, 250M (marked with โก)
- Operation Type โ Select computation operation
- "Apply 5% Inflation + 18% GST"
- "Apply 10% Clearance Discount"
Execution Nodes
Three action buttons to trigger computations:
- ๐ฅ๏ธ Sequential (1 Core)
- ๐ฟ POSIX Threads (4 Cores)
- โก OpenMP (Auto-Parallel)
Performance Metrics Chart
- Bar chart comparing execution times
- Automatic scaling based on selected workload
- Real-time updates with color-coded bars
Speedup Badge
- Displays Xfold speedup (parallel vs sequential)
- Appears only after multiple runs complete
- Example: 3.62x Faster!
Live Console Logs
- Numbered output with severity levels:
- ๐ข INFO โ General messages
- ๐ก WARN โ System initialization
- ๐ด ERROR โ Error conditions
- ๐ SUCCESS โ Successful completions
- Auto-scrolling to latest entries
๐งฎ Computation Details
The Core Operation
Each paradigm executes the same mathematical operation on every inventory item:
inventory[i] = (inventory[i] * 1.05) + (inventory[i] * 0.18);Breakdown:
- Multiply by 1.05 (5% inflation)
- Add 18% of result (GST/tax)
- Applied to 50M items by default
Performance Characteristics
Typical Speedup (4 cores, 50M items):
- Pthreads: ~3.5โ4.0x faster
- OpenMP: ~4.2โ4.8x faster
๐ Performance Benchmarks
Expected Results (Intel i7, 4 cores, 50M items)
Sequential: ~2.50 seconds (baseline)
Pthreads: ~0.60 seconds (4.2x speedup)
OpenMP: ~0.52 seconds (4.8x speedup)Scalability
- Linear to 100M items โ Time roughly doubles
- Beyond 250M items โ Diminishing returns due to cache effects
- Single-core systems โ Pthreads/OpenMP may be slower than sequential
๐จ Advanced Usage
Customization
Change thread count: Edit #define NUM_THREADS in compute.c (line 5)
Change server port: Edit #define PORT in server.c (line 8)
Enable debugging:
gcc -g -O0 -o pdc_server_debug server.c compute.c -lm -lpthread -fopenmp๐ ๏ธ Troubleshooting
Compilation Error: undefined reference to omp_get_num_threads
OpenMP not linked. Ensure -fopenmp flag is present:
gcc -O2 -o pdc_server server.c compute.c -lm -lpthread -fopenmpPort Already in Use
# Kill the occupying process
lsof -i :8080 | grep LISTEN | awk '{print $2}' | xargs kill
# Or change PORT in server.c and recompileDashboard Not Loading
- Verify server is running:
curl http://localhost:8080 - Check firewall:
sudo ufw allow 8080 - Try a different port (see Advanced Usage)
Slow Performance on Expected Fast Machine
- Ensure compilation optimization:
-O2or-O3 - Check CPU throttling:
cat /proc/cpuinfo | grep MHz - Close background processes consuming CPU
๐ค Contributing
Contributions are welcome! Here's how:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
Author
Sher Ali Saleem โ GitHub ยท HuggingFace
โญ Star this repo if you find it useful!
