Skip to content
Open
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
8 changes: 7 additions & 1 deletion .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@ jobs:
with:
checkout-scheme: release/6.2
- name: Build
run: swift build
run: swift build --traits CompatibilityModeAttributeGraphV6
working-directory: ./Compute
- name: Test
run: |
swift test --traits CompatibilityModeAttributeGraphV6 --filter UtilitiesTests
swift test --traits CompatibilityModeAttributeGraphV6 --filter ComputeLayoutDescriptorTests
swift test --traits CompatibilityModeAttributeGraphV6 --filter ComputeTests
working-directory: ./Compute
8 changes: 4 additions & 4 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ if let useLocalDepsEnv = Context.environment["COMPUTE_USE_LOCAL_DEPS"], !useLoca
dependencies +=
[
.package(
url: "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks",
from: "0.0.4"
url: "https://github.com/jcmosc/DarwinPrivateFrameworks",
branch: "main"
)
]
}
Expand Down Expand Up @@ -73,6 +73,9 @@ let package = Package(
products: [
.library(name: "Compute", targets: ["Compute"])
],
traits: [
.trait(name: "CompatibilityModeAttributeGraphV6")
],
dependencies: dependencies,
targets: [
.target(
Expand Down
8 changes: 5 additions & 3 deletions Sources/Compute/Attribute/AnyAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension Graph {
_ attribute: AnyAttribute,
type: Metadata,
invalidating: Bool,
modify: (UnsafeMutableRawPointer) -> Void
modify: @escaping (UnsafeMutableRawPointer) -> Void
)

}
Expand All @@ -35,8 +35,10 @@ extension AnyAttribute {
}

public func mutateBody<Body>(as type: Body.Type, invalidating: Bool, _ mutator: (inout Body) -> Void) {
Graph.mutateAttribute(self, type: Metadata(type), invalidating: invalidating) { pointer in
mutator(&pointer.assumingMemoryBound(to: Body.self).pointee)
withoutActuallyEscaping(mutator) { escapingMutator in
Graph.mutateAttribute(self, type: Metadata(type), invalidating: invalidating) { pointer in
escapingMutator(&pointer.assumingMemoryBound(to: Body.self).pointee)
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion Sources/Compute/Attribute/Attribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ public struct Attribute<Value> {
let typeID = graphContext.internAttributeType(
type: Metadata(Body.self)
) {
let bodyType: _AttributeBody.Type
#if CompatibilityModeAttributeGraphV6
bodyType = Body.self
#else
bodyType = flags.contains(.external) ? _External.self : Body.self
#endif
let attributeType =
_AttributeType(
selfType: flags.contains(.external) ? _External.self : Body.self,
selfType: bodyType,
valueType: Value.self,
flags: flags,
update: update()
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComputeCxx/Graph/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ void Graph::indirect_attribute_set(data::ptr<IndirectNode> indirect_node, Attrib
}

uint64_t source_subgraph_id = source && !source.is_nil() ? source.subgraph()->subgraph_id() : 0;
indirect_node->modify(WeakAttributeID(source, source_subgraph_id), resolved_source.offset());
indirect_node->modify(WeakAttributeID(source, uint32_t(source_subgraph_id)), resolved_source.offset());
indirect_node->set_traverses_contexts(AttributeID(indirect_node).subgraph()->context_id() !=
source.subgraph()->context_id());

Expand Down
42 changes: 32 additions & 10 deletions Tests/ComputeTests/Shared/Attribute/AttributeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,28 @@ struct AttributeTests {
)

let attributeType = attribute.identifier.info.type.pointee
#expect(attributeType.self_id == Metadata(_External.self))
#if CompatibilityModeAttributeGraphV6
#expect(attributeType.self_id == Metadata(External<Int>.self))
#else
#expect(attributeType.self_id == Metadata(_External.self))
#endif
#expect(attributeType.value_id == Metadata(Int.self))

#expect(attributeType.flags == [.external, .comparisonModeEquatableAlways])
#expect(attributeType.internal_offset == 28)
#expect(attributeType.value_layout == expectedlayout)

let attributeBody = unsafeBitCast(
_External.self as any _AttributeBody.Type,
to: (type: Metadata, witnessTable: UnsafeRawPointer).self
)
#if CompatibilityModeAttributeGraphV6
let attributeBody = unsafeBitCast(
External<Int>.self as any _AttributeBody.Type,
to: (type: Metadata, witnessTable: UnsafeRawPointer).self
)
#else
let attributeBody = unsafeBitCast(
_External.self as any _AttributeBody.Type,
to: (type: Metadata, witnessTable: UnsafeRawPointer).self
)
#endif
#expect(attributeType.body_conformance.type_id == attributeBody.type)
#expect(attributeType.body_conformance.witness_table == attributeBody.witnessTable)
}
Expand All @@ -69,17 +80,28 @@ struct AttributeTests {
)

let attributeType = attribute.identifier.info.type.pointee
#expect(attributeType.self_id == Metadata(_External.self))
#if CompatibilityModeAttributeGraphV6
#expect(attributeType.self_id == Metadata(External<Int>.self))
#else
#expect(attributeType.self_id == Metadata(_External.self))
#endif
#expect(attributeType.value_id == Metadata(Int.self))

#expect(attributeType.flags == [.external, .comparisonModeEquatableAlways])
#expect(attributeType.internal_offset == 28)
#expect(attributeType.value_layout == expectedlayout)

let attributeBody = unsafeBitCast(
_External.self as any _AttributeBody.Type,
to: (type: Metadata, witnessTable: UnsafeRawPointer).self
)
#if CompatibilityModeAttributeGraphV6
let attributeBody = unsafeBitCast(
External<Int>.self as any _AttributeBody.Type,
to: (type: Metadata, witnessTable: UnsafeRawPointer).self
)
#else
let attributeBody = unsafeBitCast(
_External.self as any _AttributeBody.Type,
to: (type: Metadata, witnessTable: UnsafeRawPointer).self
)
#endif
#expect(attributeType.body_conformance.type_id == attributeBody.type)
#expect(attributeType.body_conformance.witness_table == attributeBody.witnessTable)
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/ComputeTests/Shared/Graph/GraphTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ struct GraphTests {

@Test
func initialDescription() async throws {
await try #require(processExitsWith: .success) {
try await #require(processExitsWith: .success) {
let description =
try #require(
Graph.description(nil, options: [DescriptionOption.format: "graph/dict"] as NSDictionary)
Expand Down Expand Up @@ -336,7 +336,7 @@ struct GraphTests {
// which we can't predict deterministically.
@Test
func graphDescription() async throws {
await try #require(processExitsWith: .success) {
try await #require(processExitsWith: .success) {
let graph = Graph()

let subgraph = Subgraph(graph: graph)
Expand Down
Loading