Skip to content

[NFC] Clean up free function testcases #15430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 2 additions & 17 deletions sycl/test-e2e/DeviceDependencies/free_function_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void printUSM(int *usmPtr, int size) {
std::cout << "}\n";
}

bool checkUSM(int *usmPtr, int size, int *Result) {
bool checkUSM(int *usmPtr, int size, int *Result, int line = __builtin_LINE()) {
bool Pass = true;
for (int i = 0; i < size; i++) {
if (usmPtr[i] != Result[i]) {
Expand All @@ -43,6 +43,7 @@ bool checkUSM(int *usmPtr, int size, int *Result) {
std::cout << usmPtr[i] << ", ";
}
std::cout << "}\n";
std::cout << "checkUSM failed, called from line " << line << std::endl;
return false;
}

Expand Down Expand Up @@ -71,8 +72,6 @@ bool test_0(queue Queue) {
});
Queue.wait();
bool PassA = checkUSM(usmPtr, Range, Result);
// TODO: Avoid printing anything if test passes to reduce I/O.
std::cout << "Test 0a: " << (PassA ? "PASS" : "FAIL") << std::endl;

bool PassB = false;
// TODO: Avoid using __SYCL_DEVICE_ONLY__ or give rationale with a comment
Expand All @@ -90,8 +89,6 @@ bool test_0(queue Queue) {
});
Queue.wait();
PassB = checkUSM(usmPtr, Range, Result);
// TODO: Avoid printing anything if test passes to reduce I/O.
std::cout << "Test 0b: " << (PassB ? "PASS" : "FAIL") << std::endl;

free(usmPtr, Queue);
#endif
Expand Down Expand Up @@ -123,8 +120,6 @@ bool test_1(queue Queue) {
});
Queue.wait();
bool PassA = checkUSM(usmPtr, Range, Result);
// TODO: Avoid printing anything if test passes to reduce I/O.
std::cout << "Test 1a: " << (PassA ? "PASS" : "FAIL") << std::endl;

bool PassB = false;
// TODO: Avoid using __SYCL_DEVICE_ONLY__ or give rationale with a comment
Expand All @@ -143,8 +138,6 @@ bool test_1(queue Queue) {
});
Queue.wait();
PassB = checkUSM(usmPtr, Range, Result);
// TODO: Avoid printing anything if test passes to reduce I/O.
std::cout << "Test 1b: " << (PassB ? "PASS" : "FAIL") << std::endl;

free(usmPtr, Queue);
#endif
Expand Down Expand Up @@ -181,8 +174,6 @@ bool test_2(queue Queue) {
});
Queue.wait();
bool PassA = checkUSM(usmPtr, Range, Result);
// TODO: Avoid printing anything if test passes to reduce I/O.
std::cout << "Test 2a: " << (PassA ? "PASS" : "FAIL") << std::endl;

bool PassB = false;
// TODO: Avoid using __SYCL_DEVICE_ONLY__ or give rationale with a comment
Expand All @@ -200,8 +191,6 @@ bool test_2(queue Queue) {
});
Queue.wait();
PassB = checkUSM(usmPtr, Range, Result);
// TODO: Avoid printing anything if test passes to reduce I/O.
std::cout << "Test 2b: " << (PassB ? "PASS" : "FAIL") << std::endl;

free(usmPtr, Queue);
#endif
Expand Down Expand Up @@ -242,8 +231,6 @@ bool test_3(queue Queue) {
});
Queue.wait();
bool PassA = checkUSM(usmPtr, Range, Result);
// TODO: Avoid printing anything if test passes to reduce I/O.
std::cout << "Test 3a: " << (PassA ? "PASS" : "FAIL") << std::endl;

bool PassB = false;
// TODO: Avoid using __SYCL_DEVICE_ONLY__ or give rationale with a comment
Expand All @@ -261,8 +248,6 @@ bool test_3(queue Queue) {
});
Queue.wait();
PassB = checkUSM(usmPtr, Range, Result);
// TODO: Avoid printing anything if test passes to reduce I/O.
std::cout << "Test 3b: " << (PassB ? "PASS" : "FAIL") << std::endl;

free(usmPtr, Queue);
#endif
Expand Down
15 changes: 6 additions & 9 deletions sycl/test-e2e/KernelAndProgram/free_function_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void printUSM(int *usmPtr, int size) {
std::cout << "}\n";
}

bool checkUSM(int *usmPtr, int size, int *Result) {
bool checkUSM(int *usmPtr, int size, int *Result, int line = __builtin_LINE()) {
bool Pass = true;
for (int i = 0; i < size; i++) {
if (usmPtr[i] != Result[i]) {
Expand All @@ -43,6 +43,7 @@ bool checkUSM(int *usmPtr, int size, int *Result) {
std::cout << usmPtr[i] << ", ";
}
std::cout << "}\n";
std::cout << "checkUSM failed, called from line " << line << std::endl;
return false;
}

Expand Down Expand Up @@ -71,9 +72,9 @@ bool test_0(queue Queue) {
});
Queue.wait();
bool PassA = checkUSM(usmPtr, Range, Result);
std::cout << "Test 0a: " << (PassA ? "PASS" : "FAIL") << std::endl;

bool PassB = false;
// TODO: Avoid using __SYCL_DEVICE_ONLY__ or give rationale with a comment
#ifndef __SYCL_DEVICE_ONLY__
kernel_bundle Bundle =
get_kernel_bundle<bundle_state::executable>(Queue.get_context());
Expand All @@ -88,7 +89,6 @@ bool test_0(queue Queue) {
});
Queue.wait();
PassB = checkUSM(usmPtr, Range, Result);
std::cout << "Test 0b: " << (PassB ? "PASS" : "FAIL") << std::endl;

free(usmPtr, Queue);
#endif
Expand Down Expand Up @@ -120,9 +120,9 @@ bool test_1(queue Queue) {
});
Queue.wait();
bool PassA = checkUSM(usmPtr, Range, Result);
std::cout << "Test 1a: " << (PassA ? "PASS" : "FAIL") << std::endl;

bool PassB = false;
// TODO: Avoid using __SYCL_DEVICE_ONLY__ or give rationale with a comment
#ifndef __SYCL_DEVICE_ONLY__
kernel_bundle Bundle =
get_kernel_bundle<bundle_state::executable>(Queue.get_context());
Expand All @@ -138,7 +138,6 @@ bool test_1(queue Queue) {
});
Queue.wait();
PassB = checkUSM(usmPtr, Range, Result);
std::cout << "Test 1b: " << (PassB ? "PASS" : "FAIL") << std::endl;

free(usmPtr, Queue);
#endif
Expand Down Expand Up @@ -175,9 +174,9 @@ bool test_2(queue Queue) {
});
Queue.wait();
bool PassA = checkUSM(usmPtr, Range, Result);
std::cout << "Test 2a: " << (PassA ? "PASS" : "FAIL") << std::endl;

bool PassB = false;
// TODO: Avoid using __SYCL_DEVICE_ONLY__ or give rationale with a comment
#ifndef __SYCL_DEVICE_ONLY__
kernel_bundle Bundle =
get_kernel_bundle<bundle_state::executable>(Queue.get_context());
Expand All @@ -192,7 +191,6 @@ bool test_2(queue Queue) {
});
Queue.wait();
PassB = checkUSM(usmPtr, Range, Result);
std::cout << "Test 2b: " << (PassB ? "PASS" : "FAIL") << std::endl;

free(usmPtr, Queue);
#endif
Expand Down Expand Up @@ -233,9 +231,9 @@ bool test_3(queue Queue) {
});
Queue.wait();
bool PassA = checkUSM(usmPtr, Range, Result);
std::cout << "Test 3a: " << (PassA ? "PASS" : "FAIL") << std::endl;

bool PassB = false;
// TODO: Avoid using __SYCL_DEVICE_ONLY__ or give rationale with a comment
#ifndef __SYCL_DEVICE_ONLY__
kernel_bundle Bundle =
get_kernel_bundle<bundle_state::executable>(Queue.get_context());
Expand All @@ -250,7 +248,6 @@ bool test_3(queue Queue) {
});
Queue.wait();
PassB = checkUSM(usmPtr, Range, Result);
std::cout << "Test 3b: " << (PassB ? "PASS" : "FAIL") << std::endl;

free(usmPtr, Queue);
#endif
Expand Down
Loading