Skip to content
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
2 changes: 1 addition & 1 deletion Benchmarks/Benchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ struct Zone: Randomizable & Generic {

@inlinable
init(from rep: RawRepresentation) {
self.id = rep._0
self.id = Int(from: rep._0)
self.position = Vec3<Float>(from: rep._1)
}
}
23 changes: 14 additions & 9 deletions Sources/MultiArray/ArrayData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@ extension ArrayData where Buffer == UnsafeMutablePointer<Self> {
}

// Primal types
extension Int: ArrayData {}
Comment thread
JaapWijnen marked this conversation as resolved.
extension Int8: ArrayData {}
extension Int16: ArrayData {}
extension Int32: ArrayData {}
extension Int64: ArrayData {}
@available(macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, *)
extension Int128: ArrayData {}
extension UInt: ArrayData {}
extension UInt8: ArrayData {}
extension UInt16: ArrayData {}
extension UInt32: ArrayData {}
Expand All @@ -90,13 +88,13 @@ extension Float16: ArrayData {}
extension Float32: ArrayData {}
extension Float64: ArrayData {}

extension SIMD2: ArrayData {}
extension SIMD3: ArrayData {}
extension SIMD4: ArrayData {}
extension SIMD8: ArrayData {}
extension SIMD16: ArrayData {}
extension SIMD32: ArrayData {}
extension SIMD64: ArrayData {}
extension SIMD2: ArrayData where Scalar: Generic, Scalar.RawRepresentation: ArrayData {}
extension SIMD3: ArrayData where Scalar: Generic, Scalar.RawRepresentation: ArrayData {}
extension SIMD4: ArrayData where Scalar: Generic, Scalar.RawRepresentation: ArrayData {}
extension SIMD8: ArrayData where Scalar: Generic, Scalar.RawRepresentation: ArrayData {}
extension SIMD16: ArrayData where Scalar: Generic, Scalar.RawRepresentation: ArrayData {}
extension SIMD32: ArrayData where Scalar: Generic, Scalar.RawRepresentation: ArrayData {}
extension SIMD64: ArrayData where Scalar: Generic, Scalar.RawRepresentation: ArrayData {}

public extension FixedWidthInteger {
typealias Buffer = UnsafeMutablePointer<Self>
Expand Down Expand Up @@ -269,6 +267,13 @@ internal func getRawSize<T>(for _: T.Type, count: Int, from offset: Int) -> Int
internal func reserveCapacity<T>(for type: T.Type, count: Int, from context: inout UnsafeMutableRawPointer) -> UnsafeMutablePointer<T> {
let begin = context.alignedUp(for: type)
let end = begin + count * MemoryLayout<T>.stride
let pad = begin - context

// Initialise any gaps between the struct-of-array chunks
if pad > 0 {
context.initializeMemory(as: UInt8.self, repeating: 0x00, count: pad)
}

context = end
return begin.bindMemory(to: type, capacity: count)
}
Loading