Skip to content

[Accelerate] [vForce] New vForce Overlay #23153

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

Closed
wants to merge 13 commits into from
Closed
17 changes: 17 additions & 0 deletions stdlib/public/Darwin/Accelerate/Accelerate.swift
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 {}
5 changes: 5 additions & 0 deletions stdlib/public/Darwin/Accelerate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.4.3)
include("../../../../cmake/modules/StandaloneOverlay.cmake")

add_swift_target_library(swiftAccelerate ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
Accelerate.swift
ContiguousCollection.swift
vForce_Operations.swift

"${SWIFT_SOURCE_DIR}/stdlib/linker-support/magic-symbols-for-install-name.c"

Expand All @@ -17,6 +20,8 @@ add_swift_target_library(swiftAccelerate ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES
SWIFT_MODULE_DEPENDS_TVOS Darwin CoreFoundation CoreGraphics Dispatch Foundation Metal ObjectiveC os # auto-updated
SWIFT_MODULE_DEPENDS_WATCHOS Darwin CoreFoundation CoreGraphics Dispatch Foundation ObjectiveC os # auto-updated

FRAMEWORK_DEPENDS Accelerate

DEPLOYMENT_VERSION_OSX ${SWIFTLIB_DEPLOYMENT_VERSION_SIMD_OSX}
DEPLOYMENT_VERSION_IOS ${SWIFTLIB_DEPLOYMENT_VERSION_SIMD_IOS}
DEPLOYMENT_VERSION_TVOS ${SWIFTLIB_DEPLOYMENT_VERSION_SIMD_TVOS}
Expand Down
72 changes: 72 additions & 0 deletions stdlib/public/Darwin/Accelerate/ContiguousCollection.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

/// A collection that supports access to its underlying contiguous storage.
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *)
public protocol _ContiguousCollection: Collection
where SubSequence: _ContiguousCollection {
/// Calls a closure with a pointer to the array's contiguous storage.
func withUnsafeBufferPointer<R>(
_ body: (UnsafeBufferPointer<Element>) throws -> R
) rethrows -> R
}

@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *)
public extension _ContiguousCollection {
func withUnsafeBufferPointer<R>(
_ body: (UnsafeBufferPointer<Element>) throws -> R
) rethrows -> R {
return try withContiguousStorageIfAvailable(body)!
}
}

/// A collection that supports mutable access to its underlying contiguous
/// storage.
@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *)
public protocol _MutableContiguousCollection: _ContiguousCollection, MutableCollection
where SubSequence: _MutableContiguousCollection {
/// Calls the given closure with a pointer to the array'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, *)
extension _MutableContiguousCollection {
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: _MutableContiguousCollection { }

@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *)
extension ContiguousArray: _MutableContiguousCollection { }

@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *)
extension ArraySlice: _MutableContiguousCollection { }

@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *)
extension UnsafeBufferPointer: _ContiguousCollection { }

@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *)
extension UnsafeMutableBufferPointer: _MutableContiguousCollection { }

@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *)
extension Slice: _ContiguousCollection where Base: _ContiguousCollection { }

@available(iOS 9999, OSX 9999, tvOS 9999, watchOS 9999, *)
extension Slice: _MutableContiguousCollection where Base: _MutableContiguousCollection { }
Loading