Skip to content

Commit 6abcb60

Browse files
committed
enable CUDA provider on Windows
1 parent fa08100 commit 6abcb60

File tree

9 files changed

+171
-78
lines changed

9 files changed

+171
-78
lines changed

.github/workflows/pr_push.yml

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -24,56 +24,5 @@ jobs:
2424
name: Fast builds
2525
needs: [CodeChecks, DocsBuild]
2626
uses: ./.github/workflows/reusable_fast.yml
27-
Build:
28-
name: Basic builds
29-
needs: [FastBuild]
30-
uses: ./.github/workflows/reusable_basic.yml
31-
DevDax:
32-
needs: [FastBuild]
33-
uses: ./.github/workflows/reusable_dax.yml
34-
Sanitizers:
35-
needs: [FastBuild]
36-
uses: ./.github/workflows/reusable_sanitizers.yml
37-
Qemu:
38-
needs: [FastBuild]
39-
uses: ./.github/workflows/reusable_qemu.yml
40-
Benchmarks:
41-
needs: [Build]
42-
uses: ./.github/workflows/reusable_benchmarks.yml
43-
ProxyLib:
44-
needs: [Build]
45-
uses: ./.github/workflows/reusable_proxy_lib.yml
4627
GPU:
47-
needs: [Build]
4828
uses: ./.github/workflows/reusable_gpu.yml
49-
Valgrind:
50-
needs: [Build]
51-
uses: ./.github/workflows/reusable_valgrind.yml
52-
MultiNuma:
53-
needs: [Build]
54-
uses: ./.github/workflows/reusable_multi_numa.yml
55-
Coverage:
56-
# total coverage (on upstream only)
57-
if: github.repository == 'oneapi-src/unified-memory-framework'
58-
needs: [Build, DevDax, GPU, MultiNuma, Qemu, ProxyLib]
59-
uses: ./.github/workflows/reusable_coverage.yml
60-
secrets: inherit
61-
with:
62-
trigger: "${{github.event_name}}"
63-
Coverage_partial:
64-
# partial coverage (on forks)
65-
if: github.repository != 'oneapi-src/unified-memory-framework'
66-
needs: [Build, Qemu, ProxyLib]
67-
uses: ./.github/workflows/reusable_coverage.yml
68-
CodeQL:
69-
needs: [Build]
70-
permissions:
71-
contents: read
72-
security-events: write
73-
uses: ./.github/workflows/reusable_codeql.yml
74-
Trivy:
75-
needs: [Build]
76-
permissions:
77-
contents: read
78-
security-events: write
79-
uses: ./.github/workflows/reusable_trivy.yml

.github/workflows/reusable_gpu.yml

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,28 @@ jobs:
126126
name: ${{env.COVERAGE_NAME}}-shared-${{matrix.shared_library}}
127127
path: ${{env.COVERAGE_DIR}}
128128

129+
# TODO merge with above
129130
gpu-CUDA:
130131
name: CUDA
131132
env:
132133
COVERAGE_NAME : "exports-coverage-gpu-CUDA"
134+
VCPKG_PATH: "${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows;"
135+
CUDA_PATH: "c:/cuda"
136+
133137
# run only on upstream; forks will not have the HW
134138
if: github.repository == 'oneapi-src/unified-memory-framework'
135139
strategy:
136140
matrix:
137141
shared_library: ['ON', 'OFF']
138142
build_type: ['Debug', 'Release']
139-
# TODO add windows
140-
os: ['Ubuntu']
143+
os: ['Windows']
141144
include:
142-
- os: 'Ubuntu'
143-
compiler: {c: gcc, cxx: g++}
144-
number_of_processors: '$(nproc)'
145+
- os: 'Windows'
146+
compiler: {c: cl, cxx: cl}
147+
number_of_processors: '$Env:NUMBER_OF_PROCESSORS'
148+
exclude:
149+
- os: 'Windows'
150+
build_type: 'Debug'
145151

146152
runs-on: ["DSS-CUDA", "DSS-${{matrix.os}}"]
147153
steps:
@@ -154,10 +160,53 @@ jobs:
154160
if: matrix.os == 'Ubuntu'
155161
run: .github/scripts/get_system_info.sh
156162

163+
- name: Initialize vcpkg
164+
if: matrix.os == 'Windows'
165+
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
166+
with:
167+
vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289
168+
vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg
169+
vcpkgJsonGlob: '**/vcpkg.json'
170+
171+
- name: Install dependencies (windows-latest)
172+
if: matrix.os == 'Windows'
173+
run: vcpkg install
174+
shell: pwsh # Specifies PowerShell as the shell for running the script.
175+
176+
- name: Install dependencies (ubuntu-latest)
177+
if: matrix.os == 'ubuntu-latest'
178+
run: |
179+
sudo apt-get update
180+
sudo apt-get install -y cmake libjemalloc-dev libhwloc-dev libnuma-dev libtbb-dev
181+
182+
- name: Configure build for Win
183+
if: matrix.os == 'Windows'
184+
run: >
185+
cmake
186+
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}${{env.CUDA_PATH}}"
187+
-B ${{env.BUILD_DIR}}
188+
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
189+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
190+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
191+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
192+
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
193+
-DUMF_BUILD_BENCHMARKS=ON
194+
-DUMF_BUILD_TESTS=ON
195+
-DUMF_BUILD_GPU_TESTS=ON
196+
-DUMF_BUILD_GPU_EXAMPLES=ON
197+
-DUMF_FORMAT_CODE_STYLE=OFF
198+
-DUMF_DEVELOPER_MODE=ON
199+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
200+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
201+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
202+
-DUMF_BUILD_CUDA_PROVIDER=ON
203+
-DUMF_TESTS_FAIL_ON_SKIP=ON
204+
157205
- name: Configure build for Ubuntu
158206
if: matrix.os == 'Ubuntu'
159207
run: >
160-
cmake -B ${{env.BUILD_DIR}}
208+
cmake
209+
-B ${{env.BUILD_DIR}}
161210
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
162211
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
163212
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
@@ -179,6 +228,10 @@ jobs:
179228
- name: Build UMF
180229
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j ${{matrix.number_of_processors}}
181230

231+
- name: aa
232+
if: matrix.os == 'Windows'
233+
run: ${{env.BUILD_DIR}}/test/${{matrix.build_type}}/umf_test-provider_cuda
234+
182235
- name: Run tests
183236
working-directory: ${{env.BUILD_DIR}}
184237
run: ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test

cmake/FindCUDA.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ get_filename_component(CUDA_LIB_DIR ${CUDA_LIBRARIES} DIRECTORY)
1111
set(CUDA_LIBRARY_DIRS ${CUDA_LIB_DIR})
1212

1313
if(WINDOWS)
14-
find_file(CUDA_DLL NAMES "bin/cuda.dll" "cuda.dll")
14+
find_file(CUDA_DLL NAMES "nvcuda.dll")
1515
get_filename_component(CUDA_DLL_DIR ${CUDA_DLL} DIRECTORY)
1616
set(CUDA_DLL_DIRS ${CUDA_DLL_DIR})
1717
endif()

examples/cmake/FindCUDA.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ get_filename_component(CUDA_LIB_DIR ${CUDA_LIBRARIES} DIRECTORY)
1111
set(CUDA_LIBRARY_DIRS ${CUDA_LIB_DIR})
1212

1313
if(WINDOWS)
14-
find_file(CUDA_DLL NAMES "bin/cuda.dll" "cuda.dll")
14+
find_file(CUDA_DLL NAMES "nvcuda.dll")
1515
get_filename_component(CUDA_DLL_DIR ${CUDA_DLL} DIRECTORY)
1616
set(CUDA_DLL_DIRS ${CUDA_DLL_DIR})
1717
endif()

examples/cuda_shared_memory/cuda_shared_memory.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@
1414
#include <umf/pools/pool_disjoint.h>
1515
#include <umf/providers/provider_cuda.h>
1616

17+
// disable warning 4201: nonstandard extension used: nameless struct/union
18+
#if defined(_MSC_VER)
19+
#pragma warning(push)
20+
#pragma warning(disable : 4201)
21+
#endif // _MSC_VER
22+
1723
#include <cuda.h>
1824

25+
#if defined(_MSC_VER)
26+
#pragma warning(pop)
27+
#endif // _MSC_VER
28+
1929
int main(void) {
2030
// A result object for storing UMF API result status
2131
umf_result_t res;

src/provider/provider_cuda.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,18 @@ umf_memory_provider_ops_t *umfCUDAMemoryProviderOps(void) {
2121

2222
#else // !defined(UMF_NO_CUDA_PROVIDER)
2323

24+
// disable warning 4201: nonstandard extension used: nameless struct/union
25+
#if defined(_MSC_VER)
26+
#pragma warning(push)
27+
#pragma warning(disable : 4201)
28+
#endif // _MSC_VER
29+
2430
#include "cuda.h"
2531

32+
#if defined(_MSC_VER)
33+
#pragma warning(pop)
34+
#endif // _MSC_VER
35+
2636
#include "base_alloc_global.h"
2737
#include "utils_assert.h"
2838
#include "utils_common.h"
@@ -100,7 +110,7 @@ static umf_result_t cu2umf_result(CUresult result) {
100110

101111
static void init_cu_global_state(void) {
102112
#ifdef _WIN32
103-
const char *lib_name = "cudart.dll";
113+
const char *lib_name = "nvcuda.dll";
104114
#else
105115
const char *lib_name = "libcuda.so";
106116
#endif
@@ -159,6 +169,7 @@ static umf_result_t cu_memory_provider_initialize(void *params,
159169

160170
if (cu_params->memory_type == UMF_MEMORY_TYPE_UNKNOWN ||
161171
cu_params->memory_type > UMF_MEMORY_TYPE_SHARED) {
172+
LOG_ERR("Invalid memory type value");
162173
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
163174
}
164175

@@ -259,6 +270,8 @@ static umf_result_t cu_memory_provider_alloc(void *provider, size_t size,
259270
return umf_result;
260271
}
261272

273+
//fprintf(stderr, "alloc context %p\n", cu_provider->context);
274+
262275
CUresult cu_result = CUDA_SUCCESS;
263276
switch (cu_provider->memory_type) {
264277
case UMF_MEMORY_TYPE_HOST: {

0 commit comments

Comments
 (0)