- C++17 compatible compiler (GCC 8+, Clang 7+, MSVC 2019+)
- CMake 3.10 or higher
- Git
- Doxygen (for documentation)
- clang-tidy (for static analysis)
- lcov (for coverage reporting)
- Clone the Repository
git clone https://github.com/yourusername/OpenQASMCompiler.git
cd OpenQASMCompiler- Configure Development Build
mkdir build-dev
cd build-dev
cmake -DCMAKE_BUILD_TYPE=Debug \
-DENABLE_COVERAGE=ON \
-DENABLE_CLANG_TIDY=ON \
-DENABLE_DOXYGEN=ON \
..- Build the Project
cmake --build . --parallel- Run Tests
ctest --output-on-failureWe follow the Google C++ Style Guide with some modifications:
-
Naming Conventions
- Class names:
CamelCase - Method names:
camelCase - Variables:
snake_case - Constants:
UPPER_SNAKE_CASE
- Class names:
-
Formatting
- Use 4 spaces for indentation
- Maximum line length: 100 characters
- Use braces for all control structures
-
Documentation
- Document all public APIs
- Use Doxygen-style comments
- Include examples for complex functionality
-
Branch Naming
- Feature branches:
feature/description - Bug fixes:
fix/description - Documentation:
docs/description
- Feature branches:
-
Commit Messages
- Format:
type(scope): description - Types: feat, fix, docs, style, refactor, test, chore
- Example:
feat(parser): add support for custom gates
- Format:
-
Pull Requests
- Create from feature branches
- Include description of changes
- Reference related issues
- Ensure all tests pass
-
Writing Tests
- Use Google Test framework
- Follow AAA pattern (Arrange, Act, Assert)
- Test both success and failure cases
- Include edge cases
-
Running Tests
# Run all tests
ctest
# Run specific test
./tests/parser_test
# Run with coverage
ctest -T memcheck-
Test Categories
- Parser tests
- Circuit optimization tests
- Simulation tests
- End-to-end tests
-
Test Data
- Store test files in
tests/test_data - Include both valid and invalid inputs
- Document expected outputs
- Store test files in
-
Benchmarks
- Use Google Benchmark
- Test with different circuit sizes
- Measure memory usage
- Profile critical paths
-
Running Benchmarks
./benchmarks/circuit_benchmark-
Parser Errors
- Check OpenQASM syntax
- Verify include paths
- Check for unclosed blocks
-
Circuit Errors
- Verify qubit indices
- Check gate parameters
- Validate circuit depth
-
Simulation Errors
- Check state vector size
- Verify gate matrices
- Monitor memory usage
- GDB/LLDB
# Build with debug symbols
cmake -DCMAKE_BUILD_TYPE=Debug ..
# Run with debugger
gdb ./qasmc- Valgrind
valgrind --leak-check=full ./qasmc input.qasm- Sanitizers
# Build with sanitizers
cmake -DCMAKE_BUILD_TYPE=Debug \
-DENABLE_SANITIZERS=ON \
..- CPU Profiling
# Build with profiling
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
# Run with profiler
perf record ./qasmc input.qasm
perf report- Memory Profiling
valgrind --tool=massif ./qasmc input.qasm
ms_print massif.out.*-
Circuit Optimization
- Gate merging
- Circuit simplification
- Resource estimation
-
Simulation Optimization
- Sparse state representation
- Parallel gate application
- GPU acceleration
- Doxygen
# Generate documentation
cmake --build . --target docs- Documentation Standards
- Document all public APIs
- Include usage examples
- Document performance considerations
-
Component Documentation
- System architecture
- Data flow
- Performance characteristics
-
API Documentation
- Class and method descriptions
- Usage examples
- Error handling