We welcome contributions to the Lambda-CDM Universe Simulation project! This document provides guidelines for contributing.
- Check existing issues first
- Use the issue templates
- Provide detailed reproduction steps
- Include system information (GPU, CUDA version, etc.)
- Describe the physics/computational need
- Explain the expected behavior
- Consider performance implications
- Provide scientific references if applicable
# Fork and clone the repository
git clone https://github.com/yourusername/lambda-cdm-raytracing.git
cd lambda-cdm-raytracing
# Create development branch
git checkout -b feature/your-feature-name
# Build in debug mode
mkdir build-debug && cd build-debug
cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTING=ON
make -j$(nproc)- C++ Standard: C++17
- Style Guide: Google C++ Style Guide
- Formatting: Use clang-format with provided
.clang-format - Naming:
- Classes:
PascalCase - Functions:
snake_case - Variables:
snake_case - Constants:
UPPER_CASE
- Classes:
// 1. Create interface-compliant component
class MyForceComputer : public IForceComputer {
private:
std::string name_;
// Component state
public:
// Constructor with name
explicit MyForceComputer(const std::string& name) : name_(name) {}
// IComponent interface
bool initialize(const SimulationContext& context) override;
void finalize() override;
std::string get_type() const override { return "MyForceComputer"; }
std::string get_name() const override { return name_; }
std::string get_version() const override { return "1.0.0"; }
// IForceComputer interface
void compute_forces(const float* positions, const float* masses,
float* forces, size_t num_particles,
const std::any& params = {}) override;
bool supports_gpu() const override;
bool supports_mpi() const override;
size_t get_max_particles() const override;
};
// 2. Register in factory
ForceComputerFactory::register_force_computer<MyForceComputer>("MyForceComputer");// Add configuration validation
void validate_my_component_config(ConfigurationNode* node) {
// Required parameters
if (!node->has("required_param")) {
throw std::runtime_error("MyComponent requires 'required_param'");
}
// Parameter validation
auto value = node->get<double>("required_param");
if (value <= 0.0) {
throw std::runtime_error("required_param must be positive");
}
}
// Register schema
config_manager.register_schema("MyComponent", validate_my_component_config);- Unit Tests: Required for all new components
- Integration Tests: Required for physics algorithms
- Performance Tests: Required for compute-intensive features
// Example unit test
TEST(MyForceComputerTest, InitializationTest) {
auto computer = std::make_unique<MyForceComputer>("test");
SimulationContext context;
EXPECT_TRUE(computer->initialize(context));
EXPECT_EQ(computer->get_name(), "test");
EXPECT_EQ(computer->get_type(), "MyForceComputer");
}
// Example physics test
TEST(MyForceComputerTest, NewtonianGravityTest) {
auto computer = std::make_unique<MyForceComputer>("test");
// Test known configuration
float positions[] = {0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f};
float masses[] = {1.0f, 1.0f};
float forces[6] = {0};
computer->compute_forces(positions, masses, forces, 2);
// Verify expected force magnitude
float expected_force = 1.0f; // G*m1*m2/r^2
EXPECT_NEAR(forces[0], expected_force, 1e-6);
}- Header Comments: Doxygen-style documentation
- Algorithm Documentation: Explain physics and computational approach
- Performance Notes: Document computational complexity
/**
* @brief Computes gravitational forces using the Barnes-Hut tree algorithm
*
* This implementation uses an octree spatial decomposition to approximate
* long-range forces, reducing computational complexity from O(NΒ²) to O(N log N).
*
* @param positions Array of particle positions [x,y,z,x,y,z,...]
* @param masses Array of particle masses
* @param forces Output array for computed forces [fx,fy,fz,...]
* @param num_particles Number of particles
* @param params Optional parameters (opening angle, etc.)
*
* @complexity O(N log N) average case, O(NΒ²) worst case
* @memory O(N) for tree storage
*
* @see Barnes & Hut (1986) "A hierarchical O(N log N) force-calculation algorithm"
*/
void TreeForceComputer::compute_forces(const float* positions, const float* masses,
float* forces, size_t num_particles,
const std::any& params) override;- GPU Memory: Minimize transfers, use pinned memory
- CUDA Kernels: Optimize occupancy and memory coalescing
- Threading: Use thread-safe containers and synchronization
- Memory Pools: Prefer pool allocation over frequent malloc/free
-
Create Feature Branch
git checkout -b feature/descriptive-name
-
Development Workflow
# Make changes git add . git commit -m "feat: Add Barnes-Hut tree force computer - Implement octree spatial decomposition - Add GPU acceleration with CUDA kernels - Include comprehensive unit tests - Document algorithm complexity and usage"
-
Pre-submission Checklist
- Code follows style guidelines
- All tests pass (
ctest) - Documentation updated
- Performance benchmarks (if applicable)
- No memory leaks (
valgrindor similar) - CUDA code tested on target GPUs
-
Submit Pull Request
- Use descriptive title
- Reference related issues
- Include performance impact
- Add reviewer suggestions
type(scope): Brief description
Detailed explanation of changes, motivation, and impact.
Include references to issues, papers, or algorithms.
Fixes #123
Closes #456
Types: feat, fix, docs, style, refactor, perf, test, build
- Provide scientific references
- Include accuracy validation tests
- Document parameter ranges and limitations
- Consider numerical stability
- Follow standard cosmological parameter conventions
- Include unit tests against known analytical solutions
- Document assumptions and approximations
- Benchmark against reference implementations
- Include convergence tests
- Document softening and resolution effects
- Profile with
nvprofor Nsight - Optimize memory bandwidth utilization
- Consider shared memory usage patterns
- Document occupancy and performance metrics
- Provide ONNX model definitions
- Include accuracy validation against reference
- Document precision trade-offs (FP32 vs FP16)
- System configuration (OS, GPU, CUDA version)
- Compilation flags and CMake configuration
- Minimal reproducible example
- Expected vs actual behavior
- Error messages and stack traces
- Include profiling data
- Specify hardware configuration
- Provide timing comparisons
- Include memory usage statistics
- Correctness: Algorithm implementation
- Performance: Computational efficiency
- Safety: Memory management and error handling
- Maintainability: Code clarity and documentation
- Testing: Adequate test coverage
- Initial review within 48 hours
- Feedback incorporation and re-review
- Final approval from maintainers
- Semantic versioning (MAJOR.MINOR.PATCH)
- Major: Breaking API changes
- Minor: New features, backward compatible
- Patch: Bug fixes
- All tests pass on target platforms
- Performance benchmarks meet requirements
- Documentation updated
- Changelog updated
- Version numbers incremented
- Discussions: GitHub Discussions for questions
- Issues: Bug reports and feature requests
- Wiki: Detailed documentation and tutorials
- Examples: Reference implementations
Contributors will be acknowledged in:
- README.md contributors section
- Release notes
- Academic publications (for significant contributions)
Thank you for contributing to advancing cosmological simulation capabilities!