mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-16 14:19:52 +08:00
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>
49 lines
1.6 KiB
C++
49 lines
1.6 KiB
C++
/* This testcase is part of GDB, the GNU debugger.
|
|
|
|
Copyright 2021-2023 Free Software Foundation, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#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); \
|
|
} \
|
|
}
|
|
|
|
|
|
__device__ static void
|
|
break_here_execee ()
|
|
{}
|
|
|
|
__global__ void
|
|
kernel ()
|
|
{
|
|
break_here_execee ();
|
|
}
|
|
|
|
int
|
|
main ()
|
|
{
|
|
kernel<<<1, 1>>> ();
|
|
CHECK (hipDeviceSynchronize ());
|
|
return 0;
|
|
}
|