Skip to content

Commit c48793f

Browse files
Various improvements and fixes.
1 parent df48446 commit c48793f

27 files changed

+7441
-6841
lines changed

Benchmark/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
//===----------------------------------------------------------------------===//
44
//
5-
// Copyright (c) 2023 Svyatoslav Popov.
5+
// Copyright (c) 2023 Svyatoslav Popov ([email protected]).
66
//
77
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
88
// the License. You may obtain a copy of the License at

Benchmark/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# kvSIMD.swift/Benchmark
22

33
It's a simple console application measuring performance of [*kvSIMD.swift*](https://github.com/keyvariable/kvSIMD.swift) framework.
4-
It runs on platforms where the SIMD framework is avaialble.
5-
Recent report is in `/report.md` file.
4+
It runs on platforms where the SIMD framework is available.
5+
Recent report is in [`/report.md`]((./report.md)) file.

Benchmark/Sources/kvSimdBenchmark/KvBenchmark.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//===----------------------------------------------------------------------===//
22
//
3-
// Copyright (c) 2023 Svyatoslav Popov.
3+
// Copyright (c) 2023 Svyatoslav Popov ([email protected]).
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
// the License. You may obtain a copy of the License at

Benchmark/Sources/kvSimdBenchmark/KvBenchmarkApp.swift

Lines changed: 957 additions & 957 deletions
Large diffs are not rendered by default.

Package.swift

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
//===----------------------------------------------------------------------===//
44
//
5-
// Copyright (c) 2023 Svyatoslav Popov.
5+
// Copyright (c) 2023 Svyatoslav Popov ([email protected]).
66
//
77
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
88
// the License. You may obtain a copy of the License at
@@ -23,16 +23,28 @@ import PackageDescription
2323

2424
let swiftSettings: [SwiftSetting]? = nil
2525

26+
let isSimdAvailable: Bool
27+
#if canImport(simd)
28+
isSimdAvailable = true
29+
#else // !canImport(simd)
30+
isSimdAvailable = false
31+
#endif // !canImport(simd)
32+
33+
// Module is named "simd" to use `import simd` when the SIMD framework is not available.
34+
// Otherwise it's named "kvSIMD" to prevent collision.
35+
let moduleName = isSimdAvailable ? "kvSIMD" : "simd"
36+
let placeholderModuleName = "kvSIMD_Placeholder"
37+
38+
2639
let package = Package(
2740
name: "kvSIMD.swift",
2841

29-
products: [
30-
.library(name: "kvSIMD", targets: [ "kvSIMD" ]),
31-
],
42+
products: [ .library(name: "kvSIMD", targets: [ !isSimdAvailable ? moduleName : placeholderModuleName ]) ],
43+
44+
targets: Array([
45+
[ .target(name: moduleName, path: "Sources/kvSIMD", swiftSettings: swiftSettings),
46+
.target(name: placeholderModuleName), ],
3247

33-
targets: [
34-
.target(name: "kvSIMD", dependencies: [ "kvSimdImpl" ], swiftSettings: swiftSettings),
35-
.target(name: "kvSimdImpl", swiftSettings: swiftSettings),
36-
.testTarget(name: "kvSimdImplTests", dependencies: [ "kvSimdImpl" ], swiftSettings: swiftSettings),
37-
]
48+
isSimdAvailable ? [ .testTarget(name: "kvSIMDTests", dependencies: [ .target(name: moduleName) ], swiftSettings: swiftSettings) ] : [ ],
49+
].joined())
3850
)

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
# kvSIMD.swift
22

3-
*kvSIMD.swift* is a crossplatform vectorization-friendly implementation of the SIMD framework interface on Swift.
3+
*kvSIMD.swift* is a cross-platform vectorization-friendly implementation of the SIMD framework interface on Swift.
44

5-
Preferred way to import *kvSIMD.swift* is `import kvSIMD`.
6-
*kvSIMD* module is the same as `import simd` or `import kvSimdImpl` whether the SIMD framework is available.
7-
Use `import kvSimdImpl` to import custom implementation unconditionally.
5+
Structure of package is designed to import *kvSIMD.swift* via `import simd` expression when the SIMD framework is unavailable.
6+
So `import simd` expression imports the SIMD framework if available and *kvSIMD.swift* otherwise.
87

98
There are no explicit restrictions for any platform.
109
So it's assumed that *kvSIMD.swift* is compiled on any platform Swift is available on.
1110
It's checked on macOS and Linux (Ubuntu 22.04).
12-
11+
1312
*kvSIMD.swift* is covered by unit-tests.
1413

1514
Simple benchmark console application is provided.
16-
It's in `/Benchmark` directory.
17-
Benchmark runs on platforms where the SIMD framework is avaialble.
18-
Recent report is available at `/Benchmark/report.md` path.
15+
It's in [`/Benchmark`](./Benchmark) directory.
16+
Benchmark runs on platforms where the SIMD framework is available.
17+
Recent report is available at [`/Benchmark/report.md`](./Benchmark/report.md) path.
1918

2019

2120
## Getting Started
@@ -30,7 +29,7 @@ Recent report is available at `/Benchmark/report.md` path.
3029
```
3130
#### Import:
3231
```swift
33-
import kvSIMD
32+
import simd
3433
```
3534

3635

Sources/kvSimdImpl/KvAux.swift renamed to Sources/kvSIMD/KvAux.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//===----------------------------------------------------------------------===//
22
//
3-
// Copyright (c) 2023 Svyatoslav Popov.
3+
// Copyright (c) 2023 Svyatoslav Popov ([email protected]).
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
// the License. You may obtain a copy of the License at
@@ -16,7 +16,7 @@
1616
//===----------------------------------------------------------------------===//
1717
//
1818
// KvAux.swift
19-
// kvSimdImpl
19+
// kvSIMD
2020
//
2121
// Created by Svyatoslav Popov on 28.07.2023.
2222
//

Sources/kvSimdImpl/KvConstants.swift renamed to Sources/kvSIMD/KvConstants.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//===----------------------------------------------------------------------===//
22
//
3-
// Copyright (c) 2023 Svyatoslav Popov.
3+
// Copyright (c) 2023 Svyatoslav Popov ([email protected]).
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
// the License. You may obtain a copy of the License at
@@ -16,7 +16,7 @@
1616
//===----------------------------------------------------------------------===//
1717
//
1818
// KvConstants.swift
19-
// kvSimdImpl
19+
// kvSIMD
2020
//
2121
// Created by Svyatoslav Popov on 27.08.2023.
2222
//

Sources/kvSimdImpl/KvConversions.swift renamed to Sources/kvSIMD/KvConversions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//===----------------------------------------------------------------------===//
22
//
3-
// Copyright (c) 2023 Svyatoslav Popov.
3+
// Copyright (c) 2023 Svyatoslav Popov ([email protected]).
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
// the License. You may obtain a copy of the License at
@@ -16,7 +16,7 @@
1616
//===----------------------------------------------------------------------===//
1717
//
1818
// KvConversions.swift
19-
// kvSimdImpl
19+
// kvSIMD
2020
//
2121
// Created by Svyatoslav Popov on 25.08.2023.
2222
//

Sources/kvSimdImpl/KvExtensions.swift renamed to Sources/kvSIMD/KvExtensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//===----------------------------------------------------------------------===//
22
//
3-
// Copyright (c) 2023 Svyatoslav Popov.
3+
// Copyright (c) 2023 Svyatoslav Popov ([email protected]).
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
66
// the License. You may obtain a copy of the License at
@@ -16,7 +16,7 @@
1616
//===----------------------------------------------------------------------===//
1717
//
1818
// KvExtensions.swift
19-
// kvSimdImpl
19+
// kvSIMD
2020
//
2121
// Created by Svyatoslav Popov on 27.07.2023.
2222
//

0 commit comments

Comments
 (0)