Skip to content

error: use of unresolved identifier 'benchmark' #4

Open

Description

@kechan

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

Activity

  1. kechan commented on Jan 15, 2019

    @kechan
    Author

    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.

  2. kechan commented on Jan 15, 2019

    @kechan
    Author

    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.

  3. jph00 commented on Jan 19, 2019

    @jph00
    Owner

    @kechan did you fix this? Maybe just needed a package update?

  4. kechan commented on Jan 21, 2019

    @kechan
    Author

    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)

    1. $ mkdir KCTestMathBase
    2. $ cd KCTestMathBase
    3. $ swift package init
    4. in Package.swift, change:
      .package(url:"https://github.com/jph00/BaseMath.git", from: "1.0.1"),
    5. $ 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.

  5. kechan commented on Feb 7, 2019

    @kechan
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions