Skip to content

Commit b7b2762

Browse files
committed
enable CUDA provider on Windows
1 parent a1c2c34 commit b7b2762

File tree

5 files changed

+71
-64
lines changed

5 files changed

+71
-64
lines changed

.github/workflows/pr_push.yml

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concurrency:
1515
permissions:
1616
contents: read
1717

18-
jobs:
18+
jobs:
1919
CodeChecks:
2020
uses: ./.github/workflows/reusable_checks.yml
2121
DocsBuild:
@@ -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: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,31 @@ 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: ['Ubuntu', 'Windows']
141144
include:
142145
- os: 'Ubuntu'
143146
compiler: {c: gcc, cxx: g++}
144147
number_of_processors: '$(nproc)'
148+
- os: 'Windows'
149+
compiler: {c: cl, cxx: cl}
150+
number_of_processors: '$Env:NUMBER_OF_PROCESSORS'
151+
exclude:
152+
- os: 'Windows'
153+
build_type: 'Debug'
145154

146155
runs-on: ["DSS-CUDA", "DSS-${{matrix.os}}"]
147156
steps:
@@ -154,10 +163,53 @@ jobs:
154163
if: matrix.os == 'Ubuntu'
155164
run: .github/scripts/get_system_info.sh
156165

166+
- name: Initialize vcpkg
167+
if: matrix.os == 'Windows'
168+
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
169+
with:
170+
vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289
171+
vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg
172+
vcpkgJsonGlob: '**/vcpkg.json'
173+
174+
- name: Install dependencies (windows-latest)
175+
if: matrix.os == 'Windows'
176+
run: vcpkg install
177+
shell: pwsh # Specifies PowerShell as the shell for running the script.
178+
179+
- name: Install dependencies (ubuntu-latest)
180+
if: matrix.os == 'ubuntu-latest'
181+
run: |
182+
sudo apt-get update
183+
sudo apt-get install -y cmake libjemalloc-dev libhwloc-dev libnuma-dev libtbb-dev
184+
185+
- name: Configure build for Win
186+
if: matrix.os == 'Windows'
187+
run: >
188+
cmake
189+
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}${{env.CUDA_PATH}}"
190+
-B ${{env.BUILD_DIR}}
191+
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
192+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
193+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
194+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
195+
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
196+
-DUMF_BUILD_BENCHMARKS=ON
197+
-DUMF_BUILD_TESTS=ON
198+
-DUMF_BUILD_GPU_TESTS=ON
199+
-DUMF_BUILD_GPU_EXAMPLES=ON
200+
-DUMF_FORMAT_CODE_STYLE=OFF
201+
-DUMF_DEVELOPER_MODE=ON
202+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
203+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
204+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
205+
-DUMF_BUILD_CUDA_PROVIDER=ON
206+
-DUMF_TESTS_FAIL_ON_SKIP=ON
207+
157208
- name: Configure build for Ubuntu
158209
if: matrix.os == 'Ubuntu'
159210
run: >
160-
cmake -B ${{env.BUILD_DIR}}
211+
cmake
212+
-B ${{env.BUILD_DIR}}
161213
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
162214
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
163215
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}

src/provider/provider_cuda.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static umf_result_t cu2umf_result(CUresult result) {
100100

101101
static void init_cu_global_state(void) {
102102
#ifdef _WIN32
103-
const char *lib_name = "cudart.dll";
103+
const char *lib_name = "nvcuda.dll";
104104
#else
105105
const char *lib_name = "libcuda.so";
106106
#endif
@@ -159,6 +159,7 @@ static umf_result_t cu_memory_provider_initialize(void *params,
159159

160160
if (cu_params->memory_type == UMF_MEMORY_TYPE_UNKNOWN ||
161161
cu_params->memory_type > UMF_MEMORY_TYPE_SHARED) {
162+
LOG_ERR("Invalid memory type value");
162163
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
163164
}
164165

test/providers/cuda_helpers.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct DlHandleCloser {
4848
std::unique_ptr<void, DlHandleCloser> cuDlHandle = nullptr;
4949
int InitCUDAOps() {
5050
#ifdef _WIN32
51-
const char *lib_name = "cudart.dll";
51+
const char *lib_name = "nvcuda.dll";
5252
#else
5353
const char *lib_name = "libcuda.so";
5454
#endif
@@ -207,7 +207,9 @@ int cuda_fill(CUcontext context, CUdevice device, void *ptr, size_t size,
207207
libcu_ops.cuMemsetD32((CUdeviceptr)ptr, *(unsigned int *)pattern,
208208
size / sizeof(unsigned int));
209209
if (res != CUDA_SUCCESS) {
210-
fprintf(stderr, "cuMemsetD32() failed!\n");
210+
fprintf(stderr, "cuMemsetD32(%lld, %d, %zu) failed!\n",
211+
(CUdeviceptr)ptr, *(unsigned int *)pattern,
212+
size / sizeof(unsigned int));
211213
return -1;
212214
}
213215

test/providers/provider_cuda.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,18 @@ TEST_P(umfCUDAProviderTest, allocInvalidSize) {
171171
ASSERT_EQ(umf_result, UMF_RESULT_SUCCESS);
172172
ASSERT_NE(provider, nullptr);
173173

174-
// try to alloc (int)-1
175174
void *ptr = nullptr;
176-
umf_result = umfMemoryProviderAlloc(provider, -1, 0, &ptr);
177-
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY);
178175

179-
// in case of size == 0 we should got INVALID_ARGUMENT error
180-
// NOTE: this is invalid only for the DEVICE or SHARED allocations
181-
if (params.memory_type != UMF_MEMORY_TYPE_HOST) {
176+
// NOTE: some scenarios are invalid only for the DEVICE allocations
177+
if (params.memory_type == UMF_MEMORY_TYPE_DEVICE) {
178+
// try to alloc SIZE_MAX
179+
umf_result = umfMemoryProviderAlloc(provider, SIZE_MAX, 0, &ptr);
180+
ASSERT_EQ(ptr, nullptr);
181+
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY);
182+
183+
// in case of size == 0 we should got INVALID_ARGUMENT error
182184
umf_result = umfMemoryProviderAlloc(provider, 0, 0, &ptr);
185+
ASSERT_EQ(ptr, nullptr);
183186
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_INVALID_ARGUMENT);
184187
}
185188

0 commit comments

Comments
 (0)