This project demonstrates the phenomenon of false sharing in C by benchmarking a concurrent counter increment with and without padding to cache lines. It includes a Python agent using LangChain that autonomously tests thread counts and writes an analysis.
- Windows Subsystem for Linux (WSL) with
gcc,make,nproc. - Python 3.9+
- Anthropic API Key
- Create a
.envfile in theagent/directory:ANTHROPIC_API_KEY=your_key_here
- Install Python dependencies:
cd agent pip install -r requirements.txt
You can execute the entire flow by simply running the python script:
cd agent
python agent.pyThis script will:
- Detect your available WSL cores.
- Direct the AI agent to build and run the C benchmark across multiple thread counts (unpadded & padded).
- Record data in
results/benchmark_results.csv. - Command the AI to review the CSV and write a final report to
reports/analysis.md.