Skip to content

Commit 642e8d0

Browse files
authored
[SYCL][DeviceSanitizer] Fix memory leaks in e2e tests (#13540)
1 parent f90554f commit 642e8d0

File tree

6 files changed

+11
-25
lines changed

6 files changed

+11
-25
lines changed

sycl/test-e2e/AddressSanitizer/common/kernel-debug.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ int main() {
1515
// CHECK-DEBUG: [kernel]
1616
// CHECK-NOT: [kernel]
1717

18+
sycl::free(array, Q);
1819
std::cout << "PASS" << std::endl;
1920
return 0;
2021
}

sycl/test-e2e/AddressSanitizer/out-of-bounds/USM/parallel_for_char.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ int main() {
2121
auto *array = sycl::malloc_host<char>(N, Q);
2222
#elif defined(MALLOC_SHARED)
2323
auto *array = sycl::malloc_shared<char>(N, Q);
24-
#elif defined(MALLOC_DEVICE)
24+
#else // defined(MALLOC_DEVICE)
2525
auto *array = sycl::malloc_device<char>(N, Q);
26-
#elif defined(MALLOC_SYSTEM)
27-
auto *array = new char[N];
28-
#else
29-
#error "Must provide malloc type to run the test"
3026
#endif
3127

3228
Q.submit([&](sycl::handler &h) {
@@ -41,5 +37,6 @@ int main() {
4137
// CHECK: {{READ of size 1 at kernel <.*MyKernelR_4> LID\(0, 0, 0\) GID\(12345, 0, 0\)}}
4238
// CHECK: {{ #0 .* .*parallel_for_char.cpp:}}[[@LINE-7]]
4339

40+
sycl::free(array, Q);
4441
return 0;
4542
}

sycl/test-e2e/AddressSanitizer/out-of-bounds/USM/parallel_for_double.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ int main() {
2121
auto *array = sycl::malloc_host<double>(N, Q);
2222
#elif defined(MALLOC_SHARED)
2323
auto *array = sycl::malloc_shared<double>(N, Q);
24-
#elif defined(MALLOC_DEVICE)
24+
#else // defined(MALLOC_DEVICE)
2525
auto *array = sycl::malloc_device<double>(N, Q);
26-
#elif defined(MALLOC_SYSTEM)
27-
auto *array = new double[N];
28-
#else
29-
#error "Must provide malloc type to run the test"
3026
#endif
3127

3228
Q.submit([&](sycl::handler &h) {
@@ -41,5 +37,6 @@ int main() {
4137
// CHECK: {{READ of size 8 at kernel <.*MyKernelR_4> LID\(0, 0, 0\) GID\(123456, 0, 0\)}}
4238
// CHECK: {{ #0 .* .*parallel_for_double.cpp:}}[[@LINE-7]]
4339

40+
sycl::free(array, Q);
4441
return 0;
4542
}

sycl/test-e2e/AddressSanitizer/out-of-bounds/USM/parallel_for_func.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,8 @@ int main() {
2828
auto *array = sycl::malloc_host<int>(N, Q);
2929
#elif defined(MALLOC_SHARED)
3030
auto *array = sycl::malloc_shared<int>(N, Q);
31-
#elif defined(MALLOC_DEVICE)
31+
#else // defined(MALLOC_DEVICE)
3232
auto *array = sycl::malloc_device<int>(N, Q);
33-
#elif defined(MALLOC_SYSTEM)
34-
auto *array = new int[N];
35-
#else
36-
#error "Must provide malloc type to run the test"
3733
#endif
3834

3935
Q.submit([&](sycl::handler &h) {
@@ -43,5 +39,6 @@ int main() {
4339
});
4440
Q.wait();
4541

42+
sycl::free(array, Q);
4643
return 0;
4744
}

sycl/test-e2e/AddressSanitizer/out-of-bounds/USM/parallel_for_int.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ int main() {
2121
auto *array = sycl::malloc_host<int>(N, Q);
2222
#elif defined(MALLOC_SHARED)
2323
auto *array = sycl::malloc_shared<int>(N, Q);
24-
#elif defined(MALLOC_DEVICE)
24+
#else // defined(MALLOC_DEVICE)
2525
auto *array = sycl::malloc_device<int>(N, Q);
26-
#elif defined(MALLOC_SYSTEM)
27-
auto *array = new int[N];
28-
#else
29-
#error "Must provide malloc type to run the test"
3026
#endif
3127

3228
Q.submit([&](sycl::handler &h) {
@@ -41,5 +37,6 @@ int main() {
4137
// CHECK: {{READ of size 4 at kernel <.*MyKernelR_4> LID\(0, 0, 0\) GID\(1234567, 0, 0\)}}
4238
// CHECK: {{ #0 .* .*parallel_for_int.cpp:}}[[@LINE-7]]
4339

40+
sycl::free(array, Q);
4441
return 0;
4542
}

sycl/test-e2e/AddressSanitizer/out-of-bounds/USM/parallel_for_short.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ int main() {
2121
auto *array = sycl::malloc_host<short>(N, Q);
2222
#elif defined(MALLOC_SHARED)
2323
auto *array = sycl::malloc_shared<short>(N, Q);
24-
#elif defined(MALLOC_DEVICE)
24+
#else // defined(MALLOC_DEVICE)
2525
auto *array = sycl::malloc_device<short>(N, Q);
26-
#elif defined(MALLOC_SYSTEM)
27-
auto *array = new short[N];
28-
#else
29-
#error "Must provide malloc type to run the test"
3026
#endif
3127

3228
Q.submit([&](sycl::handler &h) {
@@ -41,5 +37,6 @@ int main() {
4137
// CHECK: {{READ of size 2 at kernel <.*MyKernelR_4> LID\(0, 0, 0\) GID\(123456789, 0, 0\)}}
4238
// CHECK: {{ #0 .* .*parallel_for_short.cpp:}}[[@LINE-7]]
4339

40+
sycl::free(array, Q);
4441
return 0;
4542
}

0 commit comments

Comments
 (0)