Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 46fe69c

Browse files
[SYCL][L0] Support for >4Gb device allocations. (#298)
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent d07c07c commit 46fe69c

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

SYCL/Plugin/max_malloc.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// REQUIRES: gpu, level_zero, level_zero_dev_kit
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
3+
// RUN: env SYCL_PROGRAM_COMPILE_OPTIONS=-ze-intel-greater-than-4GB-buffer-required %GPU_RUN_PLACEHOLDER %t.out
4+
5+
#include <CL/sycl.hpp>
6+
#include <iostream>
7+
8+
using namespace cl::sycl;
9+
10+
const double Gb = 1024 * 1024 * 1024;
11+
12+
int main() {
13+
auto D = device(gpu_selector());
14+
15+
std::cout << "name = " << D.get_info<info::device::name>() << std::endl;
16+
17+
auto global_mem_size = D.get_info<info::device::global_mem_size>() / Gb;
18+
std::cout << "global_mem_size = " << global_mem_size << std::endl;
19+
std::cout << "max_mem_alloc_size = "
20+
<< D.get_info<info::device::max_mem_alloc_size>() / Gb << std::endl;
21+
22+
auto Q = queue(D);
23+
for (int I = 1; I < global_mem_size; I++) {
24+
void *p;
25+
p = malloc_device(I * Gb, Q);
26+
std::cout << "malloc_device(" << I << "Gb) = " << p << std::endl;
27+
if (p == nullptr) {
28+
std::cout << "FAILED" << std::endl;
29+
return -1;
30+
}
31+
sycl::free(p, Q);
32+
33+
p = malloc_shared(I * Gb, Q);
34+
std::cout << "malloc_shared(" << I << "Gb) = " << p << std::endl;
35+
if (p == nullptr) {
36+
std::cout << "FAILED" << std::endl;
37+
return -1;
38+
}
39+
sycl::free(p, Q);
40+
}
41+
42+
return 0;
43+
}

SYCL/USM/badmalloc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// UNSUPPORTED: windows
22
//
3+
// XFAIL: level_zero
4+
// TODO: enable the test when L0 driver is honoring too large sizes.
5+
//
36
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t1.out
47
// RUN: %HOST_RUN_PLACEHOLDER %t1.out
58
// RUN: %CPU_RUN_PLACEHOLDER %t1.out

0 commit comments

Comments
 (0)