diff options
author | Lancelot Six <lancelot.six@amd.com> | 2023-10-17 15:45:45 +0000 |
---|---|---|
committer | Lancelot Six <lancelot.six@amd.com> | 2023-10-18 08:26:23 +0000 |
commit | fded0fb898618b5b659762ace776144afa876035 (patch) | |
tree | 204071443f2e22255a8f6f2cd193fd4269b63bcd /gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp | |
parent | 0f79aa900f3a69780dde1e934ffe21e30236934e (diff) | |
download | binutils-fded0fb898618b5b659762ace776144afa876035.zip binutils-fded0fb898618b5b659762ace776144afa876035.tar.gz binutils-fded0fb898618b5b659762ace776144afa876035.tar.bz2 |
gdb/testsuite/gdb.rocm: Check value returned by hipDeviceSynchronize
Functions of the hip runtime returning a hipError_t can be marked
nodiscard depending on the configuration[1] (when compiled with C++17).
This patch makes sure that we always check the value returned by
hipDeviceSynchronize and friends, and print an error message when
appropriate. This avoid a wall of warnings when running the testsuite
if the compiler defaults to using C++17.
It is always a good practice to check the return values anyway.
[1] https://github.com/ROCm-Developer-Tools/HIP/blob/docs/5.7.1/include/hip/hip_runtime_api.h#L203-L218
Change-Id: I2a819a8ac45f4bcf814efe9a2ff12c6a7ad22f97
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp')
-rw-r--r-- | gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp b/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp index bf1451a..d8ea869 100644 --- a/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp +++ b/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.cpp @@ -17,6 +17,17 @@ #include <hip/hip_runtime.h> +#define CHECK(cmd) \ + { \ + hipError_t error = cmd; \ + if (error != hipSuccess) \ + { \ + fprintf (stderr, "error: '%s'(%d) at %s:%d\n", \ + hipGetErrorString (error), error, __FILE__, __LINE__); \ + exit (EXIT_FAILURE); \ + } \ + } + __global__ void kernel () { @@ -28,6 +39,6 @@ int main (int argc, char* argv[]) { kernel<<<1, 1>>> (); - hipDeviceSynchronize (); + CHECK (hipDeviceSynchronize ()); return 0; } |