-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Offload] Improve error reporting on memory faults #104254
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f3f87e1
[Offload] Improve error reporting on memory faults
jdoerfert 3482045
Update ptr_outside_alloc_2.c
jdoerfert 94bc086
Update use_after_free_2.c
jdoerfert 926e312
Update use_after_free_1.c
jdoerfert 3ab9d6e
Update ptr_outside_alloc_2.c
jdoerfert 0ad1f96
Update ptr_outside_alloc_1.c
jdoerfert 9ae27cb
Update use_after_free_2.c
jdoerfert d9a048a
Update use_after_free_1.c
jdoerfert a06dcae
Update ptr_outside_alloc_2.c
jdoerfert 7632e15
Update ptr_outside_alloc_1.c
jdoerfert 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
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
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
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,40 @@ | ||
// clang-format off | ||
// RUN: %libomptarget-compileopt-generic | ||
// RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK,NTRCE | ||
// RUN: %libomptarget-compileopt-generic | ||
// RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION OFFLOAD_TRACK_ALLOCATION_TRACES=1 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK,TRACE | ||
// clang-format on | ||
|
||
// UNSUPPORTED: aarch64-unknown-linux-gnu | ||
// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO | ||
// UNSUPPORTED: x86_64-pc-linux-gnu | ||
// UNSUPPORTED: x86_64-pc-linux-gnu-LTO | ||
// UNSUPPORTED: s390x-ibm-linux-gnu | ||
// UNSUPPORTED: s390x-ibm-linux-gnu-LTO | ||
|
||
#include <omp.h> | ||
|
||
void *llvm_omp_target_alloc_host(size_t Size, int DeviceNum); | ||
void llvm_omp_target_free_host(void *Ptr, int DeviceNum); | ||
|
||
int main() { | ||
int N = (1 << 30); | ||
char *A = (char *)llvm_omp_target_alloc_host(N, omp_get_default_device()); | ||
char *P; | ||
#pragma omp target map(from : P) | ||
{ | ||
P = &A[0]; | ||
*P = 3; | ||
} | ||
// clang-format off | ||
// CHECK: OFFLOAD ERROR: Memory access fault by GPU {{.*}} (agent 0x{{.*}}) at virtual address [[PTR:0x[0-9a-z]*]]. Reasons: {{.*}} | ||
// NTRCE: Use 'OFFLOAD_TRACK_ALLOCATION_TRACES=true' to track device allocations | ||
// TRACE: Device pointer [[PTR]] does not point into any (current or prior) host-issued allocation. | ||
// TRACE: Closest host-issued allocation (distance 4096 bytes; might be by page): | ||
// TRACE: Last allocation of size 1073741824 | ||
// clang-format on | ||
#pragma omp target | ||
{ P[-4] = 5; } | ||
|
||
llvm_omp_target_free_host(A, omp_get_default_device()); | ||
} |
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,26 @@ | ||
// clang-format off | ||
// RUN: %libomptarget-compileopt-generic | ||
// RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION OFFLOAD_TRACK_ALLOCATION_TRACES=1 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK | ||
// clang-format on | ||
|
||
// UNSUPPORTED: aarch64-unknown-linux-gnu | ||
// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO | ||
// UNSUPPORTED: x86_64-pc-linux-gnu | ||
// UNSUPPORTED: x86_64-pc-linux-gnu-LTO | ||
// UNSUPPORTED: s390x-ibm-linux-gnu | ||
// UNSUPPORTED: s390x-ibm-linux-gnu-LTO | ||
|
||
#include <omp.h> | ||
|
||
int main() { | ||
int N = (1 << 30); | ||
char *A = (char *)malloc(N); | ||
#pragma omp target map(A[ : N]) | ||
{ A[N] = 3; } | ||
// clang-format off | ||
// CHECK: OFFLOAD ERROR: Memory access fault by GPU {{.*}} (agent 0x{{.*}}) at virtual address [[PTR:0x[0-9a-z]*]]. Reasons: {{.*}} | ||
// CHECK: Device pointer [[PTR]] does not point into any (current or prior) host-issued allocation. | ||
// CHECK: Closest host-issued allocation (distance 1 byte; might be by page): | ||
// CHECK: Last allocation of size 1073741824 | ||
// clang-format on | ||
} |
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,39 @@ | ||
// clang-format off | ||
// RUN: %libomptarget-compileopt-generic | ||
// RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK,NTRCE | ||
// RUN: %libomptarget-compileopt-generic | ||
// RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION OFFLOAD_TRACK_ALLOCATION_TRACES=1 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK,TRACE | ||
// clang-format on | ||
|
||
// UNSUPPORTED: aarch64-unknown-linux-gnu | ||
// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO | ||
// UNSUPPORTED: x86_64-pc-linux-gnu | ||
// UNSUPPORTED: x86_64-pc-linux-gnu-LTO | ||
// UNSUPPORTED: s390x-ibm-linux-gnu | ||
// UNSUPPORTED: s390x-ibm-linux-gnu-LTO | ||
|
||
#include <omp.h> | ||
|
||
void *llvm_omp_target_alloc_host(size_t Size, int DeviceNum); | ||
void llvm_omp_target_free_host(void *Ptr, int DeviceNum); | ||
|
||
int main() { | ||
int N = (1 << 30); | ||
char *A = (char *)llvm_omp_target_alloc_host(N, omp_get_default_device()); | ||
char *P; | ||
#pragma omp target map(from : P) | ||
{ | ||
P = &A[N / 2]; | ||
*P = 3; | ||
} | ||
llvm_omp_target_free_host(A, omp_get_default_device()); | ||
// clang-format off | ||
// CHECK: OFFLOAD ERROR: Memory access fault by GPU {{.*}} (agent 0x{{.*}}) at virtual address [[PTR:0x[0-9a-z]*]]. Reasons: {{.*}} | ||
// NTRCE: Use 'OFFLOAD_TRACK_ALLOCATION_TRACES=true' to track device allocations | ||
// TRACE: Device pointer [[PTR]] points into prior host-issued allocation: | ||
// TRACE: Last deallocation: | ||
// TRACE: Last allocation of size 1073741824 | ||
// clang-format on | ||
#pragma omp target | ||
{ *P = 5; } | ||
} |
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,32 @@ | ||
// clang-format off | ||
// RUN: %libomptarget-compileopt-generic | ||
// RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION OFFLOAD_TRACK_ALLOCATION_TRACES=1 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK | ||
// clang-format on | ||
|
||
// UNSUPPORTED: aarch64-unknown-linux-gnu | ||
// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO | ||
// UNSUPPORTED: x86_64-pc-linux-gnu | ||
// UNSUPPORTED: x86_64-pc-linux-gnu-LTO | ||
// UNSUPPORTED: s390x-ibm-linux-gnu | ||
// UNSUPPORTED: s390x-ibm-linux-gnu-LTO | ||
|
||
#include <omp.h> | ||
|
||
int main() { | ||
int N = (1 << 30); | ||
char *A = (char *)malloc(N); | ||
char *P; | ||
#pragma omp target map(A[ : N]) map(from : P) | ||
{ | ||
P = &A[N / 2]; | ||
*P = 3; | ||
} | ||
// clang-format off | ||
// CHECK: OFFLOAD ERROR: Memory access fault by GPU {{.*}} (agent 0x{{.*}}) at virtual address [[PTR:0x[0-9a-z]*]]. Reasons: {{.*}} | ||
// CHECK: Device pointer [[PTR]] points into prior host-issued allocation: | ||
// CHECK: Last deallocation: | ||
// CHECK: Last allocation of size 1073741824 | ||
// clang-format on | ||
#pragma omp target | ||
{ *P = 5; } | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if we should just treat these as
uintptr_t