-
Notifications
You must be signed in to change notification settings - Fork 770
[SYCL][USM] Fix USM malloc_shared and free to handle zero byte #1273
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
Merged
Merged
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
809af69
[SYCL] fix the enum variable conflict with user define
bso-intel da3f972
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel 4862f8b
[SYCL] added a regression test for macro conflict
bso-intel 11ad1ed
fixed the clang format check issue
bso-intel 2a61c01
fixed regression test compiler option
bso-intel 6dec0f2
fixed a typo
bso-intel 4fc8330
Update sycl/source/detail/scheduler/commands.hpp
bso-intel 8414e8b
fixed clang-format error
bso-intel c93c0f8
second attempt to fix the format error
bso-intel 85d75cf
Update sycl/test/regression/macro_conflict.cpp
bso-intel 50d283b
changed the enum variable per Alexey's request
bso-intel 45d6f99
removed main() to avoid runtime check per reviewer's request
bso-intel 5eda190
fixed a typo.
bso-intel 65bccf4
changed enum variables to conform to guideline
bso-intel 043f1b8
fixed the clang format issue
bso-intel 8bbcbd0
fix clang format issue
bso-intel a37642c
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel 7ad8d19
fixed LIT test failure
bso-intel f73a2d9
fixed the clang format issue
bso-intel c86049c
fixed format
bso-intel eaa89ca
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel 016c9f5
[SYCL] fixed USM malloc_shared and free to handle zero byte
bso-intel d27268a
reformat clang-format
bso-intel 682c64c
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel ec071e4
Merge branch 'shared_malloc' of https://github.com/bso-intel/llvm int…
bso-intel e942ffc
Update sycl/test/regression/usm_malloc_shared.cpp
bso-intel d311565
Merge branch 'shared_malloc' of https://github.com/bso-intel/llvm int…
bso-intel 8dd7ee0
cleaned up unnecessary lines
bso-intel 23a243d
removed GPU and ACC test run
bso-intel df098b9
added assertion of bad malloc cases
bso-intel 823df2a
fixed empty space format
bso-intel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// RUN: %clangxx -fsycl %s -o %t.out | ||
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
// RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
|
||
// This test checks if users will successfully allocate 160, 0, and -16 bytes of | ||
// shared memory, and also test user can call free() without worrying about | ||
// nullptr or invalid memory descriptor returned from malloc. | ||
|
||
#include <CL/sycl.hpp> | ||
#include <iostream> | ||
#include <stdlib.h> | ||
using namespace cl::sycl; | ||
|
||
int main(int argc, char *argv[]) { | ||
auto exception_handler = [](cl::sycl::exception_list exceptions) { | ||
for (std::exception_ptr const &e : exceptions) { | ||
try { | ||
std::rethrow_exception(e); | ||
} catch (cl::sycl::exception const &e) { | ||
std::cout << "Caught asynchronous SYCL " | ||
"exception:\n" | ||
<< e.what() << std::endl; | ||
} | ||
} | ||
}; | ||
|
||
queue myQueue(default_selector{}, exception_handler); | ||
std::cout << "Device: " << myQueue.get_device().get_info<info::device::name>() | ||
<< std::endl; | ||
|
||
double *ia = (double *)malloc_shared(160, myQueue); | ||
double *ja = (double *)malloc_shared(0, myQueue); | ||
double *result = (double *)malloc_shared(-16, myQueue); | ||
|
||
romanovvlad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
std::cout << "ia : " << ia << " ja: " << ja << " result : " << result | ||
<< std::endl; | ||
|
||
// followings should not throw CL_INVALID_VALUE | ||
cl::sycl::free(ia, myQueue); | ||
cl::sycl::free(nullptr, myQueue); | ||
cl::sycl::free(ja, myQueue); | ||
cl::sycl::free(result, myQueue); | ||
|
||
return 0; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.