https://github.com/vlang/vsl
V library to develop Artificial Intelligence and High-Performance Scientific Computations
https://github.com/vlang/vsl
computational-geometry differential-equations eigenvalues eigenvectors hacktoberfest linear-algebra openblas opencl optimization parallel-computations scientific-computing sparse-systems v
Last synced: 25 days ago
JSON representation
V library to develop Artificial Intelligence and High-Performance Scientific Computations
- Host: GitHub
- URL: https://github.com/vlang/vsl
- Owner: vlang
- License: mit
- Created: 2019-12-03T17:04:37.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2025-02-09T19:07:56.000Z (12 months ago)
- Last Synced: 2025-02-09T19:38:25.023Z (12 months ago)
- Topics: computational-geometry, differential-equations, eigenvalues, eigenvectors, hacktoberfest, linear-algebra, openblas, opencl, optimization, parallel-computations, scientific-computing, sparse-systems, v
- Language: V
- Homepage: https://vlang.github.io/vsl
- Size: 11.4 MB
- Stars: 365
- Watchers: 29
- Forks: 46
- Open Issues: 36
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-v - vsl - A Scientific Library with a great variety of different modules. Although most modules offer pure-V definitions, it also provides modules that wrap known C libraries among other backends that allow high performance computing as an alternative. Also provides opinionated wrappers for OpenBLAS, LAPACKE, MPI, OpenCL among other libraries. (Libraries / Scientific computing)
README
The V Scientific Library
[vlang.io](https://vlang.io) |
[Docs](https://vlang.github.io/vsl) |
[Examples](./examples/) |
[Changelog](#) |
[Contributing](https://github.com/vlang/vsl/blob/main/CONTRIBUTING.md)
[![Mentioned in Awesome V][awesomevbadge]][awesomevurl]
[![VSL Continuous Integration][workflowbadge]][workflowurl]
[![Deploy Documentation][deploydocsbadge]][deploydocsurl]
[![License: MIT][licensebadge]][licenseurl]
[![Modules][ModulesBadge]][ModulesUrl]
VSL is a V library to develop Artificial Intelligence and High-Performance Scientific Computations.
> [!IMPORTANT]
> The pure-V QR path (`geqrf/orgqr`) is still being aligned; the related test is temporarily skipped. Other BLAS/LAPACK routines pass, and C backends (`-d vsl_blas_cblas -d vsl_lapack_lapacke`) are recommended when you need QR correctness today.
## ๐ Pure V BLAS/LAPACK: High Performance, Zero Dependencies
VSL now features **100% pure V implementations** of BLAS and LAPACK that deliver **excellent performance** while requiring **zero external dependencies**. These implementations are production-ready and provide a compelling alternative to C backends.
### Key Benefits
- โ
**Zero Dependencies**: No need to install OpenBLAS or LAPACK system libraries
- โ
**High Performance**: Competitive performance with optimized C backends
- โ
**Cross-Platform**: Works consistently across all platforms supported by V
- โ
**Production Ready**: Stable implementations with comprehensive test coverage
### Performance Benchmarks
Run comprehensive benchmarks to see performance characteristics:
```sh
# BLAS benchmarks
v run benchmarks/blas_bench.v
# LAPACK benchmarks
v run benchmarks/lapack_bench.v
# Compare backends
v run benchmarks/compare_backends.v
```
### Backend Options
| Backend | Description | Compilation Flag | Best For |
|---------|-------------|------------------|----------|
| **Pure V** | 100% V implementation | `NONE` (default) | Zero-dependency deployment, cross-platform |
| **OpenBLAS** | Optimized C library | `-d vsl_blas_cblas` | Maximum performance when C libraries available |
| **LAPACKE** | Standard LAPACK C interface | `-d vsl_lapack_lapacke` | Maximum performance for LAPACK operations |
**Recommendation**: Start with the pure V backend for simplicity and zero dependencies. Use C backends when maximum performance is critical and system libraries are available.
See [Pure V BLAS/LAPACK Release Notes](./RELEASE_NOTES_PURE_V.md) for detailed information.
| | | | |
| :----------------------------------: | :----------------------------: | :------------: | :-------------------: |
| ![][sierpinski_triangle] | ![][mandelbrot_blue_red_black] | ![][julia] | ![][mandelbrot_basic] |
| ![][mandelbrot_pseudo_random_colors] | ![][sierpinski_triangle2] | ![][julia_set] | ![][julia_basic] |
## ๐ Documentation
Visit [VSL Documentation](https://vlang.github.io/vsl) to explore all supported features and APIs.
VSL is a comprehensive Scientific Computing Library offering a rich ecosystem of
mathematical and computational modules. The library provides both pure-V
implementations and optional high-performance backends through established C and
Fortran libraries.
### ๐ฌ Core Capabilities
- **Linear Algebra**: Complete matrix and vector operations, eigenvalue
decomposition, linear solvers
- **Machine Learning**: Clustering algorithms (K-means), classification (KNN),
regression, and NLP tools
- **Numerical Methods**: Differentiation, integration, root finding, polynomial operations
- **Data Visualization**: Advanced plotting with Plotly-style API supporting 2D/3D charts
- **Scientific Computing**: FFT, statistical analysis, probability distributions
- **Parallel Computing**: MPI support and OpenCL acceleration
- **Data I/O**: HDF5 integration for scientific data formats
### โก Performance Architecture
VSL provides flexible performance options:
- **Pure V Implementation**: High-performance, dependency-free BLAS/LAPACK implementations
- **Optimized Backends**: Optional integration with OpenBLAS, LAPACK, and MPI for maximum performance
- **GPU Acceleration**: OpenCL support for computationally intensive operations
**Pure V BLAS/LAPACK** implementations deliver competitive performance while eliminating external dependencies. Benchmark results demonstrate excellent performance characteristics across a wide range of problem sizes.
Each module clearly documents compilation flags and backend requirements, allowing
users to choose the optimal configuration for their specific use case.
## ๐ Installation & Quick Start
VSL supports multiple installation methods and deployment options to fit
different development workflows.
### ๐ฆ Package Manager Installation
**Via V's built-in package manager:**
```sh
v install vsl
```
**Via vpkg:**
```sh
vpkg get https://github.com/vlang/vsl
```
### ๐ณ Docker Development Environment (Recommended)
For the best development experience with all optional dependencies pre-configured:
1. **Install Docker** on your system
2. **Clone the starter template:**
```sh
git clone https://github.com/ulises-jeremias/hello-vsl
cd hello-vsl
```
3. **Follow the setup instructions** in the template's README
This approach provides:
- Pre-configured environment with V, VSL, and all optional dependencies
- Cross-platform compatibility (Windows, Linux, macOS)
- Isolated development environment
- Access to optimized BLAS/LAPACK libraries
### ๐ง System Dependencies (Optional)
For enhanced performance, you can install optional system libraries:
- **OpenBLAS/LAPACK**: Linear algebra acceleration
- **OpenMPI**: Parallel computing support
- **OpenCL**: GPU acceleration
- **HDF5**: Scientific data format support
Refer to individual module documentation for specific compilation flags.
## ๐งช Testing
To test the module, just type the following command:
```sh
v test .
```
## ๐ Performance Benchmarks
VSL includes comprehensive performance benchmarks using V's built-in `benchmark` module:
```sh
# Run all BLAS benchmarks
v run benchmarks/blas_bench.v
# Run all LAPACK benchmarks
v run benchmarks/lapack_bench.v
# Compare pure V vs C backends
v -d vsl_blas_cblas run benchmarks/compare_backends.v
```
Benchmark results show performance characteristics for:
- **BLAS Level 1**: Vector operations (dot product, norms, scaling)
- **BLAS Level 2**: Matrix-vector operations (GEMV, GER)
- **BLAS Level 3**: Matrix-matrix operations (GEMM, SYRK)
- **LAPACK**: Linear system solvers, factorizations, eigenvalue problems
See [benchmarks/README.md](./benchmarks/README.md) for detailed benchmark documentation.
## ๐ฅ Contributors
Made with [contributors-img](https://contrib.rocks).
[awesomevbadge]: https://awesome.re/mentioned-badge.svg
[workflowbadge]: https://github.com/vlang/vsl/actions/workflows/ci.yml/badge.svg
[deploydocsbadge]: https://github.com/vlang/vsl/actions/workflows/deploy-docs.yml/badge.svg
[licensebadge]: https://img.shields.io/badge/License-MIT-blue.svg
[ModulesBadge]: https://img.shields.io/badge/modules-reference-027d9c?logo=v&logoColor=white&logoWidth=10
[awesomevurl]: https://github.com/vlang/awesome-v/blob/master/README.md#scientific-computing
[workflowurl]: https://github.com/vlang/vsl/actions/workflows/ci.yml
[deploydocsurl]: https://github.com/vlang/vsl/actions/workflows/deploy-docs.yml
[licenseurl]: https://github.com/vlang/vsl/blob/main/LICENSE
[ModulesUrl]: https://vlang.github.io/vsl/
[sierpinski_triangle]: https://raw.githubusercontent.com/vlang/vsl/main/vcl/static/sierpinski_triangle.png
[mandelbrot_blue_red_black]: https://raw.githubusercontent.com/vlang/vsl/main/vcl/static/mandelbrot_blue_red_black.png
[julia]: https://raw.githubusercontent.com/vlang/vsl/main/vcl/static/julia.png
[mandelbrot_basic]: https://raw.githubusercontent.com/vlang/vsl/main/vcl/static/mandelbrot_basic.png
[mandelbrot_pseudo_random_colors]: https://raw.githubusercontent.com/vlang/vsl/main/vcl/static/mandelbrot_pseudo_random_colors.png
[sierpinski_triangle2]: https://raw.githubusercontent.com/vlang/vsl/main/vcl/static/sierpinski_triangle2.png
[julia_set]: https://raw.githubusercontent.com/vlang/vsl/main/vcl/static/julia_set.png
[julia_basic]: https://raw.githubusercontent.com/vlang/vsl/main/vcl/static/julia_basic.png