-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Accelerate vForce #24152
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
Merged
stephentyrone
merged 14 commits into
swiftlang:master
from
stephentyrone:accelerate-vForce
Apr 19, 2019
Merged
Accelerate vForce #24152
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8b450c0
[Accelerate] [vForce] New vForce Overlay
FlexMonkey 0f8b702
Change availability version numbers.
FlexMonkey 26df07f
Change copyright date.
FlexMonkey 922444b
Code Review Fixes,
FlexMonkey 5dffd45
fix version numbers.
FlexMonkey 7670a6d
Move vForce operations to a vForce namespace.
FlexMonkey 46ac355
* Create individual `exp`, `expm1`, `exp2` functions.
FlexMonkey 267433d
Refactor tests.
FlexMonkey 14ec828
Add versions of operations that return an array using `unsafeUninitia…
FlexMonkey 3ca63c3
Code review changes:
173e500
Added todo task.
e91bcfc
Change from _ContiguousCollection to AccelerateBuffer.
stephentyrone 6ef3f2d
Re-instate magic linker stuffs
stephentyrone fd9e1d3
s/MutableAccelerateBuffer/AccelerateMutableBuffer/
stephentyrone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// An enum that acts as a namespace for Swift overlays to vDSP based functions. | ||
public enum vDSP {} | ||
|
||
/// An enum that acts as a namespace for Swift overlays to vForce based functions. | ||
public enum vForce {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
stdlib/public/Darwin/Accelerate/ContiguousCollection.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2019 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// An object composed of count elements that are stored contiguously in memory. | ||
/// | ||
/// In practice, most types conforming to this protocol will be Collections, | ||
/// but they need not be--they need only have an Element type and count, and | ||
/// provide the withUnsafeBufferPointer function. | ||
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *) | ||
public protocol AccelerateBuffer { | ||
/// The buffer's element type. | ||
associatedtype Element | ||
|
||
/// The number of elements in the buffer. | ||
var count: Int { get } | ||
|
||
/// Calls a closure with a pointer to the object's contiguous storage. | ||
func withUnsafeBufferPointer<R>( | ||
_ body: (UnsafeBufferPointer<Element>) throws -> R | ||
) rethrows -> R | ||
} | ||
|
||
/// A mutable object composed of count elements that are stored contiguously | ||
/// in memory. | ||
/// | ||
/// In practice, most types conforming to this protocol will be | ||
/// MutableCollections, but they need not be. | ||
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *) | ||
public protocol AccelerateMutableBuffer: AccelerateBuffer { | ||
/// Calls the given closure with a pointer to the object's mutable | ||
/// contiguous storage. | ||
mutating func withUnsafeMutableBufferPointer<R>( | ||
_ body: (inout UnsafeMutableBufferPointer<Element>) throws -> R | ||
) rethrows -> R | ||
} | ||
|
||
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *) | ||
public extension AccelerateBuffer where Self: Collection { | ||
func withUnsafeBufferPointer<R>( | ||
_ body: (UnsafeBufferPointer<Element>) throws -> R | ||
) rethrows -> R { | ||
return try withContiguousStorageIfAvailable(body)! | ||
} | ||
} | ||
|
||
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *) | ||
extension AccelerateMutableBuffer where Self: MutableCollection { | ||
public mutating func withUnsafeMutableBufferPointer<R>( | ||
_ body: (inout UnsafeMutableBufferPointer<Element>) throws -> R | ||
) rethrows -> R { | ||
return try withContiguousMutableStorageIfAvailable(body)! | ||
} | ||
} | ||
|
||
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *) | ||
extension Array: AccelerateMutableBuffer { } | ||
|
||
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *) | ||
extension ContiguousArray: AccelerateMutableBuffer { } | ||
|
||
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *) | ||
extension ArraySlice: AccelerateMutableBuffer { } | ||
|
||
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *) | ||
extension UnsafeBufferPointer: AccelerateBuffer { } | ||
|
||
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *) | ||
extension UnsafeMutableBufferPointer: AccelerateMutableBuffer { } | ||
|
||
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *) | ||
extension Slice: AccelerateBuffer where Base: Collection { } | ||
|
||
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *) | ||
extension Slice: AccelerateMutableBuffer where Base: MutableCollection { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming the file as well would not be unjustified...