Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
23b445a
Add Windows support
mfranzrebsal May 7, 2026
787e435
Windows support: revert CI specific changes
mfranzrebsal May 13, 2026
78b674b
Re- Enable NVBench Windows build job
oleksandr-pavlyk May 15, 2026
460e14f
Install CUDA Profiler API into toolkit
oleksandr-pavlyk May 16, 2026
c6cd097
Add intall_cuda_profiler_api.ps1
oleksandr-pavlyk May 16, 2026
f8c0554
Inform MSVC that static library export main
oleksandr-pavlyk May 16, 2026
f402b57
Review feedback to PowerShell script
oleksandr-pavlyk May 17, 2026
71eacdc
Fix how CMAKE_CUDA_HOST_COMPILER is set in call to cmake
oleksandr-pavlyk May 17, 2026
cc209bb
Filter out empty directories LD_LIBRARY_PATH/PATH
oleksandr-pavlyk May 17, 2026
d980c2a
Check that cudaVersion and :CUDA_PATH are consistent
oleksandr-pavlyk May 17, 2026
6c44ec6
Do not overwrite ENVIRONMENT property with empty values
oleksandr-pavlyk May 17, 2026
7f2a6dc
Implement retry logic in downloading of CUDA Profiler API
oleksandr-pavlyk May 17, 2026
287d041
Strengthen publisher verification of downloaded artifact
oleksandr-pavlyk May 17, 2026
9f8bf81
Prepend new folders to LD_LIBRARY_PATH, do not overwrite
oleksandr-pavlyk May 17, 2026
adabe4a
Implement timeout, fail on 40x HTTP response code
oleksandr-pavlyk May 17, 2026
a5b3e97
USE ENVIRONMENT_MODIFICATION property, not ENVIRONMENT
oleksandr-pavlyk May 17, 2026
c6347b5
escape environment modification values
oleksandr-pavlyk May 17, 2026
919468f
Fix cmake script error breaking the build
oleksandr-pavlyk May 17, 2026
177c7b0
Added recommented timeout to Invoke-WebRequest
oleksandr-pavlyk May 17, 2026
f83429a
Set cmake_minimum_required version to 3.30.4, consistent with main pr…
oleksandr-pavlyk May 17, 2026
ccfa1b5
Pass NVBENCH environment variables through docker for Windows build
oleksandr-pavlyk May 17, 2026
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
7 changes: 6 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ jobs:

- name: Build NVBench
env:
NVBENCH_WINDOWS_CUDA: ${{ inputs.cuda }}
NVBENCH_WINDOWS_STD: ${{ inputs.std }}
NVBENCH_WINDOWS_ARCH: ${{ inputs.arch }}
run: |
Expand All @@ -131,7 +132,8 @@ jobs:
@"
`$ErrorActionPreference = 'Stop'
git config --global --add safe.directory '$containerRepo'
& '$containerRepo/ci/windows/build_nvbench.ps1' -std '$env:NVBENCH_WINDOWS_STD' -arch '$env:NVBENCH_WINDOWS_ARCH'
& '$containerRepo/ci/windows/install_cuda_profiler_api.ps1' -cudaVersion "`$env:NVBENCH_WINDOWS_CUDA"
& '$containerRepo/ci/windows/build_nvbench.ps1' -std "`$env:NVBENCH_WINDOWS_STD" -arch "`$env:NVBENCH_WINDOWS_ARCH"
exit `$LASTEXITCODE
"@ | Set-Content -Path $script -Encoding UTF8

Expand All @@ -152,6 +154,9 @@ jobs:
"--env", "GITHUB_REPOSITORY=$env:GITHUB_REPOSITORY",
"--env", "GITHUB_RUN_ID=$env:GITHUB_RUN_ID",
"--env", "GITHUB_SHA=$env:GITHUB_SHA",
"--env", "NVBENCH_WINDOWS_ARCH=$env:NVBENCH_WINDOWS_ARCH",
"--env", "NVBENCH_WINDOWS_CUDA=$env:NVBENCH_WINDOWS_CUDA",
"--env", "NVBENCH_WINDOWS_STD=$env:NVBENCH_WINDOWS_STD",
"--env", "SCCACHE_BUCKET=$env:SCCACHE_BUCKET",
"--env", "SCCACHE_IDLE_TIMEOUT=$env:SCCACHE_IDLE_TIMEOUT",
"--env", "SCCACHE_REGION=$env:SCCACHE_REGION",
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ jobs:

nvbench-windows:
name: NVBench Windows CUDA${{ matrix.config.cuda }} ${{ matrix.config.host }} C++${{ matrix.config.std }}
# TODO: Re-enable after https://github.com/NVIDIA/nvbench/pull/354 fixes the Windows build.
if: false
permissions:
id-token: write
contents: read
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ if (${CUDAToolkit_VERSION} VERSION_LESS 11.3)
endif()

option(BUILD_SHARED_LIBS "Build NVBench as a shared library" ON)
if (WIN32 AND BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()

option(NVBench_ENABLE_NVML "Build with NVML support from the Cuda Toolkit." ON)
option(NVBench_ENABLE_CUPTI "Build NVBench with CUPTI." ${cupti_default})
Expand Down
181 changes: 181 additions & 0 deletions ci/windows/install_cuda_profiler_api.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

Param(
[Parameter(Mandatory = $false)]
[Alias("cudaVersion")]
[string]$CUDA_VERSION = ""
)

$ErrorActionPreference = "Stop"

function Get-CudaVersionFromPath {
Param(
[Parameter(Mandatory = $false)]
[string]$Path = ""
)

if ($Path -and $Path -match "v(?<version>\d+\.\d+)[\\/]?$") {
return $Matches.version
}

return ""
}

function Assert-NvidiaAuthenticodeSignature {
Param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$Path
)

$signature = Get-AuthenticodeSignature -FilePath $Path
if ($signature.Status -ne "Valid") {
throw "Invalid Authenticode signature for '$Path': $($signature.Status) $($signature.StatusMessage)"
}

$expectedPublisher = "NVIDIA Corporation"
$publisher = $signature.SignerCertificate.GetNameInfo(
[System.Security.Cryptography.X509Certificates.X509NameType]::SimpleName,
$false
)
if ($publisher -ne $expectedPublisher) {
throw "Unexpected signer for '$Path': $publisher"
}

Write-Host "Validated Authenticode signature for '$Path': $publisher"
}

function Get-HttpStatusCodeFromError {
Param(
[Parameter(Mandatory = $true)]
$ErrorRecord
)

$responseProperty = $ErrorRecord.Exception.PSObject.Properties["Response"]
if (-not $responseProperty) {
return $null
}

$response = $responseProperty.Value
if ($null -eq $response) {
return $null
}

$statusCodeProperty = $response.PSObject.Properties["StatusCode"]
if (-not $statusCodeProperty) {
return $null
}

return [int]$statusCodeProperty.Value
}

function Invoke-WebRequestWithRetry {
Param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$Uri,

[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$OutFile,

[Parameter(Mandatory = $false)]
[ValidateRange(1, 10)]
[int]$MaxAttempts = 3
)

for ($attempt = 1; $attempt -le $MaxAttempts; $attempt++) {
try {
Remove-Item $OutFile -ErrorAction SilentlyContinue
Invoke-WebRequest -Uri $Uri -OutFile $OutFile -UseBasicParsing -TimeoutSec 300
return
} catch {
$statusCode = Get-HttpStatusCodeFromError -ErrorRecord $_
if ($statusCode -ge 400 -and $statusCode -lt 500) {
throw "Download failed with non-retryable HTTP status $statusCode from '$Uri'. $_"
}

if ($attempt -eq $MaxAttempts) {
throw
}

$delaySeconds = 5 * $attempt
Write-Warning "Download failed on attempt $attempt of $MaxAttempts. Retrying in $delaySeconds seconds. $_"
Start-Sleep -Seconds $delaySeconds
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
}
}

if (-not $CUDA_VERSION) {
$CUDA_VERSION = Get-CudaVersionFromPath -Path $env:CUDA_PATH
if (-not $CUDA_VERSION) {
throw "Could not determine CUDA version. Provide -cudaVersion or set CUDA_PATH to a path ending in v<major>.<minor>."
}
}

$version = [Version]$CUDA_VERSION
$major = $version.Major
$minor = $version.Minor
$build = $version.Build

if ($build -lt 0) {
$build = 0
}

$mmbVersionTag = "${major}.${minor}.${build}"
$mmVersionTag = "${major}.${minor}"

if ($env:CUDA_PATH) {
$cudaPathVersion = Get-CudaVersionFromPath -Path $env:CUDA_PATH
if (-not $cudaPathVersion) {
throw "CUDA_PATH is set but does not end in v<major>.<minor>: $env:CUDA_PATH"
}
if ($cudaPathVersion -ne $mmVersionTag) {
throw "CUDA_PATH points to CUDA $cudaPathVersion, but CUDA $mmVersionTag was requested."
}
$cudaRoot = $env:CUDA_PATH
} else {
$cudaRoot = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v$mmVersionTag"
}
$profilerHeader = "$cudaRoot\include\cuda_profiler_api.h"

if (Test-Path $profilerHeader) {
Write-Host "CUDA Profiler API is already installed: $profilerHeader"
return
}

$component = "cuda_profiler_api_$mmVersionTag"
$cudaMajorUri = "${mmbVersionTag}/network_installers/cuda_${mmbVersionTag}_windows_network.exe"
$cudaVersionUrl = "https://developer.download.nvidia.com/compute/cuda/$cudaMajorUri"
$installer = Join-Path $env:TEMP "cuda_${mmbVersionTag}_windows_network.exe"

Write-Host "Installing CUDA component: $component"
Write-Host "Downloading CUDA network installer: $cudaVersionUrl"
Invoke-WebRequestWithRetry -Uri $cudaVersionUrl -OutFile $installer
Assert-NvidiaAuthenticodeSignature -Path $installer

$installerTimeoutSeconds = 900
$process = $null
try {
$process = Start-Process -PassThru -FilePath $installer -ArgumentList @("-s", $component)
if (-not $process.WaitForExit($installerTimeoutSeconds * 1000)) {
Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue
throw "CUDA network installer timed out after $installerTimeoutSeconds seconds."
}

if ($process.ExitCode -ne 0) {
throw "CUDA network installer failed with exit code $($process.ExitCode)."
}
} finally {
if ($process) {
$process.Dispose()
}
Remove-Item $installer -ErrorAction SilentlyContinue
}

if (-not (Test-Path $profilerHeader)) {
throw "CUDA Profiler API installation completed, but header was not found: $profilerHeader"
}

Write-Host "CUDA Profiler API installed: $profilerHeader"
14 changes: 10 additions & 4 deletions cmake/NVBenchCUPTI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ function(nvbench_add_cupti_dep dep_name)
add_library(nvbench::${dep_name_lower} SHARED IMPORTED)

find_library(NVBench_${dep_name_upper}_LIBRARY ${dep_name_lower} REQUIRED
DOC "The full path to lib${dep_name_lower}.so from the CUDA Toolkit."
DOC "The import library for ${dep_name_lower} from the CUDA Toolkit."
HINTS "${nvbench_cupti_root}/lib64"
)
mark_as_advanced(NVBench_${dep_name_upper}_LIBRARY)

set_target_properties(nvbench::${dep_name_lower} PROPERTIES
IMPORTED_LOCATION "${NVBench_${dep_name_upper}_LIBRARY}"
)
if (WIN32)
set_target_properties(nvbench::${dep_name_lower} PROPERTIES
IMPORTED_IMPLIB "${NVBench_${dep_name_upper}_LIBRARY}"
)
else()
set_target_properties(nvbench::${dep_name_lower} PROPERTIES
IMPORTED_LOCATION "${NVBench_${dep_name_upper}_LIBRARY}"
)
endif()
endfunction()

nvbench_add_cupti_dep(cupti)
Expand Down
18 changes: 16 additions & 2 deletions cmake/NVBenchConfigTarget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,25 @@ endif()
if (CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
# fmtlib uses llvm's _BitInt internally, which is not available when compiling through nvcc:
target_compile_definitions(nvbench.build_interface INTERFACE "FMT_USE_BITINT=0")
if (MSVC)
# cudafe cannot evaluate fmtlib's UTF-8 literal check even when /utf-8 is passed to the host compiler:
target_compile_definitions(nvbench.build_interface INTERFACE
$<$<COMPILE_LANGUAGE:CUDA>:FMT_UNICODE=0>
)
endif()
endif()

target_compile_options(nvbench.build_interface INTERFACE
$<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:-Xcudafe=--display_error_number>
$<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:-Wno-deprecated-gpu-targets>
$<$<AND:$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>,$<CXX_COMPILER_ID:MSVC>>:-Xcompiler=/utf-8>
# Suppress cudafe diagnostics triggered by fmtlib headers when compiled through MSVC+nvcc:
# 27: character value is out of range (char32_t sentinel values in lookup tables)
# 128: loop is not reachable (dead code in constexpr string comparison)
# 2417: constexpr constructor calls non-constexpr function (bigint default ctor)
$<$<AND:$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>,$<CXX_COMPILER_ID:MSVC>>:-Xcudafe=--diag_suppress=27>
$<$<AND:$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>,$<CXX_COMPILER_ID:MSVC>>:-Xcudafe=--diag_suppress=128>
$<$<AND:$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>,$<CXX_COMPILER_ID:MSVC>>:-Xcudafe=--diag_suppress=2417>
)
if (NVBench_ENABLE_WERROR)
target_compile_options(nvbench.build_interface INTERFACE
Expand All @@ -115,8 +129,8 @@ function(nvbench_config_target target_name)
# the library path, other times they're in a subdirectory that isn't added to
# the library path...
# To simplify installed nvbench usage, add the CUPTI libraries path to the
# installed nvbench rpath:
if (NVBench_ENABLE_CUPTI AND nvbench_cupti_root)
# installed nvbench rpath (Unix only; Windows uses PATH for DLL lookup):
if (NVBench_ENABLE_CUPTI AND nvbench_cupti_root AND NOT WIN32)
set_target_properties(${target_name} PROPERTIES
INSTALL_RPATH "${nvbench_cupti_root}/lib64"
)
Expand Down
4 changes: 4 additions & 0 deletions nvbench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ nvbench_config_target(nvbench.main)
target_compile_definitions(nvbench.main PRIVATE NVBENCH_NO_IMPLICIT_SYSTEM_HEADER)
# Propagate `nvbench` to consumers but keep NVBench's own build warning-visible.
target_link_libraries(nvbench.main PUBLIC nvbench)
if (MSVC)
# inform MSVC that library provides main
target_link_options(nvbench.main INTERFACE "/INCLUDE:main")
endif()
# Ensure CUDA/CUPTI/NVML include dirs are visible for nvbench.main's build.
target_link_libraries(nvbench.main PRIVATE ${ctk_libraries})
# Add NVBench's headers privately so the main library itself sees warnings.
Expand Down
4 changes: 4 additions & 0 deletions nvbench/config.cuh.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
// Defined if NVBench has been built with CUPTI support.
#cmakedefine NVBENCH_HAS_CUPTI

#if defined(_MSVC_LANG)
#define NVBENCH_CPLUSPLUS _MSVC_LANG
#else
#define NVBENCH_CPLUSPLUS __cplusplus
#endif

// Detect current dialect:
#if NVBENCH_CPLUSPLUS < 201703L
Expand Down
1 change: 1 addition & 0 deletions testing/axes_metadata.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <fmt/format.h>

#include <algorithm>
#include <iterator>
Comment thread
oleksandr-pavlyk marked this conversation as resolved.
#include <string_view>

#include "test_asserts.cuh"
Expand Down
20 changes: 20 additions & 0 deletions testing/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ set(cmake_opts
-D "CMAKE_CUDA_FLAGS=${CMAKE_CUDA_FLAGS}"
-D "CMAKE_CUDA_ARCHITECTURES=${arches}"
)
if (WIN32)
set(cuda_host_compiler "${CMAKE_CUDA_HOST_COMPILER}")
if (NOT cuda_host_compiler)
set(cuda_host_compiler "${CMAKE_CXX_COMPILER}")
endif()
list(APPEND cmake_opts
-D "CMAKE_CUDA_HOST_COMPILER=${cuda_host_compiler}"
-D "CMAKE_LINKER=${CMAKE_LINKER}"
-D "CMAKE_RC_COMPILER=${CMAKE_RC_COMPILER}"
-D "CMAKE_MT=${CMAKE_MT}"
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
endif()

# Temporary installation prefix for tests against installed nvbench:
set(tmp_install_prefix "${CMAKE_CURRENT_BINARY_DIR}/test_nvbench_install")
Expand All @@ -32,6 +44,14 @@ function(nvbench_add_compile_test full_test_name_var subdir test_id)
${ARGN}
--test-command "${CMAKE_CTEST_COMMAND}" --output-on-failure
)
if (WIN32 AND NVBench_ENABLE_CUPTI AND nvbench_cupti_root)
set(cupti_lib_dir "${nvbench_cupti_root}/lib64")
set_property(TEST ${test_name} PROPERTY
ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<SHELL_PATH:${cupti_lib_dir}>"
"PATH=path_list_prepend:$<SHELL_PATH:${NVBench_EXECUTABLE_OUTPUT_DIR}>"
)
endif()
Comment thread
oleksandr-pavlyk marked this conversation as resolved.
set(${full_test_name_var} ${test_name} PARENT_SCOPE)
endfunction()

Expand Down
Loading
Loading