Skip to content

Instantly share code, notes, and snippets.

@LucianoPAlmeida
Created March 14, 2021 18:02
Show Gist options
  • Save LucianoPAlmeida/a5a4874c8fec5e62dd45e5458ab6a50b to your computer and use it in GitHub Desktop.
Save LucianoPAlmeida/a5a4874c8fec5e62dd45e5458ab6a50b to your computer and use it in GitHub Desktop.
typealias Vec4 = (Int8, Int8, Int8, Int8)
@inline(__always)
func vecAdd(x: inout ContiguousArray<Vec4>, s: Int8) {
for i in 0..<x.count {
x[i].0 &+= s
x[i].1 &+= s
x[i].2 &+= s
x[i].3 &+= s
}
}
@inline(__always)
func vecAddSIMD(x: inout ContiguousArray<SIMD4<Int8>>, s: Int8) {
for i in 0..<x.count {
x[i] &+= s
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment