Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate benchmarks #123

Merged
merged 16 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ xcuserdata/
## Other
*.moved-aside
*.xcuserstate
*.xcbaseline

## Obj-C/Swift specific
*.hmap
Expand Down
4 changes: 3 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ disabled_rules:
- identifier_name
- line_length
- trailing_comma

- redundant_discardable_let
- void_return

opt_in_rules:
- array_init
- attributes
Expand Down
22 changes: 22 additions & 0 deletions Metadata/Info-BenchmarkTests.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Metadata/Info-Tests.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
Expand Down
4 changes: 4 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@ let package = Package(
name: "SurgeTests",
dependencies: ["Surge"]
),
.testTarget(
name: "SurgeBenchmarkTests",
dependencies: ["Surge"]
),
]
)
28 changes: 28 additions & 0 deletions Sources/Surge/Linear Algebra/Vector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,34 @@ public func -= (lhs: inout Vector<Double>, rhs: Double) {
return subInPlace(&lhs, rhs)
}

// MARK: - Multiply Addition

public func muladd(_ lhs: Vector<Float>, _ rhs: Vector<Float>, _ alpha: Float) -> Vector<Float> {
var result = lhs
muladdInPlace(&result, rhs, alpha)
return result
}

public func muladd(_ lhs: Vector<Double>, _ rhs: Vector<Double>, _ alpha: Double) -> Vector<Double> {
var result = lhs
muladdInPlace(&result, rhs, alpha)
return result
}

// MARK: - Multiply Addition: In Place

func muladdInPlace(_ lhs: inout Vector<Float>, _ rhs: Vector<Float>, _ alpha: Float) {
precondition(lhs.dimensions == rhs.dimensions, "Vector dimensions not compatible with addition")

return muladdInPlace(&lhs.scalars, rhs.scalars, alpha)
}

func muladdInPlace(_ lhs: inout Vector<Double>, _ rhs: Vector<Double>, _ alpha: Double) {
precondition(lhs.dimensions == rhs.dimensions, "Vector dimensions not compatible with addition")

return muladdInPlace(&lhs.scalars, rhs.scalars, alpha)
}

// MARK: - Multiplication

public func mul(_ lhs: Vector<Float>, _ rhs: Float) -> Vector<Float> {
Expand Down
172 changes: 155 additions & 17 deletions Surge.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CAAF5006233A7B6700CC0AA7"
BuildableName = "SurgeBenchmarkTests-macOS.xctest"
BlueprintName = "SurgeBenchmarkTests-macOS"
ReferencedContainer = "container:Surge.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Loading