error: use of unresolved identifier 'benchmark'
Must be something basic I am missing. Here's my Package.swift:
import PackageDescription
let package = Package( name: "TestBasemath", dependencies: [ .package(url: "https://github.com/jph00/BaseMath.git", from: "1.0.0"), ], targets: [
.target(
name: "TestBasemath",
dependencies: ["BaseMath"]),
.testTarget(
name: "TestBasemathTests",
dependencies: ["TestBasemath"]),
]
)
Here's my quick test code:
import BaseMath
print("Hello, world!")
let ar1 = [1.0, 2.0, 3.0] let ar2 = [0.0, 0.0, 0.0]
benchmark(title:"swift ptr add") { let (p1, p2) = (ar1.p, ar2.p) for i in 0..<ar1.count { p2[i] = p1[i] + 2.0 } }
Note that if I just remove the benchmark, the for loop will run without error. This mean the Float or Double is understanding .p is supposed to return the raw pointer. I am not sure why it isn't resolving the benchmark func defined in Utils.swift
I am entire new to swift packager, but tracing the error in the .build directory, I see this:
.build/checkouts/BaseMath.git--313326703360584819/Sources/BaseMath
This looked like a git checkout and under Sources/BaseMath, it has (I think) everything but that Utils.swift (which contains the benchmark(...) func. E.g. it has Storage.swift
So I am not sure if I am closer to the real problem. I mean I probably can write my own benchmark func which is simple enough, and just move on. But I would like to take this chance to understand Swift packager.
I now suspect it may be based on release. My package.resolved file indicated it picked up version 1.0.1, but this was released 7 days ago, while Utils.swift was last touched 5 days ago.
@jph00 If you have a chance, pls try release 1.0.2 with the latest stuff, then I can confirm if thats my problem. I understand this is all unsupported stuff.
@kechan did you fix this? Maybe just needed a package update?
I think you have to make a release, maybe call it 1.0.2
Here's what I did to test this as a swift package (not using in an Xcode project)
- $ mkdir KCTestMathBase
- $ cd KCTestMathBase
- $ swift package init
- in Package.swift, change: .package(url:"https://github.com/jph00/BaseMath.git", from: "1.0.1"),
- $ swift build -Xswiftc -Ounchecked -Xcc -ffast-math -Xcc -O2 -Xcc -march=native
Compile CBaseMath CBaseMath.c Compile Swift Module 'BaseMath' (3 sources) Compile Swift Module 'KCTestMathBase' (1 sources)
There are only 3 sources for BaseMath which is not correct, it is based on release 1.0.1 and it doesn't have the latest sources.
I confirmed that this is indeed a problem with your release (old). I forked this repos and made a new release based on latest, and everything worked. Swift packager for some reasons doesn't checkout the latest from git. This made sense since module dependencies should be done on stable release and not the tip.