Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit df8185e

Browse files
committed
first commit
0 parents  commit df8185e

7 files changed

Lines changed: 736 additions & 0 deletions

File tree

.github/workflows/swift.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Swift
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test-macos:
11+
name: Test on macOS
12+
runs-on: macos-latest
13+
strategy:
14+
matrix:
15+
swift: ['6.0', '6.0.1', '6.0.2', '6.0.3']
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Select Xcode
20+
run: sudo xcode-select -s /Applications/Xcode_16.2.app
21+
22+
- name: Swift version
23+
run: swift --version
24+
25+
- name: Build
26+
run: swift build -v
27+
28+
- name: Run tests
29+
run: swift test -v
30+
31+
test-ubuntu:
32+
name: Test on Ubuntu
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
swift: ['6.0', '6.0.1', '6.0.2', '6.0.3']
37+
ubuntu: ['22.04', '24.04']
38+
container:
39+
image: swift:${{ matrix.swift }}-${{ matrix.ubuntu }}
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Swift version
44+
run: swift --version
45+
46+
- name: Build
47+
run: swift build -v
48+
49+
- name: Run tests
50+
run: swift test -v
51+
52+
lint:
53+
name: Swift Format
54+
runs-on: ubuntu-latest
55+
container:
56+
image: swift:latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Install swift-format
61+
run: |
62+
git clone https://github.com/swiftlang/swift-format.git
63+
cd swift-format
64+
swift build -c release
65+
cp .build/release/swift-format /usr/local/bin/
66+
67+
- name: Format check
68+
run: |
69+
swift-format lint -r Sources/ Tests/ || true

.gitignore

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Xcode
2+
#
3+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4+
5+
## User settings
6+
xcuserdata/
7+
8+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
9+
*.xcscmblueprint
10+
*.xccheckout
11+
12+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
13+
build/
14+
DerivedData/
15+
*.moved-aside
16+
*.pbxuser
17+
!default.pbxuser
18+
*.mode1v3
19+
!default.mode1v3
20+
*.mode2v3
21+
!default.mode2v3
22+
*.perspectivev3
23+
!default.perspectivev3
24+
25+
## Obj-C/Swift specific
26+
*.hmap
27+
28+
## App packaging
29+
*.ipa
30+
*.dSYM.zip
31+
*.dSYM
32+
33+
## Playgrounds
34+
timeline.xctimeline
35+
playground.xcworkspace
36+
37+
# Swift Package Manager
38+
#
39+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
40+
# Packages/
41+
# Package.pins
42+
# Package.resolved
43+
# *.xcodeproj
44+
#
45+
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
46+
# hence it is not needed unless you have added a package configuration file to your project
47+
.swiftpm
48+
49+
.build/
50+
51+
# CocoaPods
52+
#
53+
# We recommend against adding the Pods directory to your .gitignore. However
54+
# you should judge for yourself, the pros and cons are mentioned at:
55+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
56+
#
57+
# Pods/
58+
#
59+
# Add this line if you want to avoid checking in source code from the Xcode workspace
60+
# *.xcworkspace
61+
62+
# Carthage
63+
#
64+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
65+
# Carthage/Checkouts
66+
67+
Carthage/Build/
68+
69+
# Accio dependency management
70+
Dependencies/
71+
.accio/
72+
73+
# fastlane
74+
#
75+
# It is recommended to not store the screenshots in the git repo.
76+
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
77+
# For more information about the recommended setup visit:
78+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
79+
80+
fastlane/report.xml
81+
fastlane/Preview.html
82+
fastlane/screenshots/**/*.png
83+
fastlane/test_output
84+
85+
# Code Injection
86+
#
87+
# After new code Injection tools there's a generated folder /iOSInjectionProject
88+
# https://github.com/johnno1962/injectionforxcode
89+
90+
iOSInjectionProject/
91+
92+
# macOS
93+
.DS_Store

Package.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// swift-tools-version: 6.0
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "CrossPlatformSIMD",
7+
platforms: [
8+
.macOS(.v12),
9+
.iOS(.v15),
10+
.tvOS(.v15),
11+
.watchOS(.v8),
12+
.macCatalyst(.v15),
13+
.visionOS(.v1)
14+
],
15+
products: [
16+
.library(
17+
name: "CrossPlatformSIMD",
18+
targets: ["CrossPlatformSIMD"]),
19+
],
20+
targets: [
21+
.target(
22+
name: "CrossPlatformSIMD",
23+
dependencies: [],
24+
swiftSettings: [
25+
.swiftLanguageMode(.v6)
26+
]
27+
),
28+
.testTarget(
29+
name: "CrossPlatformSIMDTests",
30+
dependencies: ["CrossPlatformSIMD"],
31+
swiftSettings: [
32+
.swiftLanguageMode(.v6)
33+
]
34+
),
35+
]
36+
)

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# CrossPlatformSIMD
2+
3+
A Swift library that provides cross-platform SIMD (Single Instruction, Multiple Data) operations for high-performance vector computations.
4+
5+
## Features
6+
7+
- Cross-platform support (macOS, iOS, tvOS, watchOS, visionOS)
8+
- Optimized vector operations using Swift's built-in SIMD types
9+
- Support for Float and Double precision
10+
- Matrix multiplication
11+
- Swift 6.1 compatible
12+
13+
## Installation
14+
15+
Add this package to your Swift project using Swift Package Manager:
16+
17+
```swift
18+
dependencies: [
19+
.package(url: "path/to/CrossPlatformSIMD", from: "1.0.0")
20+
]
21+
```
22+
23+
## Usage
24+
25+
```swift
26+
import CrossPlatformSIMD
27+
28+
let simd = SIMDOperations()
29+
30+
// Vector addition
31+
let a: [Float] = [1.0, 2.0, 3.0, 4.0]
32+
let b: [Float] = [5.0, 6.0, 7.0, 8.0]
33+
let sum = simd.addVectors(a, b) // [6.0, 8.0, 10.0, 12.0]
34+
35+
// Dot product
36+
let dot = simd.dotProduct(a, b) // 70.0
37+
38+
// Vector multiplication
39+
let product = simd.multiplyVectors(a, b) // [5.0, 12.0, 21.0, 32.0]
40+
41+
// Scale vector
42+
let scaled = simd.scaleVector(a, by: 2.0) // [2.0, 4.0, 6.0, 8.0]
43+
44+
// Sum all elements
45+
let total = simd.sumVector(a) // 10.0
46+
47+
// Matrix multiplication
48+
let matrixA = [[1.0, 2.0], [3.0, 4.0]]
49+
let matrixB = [[5.0, 6.0], [7.0, 8.0]]
50+
let matrixResult = simd.matrixMultiply(matrixA, matrixB)
51+
// [[19.0, 22.0], [43.0, 50.0]]
52+
```
53+
54+
## Performance
55+
56+
This library automatically uses SIMD instructions available on the target platform to accelerate vector operations. Operations are performed in chunks of 4 elements at a time for optimal performance.
57+
58+
## Testing
59+
60+
Run tests using Swift's built-in testing framework:
61+
62+
```bash
63+
swift test
64+
```
65+
66+
## Requirements
67+
68+
- Swift 6.1+
69+
- Xcode 16.0+ (for development)
70+
- macOS 12.0+ / iOS 15.0+ / tvOS 15.0+ / watchOS 8.0+ / visionOS 1.0+

0 commit comments

Comments
 (0)