diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d39fe50 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + lint: + runs-on: macos-26 + steps: + - uses: actions/checkout@v6 + - name: SwiftFormat + run: swiftformat --lint --strict . --reporter github-actions-log + + build: + runs-on: [self-hosted, linux, nvidia, gpu] + container: ghcr.io/dataparallel-swift/swift:6.1 + steps: + - uses: actions/checkout@v6 + + - uses: actions/cache@v5 + with: + path: .build + key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} + restore-keys: | + ${{ runner.os }}-spm- + + - name: Build + run: swift build + + - name: Test + run: swift run nvidia-device-query diff --git a/.swiftformat b/.swiftformat index 3099ba2..99f5d54 100644 --- a/.swiftformat +++ b/.swiftformat @@ -2,3 +2,95 @@ --header "Copyright (c) {year} The swift-cuda authors. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License." # rules +--disable extensionAccessControl +--allman false +--binarygrouping none +--decimalgrouping 3,5 +--disable redundantSelf,trailingClosures +--elseposition next-line +--exponentcase uppercase +--guardelse same-line +--hexliteralcase lowercase +--indent 4 +--indentcase true +--ifdef no-indent +--maxwidth 140 +--self insert +--semicolons never +--swiftversion 6 +--trimwhitespace always +--storedvarattrs prev-line +--computedvarattrs prev-line +--typeattributes prev-line +--wrapparameters before-first +--wrapcollections before-first +--wraparguments before-first + +# Explicitly enable rules to prevent automatic opt-in +# Generated from `swiftformat --rules` on v0.47.1 +--rules andOperator +--rules anyObjectProtocol +--rules blankLinesAroundMark +--rules blankLinesAtEndOfScope +--rules blankLinesAtStartOfScope +--rules blankLinesBetweenScopes +--rules braces +--rules consecutiveBlankLines +--rules consecutiveSpaces +--rules duplicateImports +--rules elseOnSameLine +--rules emptyBraces +--rules enumNamespaces +--rules fileHeader +--rules hoistPatternLet +--rules indent +--rules initCoderUnavailable +--rules leadingDelimiters +--rules linebreakAtEndOfFile +--rules linebreaks +--rules modifierOrder +--rules numberFormatting +--rules preferKeyPath +--rules redundantBackticks +--rules redundantBreak +--rules redundantExtensionACL +--rules redundantFileprivate +--rules redundantGet +--rules redundantInit +--rules redundantLet +--rules redundantLetError +--rules redundantNilInit +--rules redundantObjc +--rules redundantParens +--rules redundantPattern +--rules redundantRawValues +--rules redundantReturn +--rules redundantSelf +--rules redundantType +--rules semicolons +--rules sortImports +--rules spaceAroundBraces +--rules spaceAroundBrackets +--rules spaceAroundComments +--rules spaceAroundGenerics +--rules spaceAroundOperators +--rules spaceAroundParens +--rules spaceInsideBraces +--rules spaceInsideBrackets +--rules spaceInsideComments +--rules spaceInsideGenerics +--rules spaceInsideParens +--rules strongOutlets +--rules strongifiedSelf +--rules todos +--rules trailingClosures +--rules trailingCommas +--rules trailingSpace +--rules unusedArguments +--rules void +--rules wrap +--rules wrapArguments +--rules wrapAttributes +--rules wrapMultilineStatementBraces +--rules wrapSingleLineComments +--rules yodaConditions diff --git a/Package.swift b/Package.swift index 8273913..220aec5 100644 --- a/Package.swift +++ b/Package.swift @@ -32,7 +32,7 @@ let package = Package( publicHeadersPath: ".", linkerSettings: [ .linkedLibrary("cupti"), - ], + ] ), .executableTarget( name: "nvidia-device-query", diff --git a/Sources/nvidia-device-query/main.swift b/Sources/nvidia-device-query/main.swift index f16b747..9daeb06 100644 --- a/Sources/nvidia-device-query/main.swift +++ b/Sources/nvidia-device-query/main.swift @@ -1,4 +1,4 @@ -// Copyright (c) 2025 The swift-cuda authors. All rights reserved. +// Copyright (c) 2026 The swift-cuda authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -183,7 +183,7 @@ else { print("Device \(devid): \(name)") print(" CUDA capability: \(major).\(minor)") print(" CUDA cores: \(coresPerMP * multiProcessorCount) cores in \(multiProcessorCount) multiprocessors (\(coresPerMP) cores/MP)") - print(" Global memory: \(totalGlobalMem / 1048576) MB") + print(" Global memory: \(totalGlobalMem / 1_048_576) MB") print(" Constant memory: \(totalConstantMem / 1024) kB") print(" Shared memory per block: \(sharedMemoryPerBlock / 1024) kB") print(" L2 cache per block: \(l2CacheSize / 1024) kB")