Skip to content

Commit c03f2c0

Browse files
committed
Merge branch 'main' into wip-distributed-actors-prime-main
2 parents 9530ee1 + c5a7512 commit c03f2c0

File tree

777 files changed

+47561
-10016
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

777 files changed

+47561
-10016
lines changed

.mailmap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Adrian-Constantin Popescu <[email protected]> <[email protected]>
22
3-
4-
3+
4+
55
Alexis Beingessner <[email protected]> <[email protected]>
66
77

CHANGELOG.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
| Version | Released | Toolchain |
88
| :--------------------- | :--------- | :---------- |
9+
| [Swift 5.5](#swift-55) | | |
910
| [Swift 5.4](#swift-54) | | |
1011
| [Swift 5.3](#swift-53) | 2020-09-16 | Xcode 12.0 |
1112
| [Swift 5.2](#swift-52) | 2020-03-24 | Xcode 11.4 |
@@ -25,8 +26,28 @@ CHANGELOG
2526

2627
</details>
2728

28-
Swift Next
29-
----------
29+
Swift 5.5
30+
---------
31+
32+
* [SE-0299][]:
33+
34+
It is now possible to use leading-dot syntax in generic contexts to access static members of protocol extensions where `Self` is constrained to a fully concrete type:
35+
36+
```swift
37+
public protocol ToggleStyle { ... }
38+
39+
public struct DefaultToggleStyle: ToggleStyle { ... }
40+
41+
extension ToggleStyle where Self == DefaultToggleStyle {
42+
public static var `default`: Self { .init() }
43+
}
44+
45+
struct Toggle {
46+
func applyToggle<T: ToggleStyle>(_ style: T) { ... }
47+
}
48+
49+
Toggle(...).applyToggle(.default)
50+
```
3051

3152
* Whenever a reference to `Self` does not impede the usage of a protocol as a value type, or a protocol member on a value of protocol type, the same is now true for references to `[Self]` and `[Key : Self]`:
3253

@@ -8363,6 +8384,7 @@ Swift 1.0
83638384
[SE-0296]: <https://github.com/apple/swift-evolution/blob/main/proposals/0296-async-await.md>
83648385
[SE-0297]: <https://github.com/apple/swift-evolution/blob/main/proposals/0297-concurrency-objc.md>
83658386
[SE-0298]: <https://github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
8387+
[SE-0299]: <https://github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md>
83668388

83678389
[SR-75]: <https://bugs.swift.org/browse/SR-75>
83688390
[SR-106]: <https://bugs.swift.org/browse/SR-106>

CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
148148
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
149149
# can be reused when a new version of Swift comes out (assuming the user hasn't
150150
# manually set it as part of their own CMake configuration).
151-
set(SWIFT_VERSION "5.4")
151+
set(SWIFT_VERSION "5.5")
152152

153153
set(SWIFT_VENDOR "" CACHE STRING
154154
"The vendor name of the Swift compiler")
@@ -196,13 +196,6 @@ if(SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE})
196196
add_definitions("-fprofile-instr-use=${SWIFT_PROFDATA_FILE}")
197197
endif()
198198

199-
option(USE_SWIFT_ASYNC_LOWERING
200-
"Indicates if Swiftc should use async-specific lowering for async
201-
functions if it is supported for the target. The runtime also checks
202-
this setting before using async-specific attributes. This only applies
203-
to the async calling convention and not to the async context attribute."
204-
TRUE)
205-
206199
#
207200
# User-configurable Swift Standard Library specific options.
208201
#

benchmark/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ set(SWIFT_BENCH_MODULES
158158
single-source/RemoveWhere
159159
single-source/ReversedCollections
160160
single-source/RomanNumbers
161+
single-source/SIMDReduceInteger
161162
single-source/SequenceAlgos
162163
single-source/SetTests
163164
single-source/SevenBoom
@@ -179,6 +180,7 @@ set(SWIFT_BENCH_MODULES
179180
single-source/StringMatch
180181
single-source/StringRemoveDupes
181182
single-source/StringReplaceSubrange
183+
single-source/StringSplitting
182184
single-source/StringSwitch
183185
single-source/StringTests
184186
single-source/StringWalk
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
//===--- SIMDReduceInteger.swift ------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2021 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import TestsUtils
14+
15+
public let SIMDReduceInteger = [
16+
BenchmarkInfo(
17+
name: "SIMDReduce.Int32",
18+
runFunction: run_SIMDReduceInt32x1,
19+
tags: [.validation, .SIMD],
20+
setUpFunction: { blackHole(int32Data) }
21+
),
22+
BenchmarkInfo(
23+
name: "SIMDReduce.Int32x4.Initializer",
24+
runFunction: run_SIMDReduceInt32x4_init,
25+
tags: [.validation, .SIMD],
26+
setUpFunction: { blackHole(int32Data) }
27+
),
28+
BenchmarkInfo(
29+
name: "SIMDReduce.Int32x4.Cast",
30+
runFunction: run_SIMDReduceInt32x4_cast,
31+
tags: [.validation, .SIMD],
32+
setUpFunction: { blackHole(int32Data) }
33+
),
34+
BenchmarkInfo(
35+
name: "SIMDReduce.Int32x16.Initializer",
36+
runFunction: run_SIMDReduceInt32x16_init,
37+
tags: [.validation, .SIMD],
38+
setUpFunction: { blackHole(int32Data) }
39+
),
40+
BenchmarkInfo(
41+
name: "SIMDReduce.Int32x16.Cast",
42+
runFunction: run_SIMDReduceInt32x16_cast,
43+
tags: [.validation, .SIMD],
44+
setUpFunction: { blackHole(int32Data) }
45+
),
46+
BenchmarkInfo(
47+
name: "SIMDReduce.Int8",
48+
runFunction: run_SIMDReduceInt8x1,
49+
tags: [.validation, .SIMD],
50+
setUpFunction: { blackHole(int8Data) }
51+
),
52+
BenchmarkInfo(
53+
name: "SIMDReduce.Int8x16.Initializer",
54+
runFunction: run_SIMDReduceInt8x16_init,
55+
tags: [.validation, .SIMD],
56+
setUpFunction: { blackHole(int8Data) }
57+
),
58+
BenchmarkInfo(
59+
name: "SIMDReduce.Int8x16.Cast",
60+
runFunction: run_SIMDReduceInt8x16_cast,
61+
tags: [.validation, .SIMD],
62+
setUpFunction: { blackHole(int8Data) }
63+
),
64+
BenchmarkInfo(
65+
name: "SIMDReduce.Int8x64.Initializer",
66+
runFunction: run_SIMDReduceInt8x64_init,
67+
tags: [.validation, .SIMD],
68+
setUpFunction: { blackHole(int8Data) }
69+
),
70+
BenchmarkInfo(
71+
name: "SIMDReduce.Int8x64.Cast",
72+
runFunction: run_SIMDReduceInt8x64_cast,
73+
tags: [.validation, .SIMD],
74+
setUpFunction: { blackHole(int8Data) }
75+
)
76+
]
77+
78+
// TODO: use 100 for Onone?
79+
let scale = 1000
80+
81+
let int32Data: UnsafeBufferPointer<Int32> = {
82+
let count = 256
83+
// Allocate memory for `count` Int32s with alignment suitable for all
84+
// SIMD vector types.
85+
let untyped = UnsafeMutableRawBufferPointer.allocate(
86+
byteCount: MemoryLayout<Int32>.size * count, alignment: 16
87+
)
88+
// Intialize the memory as Int32 and fill with random values.
89+
let typed = untyped.initializeMemory(as: Int32.self, repeating: 0)
90+
var g = SplitMix64(seed: 0)
91+
for i in 0 ..< typed.count {
92+
typed[i] = .random(in: .min ... .max, using: &g)
93+
}
94+
return UnsafeBufferPointer(typed)
95+
}()
96+
97+
@inline(never)
98+
public func run_SIMDReduceInt32x1(_ N: Int) {
99+
for _ in 0 ..< scale*N {
100+
var accum: Int32 = 0
101+
for v in int32Data {
102+
accum &+= v &* v
103+
}
104+
blackHole(accum)
105+
}
106+
}
107+
108+
@inline(never)
109+
public func run_SIMDReduceInt32x4_init(_ N: Int) {
110+
for _ in 0 ..< scale*N {
111+
var accum = SIMD4<Int32>()
112+
for i in stride(from: 0, to: int32Data.count, by: 4) {
113+
let v = SIMD4(int32Data[i ..< i+4])
114+
accum &+= v &* v
115+
}
116+
blackHole(accum.wrappedSum())
117+
}
118+
}
119+
120+
@inline(never)
121+
public func run_SIMDReduceInt32x4_cast(_ N: Int) {
122+
// Morally it seems like we "should" be able to use withMemoryRebound
123+
// to SIMD4<Int32>, but that function requries that the sizes match in
124+
// debug builds, so this is pretty ugly. The following "works" for now,
125+
// but is probably in violation of the formal model (the exact rules
126+
// for "assumingMemoryBound" are not clearly documented). We need a
127+
// better solution.
128+
let vecs = UnsafeBufferPointer<SIMD4<Int32>>(
129+
start: UnsafeRawPointer(int32Data.baseAddress!).assumingMemoryBound(to: SIMD4<Int32>.self),
130+
count: int32Data.count / 4
131+
)
132+
for _ in 0 ..< scale*N {
133+
var accum = SIMD4<Int32>()
134+
for v in vecs {
135+
accum &+= v &* v
136+
}
137+
blackHole(accum.wrappedSum())
138+
}
139+
}
140+
141+
@inline(never)
142+
public func run_SIMDReduceInt32x16_init(_ N: Int) {
143+
for _ in 0 ..< scale*N {
144+
var accum = SIMD16<Int32>()
145+
for i in stride(from: 0, to: int32Data.count, by: 16) {
146+
let v = SIMD16(int32Data[i ..< i+16])
147+
accum &+= v &* v
148+
}
149+
blackHole(accum.wrappedSum())
150+
}
151+
}
152+
153+
@inline(never)
154+
public func run_SIMDReduceInt32x16_cast(_ N: Int) {
155+
let vecs = UnsafeBufferPointer<SIMD16<Int32>>(
156+
start: UnsafeRawPointer(int32Data.baseAddress!).assumingMemoryBound(to: SIMD16<Int32>.self),
157+
count: int32Data.count / 16
158+
)
159+
for _ in 0 ..< scale*N {
160+
var accum = SIMD16<Int32>()
161+
for v in vecs {
162+
accum &+= v &* v
163+
}
164+
blackHole(accum.wrappedSum())
165+
}
166+
}
167+
168+
let int8Data: UnsafeBufferPointer<Int8> = {
169+
let count = 1024
170+
// Allocate memory for `count` Int8s with alignment suitable for all
171+
// SIMD vector types.
172+
let untyped = UnsafeMutableRawBufferPointer.allocate(
173+
byteCount: MemoryLayout<Int8>.size * count, alignment: 16
174+
)
175+
// Intialize the memory as Int8 and fill with random values.
176+
let typed = untyped.initializeMemory(as: Int8.self, repeating: 0)
177+
var g = SplitMix64(seed: 0)
178+
for i in 0 ..< typed.count {
179+
typed[i] = .random(in: .min ... .max, using: &g)
180+
}
181+
return UnsafeBufferPointer(typed)
182+
}()
183+
184+
@inline(never)
185+
public func run_SIMDReduceInt8x1(_ N: Int) {
186+
for _ in 0 ..< scale*N {
187+
var accum: Int8 = 0
188+
for v in int8Data {
189+
accum &+= v &* v
190+
}
191+
blackHole(accum)
192+
}
193+
}
194+
195+
@inline(never)
196+
public func run_SIMDReduceInt8x16_init(_ N: Int) {
197+
for _ in 0 ..< scale*N {
198+
var accum = SIMD16<Int8>()
199+
for i in stride(from: 0, to: int8Data.count, by: 16) {
200+
let v = SIMD16(int8Data[i ..< i+16])
201+
accum &+= v &* v
202+
}
203+
blackHole(accum.wrappedSum())
204+
}
205+
}
206+
207+
@inline(never)
208+
public func run_SIMDReduceInt8x16_cast(_ N: Int) {
209+
let vecs = UnsafeBufferPointer<SIMD16<Int8>>(
210+
start: UnsafeRawPointer(int8Data.baseAddress!).assumingMemoryBound(to: SIMD16<Int8>.self),
211+
count: int8Data.count / 16
212+
)
213+
for _ in 0 ..< scale*N {
214+
var accum = SIMD16<Int8>()
215+
for v in vecs {
216+
accum &+= v &* v
217+
}
218+
blackHole(accum.wrappedSum())
219+
}
220+
}
221+
222+
@inline(never)
223+
public func run_SIMDReduceInt8x64_init(_ N: Int) {
224+
for _ in 0 ..< scale*N {
225+
var accum = SIMD64<Int8>()
226+
for i in stride(from: 0, to: int8Data.count, by: 64) {
227+
let v = SIMD64(int8Data[i ..< i+64])
228+
accum &+= v &* v
229+
}
230+
blackHole(accum.wrappedSum())
231+
}
232+
}
233+
234+
@inline(never)
235+
public func run_SIMDReduceInt8x64_cast(_ N: Int) {
236+
let vecs = UnsafeBufferPointer<SIMD64<Int8>>(
237+
start: UnsafeRawPointer(int8Data.baseAddress!).assumingMemoryBound(to: SIMD64<Int8>.self),
238+
count: int8Data.count / 64
239+
)
240+
for _ in 0 ..< scale*N {
241+
var accum = SIMD64<Int8>()
242+
for v in vecs {
243+
accum &+= v &* v
244+
}
245+
blackHole(accum.wrappedSum())
246+
}
247+
}

0 commit comments

Comments
 (0)