Skip to content

Commit 8acf14f

Browse files
committed
Initial commit
0 parents  commit 8acf14f

24 files changed

Lines changed: 3978 additions & 0 deletions

.github/workflows/test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: macos-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x, 20.x, 22.x]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
- name: Install dependencies
26+
run: npm install
27+
28+
- name: Build addon
29+
run: npm run build
30+
31+
- name: Run tests
32+
run: npm test
33+
34+
- name: Run benchmarks
35+
run: npm run benchmark

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
build/
3+
*.node
4+
*.log
5+
.DS_Store
6+
package-lock.json
7+
yarn.lock

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
build/
3+
*.log
4+
.DS_Store
5+
test.js
6+
benchmark.js
7+
.git/
8+
.github/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

CHANGELOG.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0] - 2024-12-30
9+
10+
### Added
11+
- Initial release
12+
- Matrix operations:
13+
- Matrix multiplication (BLAS GEMM) with 283x speedup
14+
- Matrix-vector multiplication (BLAS GEMV)
15+
- AXPY operation (y = alpha*x + y)
16+
- Vector arithmetic (vDSP):
17+
- Dot product (5x speedup)
18+
- Addition, subtraction, multiplication, division
19+
- Scalar multiplication
20+
- Vector functions (vDSP):
21+
- Absolute value
22+
- Square, square root
23+
- Normalize to unit length
24+
- Reductions (vDSP):
25+
- Sum (7.6x speedup)
26+
- Mean, max, min
27+
- Root Mean Square (RMS)
28+
- Distance metrics:
29+
- Euclidean distance
30+
- Signal processing:
31+
- Fast Fourier Transform (FFT)
32+
- Full TypeScript definitions
33+
- Comprehensive test suite (26 tests)
34+
- Performance benchmarks
35+
- Complete documentation
36+
37+
### Performance
38+
- Matrix multiply (500×500): 93ms → 0.33ms (283x faster)
39+
- Vector dot product (1M): 0.66ms → 0.13ms (5x faster)
40+
- Vector sum (1M): 0.59ms → 0.08ms (7.6x faster)
41+
- Vector add (1M): 0.74ms → 0.20ms (3.7x faster)
42+
43+
### Requirements
44+
- macOS (Apple Silicon or Intel)
45+
- Node.js >= 18.0.0
46+
- Xcode Command Line Tools
47+
48+
## [Unreleased]
49+
50+
### Planned
51+
- Float32 support for single-precision operations
52+
- Additional BLAS operations (GEMV, triangular solve)
53+
- Additional vDSP operations (convolution, correlation)
54+
- Improved error handling and validation
55+
- More comprehensive benchmarks
56+
- CI/CD pipeline
57+
58+
---
59+
60+
[1.0.0]: https://github.com/Digital-Defiance/node-accelerate/releases/tag/v1.0.0

CONTRIBUTING.md

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
# Contributing to node-accelerate
2+
3+
Thank you for your interest in contributing! This document provides guidelines for contributing to node-accelerate.
4+
5+
## Development Setup
6+
7+
### Prerequisites
8+
9+
- macOS (Apple Silicon or Intel)
10+
- Node.js >= 18.0.0
11+
- Xcode Command Line Tools
12+
- Git
13+
14+
### Getting Started
15+
16+
1. Fork the repository
17+
2. Clone your fork:
18+
```bash
19+
git clone https://github.com/Digital-Defiance/node-accelerate.git
20+
cd node-accelerate
21+
```
22+
23+
3. Install dependencies:
24+
```bash
25+
npm install
26+
```
27+
28+
4. Build the addon:
29+
```bash
30+
npm run build
31+
```
32+
33+
5. Run tests:
34+
```bash
35+
npm test
36+
```
37+
38+
## Project Structure
39+
40+
```
41+
node-accelerate/
42+
├── accelerate.cc # C++ implementation
43+
├── binding.gyp # Build configuration
44+
├── index.js # JavaScript wrapper
45+
├── index.d.ts # TypeScript definitions
46+
├── test.js # Test suite
47+
├── benchmark.js # Performance benchmarks
48+
└── README.md # Documentation
49+
```
50+
51+
## Making Changes
52+
53+
### Code Style
54+
55+
**C++ Code:**
56+
- Follow Google C++ Style Guide
57+
- Use 2-space indentation
58+
- Add comments for complex operations
59+
- Include error handling
60+
61+
**JavaScript Code:**
62+
- Use 2-space indentation
63+
- Use `const` and `let`, not `var`
64+
- Add JSDoc comments for functions
65+
- Follow Node.js best practices
66+
67+
### Adding New Functions
68+
69+
1. **Add C++ implementation** in `accelerate.cc`:
70+
```cpp
71+
Napi::Value YourFunction(const Napi::CallbackInfo& info) {
72+
Napi::Env env = info.Env();
73+
74+
// Validate arguments
75+
if (info.Length() < 1) {
76+
Napi::TypeError::New(env, "Expected 1 argument").ThrowAsJavaScriptException();
77+
return env.Null();
78+
}
79+
80+
// Your implementation using Accelerate framework
81+
82+
return result;
83+
}
84+
```
85+
86+
2. **Export the function** in `Init()`:
87+
```cpp
88+
exports.Set("yourFunction", Napi::Function::New(env, YourFunction));
89+
```
90+
91+
3. **Add TypeScript definition** in `index.d.ts`:
92+
```typescript
93+
export function yourFunction(arg: Float64Array): number;
94+
```
95+
96+
4. **Add tests** in `test.js`:
97+
```javascript
98+
console.log('Testing your function...');
99+
const result = accelerate.yourFunction(testData);
100+
assertClose(result, expectedValue, 1e-10, 'Your function test');
101+
```
102+
103+
5. **Update documentation** in `README.md`
104+
105+
### Testing
106+
107+
Run the test suite:
108+
```bash
109+
npm test
110+
```
111+
112+
Add tests for:
113+
- Correct results with known inputs
114+
- Edge cases (empty arrays, single elements)
115+
- Large inputs (performance validation)
116+
- Error handling (invalid arguments)
117+
118+
### Benchmarking
119+
120+
Run benchmarks:
121+
```bash
122+
npm run benchmark
123+
```
124+
125+
When adding new functions, include benchmarks comparing:
126+
- Pure JavaScript implementation
127+
- Accelerate-based implementation
128+
- Speedup factor
129+
130+
## Pull Request Process
131+
132+
1. **Create a branch** for your feature:
133+
```bash
134+
git checkout -b feature/your-feature-name
135+
```
136+
137+
2. **Make your changes** following the code style guidelines
138+
139+
3. **Add tests** for new functionality
140+
141+
4. **Run tests** to ensure everything works:
142+
```bash
143+
npm test
144+
npm run benchmark
145+
```
146+
147+
5. **Commit your changes** with clear messages:
148+
```bash
149+
git commit -m "Add feature: description"
150+
```
151+
152+
6. **Push to your fork**:
153+
```bash
154+
git push origin feature/your-feature-name
155+
```
156+
157+
7. **Create a Pull Request** with:
158+
- Clear description of changes
159+
- Test results
160+
- Benchmark results (if applicable)
161+
- Documentation updates
162+
163+
## What to Contribute
164+
165+
### High Priority
166+
167+
- **More BLAS operations**: Matrix-vector multiply, triangular solve, etc.
168+
- **More vDSP operations**: Convolution, correlation, windowing
169+
- **Float32 support**: Add single-precision variants
170+
- **Error handling**: Improve validation and error messages
171+
- **Documentation**: More examples and use cases
172+
173+
### Medium Priority
174+
175+
- **Performance optimizations**: Reduce overhead, optimize memory usage
176+
- **Additional tests**: Edge cases, stress tests
177+
- **CI/CD**: GitHub Actions for automated testing
178+
- **Benchmarks**: More comprehensive performance tests
179+
180+
### Low Priority
181+
182+
- **Additional platforms**: Explore other ARM64 platforms
183+
- **Advanced features**: Sparse matrices, complex numbers
184+
- **Utilities**: Helper functions for common patterns
185+
186+
## Code Review
187+
188+
All submissions require review. We'll look for:
189+
190+
- **Correctness**: Does it work as intended?
191+
- **Performance**: Does it maintain or improve performance?
192+
- **Tests**: Are there adequate tests?
193+
- **Documentation**: Is it well-documented?
194+
- **Style**: Does it follow the style guide?
195+
196+
## Reporting Issues
197+
198+
When reporting issues, include:
199+
200+
1. **Environment**:
201+
- macOS version
202+
- Node.js version
203+
- Chip (M1/M2/M3/M4/Intel)
204+
205+
2. **Description**: Clear description of the issue
206+
207+
3. **Reproduction**: Minimal code to reproduce
208+
209+
4. **Expected vs Actual**: What you expected vs what happened
210+
211+
5. **Logs**: Any error messages or logs
212+
213+
## Questions?
214+
215+
- Open an issue for questions
216+
- Check existing issues first
217+
- Be respectful and constructive
218+
219+
## License
220+
221+
By contributing, you agree that your contributions will be licensed under the MIT License.
222+
223+
## Acknowledgments
224+
225+
Thank you for contributing to node-accelerate! Your efforts help make high-performance numerical computing accessible to the Node.js community.

0 commit comments

Comments
 (0)